| | |
| | | return newLayerJsonName; |
| | | } |
| | | |
| | | // private static void readDemData(File serviceNameDir, LayerDto layerDto) { |
| | | // File dem = new File(serviceNameDir, "DEM.tif"); |
| | | // Dataset ds = gdal.Open(dem.getAbsolutePath(), gdalconstConstants.GA_ReadOnly); |
| | | // Band band = ds.GetRasterBand(1); |
| | | // int width = ds.getRasterXSize(); |
| | | // int height = ds.getRasterYSize(); |
| | | // float[] buffer = new float[width * height]; |
| | | // band.ReadRaster(0, 0, width, height, buffer); |
| | | // layerDto.getTerrain().getVals().put(width + "_" + height, buffer); |
| | | // } |
| | | |
| | | private static File generateNewZarr2TifJson(File serviceNameDir, long currentTime) throws IOException { |
| | | File srcZarr2TifJson = new File(serviceNameDir, "zarr2tif.json"); |
| | | ObjectMapper mapper = new ObjectMapper(); |
| | |
| | | //修改zarr2tif对象中的字段 |
| | | 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_" + currentTime + ".zarr"; |
| | | String newZarrPath = serviceNameDir + File.separator + "result.zarr"; |
| | | zarr2Tif.setZarr_file(newZarrPath); |
| | | zarr2Tif.setGeotiff_dir(serviceNameDir + File.separator + "depth_" + currentTime); |
| | | File newZarr2TifJson = new File(serviceNameDir, "zarr2tif_" + currentTime + ".json"); |
| | |
| | | |
| | | private File generateNewZarrConfigFile(File serviceNameDir, String serviceName, long currentTime, File newDatFile) throws IOException { |
| | | File configFile = new File(serviceNameDir, serviceName + ".json"); |
| | | String str = Files.readAllLines(configFile.toPath()).stream().collect(Collectors.joining()); |
| | | ConfigVo configVo = JSON.parseObject(str, ConfigVo.class); |
| | | configVo.setDuration(300); //固定为5min |
| | | ObjectMapper mapper = new ObjectMapper(); |
| | | ConfigVo configVo = mapper.readValue(configFile, ConfigVo.class); |
| | | configVo.setDuration(configVo.getDuration() + 300); //固定为5min |
| | | configVo.getRaingage().set(0, newDatFile.getAbsolutePath()); //raingage file |
| | | ResultVo result = configVo.getResult(); |
| | | result.setSave_interval(60); //60s生成一帧 |
| | | result.setSave_frames(5); //保留5帧 |
| | | String newZarrPath = serviceNameDir + File.separator + "result_" + currentTime + ".zarr"; |
| | | result.setSave_frames(result.getSave_frames() + 5); //保留5帧,在原来的基础上增加5帧 |
| | | // String newZarrPath = serviceNameDir + File.separator + "result_" + currentTime + ".zarr"; |
| | | String newZarrPath = serviceNameDir + File.separator + "result.zarr"; |
| | | result.setSave_name(newZarrPath); |
| | | ObjectMapper mapper = new ObjectMapper(); |
| | | File newConfigFile = new File(serviceNameDir, currentTime + ".json"); |
| | | mapper.writeValue(newConfigFile, configVo); |
| | | return newConfigFile; |