| | |
| | | import com.se.nsl.config.PropertiesConfig; |
| | | import com.se.nsl.domain.po.DataPo; |
| | | import com.se.nsl.domain.po.Region; |
| | | import com.se.nsl.domain.po.SimuData; |
| | | import com.se.nsl.domain.vo.R; |
| | | import com.se.nsl.helper.GdalHelper; |
| | | import com.se.nsl.helper.ShpHelper; |
| | |
| | | |
| | | @ApiOperation(value = "10.å½åæ¶é´ *") |
| | | @GetMapping("/getTime") |
| | | public Object getTime() { |
| | | String rs = resolveService.createRainfallCsv("D:\\360\\zt.csv", "æ£æåå¸", 100, 10, 1); |
| | | rs = resolveService.createRainfallCsv("D:\\360\\pj.csv", "å¹³ååå¸", 100, 10, 1); |
| | | rs = resolveService.createRainfallCsv("D:\\360\\bdpj.csv", "æ³¢å¨å¹³ååå¸", 100, 10, 1); |
| | | rs = resolveService.createRainfallCsv("D:\\360\\cxss.csv", "æç»ä¸å", 100, 10, 1); |
| | | public Object getTime() throws Exception { |
| | | //String rs = resolveService.createRainfallCsv("D:\\360\\zt.csv", "æ£æåå¸", 100, 10, 1); |
| | | //rs = resolveService.createRainfallCsv("D:\\360\\pj.csv", "å¹³ååå¸", 100, 10, 1); |
| | | //rs = resolveService.createRainfallCsv("D:\\360\\bdpj.csv", "æ³¢å¨å¹³ååå¸", 100, 10, 1); |
| | | //rs = resolveService.createRainfallCsv("D:\\360\\cxss.csv", "æç»ä¸å", 100, 10, 1); |
| | | |
| | | SimuData data = new SimuData(); |
| | | data.setStartTime(new Date()); |
| | | data.setInPath("20250504203823"); |
| | | |
| | | String rs = resolveService.callZarr2tif(data); |
| | | |
| | | return (Object) System.currentTimeMillis(); |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.se.nsl.domain.dto; |
| | | |
| | | import com.se.nsl.helper.StringHelper; |
| | | |
| | | import java.util.ArrayList; |
| | | import java.util.Arrays; |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | |
| | | @SuppressWarnings("ALL") |
| | | public class Zarr2Tif { |
| | | private List<String> variables; |
| | | |
| | | private String zarr_file; |
| | | |
| | | private String geotiff_dir; |
| | | |
| | | private String terrain_file; |
| | | |
| | | private String start_timestamp; |
| | | |
| | | private List<Integer> frame_range; |
| | | |
| | | private boolean fliplr; |
| | | |
| | | private boolean flipud; |
| | | |
| | | public Zarr2Tif() { |
| | | variables = new ArrayList<>(Arrays.asList("depth", "xmomentum", "ymomentum")); |
| | | frame_range = null; |
| | | fliplr = false; |
| | | flipud = false; |
| | | } |
| | | |
| | | public Zarr2Tif(String zarrFile, String geotiffDir, String terrainFile, String startTimestamp) { |
| | | this(); |
| | | |
| | | this.zarr_file = zarrFile.replace("\\", "/"); |
| | | this.geotiff_dir = geotiffDir.replace("\\", "/"); |
| | | this.terrain_file = terrainFile.replace("\\", "/"); |
| | | this.start_timestamp = startTimestamp; |
| | | } |
| | | |
| | | public Zarr2Tif(String zarrFile, String geotiffDir, String terrainFile, Date startTime) { |
| | | this(zarrFile, geotiffDir, terrainFile, StringHelper.YMDHMS_FORMAT.format(startTime)); |
| | | } |
| | | |
| | | public List<String> getVariables() { |
| | | return variables; |
| | | } |
| | | |
| | | public void setVariables(List<String> variables) { |
| | | this.variables = variables; |
| | | } |
| | | |
| | | public String getZarr_file() { |
| | | return zarr_file; |
| | | } |
| | | |
| | | public void setZarr_file(String zarr_file) { |
| | | this.zarr_file = zarr_file; |
| | | } |
| | | |
| | | public String getGeotiff_dir() { |
| | | return geotiff_dir; |
| | | } |
| | | |
| | | public void setGeotiff_dir(String geotiff_dir) { |
| | | this.geotiff_dir = geotiff_dir; |
| | | } |
| | | |
| | | public String getTerrain_file() { |
| | | return terrain_file; |
| | | } |
| | | |
| | | public void setTerrain_file(String terrain_file) { |
| | | this.terrain_file = terrain_file; |
| | | } |
| | | |
| | | public String getStart_timestamp() { |
| | | return start_timestamp; |
| | | } |
| | | |
| | | public void setStart_timestamp(String start_timestamp) { |
| | | this.start_timestamp = start_timestamp; |
| | | } |
| | | |
| | | public List<Integer> getFrame_range() { |
| | | return frame_range; |
| | | } |
| | | |
| | | public void setFrame_range(List<Integer> frame_range) { |
| | | this.frame_range = frame_range; |
| | | } |
| | | |
| | | public boolean isFliplr() { |
| | | return fliplr; |
| | | } |
| | | |
| | | public void setFliplr(boolean fliplr) { |
| | | this.fliplr = fliplr; |
| | | } |
| | | |
| | | public boolean isFlipud() { |
| | | return flipud; |
| | | } |
| | | |
| | | public void setFlipud(boolean flipud) { |
| | | this.flipud = flipud; |
| | | } |
| | | } |
| | |
| | | import cn.hutool.json.JSONUtil; |
| | | import com.alibaba.fastjson.JSON; |
| | | import com.se.nsl.config.PropertiesConfig; |
| | | import com.se.nsl.domain.dto.Zarr2Tif; |
| | | import com.se.nsl.domain.po.Rainfall; |
| | | import com.se.nsl.domain.po.Simu; |
| | | import com.se.nsl.domain.po.SimuData; |
| | |
| | | import org.springframework.util.StringUtils; |
| | | |
| | | import javax.annotation.Resource; |
| | | import java.io.BufferedReader; |
| | | import java.io.File; |
| | | import java.io.IOException; |
| | | import java.io.InputStreamReader; |
| | | import java.math.BigDecimal; |
| | | import java.math.RoundingMode; |
| | | import java.nio.charset.StandardCharsets; |
| | |
| | | /** |
| | | * è°ç¨zarr2tif |
| | | */ |
| | | private String callZarr2tif(SimuData data) throws Exception { |
| | | String zarr2tifBat = config.getZarr2tifBat(); |
| | | File dir = new File(zarr2tifBat).getParentFile(); |
| | | String configJson = new File(dir, "config.json").getAbsolutePath(); |
| | | public String callZarr2tif(SimuData data) throws Exception { |
| | | 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 jsonPath = inPath + File.separator + "zarr2tif.json"; |
| | | |
| | | String cmd = String.format("%s \"%s\"", zarr2tifBat, configJson); |
| | | String res = callBat(cmd); |
| | | Zarr2Tif zarr2Tif = new Zarr2Tif(zarrFile, geotiffDir, terrainFile, data.getStartTime()); |
| | | ComHelper.writeJson(jsonPath, JSON.toJSONString(zarr2Tif)); |
| | | |
| | | File resultTifDir = new File(dir, "result_tif"); |
| | | File targetDir = new File(config.getInPath(), data.getInPath() + File.separator + "depth"); |
| | | System.out.println("targetDir:" + targetDir); |
| | | File[] files = resultTifDir.listFiles(); |
| | | for (File file : files) { |
| | | File target = new File(targetDir, file.getName()); |
| | | Files.copy(file.toPath(), target.toPath()); |
| | | String cmd = String.format("%s \"%s\"", config.getZarr2tifBat(), jsonPath); |
| | | |
| | | return callBat2(cmd); |
| | | } |
| | | |
| | | return res; |
| | | private String callBat2(String cmd) { |
| | | try { |
| | | ProcessBuilder pb = new ProcessBuilder("cmd", "/c", cmd); |
| | | pb.redirectErrorStream(true); // åå¹¶é误æµå°æ åè¾åº |
| | | |
| | | Process process = pb.start(); |
| | | process.getOutputStream().close(); |
| | | |
| | | //StringBuilder sb = new StringBuilder(); |
| | | try (BufferedReader reader = new BufferedReader(new InputStreamReader(process.getInputStream(), "GBK"))) { |
| | | String line; |
| | | while ((line = reader.readLine()) != null) { |
| | | System.out.println(line); |
| | | //sb.append(line); |
| | | } |
| | | } |
| | | |
| | | int exitCode = process.waitFor(); |
| | | |
| | | return "ok"; // sb.toString(); |
| | | } catch (Exception ex) { |
| | | log.error(ex.getMessage(), ex); |
| | | return null; |
| | | } |
| | | } |
| | | |
| | | /*private String callZarr2tif(SimuData data) throws Exception { |
| | |
| | | server: |
| | | port: 8079 |
| | | port: 8078 |
| | | servlet: |
| | | context-path: /api |
| | | |
| | |
| | | # 模æé¡¹ç® |
| | | simu-app: |
| | | # é¡¹ç®æ¨¡ææä»¶ä¸ä¼ åæ¾çä½ç½® |
| | | filePath: D:\simu\files |
| | | filePath: D:\other\simu\files |
| | | |
| | | config: |
| | | ver: 0.2 |
| | | cacheTime: 60 |
| | | # Gdal驱å¨ç®å½ |
| | | gdalPath: H:/simu/release-1928-x64-dev/release-1928-x64/bin |
| | | #gdalPath: D:\soft\release-1928-x64-dev\release-1928-x64\bin |
| | | gdalPath: C:\Program Files\GDAL |
| | | #inPath: D:\simu\in |
| | | inPath: H:\simu\uwsolver |
| | | outPath: H:\simu\out |
| | | inPath: D:\other\simu\uwsolver |
| | | outPath: D:\other\simu\out |
| | | host: http://106.120.22.26:8024/ |
| | | user: admin |
| | | pwd: admin |
| | |
| | | rainPeriod: 10 |
| | | # æµéåä½ï¼LPSï¼å/ç§ï¼ãCMSï¼ç«æ¹ç±³/ç§)ãCFS(ç«æ¹è±å°º/ç§) |
| | | flowUnits: CMS |
| | | solverBat: H:\simu\uwsolver\run_solver.bat |
| | | sww2tifBat: H:\simu\uwsolver\sww2tif.bat |
| | | #sizes: 64,128,256,512,1024,2048 |
| | | solverBat: D:\other\simu\uwsolver\run_solver.bat |
| | | sww2tifBat: D:\other\simu\uwsolver\sww2tif.bat |
| | | uwSolverBat: D:\other\simu\CudaUWSolver.Demo.NoVis.20250430\start.bat |
| | | #zarr2tifBat: D:\other\simu\zarr2tif1.0\start.bat |
| | | #zarr2tifBat: D:\other\simu\zarr2tif-2.0-mkl\start.bat |
| | | zarr2tifBat: D:\other\simu\zarr2tif-2.1\start.bat |
| | | createRainfall: '"C:\Program Files\Python310\python.exe" D:\terrait\NslServer\data\CreatRainfall.py' |
| | | rainfallTitle: Station Longitude Latitude Year Month Day Hour Minute Intensity |
| | | rainfallSite: beijing |
| | | epsg: 4548 |
| | | saveFrames: 10 |
| | | # åå°å©ç¨ï¼1-Cropland,2-Forest,3-Shrub,4-Grassland,5-Water,6-Snow/Ice,7-Barren,8-Impervious,9-Wetland |
| | | landuse: 2 |
| | | #sizes: 64,128,256,512,1024,2048,4096 |
| | | sizes: 1024 |
| | | # è¾åºæä»¶ |
| | | terrainFile: DEM.tif |
| | |
| | | waterPath: depth |
| | | flowPath: velocity |
| | | copyTif: false |
| | | tifPath: D:\åå¸å
æ¶\sem\tongzhou_1m_tif\tongzhou_raster_4548_1m_clip_river_fill.tif |
| | | tifPath: D:\other\simu\uwsolver\5ca43c87cd8e48c5a9c5399a5da46dbc\tongzhou_raster_4548_1m_clip_river_fill.tif |