| | |
| | | import com.se.nsl.domain.po.SimuData; |
| | | import com.se.nsl.domain.vo.ConfigVo; |
| | | import com.se.nsl.helper.ComHelper; |
| | | import com.se.nsl.helper.GdalHelper; |
| | | import com.se.nsl.helper.StringHelper; |
| | | import com.se.nsl.helper.WebHelper; |
| | | import lombok.SneakyThrows; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.gdal.gdal.Dataset; |
| | | import org.gdal.gdal.gdal; |
| | | import org.gdal.gdalconst.gdalconstConstants; |
| | | import org.gdal.ogr.Geometry; |
| | | import org.gdal.ogr.ogr; |
| | | import org.gdal.osr.CoordinateTransformation; |
| | | import org.gdal.osr.SpatialReference; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.util.StringUtils; |
| | | |
| | |
| | | SimuData data = JSONUtil.toBean(simu.getData(), SimuData.class); |
| | | |
| | | update(simu, 1, "初始化参数"); |
| | | initArgs(data); |
| | | initArgs(simu, data); |
| | | createRainfallFile(simu, data); |
| | | |
| | | update(simu, 2, "调用求解器"); |
| | |
| | | /** |
| | | * 初始化参数 |
| | | */ |
| | | public void initArgs(SimuData data) throws IOException { |
| | | public void initArgs(Simu simu, SimuData data) throws IOException { |
| | | String inPath = config.getInPath() + File.separator + data.getInPath(); |
| | | createDir(inPath); |
| | | createDir(inPath + File.separator + "depth"); |
| | | createDir(inPath + File.separator + "velocity"); |
| | | createDir(config.getOutPath() + File.separator + data.getOutPath()); |
| | | |
| | | // 临时复制高程tif,以后需要自行切割 |
| | | File uwBat = new File(config.getUwSolverBat()); |
| | | String sourceTif = uwBat.getParent() + File.separator + "case1" + File.separator + "LiuLiMiaoZhen_5m_f32.tif"; |
| | | String targetTif = inPath + File.separator + config.getDemFile(); |
| | | Files.copy(Paths.get(sourceTif), Paths.get(targetTif), StandardCopyOption.REPLACE_EXISTING); |
| | | Geometry geom = Geometry.CreateFromWkt(simu.getGeom()); |
| | | if (geom.GetGeometryType() == ogr.wkbMultiPolygon) geom = geom.GetGeometryRef(0); |
| | | SpatialReference dstSR = GdalHelper.createSpatialReference(config.getEpsg()); |
| | | |
| | | CoordinateTransformation ct = CoordinateTransformation.CreateCoordinateTransformation(GdalHelper.SR4326, dstSR); |
| | | geom.Transform(ct); |
| | | String wkt = geom.ExportToWkt(); |
| | | |
| | | String terrainFile = inPath + File.separator + config.getTerrainFile(); |
| | | Dataset dsDem = gdal.Open(config.getSourceDem(), gdalconstConstants.GA_ReadOnly); |
| | | ComHelper.Resample(dsDem, null, terrainFile, wkt, null, null); |
| | | dsDem.delete(); |
| | | |
| | | String landuseFile = inPath + File.separator + config.getLanduseFile(); |
| | | Dataset dsLanduse = gdal.Open(config.getSourceLanduse(), gdalconstConstants.GA_ReadOnly); |
| | | ComHelper.Resample(dsLanduse, null, landuseFile, wkt, null, null); |
| | | dsLanduse.delete(); |
| | | } |
| | | |
| | | private void createDir(String path) { |
| | |
| | | } |
| | | |
| | | String inPath = config.getInPath() + File.separator + data.getInPath(); |
| | | String terrainFile = (inPath + File.separator + config.getDemFile()); |
| | | String terrainFile = inPath + File.separator + config.getTerrainFile(); |
| | | String landuseFile = inPath + File.separator + config.getLanduseFile(); |
| | | String rainfallFile = (inPath + File.separator + "rainfall.dat"); |
| | | String saveName = inPath + File.separator + "result.zarr"; |
| | | ConfigVo vo = new ConfigVo(terrainFile, terrainFile, terrainFile, rainfallFile, saveName, duration, config.getSaveFrames()); |
| | | ConfigVo vo = new ConfigVo(terrainFile, landuseFile, terrainFile, rainfallFile, saveName, duration, config.getSaveFrames()); |
| | | |
| | | String configFile = config.getInPath() + File.separator + data.getInPath() + File.separator + data.getInPath() + ".json"; |
| | | ComHelper.writeJson(configFile, JSON.toJSONString(vo)); |
| | |
| | | String inPath = config.getInPath() + File.separator + data.getInPath(); |
| | | String zarrFile = inPath + File.separator + "result.zarr"; |
| | | String geotiffDir = inPath + File.separator + "depth"; |
| | | String terrainFile = inPath + File.separator + config.getDemFile(); |
| | | String terrainFile = inPath + File.separator + config.getTerrainFile(); |
| | | String jsonPath = inPath + File.separator + "zarr2tif.json"; |
| | | |
| | | Zarr2Tif zarr2Tif = new Zarr2Tif(zarrFile, geotiffDir, terrainFile, data.getStartTime()); |
| | |
| | | File uwBat = new File(config.getUwSolverBat()); |
| | | String zarrFile = uwBat.getParent() + File.separator + "result.zarr"; |
| | | String inPath = config.getInPath() + File.separator + data.getInPath(); |
| | | String terrainFile = inPath + File.separator + config.getDemFile(); |
| | | String terrainFile = inPath + File.separator + config.getTerrainFile(); |
| | | String waterPath = inPath + File.separator + "depth"; |
| | | |
| | | String cmd = String.format("%s \"%s\" \"%s\" \"%s\" \"%s\"", config.getZarr2tifBat(), "depth", zarrFile, terrainFile, waterPath); |