From b50aa418312034cfebf121f416e197d68aa5d0de Mon Sep 17 00:00:00 2001
From: wuww <252740454@qq.com>
Date: 星期五, 25 四月 2025 13:46:16 +0800
Subject: [PATCH] 修改测试方法

---
 src/main/java/com/se/nsl/controller/TestController.java |   54 ++++++++++++++++++++++----
 src/main/java/com/se/nsl/domain/po/Region.java          |   10 ++--
 src/main/java/com/se/nsl/service/TestService.java       |    4 +-
 src/main/java/com/se/nsl/helper/GdalHelper.java         |    6 +-
 src/main/resources/application-dev.yml                  |    6 +-
 src/test/java/com/se/nsl/AppTest.java                   |    7 ++-
 pom.xml                                                 |    4 +-
 7 files changed, 64 insertions(+), 27 deletions(-)

diff --git a/pom.xml b/pom.xml
index cd0b5b2..066695b 100644
--- a/pom.xml
+++ b/pom.xml
@@ -118,8 +118,8 @@
         <dependency>
             <groupId>org.gdal</groupId>
             <artifactId>gdal</artifactId>
-            <version>3.5.0</version>
-            <!--<version>3.10.0</version>
+            <version>3.10.0</version>
+            <!--<version>3.5.0</version>
             <version>3.10.1</version>-->
             <!--<scope>system</scope>
             <systemPath>${project.basedir}/libs/gdal.jar</systemPath>-->
diff --git a/src/main/java/com/se/nsl/controller/TestController.java b/src/main/java/com/se/nsl/controller/TestController.java
index 5d18af0..d19efa9 100644
--- a/src/main/java/com/se/nsl/controller/TestController.java
+++ b/src/main/java/com/se/nsl/controller/TestController.java
@@ -20,7 +20,10 @@
 
 import javax.annotation.Resource;
 import java.io.File;
+import java.io.IOException;
+import java.nio.charset.StandardCharsets;
 import java.nio.file.Files;
+import java.nio.file.Path;
 import java.nio.file.Paths;
 import java.nio.file.StandardCopyOption;
 import java.text.SimpleDateFormat;
@@ -59,7 +62,7 @@
     @ApiOperation(value = "褰撳墠鏃堕棿 *")
     @GetMapping("/getTime")
     public Object getTime() {
-        return System.currentTimeMillis();
+        return (Object) System.currentTimeMillis();
     }
 
     @ApiOperation(value = "testCallExe *")
