From e243ecf8d43eb00b2a0461230076ada26d2d11c1 Mon Sep 17 00:00:00 2001 From: 13693261870 <252740454@qq.com> Date: 星期二, 14 三月 2023 10:51:52 +0800 Subject: [PATCH] 1 --- /dev/null | 59 ----------- ExportMap/cs/SGUtils.cs | 2 ExportMap/cs/XYZUtils.cs | 89 +++++++++++++++++ ExportMap/Controllers/ConvertController.cs | 37 +++++++ ExportMap/cs/ConvertUtils.cs | 12 ++ ExportMap/cs/CacheUtils.cs | 4 ExportMap/ExportMap.csproj | 9 + ExportMap/Models/SysMeta.cs | 50 ++++++++++ ExportMap/cs/Tool.cs | 22 ++++ ExportMap/Models/XYZArgs.cs | 4 ExportMap/export.html | 3 11 files changed, 222 insertions(+), 69 deletions(-) diff --git a/ExportMap/Controllers/ConvertController.cs b/ExportMap/Controllers/ConvertController.cs new file mode 100644 index 0000000..fba7c7e --- /dev/null +++ b/ExportMap/Controllers/ConvertController.cs @@ -0,0 +1,37 @@ +锘縰sing ExportMap.cs; +using ExportMap.Models; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Net; +using System.Net.Http; +using System.Web.Http; + +namespace ExportMap.Controllers +{ + public class ConvertController : ApiController + { + [HttpPost] + public ResponseMsg<int> ToTileset([FromBody]ExportArgs args) + { + try + { + + + return ResponseMsg<int>.success("鎴愬姛", 1); + } + catch (Exception ex) + { + LogOut.Error(ex.StackTrace); + return ResponseMsg<int>.fail(ex.Message); + } + } + + [HttpGet] + public ResponseMsg<string> Test() + { + + return ResponseMsg<string>.success("鎴愬姛", ""); + } + } +} diff --git a/ExportMap/ExportMap.csproj b/ExportMap/ExportMap.csproj index 889a787..4feb5e5 100644 --- a/ExportMap/ExportMap.csproj +++ b/ExportMap/ExportMap.csproj @@ -129,17 +129,19 @@ </ItemGroup> <ItemGroup> <Compile Include="App_Start\WebApiConfig.cs" /> + <Compile Include="Controllers\ConvertController.cs" /> <Compile Include="Controllers\ExportController.cs" /> <Compile Include="Controllers\FloatServerController.cs" /> <Compile Include="Controllers\licenseEncryptionController.cs" /> - <Compile Include="cs\CacheUtil.cs" /> + <Compile Include="cs\CacheUtils.cs" /> + <Compile Include="cs\ConvertUtils.cs" /> <Compile Include="cs\CustomMultipartFormDataStreamProvider.cs" /> <Compile Include="cs\ExportUtil.cs" /> <Compile Include="cs\LogOut.cs" /> <Compile Include="cs\NoBufferPolicySelector.cs" /> - <Compile Include="cs\SGUtil.cs" /> + <Compile Include="cs\SGUtils.cs" /> <Compile Include="cs\Tool.cs" /> - <Compile Include="cs\XYZUtil.cs" /> + <Compile Include="cs\XYZUtils.cs" /> <Compile Include="db\ModelHandler.cs" /> <Compile Include="db\PostgreHelper.cs" /> <Compile Include="db\SQLiteHelper.cs" /> @@ -150,6 +152,7 @@ <Compile Include="Models\ExportArgs.cs" /> <Compile Include="Models\ResponseMsg.cs" /> <Compile Include="Models\Secret.cs" /> + <Compile Include="Models\SysMeta.cs" /> <Compile Include="Models\XYZArgs.cs" /> <Compile Include="Properties\AssemblyInfo.cs" /> </ItemGroup> diff --git a/ExportMap/Models/SysMeta.cs b/ExportMap/Models/SysMeta.cs new file mode 100644 index 0000000..c436174 --- /dev/null +++ b/ExportMap/Models/SysMeta.cs @@ -0,0 +1,50 @@ +锘縰sing System; +using System.Collections.Generic; +using System.Linq; +using System.Web; + +namespace ExportMap.Models +{ + public class SysMeta + { + public int id { set; get; } + + public string eventid { set; get; } + + public int metaid { set; get; } + + public int ismeta { set; get; } + + public string depcode { set; get; } + + public string dircode { set; get; } + + public int verid { set; get; } + + public string name { set; get; } + + public string type { set; get; } + + public string guid { set; get; } + + public string path { set; get; } + + public double sizes { set; get; } + + public string tab { set; get; } + + public string layer { set; get; } + + public int rows { set; get; } + + public int create_user { set; get; } + + public DateTime create_time { set; get; } + + public int update_user { set; get; } + + public DateTime update_time { set; get; } + + public string bak { set; get; } + } +} diff --git a/ExportMap/Models/XYZArgs.cs b/ExportMap/Models/XYZArgs.cs index 2b144b8..3ebe9ee 100644 --- a/ExportMap/Models/XYZArgs.cs +++ b/ExportMap/Models/XYZArgs.cs @@ -31,9 +31,9 @@ public int max { set; get; } /// <summary> - /// 鏁版嵁鐩綍ID + /// 鏁版嵁鐩綍缂栫爜 /// </summary> - public string dirid { set; get; } + public string dircode { set; get; } /// <summary> /// 鍏冩暟鎹甀D闆嗗悎 diff --git a/ExportMap/cs/CacheUtil.cs b/ExportMap/cs/CacheUtils.cs similarity index 98% rename from ExportMap/cs/CacheUtil.cs rename to ExportMap/cs/CacheUtils.cs index 1a2bf02..18d4f98 100644 --- a/ExportMap/cs/CacheUtil.cs +++ b/ExportMap/cs/CacheUtils.cs @@ -11,11 +11,11 @@ /// <summary> /// 缂撳瓨甯哥敤鎿嶄綔 /// </summary> - public class CacheUtil + public class CacheUtils { public static CacheItemRemovedReason reason; - public CacheUtil() + public CacheUtils() { } diff --git a/ExportMap/cs/ConvertUtils.cs b/ExportMap/cs/ConvertUtils.cs new file mode 100644 index 0000000..e2ba3c0 --- /dev/null +++ b/ExportMap/cs/ConvertUtils.cs @@ -0,0 +1,12 @@ +锘縰sing System; +using System.Collections.Generic; +using System.Linq; +using System.Web; + +namespace ExportMap.cs +{ + public class ConvertUtils + { + + } +} diff --git a/ExportMap/cs/SGUtil.cs b/ExportMap/cs/SGUtils.cs similarity index 97% rename from ExportMap/cs/SGUtil.cs rename to ExportMap/cs/SGUtils.cs index 3590407..df8e3f7 100644 --- a/ExportMap/cs/SGUtil.cs +++ b/ExportMap/cs/SGUtils.cs @@ -6,7 +6,7 @@ namespace ExportMap.cs { - public class SGUtil + public class SGUtils { /// <summary> /// Mpt鐩綍 diff --git a/ExportMap/cs/Tool.cs b/ExportMap/cs/Tool.cs index b7855b5..56bc21a 100644 --- a/ExportMap/cs/Tool.cs +++ b/ExportMap/cs/Tool.cs @@ -1,4 +1,5 @@ -锘縰sing Npgsql; +锘縰sing ExportMap.db; +using Npgsql; using System; using System.Collections.Generic; using System.Configuration; @@ -21,6 +22,24 @@ /// 鍩虹鐩綍 /// </summary> public static readonly string BaseDir = AppDomain.CurrentDomain.BaseDirectory; + + private static PostgreHelper _dbHelper; + + /// <summary> + /// DB甯姪绫� + /// </summary> + public static PostgreHelper DBHelper + { + get + { + if (null == _dbHelper) + { + _dbHelper = new PostgreHelper(DbEnum.langfang); + } + + return _dbHelper; + } + } /// <summary> /// 瀛楄妭鏍煎紡鍖� @@ -166,7 +185,6 @@ } return str; - } } } diff --git a/ExportMap/cs/XYZUtil.cs b/ExportMap/cs/XYZUtil.cs deleted file mode 100644 index d6d67bb..0000000 --- a/ExportMap/cs/XYZUtil.cs +++ /dev/null @@ -1,59 +0,0 @@ -锘縰sing ExportMap.Models; -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -using System.Web; - -namespace ExportMap.cs -{ - public class XYZUtil - { - - private static string pyFile; - - /// <summary> - /// 鑾峰彇Python鏂囦欢 - /// </summary> - public static string PyFile - { - get - { - if (string.IsNullOrWhiteSpace(pyFile)) - { - pyFile = Path.Combine(ExportUtil.SourcesPath, "xyz.py"); - } - - return pyFile; - } - } - - /// <summary> - /// QGIS宸ョ▼ - /// </summary> - public static string Qgz - { - get - { - return "xyz.qgz"; - } - } - - /// <summary> - /// 鐢熸垚 - /// </summary> - /// <param name="args">XYZ鍙傛暟</param> - /// <param name="err">閿欒淇℃伅</param> - /// <returns>鏁版嵁鍙戝竷ID</returns> - public static int Generate(XYZArgs args, ref string err) - { - string tifFile = Path.Combine(ExportUtil.SourcesPath, ExportUtil.DateStr + ".txt"); - string xyzPath = ""; - - string cmd = string.Format("python {0} -qgz {1} -file {2} -out {3} -min {4} -max {5}", PyFile, Qgz, tifFile, xyzPath, args.min, args.max); - err = Tool.ExecPython(cmd); - - return args.id; - } - } -} diff --git a/ExportMap/cs/XYZUtils.cs b/ExportMap/cs/XYZUtils.cs new file mode 100644 index 0000000..56fa28e --- /dev/null +++ b/ExportMap/cs/XYZUtils.cs @@ -0,0 +1,89 @@ +锘縰sing ExportMap.db; +using ExportMap.Models; +using System; +using System.Collections.Generic; +using System.Data; +using System.IO; +using System.Linq; +using System.Web; + +namespace ExportMap.cs +{ + public class XYZUtils + { + + private static string pyFile; + + /// <summary> + /// 鑾峰彇Python鏂囦欢 + /// </summary> + public static string PyFile + { + get + { + if (string.IsNullOrWhiteSpace(pyFile)) + { + pyFile = Path.Combine(ExportUtil.SourcesPath, "xyz.py"); + } + + return pyFile; + } + } + + /// <summary> + /// QGIS宸ョ▼ + /// </summary> + public static string Qgz + { + get + { + return "xyz.qgz"; + } + } + + /// <summary> + /// 鐢熸垚 + /// </summary> + /// <param name="args">XYZ鍙傛暟</param> + /// <param name="err">閿欒淇℃伅</param> + /// <returns>鏁版嵁鍙戝竷ID</returns> + public static int Generate(XYZArgs args, ref string err) + { + string tifFile = Path.Combine(ExportUtil.SourcesPath, ExportUtil.DateStr + ".txt"); + string xyzPath = Path.Combine(SGUtils.LFData, "2d\\tiles", args.id.ToString()); + if (!Directory.Exists(xyzPath)) Directory.CreateDirectory(xyzPath); + + string cmd = string.Format("python {0} -qgz {1} -file {2} -out {3} -min {4} -max {5}", PyFile, Qgz, tifFile, xyzPath, args.min, args.max); + err = Tool.ExecPython(cmd); + + return args.id; + } + + /// <summary> + /// 鏌ヨ鍏冩暟鎹� + /// </summary> + private static List<SysMeta> selectMetas(string dircode) + { + string sql = string.Format("select * from lf.sys_meta where dircode like '{0}%'", dircode); + + DataTable dt = Tool.DBHelper.GetDataTable(sql); + List<SysMeta> list = ModelHandler.FillModel<SysMeta>(dt); + + return list; + } + + /// <summary> + /// 鏌ヨ鍏冩暟鎹� + /// </summary> + private static List<SysMeta> selectMetas(List<int> ids) + { + string sql = string.Format("select * from lf.sys_meta where id in ({0})", string.Join(",", ids)); + DataTable dt = Tool.DBHelper.GetDataTable(sql); + List<SysMeta> list = ModelHandler.FillModel<SysMeta>(dt); + + return list; + } + + + } +} diff --git a/ExportMap/export.html b/ExportMap/export.html index 1e267cc..c6ca19c 100644 --- a/ExportMap/export.html +++ b/ExportMap/export.html @@ -84,5 +84,8 @@ </select> <input type="button" value="鍑哄浘-1" onclick="exportMap1()" /> <input type="button" value="鍑哄浘-2" onclick="exportMap2()" /> + <br /><br /> + + <a href="Convert/Test" >娴嬭瘯rvt</a> </body> </html> -- Gitblit v1.9.3