From 5eb4b1b063d4ff6df13758648dfef19e27ac105a Mon Sep 17 00:00:00 2001
From: 13693261870 <252740454@qq.com>
Date: 星期二, 19 九月 2023 12:43:33 +0800
Subject: [PATCH] 1

---
 ExportMap/cs/TerrainUtils.cs               |   62 +++++++++++++++++++++++++++++++
 ExportMap/Controllers/ConvertController.cs |    8 +++
 ExportMap/ExportMap.csproj                 |    1 
 ExportMap/export.html                      |    1 
 ExportMap/Web.config                       |    4 +-
 5 files changed, 73 insertions(+), 3 deletions(-)

diff --git a/ExportMap/Controllers/ConvertController.cs b/ExportMap/Controllers/ConvertController.cs
index e4eb5ff..e03b984 100644
--- a/ExportMap/Controllers/ConvertController.cs
+++ b/ExportMap/Controllers/ConvertController.cs
@@ -20,7 +20,13 @@
 
             //return Tools.GetLocalIP();
 
-            return Tools.GetEPSG("D:\\Moon\\data\\dem_tif\\ldem.tif");
+            //return Tools.GetEPSG("D:\\Moon\\data\\dem_tif\\ldem.tif");
+
+            //TerrainUtils.Reproject("D:/xyz/dem/dem/32a.tif", "D:/xyz/dem/dem/32a_4326_.tif", "EPSG:4528", "EPSG:4326");
+
+            TerrainUtils.Project("D:/xyz/dem/dem/32a_4326_.tif", "EPSG:4490");
+
+            return DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
         }
 
         /// <summary>
diff --git a/ExportMap/ExportMap.csproj b/ExportMap/ExportMap.csproj
index ecc67bd..58b4c2d 100644
--- a/ExportMap/ExportMap.csproj
+++ b/ExportMap/ExportMap.csproj
@@ -156,6 +156,7 @@
     <Compile Include="cs\PyLasUtils.cs" />
     <Compile Include="cs\SGUtils.cs" />
     <Compile Include="cs\TBUtils.cs" />
+    <Compile Include="cs\TerrainUtils.cs" />
     <Compile Include="cs\TerraUtils.cs" />
     <Compile Include="cs\Tools.cs" />
     <Compile Include="cs\XYZUtils.cs" />
diff --git a/ExportMap/Web.config b/ExportMap/Web.config
index 315f96e..4b3d2e9 100644
--- a/ExportMap/Web.config
+++ b/ExportMap/Web.config
@@ -31,9 +31,9 @@
     <!-- Mpt璺緞 -->
     <add key="mpt" value="D:\LF\data\mpt\tb.mpt" />
     <!-- PG杩炴帴 -->
-    <!--<add key="pgConn" value="Server=127.0.0.1;Port=5433;Database=langfang;User Id=postgres;Password=postgres;"/>-->
+    <add key="pgConn" value="Server=127.0.0.1;Port=5433;Database=langfang;User Id=postgres;Password=postgres;"/>
     <!--<add key="pgConn" value="Server=192.168.20.205;Port=5433;Database=langfang;User Id=postgres;Password=Postgres!_14_Lf;"/>-->
-    <add key="pgConn" value="Server=103.85.165.99;Port=5433;Database=langfang;User Id=postgres;Password=Postgres!_14_Lf;"/>
+    <!--<add key="pgConn" value="Server=103.85.165.99;Port=5433;Database=langfang;User Id=postgres;Password=Postgres!_14_Lf;"/>-->
     <add key="webpages:Version" value="3.0.0.0"/>
     <add key="webpages:Enabled" value="false"/>
     <add key="ClientValidationEnabled" value="true"/>
diff --git a/ExportMap/cs/TerrainUtils.cs b/ExportMap/cs/TerrainUtils.cs
new file mode 100644
index 0000000..5a0f3ce
--- /dev/null
+++ b/ExportMap/cs/TerrainUtils.cs
@@ -0,0 +1,62 @@
+锘縰sing ExportMap.Models;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Web;
+
+namespace ExportMap.cs
+{
+    public class TerrainUtils
+    {
+        private static int terrainMaxLevel = 0;
+
+        /// <summary>
+        /// 鍦板舰鏈�澶х骇鍒�
+        /// </summary>
+        public static int TERRAIN_MAX_LEVEL
+        {
+            get
+            {
+                if (0 == terrainMaxLevel)
+                {
+                    string str = Tools.GetSetting("terrainMaxLevel");
+                    if (!int.TryParse(str, out terrainMaxLevel))
+                    {
+                        terrainMaxLevel = 14;
+                    }
+                }
+
+                return terrainMaxLevel;
+            }
+        }
+
+        /// <summary>
+        /// 閲嶆姇褰�
+        /// </summary>
+        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);
+
+            Tools.ExecCmd(new List<string> { cmd });
+        }
+
+        /// <summary>
+        /// 鎸囧畾鎶曞奖
+        /// </summary>
+        public static void Project(string sourceFile, string targetSrs)
+        {
+            List<string> list = new List<string>();
+            list.Add("cd \"C:\\Program Files\\QGIS 3.16\\apps\\Python37\"");
+            //list.Add("set GDAL_DATA=\"C:\\Program Files\\QGIS 3.16\\share\\gdal\"");
+            //list.Add("set PROJ_LIB=\"C:\\Program Files\\QGIS 3.16\\share\\proj\"");
+            list.Add("\"C:\\Program Files\\QGIS 3.16\\bin\\qgis_process-qgis-ltr.bat\"");
+
+            string cmd = string.Format("python \"C:\\Program Files\\QGIS 3.16\\apps\\Python37\\Scripts\\gdal_edit.py\" -a_srs {0} {1}", targetSrs, sourceFile);
+            list.Add(cmd);
+
+            string rs = "";
+            string err = Tools.ExecCmd(new List<string> { cmd }, ref rs);
+        }
+    }
+}
diff --git a/ExportMap/export.html b/ExportMap/export.html
index 2655c71..f989442 100644
--- a/ExportMap/export.html
+++ b/ExportMap/export.html
@@ -212,6 +212,7 @@
   </select>
   <input type="button" value="鍑哄浘-1" onclick="exportMap1()" />
   <input type="button" value="鍑哄浘-2" onclick="exportMap2()" />
+  <a href="Convert/Test">Test</a>
   <br /><br />
   
   <input type="button" value="娴嬭瘯鍒囧浘" onclick="convertXYZ();" />

--
Gitblit v1.9.3