From 75a3851294865b31d228872ea677f80cd0cda028 Mon Sep 17 00:00:00 2001 From: 张洋洋 <10611411+yang-yang-z@user.noreply.gitee.com> Date: 星期三, 12 二月 2025 17:25:58 +0800 Subject: [PATCH] [add]tif裁剪 --- src/main/java/com/se/simu/controller/SimuController.java | 96 ++++++++++++++++++++++++------------------------ 1 files changed, 48 insertions(+), 48 deletions(-) diff --git a/src/main/java/com/se/simu/controller/SimuController.java b/src/main/java/com/se/simu/controller/SimuController.java index 31b3435..c1282d6 100644 --- a/src/main/java/com/se/simu/controller/SimuController.java +++ b/src/main/java/com/se/simu/controller/SimuController.java @@ -492,54 +492,54 @@ SemUtils.cityJsonToSem(pointPath, filePatn + "node.sem"); return success(filePatn + "node.sem"); } -// @ApiOperation(value = "绠$偣杞琧ityjson") -// @GetMapping(value = "/pointToCityJson", produces = "application/json; charset=UTF-8") -// public R<String> pointToCityJson(@RequestParam("shpPath") String shpPath) throws Exception { -// String path = outPath + "\\point\\"; -// List<Map<String, Object>> list = ShpReadUtils.readPointShp(shpPath); -// JSONObject jsonObject = getModule("pointmodule.json"); -// for (Map<String, Object> map : list -// ) { -// //鎷艰鍧愭爣 -// JSONArray vertice = new JSONArray(); -// vertice.add(map.get("lon")); -// vertice.add(map.get("lat")); -// vertice.add(0.0); -// jsonObject.getJSONArray("vertices").add(vertice); -// //鎷艰鍩虹淇℃伅 -// JSONObject cityObject = new JSONObject(); -// cityObject.put("type", "+PipePoint"); -// JSONObject attribute = new JSONObject(); -// attribute.put("name", map.get("fsw")); -// cityObject.put("attributes", attribute); -// JSONArray geometry = new JSONArray(); -// JSONObject metry = new JSONObject(); -// metry.put("type", "MultiPoint"); -// metry.put("lod", 0); -// JSONArray boundarie = new JSONArray(); -// boundarie.add(jsonObject.getJSONArray("vertices").size() - 1); -// metry.put("boundaries", boundarie); -// geometry.add(metry); -// cityObject.put("geometry", geometry); -// jsonObject.getJSONObject("CityObjects").put("UUID_" + UUID.randomUUID().toString(), cityObject); -// } -// long times = System.currentTimeMillis(); -// String pointPath = path + times + "\\绠$偣.json"; -// File dirFile = new File(path + times); -// if (!dirFile.exists()) { -// dirFile.mkdirs(); -// } -// FileWriter fileWriter = new FileWriter(pointPath); -// fileWriter.write(jsonObject.toJSONString()); -// fileWriter.close(); -// String filePatn = inPath + "\\tongzhou\\"; -// File file = new File(filePatn); -// if (!file.exists()) { -// file.mkdirs(); -// } -// SemUtils.cityJsonToSem(pointPath, filePatn + "node.sem"); -// return success(filePatn + "node.sem"); -// } + @ApiOperation(value = "绠$偣杞琧ityjson") + @GetMapping(value = "/pointToCityJson", produces = "application/json; charset=UTF-8") + public R<String> pointToCityJson(@RequestParam("shpPath") String shpPath) throws Exception { + String path = outPath + "\\point\\"; + List<Map<String, Object>> list = ShpReadUtils.readPointShp(shpPath); + JSONObject jsonObject = getModule("pointmodule.json"); + for (Map<String, Object> map : list + ) { + //鎷艰鍧愭爣 + JSONArray vertice = new JSONArray(); + vertice.add(map.get("lon")); + vertice.add(map.get("lat")); + vertice.add(0.0); + jsonObject.getJSONArray("vertices").add(vertice); + //鎷艰鍩虹淇℃伅 + JSONObject cityObject = new JSONObject(); + cityObject.put("type", "+PipePoint"); + JSONObject attribute = new JSONObject(); + attribute.put("name", map.get("fsw")); + cityObject.put("attributes", attribute); + JSONArray geometry = new JSONArray(); + JSONObject metry = new JSONObject(); + metry.put("type", "MultiPoint"); + metry.put("lod", 0); + JSONArray boundarie = new JSONArray(); + boundarie.add(jsonObject.getJSONArray("vertices").size() - 1); + metry.put("boundaries", boundarie); + geometry.add(metry); + cityObject.put("geometry", geometry); + jsonObject.getJSONObject("CityObjects").put("UUID_" + UUID.randomUUID().toString(), cityObject); + } + long times = System.currentTimeMillis(); + String pointPath = path + times + "\\绠$偣.json"; + File dirFile = new File(path + times); + if (!dirFile.exists()) { + dirFile.mkdirs(); + } + FileWriter fileWriter = new FileWriter(pointPath); + fileWriter.write(jsonObject.toJSONString()); + fileWriter.close(); + String filePatn = inPath + "\\tongzhou\\"; + File file = new File(filePatn); + if (!file.exists()) { + file.mkdirs(); + } + SemUtils.cityJsonToSem(pointPath, filePatn + "node.sem"); + return success(filePatn + "node.sem"); + } @ApiOperation(value = "绠$嚎sem鐢熸垚") @PostMapping(value = "/lineToSem", produces = "application/json; charset=UTF-8") -- Gitblit v1.9.3