From ecfe110922f3c542df7aaef9ac9e26cdb0b73e55 Mon Sep 17 00:00:00 2001
From: 13693261870 <252740454@qq.com>
Date: 星期六, 20 七月 2024 09:52:58 +0800
Subject: [PATCH] 1

---
 SimuTools/Tools/Handle.cs |   59 ++++++++++++++++++++++++++++-------------------------------
 1 files changed, 28 insertions(+), 31 deletions(-)

diff --git a/SimuTools/Tools/Handle.cs b/SimuTools/Tools/Handle.cs
index 8b45ace..74796fc 100644
--- a/SimuTools/Tools/Handle.cs
+++ b/SimuTools/Tools/Handle.cs
@@ -92,8 +92,8 @@
             foreach (int[] sizes in layer.terrain.size)
             {
                 string tif = Path.Combine(tempPath, DateTime.Now.Ticks.ToString() + ".tif");
-                Resample(ds.GetDescription(), tif, sizes[0], sizes[1]);
-                //Resample(ds, tif, sizes[0], sizes[1]);
+                //Resample(ds.GetDescription(), tif, sizes[0], sizes[1]);
+                Resample(ds, tif, sizes[0], sizes[1]);
                 if (!File.Exists(tif))
                 {
                     continue;
@@ -106,6 +106,32 @@
 
         /// <summary>
         /// 閲嶉噰鏍�
+        /// </summary>
+        private static void Resample(Dataset ds, string dest, int width, int height)
+        {
+            // https://blog.51cto.com/u_16099346/6691820
+            //string args = string.Format("-t_srs {0} -ts {1} {2} -r {3} -of {4}", "EPSG:4326", width, height, "bilinear", "GTiff");
+            //string[] options = Gdal.ParseCommandLine(args);
+            string[] options = new string[]
+            {
+                "-t_srs",
+                "EPSG:4326",
+                "-ts",
+                width.ToString(),
+                height.ToString(),
+                "-r",
+                "bilinear",
+                "-of",
+                "GTiff"
+            };
+            GDALWarpAppOptions warpAppOptions = new GDALWarpAppOptions(options);
+
+            Dataset destDs = Gdal.Warp(dest, new Dataset[] { ds }, warpAppOptions, null, null);
+            destDs.Dispose();
+        }
+
+        /// <summary>
+        /// 閲嶉噰鏍� *
         /// </summary>
         private static void Resample(string source, string dest, int width, int height)
         {
@@ -439,35 +465,6 @@
             {
                 sw.Write(json);
             }
-        }
-        #endregion
-
-        #region 鏆傛椂涓嶇敤
-        /// <summary>
-        /// 閲嶉噰鏍� *
-        /// </summary>
-        private static void Resample(Dataset ds, string dest, int width, int height)
-        {
-            // https://blog.51cto.com/u_16099346/6691820
-            //string args = string.Format("-t_srs {0} -ts {1} {2} -r {3} -of {4}", "EPSG:4326", width, height, "bilinear", "GTiff");
-            //string[] options = Gdal.ParseCommandLine(args);
-
-            string[] options = new string[]
-            {
-                "-t_srs",
-                "EPSG:4326",
-                "-ts",
-                width.ToString(),
-                height.ToString(),
-                "-r",
-                "bilinear",
-                "-of",
-                "GTiff"
-            };
-            GDALWarpAppOptions warpAppOptions = new GDALWarpAppOptions(options);
-
-            Dataset destDs = Gdal.Warp(dest, new Dataset[] { ds }, warpAppOptions, null, null);
-            destDs.Dispose();
         }
         #endregion
     }

--
Gitblit v1.9.3