From 4648e5b8b753bf938989c7d4d016cbe54fa671c0 Mon Sep 17 00:00:00 2001
From: 13693261870 <252740454@qq.com>
Date: 星期二, 19 九月 2023 21:38:03 +0800
Subject: [PATCH] 1

---
 ExportMap/cs/TerrainUtils.cs               |   26 ++++++------
 ExportMap/Controllers/ConvertController.cs |   29 ++++++++++++++
 ExportMap/export.html                      |    8 ++--
 ExportMap/Web.config                       |    2 +
 4 files changed, 48 insertions(+), 17 deletions(-)

diff --git a/ExportMap/Controllers/ConvertController.cs b/ExportMap/Controllers/ConvertController.cs
index e92b4d5..ea51baa 100644
--- a/ExportMap/Controllers/ConvertController.cs
+++ b/ExportMap/Controllers/ConvertController.cs
@@ -142,6 +142,35 @@
         }
 
         /// <summary>
+        /// 杞崲鍦板舰
+        /// </summary>
+        [HttpPost]
+        public ResponseMsg<string> ToTerrain([FromBody]XYZArgs args)
+        {
+            try
+            {
+                ResponseMsg<string> msg = checkArgs(args, true);
+                if (null != msg) return msg;
+
+                checkMinMax(args);
+
+                string err = null;
+                List<int> rs = TerrainUtils.Generate(args, ref err);
+                if (null == rs || rs.Count == 0)
+                {
+                    return ResponseMsg<string>.fail(null == err ? "澶辫触" : err);
+                }
+
+                return ResponseMsg<string>.success("鎴愬姛", string.Join(",", rs), rs.Count);
+            }
+            catch (Exception ex)
+            {
+                LogOut.Error(ex.Message + "\r\n" + ex.StackTrace);
+                return ResponseMsg<string>.fail(ex.Message);
+            }
+        }
+
+        /// <summary>
         /// 杞崲LAS
         /// </summary>
         [HttpPost]
diff --git a/ExportMap/Web.config b/ExportMap/Web.config
index 579682d..48109e4 100644
--- a/ExportMap/Web.config
+++ b/ExportMap/Web.config
@@ -22,6 +22,8 @@
     <add key="sgDB" value="D:\LF\SG\catalog.db"/>
     <!-- cesium-terrain-builder璺緞 -->
     <add key="ctbPath" value="E:\WebSite\Cesium\Tool\ctb-0.41" />
+    <!-- CTB-JL鐗堟湰 -->
+    <add key="ctbJL" value="E:\WebSite\Cesium\Tool\ctb_jl"/>
     <!-- 3dtiles璺緞 -->
     <add key="d3tilesPath" value="E:\WebSite\Cesium\Tool\3dtiles" />
     <!-- gocesiumtiler璺緞 -->
