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 +++++++++++++-------------
 1 files changed, 13 insertions(+), 13 deletions(-)

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)
         {

--
Gitblit v1.9.3