From 170ca96f9a0b814b32896bfb128cfa3e1e4be189 Mon Sep 17 00:00:00 2001
From: 13693261870 <252740454@qq.com>
Date: 星期五, 19 七月 2024 16:41:57 +0800
Subject: [PATCH] 1

---
 SimuTools/Tools/Handle.cs |   43 +++++++++++++++++++++++++++++++++++++++++--
 1 files changed, 41 insertions(+), 2 deletions(-)

diff --git a/SimuTools/Tools/Handle.cs b/SimuTools/Tools/Handle.cs
index af7aef4..e8f81ab 100644
--- a/SimuTools/Tools/Handle.cs
+++ b/SimuTools/Tools/Handle.cs
@@ -35,7 +35,7 @@
             string temp = Path.Combine(outPath, "temp");
             if (!Directory.Exists(temp)) Directory.CreateDirectory(temp);
 
-            CopeTerrain(terrainFile, outPath, layer);
+            //CopeTerrain(terrainFile, outPath, layer);
             CopeWater(waterPath, outPath, layer);
             CopeFlow(flowPath, outPath, layer);
             CopeLayerJson(outPath, layer);
@@ -216,7 +216,47 @@
         /// </summary>
         private static void CopeWater(string waterPath, string outPath, Domain.Layer layer)
         {
+            string watersPath = Path.Combine(outPath, "waters");
+            if (!Directory.Exists(watersPath)) Directory.CreateDirectory(watersPath);
 
+            List<string> files = GetFiles(waterPath);
+            if (null == files || files.Count == 0) return;
+
+            SetWaterData(layer, files);
+        }
+
+        /// <summary>
+        /// 鑾峰彇鏂囦欢
+        /// </summary>
+        private static List<String> GetFiles(string path)
+        {
+            string[] files = Directory.GetFiles(path, "*.tif?", SearchOption.TopDirectoryOnly);
+            if (null == files || files.Length == 0) return null;
+
+            List<string> list = files.ToList();
+            list.Sort();
+
+            return list;
+        }
+
+        /// <summary>
+        /// 璁剧疆姘撮潰鏁版嵁
+        /// </summary>
+        private static void SetWaterData(Domain.Layer layer, List<string> files)
+        {
+            DateTime now = DateTime.Now;
+            long startTicks = new DateTime(1970, 1, 1, 0, 0, 0).Ticks;
+
+            foreach (string file in files)
+            {
+                string fileName = Path.GetFileNameWithoutExtension(file);
+                int hour = Convert.ToInt32(fileName.Substring(0, 2));
+                int minute = Convert.ToInt32(fileName.Substring(2, 2));
+                int second = Convert.ToInt32(fileName.Substring(4, 2));
+
+                DateTime d = new DateTime(now.Year, now.Month, now.Day, hour, minute, second);
+                layer.waters.data.Add((d.Ticks - startTicks) / 10000);
+            }
         }
 
         /// <summary>
@@ -265,7 +305,6 @@
 
             destDs.Dispose();
         }
-
         #endregion
     }
 }

--
Gitblit v1.9.3