wuww
2025-04-25 b50aa418312034cfebf121f416e197d68aa5d0de
修改测试方法
已修改7个文件
91 ■■■■ 文件已修改
pom.xml 4 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/se/nsl/controller/TestController.java 54 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/se/nsl/domain/po/Region.java 10 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/se/nsl/helper/GdalHelper.java 6 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/se/nsl/service/TestService.java 4 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/resources/application-dev.yml 6 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/test/java/com/se/nsl/AppTest.java 7 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
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>-->
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);
        }
    }
}
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;
    }
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)) {
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;
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
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();
        }