From a0ea5dbbabd0dec22f287a536d7526f2df805ad5 Mon Sep 17 00:00:00 2001
From: 13693261870 <252740454@qq.com>
Date: 星期六, 06 五月 2023 12:51:33 +0800
Subject: [PATCH] 1

---
 ExportMap/Controllers/ConvertController.cs |   15 +++++++++++++++
 ExportMap/cs/TerraUtils.cs                 |   32 +++++++++++++++++++++++++-------
 ExportMap/export.html                      |    4 ++--
 3 files changed, 42 insertions(+), 9 deletions(-)

diff --git a/ExportMap/Controllers/ConvertController.cs b/ExportMap/Controllers/ConvertController.cs
index 76ad7f2..303acd2 100644
--- a/ExportMap/Controllers/ConvertController.cs
+++ b/ExportMap/Controllers/ConvertController.cs
@@ -161,6 +161,21 @@
                 {
                     return ResponseMsg<string>.fail("浠ょ墝鏃犳晥");
                 }
+                if (string.IsNullOrWhiteSpace(args.dircode))
+                {
+                    return ResponseMsg<string>.fail("鍗曚綅浠g爜涓嶈兘涓虹┖");
+                }
+
+                if (args.min < 0) args.min = 0;
+                if (args.min > 22) args.min = 22;
+                if (args.max < 0) args.max = 0;
+                if (args.max > 22) args.max = 22;
+                if (args.min > args.max)
+                {
+                    int tmp = args.min;
+                    args.min = args.max;
+                    args.max = tmp;
+                }
 
                 string err = null;
                 List<int> rs = TerraUtils.Generate(args, ref err);
diff --git a/ExportMap/cs/TerraUtils.cs b/ExportMap/cs/TerraUtils.cs
index 85bde5f..3ba3b34 100644
--- a/ExportMap/cs/TerraUtils.cs
+++ b/ExportMap/cs/TerraUtils.cs
@@ -73,9 +73,9 @@
         /// <summary>
         /// 鑾峰彇鍦板舰璺緞
         /// </summary>
-        public static string GetTerrainPath(XYZArgs args)
+        public static string GetTerrainPath(string dircode)
         {
-            return Path.Combine(SGUtils.LFData, "3d\\terrain", args.dircode);
+            return Path.Combine(SGUtils.LFData, "3d\\terrain", dircode);
         }
 
         /// <summary>
@@ -92,8 +92,8 @@
                 tifFile = Merge(args, ref err);
                 if (!File.Exists(tifFile)) return null;
 
-                Generate(args, tifFile);
-
+                Generate(args, tifFile, ref err);
+                Save(args);
 
                 return null;
             }
@@ -124,7 +124,7 @@
                 if (null == list || list.Count == 0) return null;
 
                 txtFile = Path.Combine(Tools.TempDir, ExportUtil.DateStr + ".txt");
-                string dirPath = GetTerrainPath(args);
+                string dirPath = GetTerrainPath(args.dircode);
                 if (!Directory.Exists(dirPath)) Directory.CreateDirectory(dirPath);
 
                 string tifFile = Path.Combine(dirPath, args.dircode + ".tif");
@@ -173,9 +173,27 @@
         /// <summary>
         /// 鐢熸垚楂樼▼鍒囩墖
         /// </summary>
-        private static void Generate(XYZArgs args, string tifFile)
+        private static void Generate(XYZArgs args, string tifFile, ref string err)
         {
-            string dirPath = GetTerrainPath(args);
+            string dirPath = GetTerrainPath(args.dircode).Replace("\\", "/");
+            string name = "ctb_" + ExportUtil.DateStr;
+
+            string runDocker = string.Format("docker run -it --name {0} -v \"{1}\":\"/data\" tumgis/ctb-quantized-mesh", name, dirPath);
+            string createMesh = string.Format("ctb-tile -f Mesh -C -N -s {0} -e {1} -o /data /data/{2}.tif", args.max, args.min, args.dircode);
+            string createLayer = string.Format("ctb-tile -f Mesh -C -N -s {0} -e {1} -l -o /data /data/{0}.tif", args.max, args.min, args.dircode);
+            string exit = "exit";
+            string rm = string.Format("docker rm {0}", name);
+
+            List<string> list = new List<string> { runDocker, createMesh, createLayer, exit, rm };
+            err = Tools.ExecCmd(list);
+        }
+
+        /// <summary>
+        /// 淇濆瓨
+        /// </summary>
+        private static void Save(XYZArgs args)
+        {
+
         }
     }
 }
diff --git a/ExportMap/export.html b/ExportMap/export.html
index 44ee0de..5a577a8 100644
--- a/ExportMap/export.html
+++ b/ExportMap/export.html
@@ -5,7 +5,7 @@
   <title></title>
   <script src="js/jquery.1.12.4.js"></script>
   <script>
-    var token = "af7f814c-9f3d-4123-af04-70abb7d5a21c";
+    var token = "c9530551-ebca-46bc-b8ea-25590153d1a3";
 
     // Ajax
     function ajax(url, type, data, dataType, contentType, fn) {
@@ -122,7 +122,7 @@
     
     // 娴嬭瘯Terra
     function toTerra() {
-      var data = { token: token, ids: [7088, 7089, 7090], depcode: "00", dircode: "0C00000003", userId: 1 };
+      var data = { token: token, ids: [7088, 7089, 7090], min: 4, max: 18, depcode: "00", dircode: "0C00000003", userId: 1, name: "astgtm2" };
       ajax("Convert/ToTerra", "POST", JSON.stringify(data), null, null, function (rs) {
         alert("code = " + rs.code + ", msg = " + rs.msg + ", result = " + rs.result);
         console.log(rs);

--
Gitblit v1.9.3