| | |
| | | package com.se.nsl.controller; |
| | | |
| | | import com.alibaba.fastjson.JSON; |
| | | 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.Simu; |
| | | 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; |
| | |
| | | @Resource |
| | | SimuPoService simuPoService; |
| | | |
| | | @Resource |
| | | Hdf5Service hdf5Service; |
| | | //@Resource |
| | | //Hdf5Service hdf5Service; |
| | | |
| | | @Resource |
| | | ResultService resultService; |
| | |
| | | |
| | | @Resource |
| | | PropertiesConfig config; |
| | | |
| | | @Resource |
| | | SimuService simuService; |
| | | |
| | | @Resource |
| | | ResolveService resolveService; |
| | | |
| | | @ApiOperation(value = "01.insertRegion <") |
| | | @GetMapping("/insertRegion") |
| | |
| | | @ApiOperation(value = "04.testPngList <") |
| | | @GetMapping("/testPngList") |
| | | @ApiImplicitParams({ |
| | | @ApiImplicitParam(name = "path", value = "路径", dataType = "String", paramType = "query", example = "D:\\other\\simu\\out\\chicago\\waters"), |
| | | @ApiImplicitParam(name = "path", value = "路径", dataType = "String", paramType = "query", example = "fs24cubic"), |
| | | @ApiImplicitParam(name = "size", value = "尺寸", dataType = "Integer", paramType = "query", example = "1024") |
| | | }) |
| | | public R<Object> testPngList(String path, Integer size) { |
| | | try { |
| | | if (null == size) size = (Integer) 1024; |
| | | |
| | | String newPath = config.getOutPath() + File.separator + path + File.separator + "waters"; |
| | | String pngPath = config.getOutPath() + File.separator + path + File.separator + "png"; |
| | | if (!new File(pngPath).exists()) new File(pngPath).mkdirs(); |
| | | |
| | | int i = 1; |
| | | List<String> list = new ArrayList<>(); |
| | | for (File file : new File(path).listFiles()) { |
| | | for (File file : new File(newPath).listFiles()) { |
| | | if (!file.exists() || file.isFile()) continue; |
| | | |
| | | File pngFile = new File(file.getPath() + File.separator + size + "_" + size + ".png"); |
| | | if (!pngFile.exists() || pngFile.isDirectory()) continue; |
| | | |
| | | list.add("file '" + pngFile.getPath().replace("\\", "/") + "'"); |
| | | String pngName = i + ".png"; // String.format("f%06d", i) |
| | | Files.copy(pngFile.toPath(), Paths.get(pngPath + File.separator + pngName), StandardCopyOption.REPLACE_EXISTING); |
| | | |
| | | list.add("file '" + pngName + "'"); |
| | | System.out.println(list.get(list.size() - 1)); |
| | | i++; |
| | | } |
| | | |
| | | Path outPath = Paths.get(path + File.separator + "list.txt"); |
| | | Path outPath = Paths.get(pngPath + File.separator + "list.txt"); |
| | | try { |
| | | Files.write(outPath, list, StandardCharsets.UTF_8); |
| | | } catch (IOException e) { |
| | |
| | | }) |
| | | public R<Object> testNsl(String inPath, String startTime, Integer epsg) { |
| | | try { |
| | | DataPo data = new DataPo(); |
| | | SimuData data = new SimuData(); |
| | | data.setInPath(inPath); |
| | | data.setStartTime(StringHelper.YMDHMS_FORMAT.parse(startTime)); |
| | | data.setEpsg(epsg); |
| | |
| | | @ApiImplicitParams({ |
| | | @ApiImplicitParam(name = "tifPath", value = "Tif路径", dataType = "String", paramType = "query", example = "D:\\other\\simu\\uwsolver\\chicago"), |
| | | @ApiImplicitParam(name = "inPath", value = "输入路径", dataType = "String", paramType = "query", example = "20250425"), |
| | | @ApiImplicitParam(name = "startTime", value = "开始时间", dataType = "Integer", paramType = "query", example = "2025-04-25 00:00:00"), |
| | | @ApiImplicitParam(name = "startTime", value = "开始时间", dataType = "Integer", paramType = "query", example = "2025-04-29 00:00:00"), |
| | | @ApiImplicitParam(name = "epsg", value = "坐标系ID", dataType = "Integer", paramType = "query", example = "4548") |
| | | }) |
| | | public R<Object> testCreateNsl(String tifPath, String inPath, String startTime, Integer epsg) { |
| | | try { |
| | | DataPo data = new DataPo(); |
| | | SimuData data = new SimuData(); |
| | | data.setInPath(inPath); |
| | | data.setStartTime(StringHelper.YMDHMS_FORMAT.parse(startTime)); |
| | | data.setEpsg(epsg); |
| | | |
| | | procTifs(tifPath, data.getStartTime()); |
| | | procTifs(tifPath, inPath, data.getStartTime()); |
| | | testService.test(data); |
| | | |
| | | return success("ok"); |
| | |
| | | } |
| | | } |
| | | |
| | | private void procTifs(String tifPath, Date startTime) { |
| | | private void procTifs(String tifPath, String inPath, Date startTime) { |
| | | if (StringUtils.isEmpty(tifPath)) return; |
| | | |
| | | Calendar calendar = Calendar.getInstance(); |
| | | calendar.setTime(new Date(startTime.getYear() - 1900, startTime.getMonth() - 1, startTime.getDay(), 0, 0, 0)); |
| | | //calendar.setTime(new Date(startTime.getYear() - 1900, startTime.getMonth() - 1, startTime.getDay(), 0, 0, 0)); |
| | | calendar.setTime(startTime); |
| | | SimpleDateFormat df = new SimpleDateFormat("yyyyMMddHHmmss"); |
| | | String newPath = config.getInPath() + File.separator + "depth"; |
| | | String newPath = config.getInPath() + File.separator + inPath + File.separator + "depth"; |
| | | if (!new File(newPath).exists()) new File(newPath).mkdirs(); |
| | | |
| | | for (File file : new File(tifPath).listFiles()) { |
| | | if (!file.exists() || !file.isDirectory()) continue; |
| | |
| | | } |
| | | } |
| | | |
| | | @ApiOperation(value = "11.renametifs <") |
| | | @GetMapping("/renametifs") |
| | | @ApiImplicitParams({ |
| | | @ApiImplicitParam(name = "path", value = "路径", dataType = "String", paramType = "query", example = "D:\\other\\simu\\uwsolver\\chicago\\depth"), |
| | | @ApiImplicitParam(name = "prefix", value = "前缀", dataType = "Integer", paramType = "query", example = "01250302"), |
| | | @ApiImplicitParam(name = "newPrefix", value = "新前缀", dataType = "Integer", paramType = "query", example = "20250429") |
| | | }) |
| | | public R<Object> renametifs(String path, String prefix, String newPrefix) { |
| | | try { |
| | | File[] files = new File(path).listFiles(); |
| | | for (File file : files) { |
| | | String newName = file.getPath().replace(prefix, newPrefix); |
| | | file.renameTo(new File(newName)); |
| | | } |
| | | |
| | | return success("ok"); |
| | | } catch (Exception ex) { |
| | | return fail(ex, null); |
| | | } |
| | | } |
| | | |
| | | @ApiOperation(value = "10.当前时间 *") |
| | | @GetMapping("/getTime") |
| | | public Object getTime() { |
| | | 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);*/ |
| | | |
| | | /*Simu simu = simuService.selectById(17); |
| | | SimuData data = JSON.parseObject(simu.getData(), SimuData.class); |
| | | resolveService.initArgs(data); |
| | | resolveService.createRainfallFile(simu, data); |
| | | resolveService.callUwSolver(data);*/ |
| | | |
| | | /*SimuData data = new SimuData(); |
| | | data.setStartTime(new Date(1748747454000L)); |
| | | data.setInPath("20250515143948"); |
| | | data.setOutPath(data.getInPath()); |
| | | data.setEpsg(4548); |
| | | testService.test(data);*/ |
| | | |
| | | Simu simu = simuService.selectById(17); |
| | | SimuData data = JSON.parseObject(simu.getData(), SimuData.class); |
| | | resolveService.initArgs(simu, data); |
| | | |
| | | return (Object) System.currentTimeMillis(); |
| | | } |
| | | |