From f0586817d86bb5b86efce42230e872fd9a254d69 Mon Sep 17 00:00:00 2001 From: 13693261870 <252740454@qq.com> Date: 星期二, 29 八月 2023 20:12:24 +0800 Subject: [PATCH] 1 --- ExportMap/cs/Tools.cs | 82 +++++++++++++++++++++++++++++++++++++++- ExportMap/cs/XYZUtils.cs | 13 ++++++ DataLoader/CS/GdalHelper.cs | 4 +- ExportMap/Controllers/ConvertController.cs | 17 ++++++++ ExportMap/Web.config | 2 + 5 files changed, 112 insertions(+), 6 deletions(-) diff --git a/DataLoader/CS/GdalHelper.cs b/DataLoader/CS/GdalHelper.cs index 9c69bae..793b9bf 100644 --- a/DataLoader/CS/GdalHelper.cs +++ b/DataLoader/CS/GdalHelper.cs @@ -26,7 +26,7 @@ public static string MOON200 = "GCS_Moon_2000"; - public static List<string> EPSGS = new List<string>() { "EPSG:4326", "EPSG:4490", "ESRI:104903" }; + public static List<string> EPSGS = new List<string>() { "EPSG:4326", "EPSG:4490", "EPSG:104903" }; /// <summary> /// 鏋勯�犲嚱鏁� @@ -116,7 +116,7 @@ vd.Meta.coor_sys = sr.GetName(); // 鍧愭爣绯荤粺 if (MOON200 == vd.Meta.coor_sys) { - vd.Meta.epsg = "ESRI:104903"; // EPSG缂栫爜 + vd.Meta.epsg = "EPSG:104903"; // EPSG缂栫爜 } else { diff --git a/ExportMap/Controllers/ConvertController.cs b/ExportMap/Controllers/ConvertController.cs index c4ea621..e4eb5ff 100644 --- a/ExportMap/Controllers/ConvertController.cs +++ b/ExportMap/Controllers/ConvertController.cs @@ -2,6 +2,7 @@ using ExportMap.Models; using System; using System.Collections.Generic; +using System.IO; using System.Linq; using System.Net; using System.Net.Http; @@ -17,7 +18,9 @@ //string name = "8-鐟炰附绔�0.05m.cpt"; //string cnName = name.Substring(0, name.LastIndexOf(".")); - return Tools.GetLocalIP(); + //return Tools.GetLocalIP(); + + return Tools.GetEPSG("D:\\Moon\\data\\dem_tif\\ldem.tif"); } /// <summary> @@ -303,6 +306,18 @@ } + [HttpGet] + public string GetRasterEPSG(int id) + { + SysMeta meta = XYZUtils.SelectMeta(id); + if (null == meta || string.IsNullOrEmpty(meta.path)) return null; + + string file = Path.Combine(Tools.GetSetting("uploadFolder"), meta.path); + if (!File.Exists(file)) return null; + + return Tools.GetEPSG(file); + } + /// <summary> /// 妫�鏌ュ弬鏁� /// </summary> diff --git a/ExportMap/Web.config b/ExportMap/Web.config index 75d9bcd..4f84f6e 100644 --- a/ExportMap/Web.config +++ b/ExportMap/Web.config @@ -26,6 +26,8 @@ <add key="d3tilesPath" value="E:\WebSite\Cesium\Tool\3dtiles" /> <!-- gocesiumtiler璺緞 --> <add key="tilerPath" value="E:\WebSite\Cesium\Tool\gocesiumtiler-1.2.3" /> + <!-- GDAL璺緞 --> + <add key="gdalPath" value="E:\terrait\TianJin\Zip\release-1928-x64-dev\release-1928-x64\bin" /> <!-- Mpt璺緞 --> <add key="mpt" value="D:\LF\data\mpt\tb.mpt" /> <!-- PG杩炴帴 --> diff --git a/ExportMap/cs/Tools.cs b/ExportMap/cs/Tools.cs index 4603d02..45372bb 100644 --- a/ExportMap/cs/Tools.cs +++ b/ExportMap/cs/Tools.cs @@ -6,6 +6,7 @@ using System.Configuration; using System.Data.Common; using System.Diagnostics; +using System.Drawing; using System.IO; using System.Linq; using System.Net; @@ -16,7 +17,7 @@ using System.Runtime.Serialization.Formatters.Binary; using System.Security.AccessControl; using System.Security.Principal; -using System.Web; +using System.Web.WebSockets; namespace ExportMap.cs { @@ -197,7 +198,7 @@ /// <returns>鎵ц缁撴灉鎴栧嚭閿欎俊鎭�</returns> public static string ExecCmd(SysTask task, List<string> list, bool isOut = false) { - string str = null; + string str; try { Process p = new Process(); @@ -304,7 +305,58 @@ if (p != null) { p.Close(); - p = null; + } + } + return str; + } + + /// <summary> + /// 鎵ц鍛戒护 + /// </summary> + public static string ExecCmd(List<string> list, ref string rs) + { + string str = null; + Process p = null; + try + { + p = new Process(); + p.StartInfo.FileName = "cmd.exe"; + p.StartInfo.UseShellExecute = false; + p.StartInfo.CreateNoWindow = true; + p.StartInfo.RedirectStandardInput = true; + p.StartInfo.RedirectStandardOutput = true; + p.StartInfo.RedirectStandardError = true; + p.Start(); + + StreamWriter si = p.StandardInput; + StreamReader so = p.StandardOutput; + StreamReader se = p.StandardError; + + LogOut.Info("cmd = " + string.Join("锛�", list)); + si.AutoFlush = true; + foreach (string cmd in list) + { + si.WriteLine(cmd); + } + si.WriteLine("exit"); + + rs = so.ReadToEnd(); + str = se.ReadToEnd(); + + se.Close(); + so.Close(); + si.Close(); + } + catch (Exception ex) + { + LogOut.Error(ex.Message + "\r\n" + ex.StackTrace); + str = ex.Message; + } + finally + { + if (p != null) + { + p.Close(); } } return str; @@ -345,6 +397,30 @@ } /// <summary> + /// 鑾峰彇EPSG浠g爜 + /// </summary> + public static string GetEPSG(string file) + { + string gdalPath = GetSetting("gdalPath"); + string cmd = string.Format("{0}\\gdalsrsinfo.exe \"{1}\" -o epsg", gdalPath, file); + + string rs = null; + string ostr = ExecCmd(new List<string> { cmd }, ref rs); + if (string.IsNullOrEmpty(rs)) return null; + + string[] strs = rs.Split(new string[] { "\r\n" }, StringSplitOptions.RemoveEmptyEntries); + foreach (string str in strs) + { + if (str.Contains("EPSG:")) + { + return str; + } + } + + return null; + } + + /// <summary> /// 璁剧疆鍗曚綋妯″瀷鍙傛暟 /// </summary> public static void SetIsModel(XYZArgs args, List<SysMeta> list) diff --git a/ExportMap/cs/XYZUtils.cs b/ExportMap/cs/XYZUtils.cs index 0dc8cda..6cfd3af 100644 --- a/ExportMap/cs/XYZUtils.cs +++ b/ExportMap/cs/XYZUtils.cs @@ -128,6 +128,19 @@ } /// <summary> + /// 鏍规嵁ID鏌ヨ鍏冩暟鎹� + /// </summary> + public static SysMeta SelectMeta(int id) + { + string sql = string.Format("select a.*, fn_get_fullname(dircode, 2) dirname from lf.sys_meta a where id = {0}", id); + + DataTable dt = Tools.DBHelper.GetDataTable(sql); + List<SysMeta> list = ModelHandler.FillModel<SysMeta>(dt); + + return null == list || list.Count == 0 ? null : list[0]; + } + + /// <summary> /// 鍐欐枃鏈枃浠� /// </summary> private static void WriteText(string file, List<SysMeta> list, List<int> mids) -- Gitblit v1.9.3