diff --git a/ExportMap/cs/TerrainUtils.cs b/ExportMap/cs/TerrainUtils.cs
index bd61cfc..19287c8 100644
--- a/ExportMap/cs/TerrainUtils.cs
+++ b/ExportMap/cs/TerrainUtils.cs
@@ -66,7 +66,7 @@
         {
             try
             {
-                List<SysMeta> metas = XYZUtils.SelectMetas(args.ids, "and type in ('tif', 'tiff')");
+                List<SysMeta> metas = XYZUtils.SelectMetas(args.ids, "and type in ('tif', 'tiff', 'dem')");
                 if (null == metas || metas.Count == 0) return PrintInfo("鎵句笉鍒板厓鏁版嵁");
 
                 string dirPath = GetTerrainPath(args.dircode);
@@ -145,14 +145,13 @@
         /// </summary>
         private static void CreateTerrain(XYZArgs args, string tifFile, ref string err)
         {
-            string ctbPath = Tools.GetSetting("ctbPath");
+            string ctbPath = Tools.GetSetting("ctbJL");
             string dirPath = GetTerrainPath(args.dircode);
-            int maxLevel = GetTerrainMaxLevel(args, tifFile);
+            //int maxLevel =  GetTerrainMaxLevel(args, tifFile);
 
             string gdal_data = string.Format("set GDAL_DATA={0}\\data", ctbPath);
-            // -N 椤剁偣娉曠嚎, -C 寮哄埗鍒涘缓缂哄け鏍圭摝鐗�, -R 涓嶈鐩栫幇鏈夋枃浠�
-            string createMesh = string.Format("{0}\\ctb-tile.exe -R -C -s {4} -o \"{1}\" -f Mesh \"{2}\\{3}.tif\"", ctbPath, dirPath, dirPath, args.dircode, maxLevel);
-            //string createLayer = string.Format("{0}\\ctb-tile.exe -l -s {4} -o \"{1}\" -f Mesh \"{2}\\{3}.tif\"", ctbPath, dirPath, dirPath, args.dircode, maxLevel);
+            // -N 椤剁偣娉曠嚎, -C 寮哄埗鍒涘缓缂哄け鏍圭摝鐗�, -R 涓嶈鐩栫幇鏈夋枃浠讹紝-f Mesh
+            string createMesh = string.Format("{0}\\ctb-tile.exe -s {1} -o \"{2}\" \"{3}\"", ctbPath, TERRAIN_MAX_LEVEL, dirPath, tifFile);
 
             List<string> list = new List<string>() { gdal_data, createMesh };
             SysTask task = TaskDBHelper.CreateTask(args, "DEM", "楂樼▼鏁版嵁(DEM)");
@@ -169,9 +168,9 @@
             CreateVrt(files, vrt);
             if (!File.Exists(vrt)) return null;
 
-            string ctbPath = Tools.GetSetting("ctbPath");
+            string ctbPath = Tools.GetSetting("ctbJL");
             string gdal_data = string.Format("set GDAL_DATA={0}\\data", ctbPath);
-            string createLayer = string.Format("{0}\\ctb-tile.exe -l -o \"{1}\" -f Mesh \"{2}\"", ctbPath, dirPath, vrt);
+            string createLayer = string.Format("{0}\\ctb-tile.exe -l -s {1} -o \"{2}\" \"{3}\"", ctbPath, TERRAIN_MAX_LEVEL, dirPath, vrt);
             Tools.ExecCmd(new List<string>() { gdal_data, createLayer });
 
             return vrt;
@@ -199,15 +198,16 @@
             FileInfo fi = new FileInfo(tifFile);
             if (fi.Length > DEFAULT_MAX_SIZE) return TERRAIN_MAX_LEVEL;
 
-            string ctbPath = Tools.GetSetting("ctbPath");
+            string ctbPath = Tools.GetSetting("ctbJL");
             string dirPath = GetTerrainPath(args.dircode);
+            string subPath = Path.Combine(dirPath, "subs");
 
             string gdal_data = string.Format("set GDAL_DATA={0}\\data", ctbPath);
-            string createLayer = string.Format("{0}\\ctb-tile.exe -l -o \"{1}\" -f Mesh \"{2}\\{3}.tif\"", ctbPath, dirPath, dirPath, args.dircode);
+            string createLayer = string.Format("{0}\\ctb-tile.exe -l -o \"{1}\" \"{2}\"", ctbPath, subPath, tifFile);
 
             Tools.ExecCmd(new List<string>() { gdal_data, createLayer });
 
-            string layerJson = Path.Combine(dirPath, "layer.json");
+            string layerJson = Path.Combine(subPath, "layer.json");
             if (!File.Exists(layerJson)) return TERRAIN_MAX_LEVEL;
 
             string[] lines = File.ReadAllLines(layerJson, Encoding.UTF8);
@@ -320,13 +320,13 @@
         public static void Reproject(string sourceFile, string targetFile, string sourceSrs, string targetSrs)
         {
             string gdalPath = Tools.GetSetting("gdalPath");
-            string cmd = string.Format("{0}\\gdalwarp.exe -s_srs {1} -t_srs {2} -r near -of GTiff {3} {4}", gdalPath, sourceSrs, targetSrs, sourceFile, targetFile);
+            string cmd = string.Format("\"{0}\\gdalwarp.exe\" -s_srs {1} -t_srs {2} -r near -of GTiff \"{3}\" \"{4}\"", gdalPath, sourceSrs, targetSrs, sourceFile, targetFile);
 
             Tools.ExecCmd(new List<string> { cmd });
         }
 
         /// <summary>
-        /// 鎸囧畾鎶曞奖
+        /// 鎸囧畾鎶曞奖 *
         /// </summary>
         public static void Project(string sourceFile, string targetSrs)
         {
diff --git a/ExportMap/export.html b/ExportMap/export.html
index f989442..12f8ef2 100644
--- a/ExportMap/export.html
+++ b/ExportMap/export.html
@@ -10,7 +10,7 @@
   <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
   <script src="js/jquery.1.12.4.js"></script>
   <script>
-    var token = "384d7382-ea48-400b-bc92-58cb2b28bcbc";
+    var token = "0b8d4418-d7bd-4846-ba45-edccf42e87c3";
 
     $(function () {
       $("#token").html(token);
@@ -129,10 +129,10 @@
       });
     }
     
-    // 娴嬭瘯Terra锛�10526锛�10527
+    // 娴嬭瘯Terra锛�10526锛�10527 | 10531
     function toTerra() {
-      var data = { token: token, ids: [10531], min: 0, max: 18, depcode: "00", dircode: "090000", userId: 1, name: "涓紖" };
-      ajax("Convert/ToTerra", "POST", JSON.stringify(data), null, null, function (rs) {
+      var data = { token: token, ids: [1413, 1412], min: 0, max: 18, depcode: "00", dircode: "0B", userId: 1, name: "宸濅簩" };
+      ajax("Convert/ToTerrain", "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