From 1cae540cd2b99803808d31a3a5dd35e3216f19c7 Mon Sep 17 00:00:00 2001 From: wuww <252740454@qq.com> Date: 星期三, 30 四月 2025 14:50:54 +0800 Subject: [PATCH] 插值处理-四邻域 --- src/main/java/com/se/nsl/controller/TestController.java | 51 ++++++++++++++++++++++++++++++++++++++++++--------- 1 files changed, 42 insertions(+), 9 deletions(-) diff --git a/src/main/java/com/se/nsl/controller/TestController.java b/src/main/java/com/se/nsl/controller/TestController.java index 3f4a6c4..a306916 100644 --- a/src/main/java/com/se/nsl/controller/TestController.java +++ b/src/main/java/com/se/nsl/controller/TestController.java @@ -175,24 +175,34 @@ @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 = "D:\\other\\simu\\out\\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) { @@ -232,7 +242,7 @@ @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 = "鍧愭爣绯籌D", dataType = "Integer", paramType = "query", example = "4548") }) public R<Object> testCreateNsl(String tifPath, String inPath, String startTime, Integer epsg) { @@ -242,7 +252,7 @@ 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"); @@ -251,13 +261,15 @@ } } - 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; @@ -275,6 +287,27 @@ } } + @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() { -- Gitblit v1.9.3