| | |
| | | import com.se.nsl.domain.vo.BuildingDepthVo; |
| | | import com.se.nsl.helper.ComHelper; |
| | | import com.se.nsl.helper.GdalHelper; |
| | | import com.se.nsl.utils.TimeFormatUtil; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.gdal.gdal.Band; |
| | | import org.gdal.gdal.Dataset; |
| | |
| | | |
| | | public final static SimpleDateFormat SDF = new SimpleDateFormat("yyyy-MM-dd HH:mm"); |
| | | |
| | | public void test(SimuData data) throws Exception { |
| | | public void test(SimuData data) throws IOException { |
| | | String basePath = config.getInPath() + File.separator + data.getInPath() + File.separator; |
| | | ResultDto dto = new ResultDto( |
| | | data.getInPath(), |
| | |
| | | process(dto, layer); |
| | | } |
| | | |
| | | private void process(ResultDto dto, LayerDto layer) throws Exception { |
| | | private void process(ResultDto dto, LayerDto layer) throws IOException { |
| | | try { |
| | | copeTerrain(dto, layer); |
| | | copeWater(dto, layer); |
| | |
| | | } |
| | | } |
| | | |
| | | public void processRealTime(ResultDto dto, LayerDto layer) throws IOException { |
| | | try { |
| | | copeTerrainRealTime(dto, layer); |
| | | copeWater(dto, layer); |
| | | copeFlow(dto, layer); |
| | | copeLayerJson(dto, layer); |
| | | } finally { |
| | | File dir = new File(dto.getTemp()); |
| | | if (dir.exists()) { |
| | | FileUtil.del(dir); |
| | | } |
| | | } |
| | | } |
| | | |
| | | public void copeTerrain(ResultDto dto, LayerDto layer) { |
| | | Dataset ds = null; |
| | | try { |
| | | ds = gdal.Open(dto.getTerrainFile(), gdalconstConstants.GA_ReadOnly); // gdalconst |
| | | if (null == ds || 0 == ds.getRasterCount()) return; |
| | | |
| | | setSizes(ds, layer); |
| | | setTerrainInfo(ds, layer); |
| | | setWaterInfo(dto, layer); |
| | | createTerrainPng(dto, ds, layer); |
| | | } finally { |
| | | if (null != ds) ds.delete(); |
| | | } |
| | | } |
| | | |
| | | private void copeTerrainRealTime(ResultDto dto, LayerDto layer) { |
| | | Dataset ds = null; |
| | | try { |
| | | ds = gdal.Open(dto.getTerrainFile(), gdalconstConstants.GA_ReadOnly); // gdalconst |
| | |
| | | } |
| | | |
| | | public void setWaterData(LayerDto layer, List<String> files) { |
| | | DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyyMMddHHmmss"); |
| | | for (String file : files) { |
| | | String fileName = ComHelper.getNameWithExt(file); |
| | | LocalDateTime dateTime = LocalDateTime.parse(fileName, formatter); |
| | | Instant instant = dateTime.atZone(ZoneId.systemDefault()).toInstant(); |
| | | long timestamp = instant.toEpochMilli(); |
| | | long timestamp = TimeFormatUtil.toMillis(fileName, "yyyyMMddHHmmss"); |
| | | layer.getWaters().getData().add(timestamp); |
| | | } |
| | | layer.getDuration().setStart(layer.getWaters().getData().get(0)); |
| | |
| | | layer.setFlowUrl("/hls/f" + path + ".m3u8"); |
| | | |
| | | String json = JSON.toJSONString(layer); |
| | | // String json = JSONUtil.toJsonPrettyStr(layer); |
| | | String filePath = dto.getOutPath() + File.separator + "layer.json"; |
| | | // String filePath = dto.getOutPath() + File.separator + "layer.json"; |
| | | String filePath = dto.getOutPath() + File.separator + layer.getName(); |
| | | |
| | | ComHelper.writeJson(filePath, json); |
| | | } |