From 4c4d0f591f94428ed7e5d2f4ae5df5c5087d8c26 Mon Sep 17 00:00:00 2001 From: dcb <xgybdcb@163.com> Date: 星期三, 18 六月 2025 09:51:35 +0800 Subject: [PATCH] 求解器版本升级到2.2 --- src/main/java/com/se/nsl/service/ResolveService.java | 48 ++++++++++++++++++++++++++++++------------------ 1 files changed, 30 insertions(+), 18 deletions(-) diff --git a/src/main/java/com/se/nsl/service/ResolveService.java b/src/main/java/com/se/nsl/service/ResolveService.java index 4cd5f04..bccb075 100644 --- a/src/main/java/com/se/nsl/service/ResolveService.java +++ b/src/main/java/com/se/nsl/service/ResolveService.java @@ -69,6 +69,8 @@ @Resource TestService testService; + private ObjectMapper mapper = new ObjectMapper(); + Integer DIGIT = 1000000; SimpleDateFormat YYYYMDHM = new SimpleDateFormat("yyyy M d H m "); @@ -165,6 +167,7 @@ AreaType at = AreaType.of(areaType); String terrainTif = config.getSourceDem(); String landuseTif = config.getSourceLanduse(); + String stationTif = null; if (at == AreaType.KEY_DITCH) { File keyDitchDir = new File(config.getKeyDitch()); String areaName = simu.getAreaName(); @@ -179,6 +182,9 @@ } if (name.toLowerCase().contains("landuse")) { landuseTif = file.getAbsolutePath(); + } + if (name.toLowerCase().contains("station")) { + stationTif = file.getAbsolutePath(); } } } @@ -203,9 +209,14 @@ Dataset dsLanduse = gdal.Open(landuseTif, gdalconstConstants.GA_ReadOnly); ComHelper.Resample(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(); } - public void updateTif(Simu simu, SimuData data2) throws IOException { + public void updateTif(Simu simu, SimuData data2) { Dataset ds = gdal.Open(config.getSourceLanduse(), gdalconstConstants.GA_Update); // 浠ヨ鍐欐ā寮忔墦寮�TIFF鏂囦欢 Band band = ds.GetRasterBand(1); @@ -332,13 +343,13 @@ Short type = simu.getType(); SimulateType simulateType = SimulateType.of(type); String saveMode = simulateType.getSaveMode(); - ConfigVo vo = new ConfigVo(terrainFile, landuseFile, terrainFile, rainfallFile, saveName, duration, saveFrames, saveMode); - + String startTime = TimeFormatUtil.formatDate(data.getStartTime()); + ConfigVo vo = new ConfigVo(terrainFile, landuseFile, terrainFile, rainfallFile, + saveName, duration, saveFrames, saveMode, startTime); String configFile = config.getInPath() + File.separator + data.getInPath() + File.separator + data.getInPath() + ".json"; - ComHelper.writeJson(configFile, JSON.toJSONString(vo)); - +// ComHelper.writeJson(configFile, JSON.toJSONString(vo)); + mapper.writeValue(new File(configFile), vo); String cmd = String.format("%s \"%s\"", config.getUwSolverBat(), configFile); - return callBat2(cmd); } @@ -351,10 +362,9 @@ String geotiffDir = inPath + File.separator + "depth"; String terrainFile = inPath + File.separator + config.getTerrainFile(); String jsonPath = inPath + File.separator + "zarr2tif.json"; - - Zarr2Tif zarr2Tif = new Zarr2Tif(zarrFile, geotiffDir, terrainFile, data.getStartTime()); - ComHelper.writeJson(jsonPath, JSON.toJSONString(zarr2Tif)); - + Zarr2Tif zarr2Tif = new Zarr2Tif(zarrFile, geotiffDir, terrainFile, Collections.emptyList()); +// ComHelper.writeJson(jsonPath, JSON.toJSONString(zarr2Tif)); + mapper.writeValue(new File(jsonPath), zarr2Tif); String cmd = String.format("%s \"%s\"", config.getZarr2tifBat(), jsonPath); return callBat2(cmd); @@ -556,13 +566,12 @@ return newLayerJsonName; } - private static File generateNewZarr2TifJson(File serviceNameDir, long currentTime) throws IOException { + private File generateNewZarr2TifJson(File serviceNameDir, long currentTime) throws IOException { File srcZarr2TifJson = new File(serviceNameDir, "zarr2tif.json"); - ObjectMapper mapper = new ObjectMapper(); Zarr2Tif zarr2Tif = mapper.readValue(srcZarr2TifJson, Zarr2Tif.class); //淇敼zarr2tif瀵硅薄涓殑瀛楁 - String stamp = TimeFormatUtil.formatTime(currentTime, "yyyy-MM-dd HH:mm:ss"); - zarr2Tif.setStart_timestamp(stamp); +// String stamp = TimeFormatUtil.formatTime(currentTime, "yyyy-MM-dd HH:mm:ss"); +// zarr2Tif.setStart_timestamp(stamp); // String newZarrPath = serviceNameDir + File.separator + "result_" + currentTime + ".zarr"; String newZarrPath = serviceNameDir + File.separator + "result.zarr"; zarr2Tif.setZarr_file(newZarrPath); @@ -574,13 +583,16 @@ private File generateNewZarrConfigFile(File serviceNameDir, String serviceName, long currentTime, File newDatFile) throws IOException { File configFile = new File(serviceNameDir, serviceName + ".json"); - ObjectMapper mapper = new ObjectMapper(); ConfigVo configVo = mapper.readValue(configFile, ConfigVo.class); - configVo.setDuration(configVo.getDuration() + 300); //鍥哄畾涓�5min + int simulateTime = 300; //妯℃嫙鏃堕棿锛岄粯璁や负5min锛屽嵆300s + int intervalTime = 60; //姣忓抚鐨勯棿闅旀椂闂达紝榛樿涓�60s,60s鐢熸垚涓�甯� configVo.getRaingage().set(0, newDatFile.getAbsolutePath()); //raingage file ResultVo result = configVo.getResult(); - result.setSave_interval(60); //60s鐢熸垚涓�甯� - result.setSave_frames(result.getSave_frames() + 5); //淇濈暀5甯э紝鍦ㄥ師鏉ョ殑鍩虹涓婂鍔�5甯� + Integer oldDuration = configVo.getDuration(); +// result.setSave_start(oldDuration); //璧峰鏃堕棿瑕佸湪涓婃鏃堕棿鐨勫熀纭�涓婂紑濮� + configVo.setDuration(oldDuration + simulateTime); //鍥哄畾涓�5min + result.setSave_interval(intervalTime); + result.setSave_frames(result.getSave_frames() + (simulateTime / intervalTime)); //淇濈暀5甯э紝鍦ㄥ師鏉ョ殑鍩虹涓婂鍔�5甯� // String newZarrPath = serviceNameDir + File.separator + "result_" + currentTime + ".zarr"; String newZarrPath = serviceNameDir + File.separator + "result.zarr"; result.setSave_name(newZarrPath); -- Gitblit v1.9.3