From 8c7daad24082b796f1f49b4e2b3f18d2d3c058bf Mon Sep 17 00:00:00 2001 From: dcb <xgybdcb@163.com> Date: 星期二, 24 六月 2025 17:48:45 +0800 Subject: [PATCH] 代码优化 --- src/main/java/com/se/nsl/service/ResolveService.java | 21 ++++++++++----------- 1 files changed, 10 insertions(+), 11 deletions(-) diff --git a/src/main/java/com/se/nsl/service/ResolveService.java b/src/main/java/com/se/nsl/service/ResolveService.java index bccb075..e041ab5 100644 --- a/src/main/java/com/se/nsl/service/ResolveService.java +++ b/src/main/java/com/se/nsl/service/ResolveService.java @@ -201,19 +201,21 @@ String terrainFile = inPath + File.separator + config.getTerrainFile(); Dataset dsDem = gdal.Open(terrainTif, gdalconstConstants.GA_ReadOnly); - ComHelper.Resample(dsDem, null, terrainFile, null, wkt, null, null); + ComHelper.cutAndResample(dsDem, null, terrainFile, null, wkt, null, null); dsDem.delete(); String landuseFile = inPath + File.separator + config.getLanduseFile(); Dataset dsLanduse = gdal.Open(landuseTif, gdalconstConstants.GA_ReadOnly); - ComHelper.Resample(dsLanduse, null, landuseFile, null, wkt, null, null); + ComHelper.cutAndResample(dsLanduse, null, landuseFile, null, wkt, null, null); dsLanduse.delete(); - String stationFile = inPath + File.separator + "Station.tif"; - Dataset dsStation = gdal.Open(stationTif, gdalconstConstants.GA_ReadOnly); - ComHelper.Resample(dsStation, null, stationFile, null, wkt, null, null); - dsStation.delete(); + if (stationTif != null) { + String stationFile = inPath + File.separator + "Station.tif"; + Dataset dsStation = gdal.Open(stationTif, gdalconstConstants.GA_ReadOnly); + ComHelper.cutAndResample(dsStation, null, stationFile, null, wkt, null, null); + dsStation.delete(); + } } public void updateTif(Simu simu, SimuData data2) { @@ -318,8 +320,6 @@ * 璋冪敤UWSolver */ public String callUwSolver(Simu simu, SimuData data) throws Exception { - File uwBat = new File(config.getUwSolverBat()); - int duration = 3600 * data.getDuration(); // 绉掓暟 if (null != data.getRainfalls() && data.getRainfalls().size() > 1) { List<Rainfall> rainfalls = data.getRainfalls(); @@ -346,6 +346,7 @@ String startTime = TimeFormatUtil.formatDate(data.getStartTime()); ConfigVo vo = new ConfigVo(terrainFile, landuseFile, terrainFile, rainfallFile, saveName, duration, saveFrames, saveMode, startTime); + vo.getResult().setSave_filter(config.getSaveFilter()); String configFile = config.getInPath() + File.separator + data.getInPath() + File.separator + data.getInPath() + ".json"; // ComHelper.writeJson(configFile, JSON.toJSONString(vo)); mapper.writeValue(new File(configFile), vo); @@ -481,11 +482,10 @@ } private List<Double> getValues(String csvPath) throws Exception { - if (!new File(csvPath).exists()) return null; + if (!new File(csvPath).exists()) return Collections.emptyList(); List<String> list = Files.readAllLines(Paths.get(csvPath)); list.remove(0); - //list.remove(list.size() - 1); return list.stream() .map(s -> new BigDecimal(s).setScale(6, RoundingMode.HALF_DOWN).doubleValue()) @@ -557,7 +557,6 @@ File dem = new File(serviceNameDir, "DEM.tif"); resultDto.setTerrainFile(dem.getAbsolutePath()); File newDepthDir = new File(serviceNameDir + File.separator + "depth_" + currentTime); - File[] files = newDepthDir.listFiles(); resultDto.setWaterPath(newDepthDir.getAbsolutePath()); LayerDto layerDto = new LayerDto(config.getVer(), 4548, config.getSizes()); String newLayerJsonName = "layer_" + currentTime + ".json"; -- Gitblit v1.9.3