@@ -89,7 +92,7 @@
     public R<Object> testResuslt(String path, String time) {
         try {
             DataPo data = new DataPo();
-            data.setEpsg(4548);
+            data.setEpsg(Integer.valueOf(4548));
             data.setInPath(path);
             data.setStartTime(StringHelper.YMDHMS_FORMAT.parse(time));
 
@@ -106,7 +109,7 @@
     public R<Object> testSww2Tif() {
         try {
             DataPo data = new DataPo();
-            data.setEpsg(4548);
+            data.setEpsg(Integer.valueOf(4548));
             data.setInPath("20241010095328");
             data.setStartTime(StringHelper.YMDHMS_FORMAT.parse("2024-09-30 00:00:00"));
 
@@ -123,9 +126,9 @@
     public R<Object> testRainfall() {
         try {
             DataPo data = new DataPo();
-            data.setEpsg(4548);
-            data.setTotal(60.0);
-            data.setDuration(60);
+            data.setEpsg(Integer.valueOf(4548));
+            data.setTotal(Double.valueOf(60.0));
+            data.setDuration(Integer.valueOf(60));
             data.setInPath("20241010095328");
             data.setStartTime(StringHelper.YMDHMS_FORMAT.parse("2024-07-01 00:00:00"));
 
@@ -166,7 +169,7 @@
     public R<Object> testH5() {
         try {
             DataPo data = new DataPo();
-            data.setEpsg(4548);
+            data.setEpsg(Integer.valueOf(4548));
             data.setInPath("20241010095328");
             data.setStartTime(StringHelper.YMDHMS_FORMAT.parse("2024-09-30 00:00:00"));
 
@@ -232,8 +235,8 @@
                     continue; // g.GetGeometryType() == ogr.wkbPolygon || g.GetGeometryType() == ogr.wkbMultiPolygon
 
                 if (!wkt.contains("MULTIPOLYGON")) wkt = wkt.replace("POLYGON (", "MULTIPOLYGON ((") + ")";
-                list.add(new Region(f.GetFieldAsString("name"), type.shortValue(), wkt));
-                if (path.contains("瀛欒儭娌�")) list.add(new Region(f.GetFieldAsString("name"), (short) 3, wkt));
+                list.add(new Region(f.GetFieldAsString("name"), type, wkt)); // type.shortValue()
+                if (path.contains("瀛欒儭娌�")) list.add(new Region(f.GetFieldAsString("name"), 3, wkt));
             }
         }
         ds.delete();
@@ -310,4 +313,37 @@
             return fail(ex, null);
         }
     }
+
+    @ApiOperation(value = "testPngList <")
+    @GetMapping("/testPngList")
+    @ApiImplicitParams({
+            @ApiImplicitParam(name = "path", value = "璺緞", dataType = "String", paramType = "query", example = "D:\\other\\simu\\out\\chicago\\waters"),
+            @ApiImplicitParam(name = "size", value = "灏哄", dataType = "Integer", paramType = "query", example = "1024")
+    })
+    public R<Object> testPngList(String path, Integer size) {
+        try {
+            if (null == size) size = (Integer) 1024;
+            List<String> list = new ArrayList<>();
+            for (File file : new File(path).listFiles()) {
+                if (!file.exists() || file.isFile()) continue;
+
+                File pngFile = new File(file.getPath() + File.separator + size + "_" + size + ".png");
+                if (!pngFile.exists() || pngFile.isDirectory()) continue;
+
+                list.add("file '" + pngFile.getPath().replace("\\", "/") + "'");
+                System.out.println(list.get(list.size() - 1));
+            }
+
+            Path outPath = Paths.get(path + File.separator + "list.txt");
+            try {
+                Files.write(outPath, list, StandardCharsets.UTF_8);
+            } catch (IOException e) {
+                e.printStackTrace();
+            }
+
+            return success("ok");
+        } catch (Exception ex) {
+            return fail(ex, null);
+        }
+    }
 }
diff --git a/src/main/java/com/se/nsl/domain/po/Region.java b/src/main/java/com/se/nsl/domain/po/Region.java
index dce31cf..294ad2e 100644
--- a/src/main/java/com/se/nsl/domain/po/Region.java
+++ b/src/main/java/com/se/nsl/domain/po/Region.java
@@ -20,7 +20,7 @@
     private String name;
 
     @ApiModelProperty("绫诲埆锛�1-琛屾斂鍖哄垝锛�2-閲嶇偣鍖哄煙锛�3-閲嶇偣娌�")
-    private Short type;
+    private Integer type;
 
     @ApiModelProperty("绌洪棿浣嶇疆")
     @TableField(value = "st_astext(geom)", select = true)
@@ -29,9 +29,9 @@
     public Region() {
     }
 
-    public Region(String name, Short type, String geom) {
+    public Region(String name, int type, String geom) {
         this.name = name;
-        this.type = type;
+        this.type = Integer.valueOf(type);
         this.geom = geom;
     }
 
@@ -51,11 +51,11 @@
         this.name = name;
     }
 
-    public Short getType() {
+    public Integer getType() {
         return type;
     }
 
-    public void setType(Short type) {
+    public void setType(Integer type) {
         this.type = type;
     }
 
diff --git a/src/main/java/com/se/nsl/helper/GdalHelper.java b/src/main/java/com/se/nsl/helper/GdalHelper.java
index b5dabab..85380f6 100644
--- a/src/main/java/com/se/nsl/helper/GdalHelper.java
+++ b/src/main/java/com/se/nsl/helper/GdalHelper.java
@@ -33,9 +33,9 @@
         if (!StringHelper.isEmpty(gdalPath)) {
             if (WebHelper.isWin()) {
                 gdal.SetConfigOption("GDAL_HOME", gdalPath);
-                gdal.SetConfigOption("GDAL_DATA", gdalPath + "/gdal-data");
-                gdal.SetConfigOption("PROJ_LIB", gdalPath + "/projlib"); ///proj7/share
-                gdal.SetConfigOption("GDAL_DRIVER_PATH", gdalPath + "/gdalplugins");
+                gdal.SetConfigOption("GDAL_DATA", gdalPath + File.separator + "gdal-data");
+                gdal.SetConfigOption("PROJ_LIB", gdalPath + File.separator + "projlib"); // /proj7/share
+                gdal.SetConfigOption("GDAL_DRIVER_PATH", gdalPath + File.separator + "gdalplugins");
 
                 String path = System.getenv("PATH");
                 if (!path.contains(gdalPath)) {
diff --git a/src/main/java/com/se/nsl/service/TestService.java b/src/main/java/com/se/nsl/service/TestService.java
index 11843f8..764be0e 100644
--- a/src/main/java/com/se/nsl/service/TestService.java
+++ b/src/main/java/com/se/nsl/service/TestService.java
@@ -312,7 +312,7 @@
                 for (int y = 0; y < height; y++) {
                     int offset = x + y * width;
                     //if (Float.isNaN(buffer[offset]) || buffer[offset] < -999 || buffer[offset] < minHeight) continue;
-                    if (Float.isNaN(buffer[offset]) || buffer[offset] <= 0.001 || Float.isNaN(ts[offset])) continue;
+                    if (Float.isNaN(buffer[offset]) || buffer[offset] <= 0.00001 || Float.isNaN(ts[offset])) continue;
 
                     //double X = transform[0] + x * transform[1] + y * transform[2];
                     //double Y = transform[3] + x * transform[4] + y * transform[5];
@@ -541,7 +541,7 @@
                 int offset = x + y * width;
                 float fx = ComHelper.getFloatValue(vxBuffer[offset]);
                 float fy = ComHelper.getFloatValue(vyBuffer[offset]);
-                if (Float.isNaN(fx) && Float.isNaN(fy) || (fx == 0 && fy == 0)) continue;
+                if (Float.isNaN(fx) && Float.isNaN(fy) || (fx == 0.00001 && fy == 0.00001)) continue;
 
                 fx = Float.isNaN(fx) ? 0 : fx;
                 fy = Float.isNaN(fy) ? 0 : fy;
diff --git a/src/main/resources/application-dev.yml b/src/main/resources/application-dev.yml
index 6148f89..54a321e 100644
--- a/src/main/resources/application-dev.yml
+++ b/src/main/resources/application-dev.yml
@@ -111,8 +111,8 @@
   ver: 0.2
   cacheTime: 60
   # Gdal椹卞姩鐩綍
-  gdalPath: D:\soft\release-1928-x64-dev\release-1928-x64\bin
-  #gdalPath: C:\Program Files\GDAL
+  #gdalPath: D:\soft\release-1928-x64-dev\release-1928-x64\bin
+  gdalPath: C:\Program Files\GDAL
   #inPath: D:\simu\in
   inPath: D:\other\simu\uwsolver
   outPath: D:\other\simu\out
@@ -142,7 +142,7 @@
   solverBat: D:\other\simu\uwsolver\run_solver.bat
   sww2tifBat: D:\other\simu\uwsolver\sww2tif.bat
   #sizes: 64,128,256,512,1024,2048
-  sizes: 1024
+  sizes: 1024,2048,4096
   # 杈撳嚭鏂囦欢
   terrainFile: DEM.tif
   buildingFile: buildings_inside.shp
diff --git a/src/test/java/com/se/nsl/AppTest.java b/src/test/java/com/se/nsl/AppTest.java
index 2a54a2b..c527930 100644
--- a/src/test/java/com/se/nsl/AppTest.java
+++ b/src/test/java/com/se/nsl/AppTest.java
@@ -42,6 +42,7 @@
         //procDepthFiles();
         System.out.println("> test ----------------------");
         readZarr();
+        //collectPngToList();
     }
 
     private void procDepthFiles() {
@@ -77,7 +78,7 @@
     public void collectPngToList() {
         System.out.println("------------------------------------------- start");
         int size = 1024;
-        String outputPath = "D:\\other\\simu\\out\\20250412\\waters";
+        String outputPath = "D:\\other\\simu\\out\\chicago96\\waters"; // ""D:\\other\\simu\\out\\20250412\\waters";
         List<String> list = new ArrayList<>();
         for (File file : new File(outputPath).listFiles()) {
             if (!file.exists() || file.isFile()) continue;
@@ -116,7 +117,7 @@
                 Feature f = layer.GetFeature(j);
                 Geometry g = f.GetGeometryRef();
                 if (null != g) { //  && (g.GetGeometryType() == ogr.wkbPolygon || g.GetGeometryType() == ogr.wkbMultiPolygon)
-                    list.add(new Region(f.GetFieldAsString(""), (short) 3, g.ExportToWkt()));
+                    list.add(new Region(f.GetFieldAsString(""),  3, g.ExportToWkt()));
                 }
             }
         }
@@ -162,7 +163,7 @@
 
             System.out.println("Successfully opened...");
             System.out.println("Driver: " + ds.GetDriver().getShortName() + "/" + ds.GetDriver().getLongName());
-            System.out.println("Size: " + ds.getRasterXSize() + "x" + ds.getRasterYSize() + "x" + ds.getRasterCount());
+            System.out.println("Size: " + ds.getRasterXSize() + " - " + ds.getRasterYSize() + " - " + ds.getRasterCount());
         } finally {
             if (null != ds) ds.delete();
         }

--
Gitblit v1.9.3