From c3137476e71b28cb77f52d24b2714cee336fc2f4 Mon Sep 17 00:00:00 2001 From: 张洋洋 <10611411+yang-yang-z@user.noreply.gitee.com> Date: 星期一, 10 二月 2025 13:43:40 +0800 Subject: [PATCH] [add]cityjson转sem --- src/main/java/com/se/simu/controller/SimuController.java | 102 +++++++++++++++++++++++++++++++++++++++++++------- 1 files changed, 87 insertions(+), 15 deletions(-) diff --git a/src/main/java/com/se/simu/controller/SimuController.java b/src/main/java/com/se/simu/controller/SimuController.java index e11153d..dd371ea 100644 --- a/src/main/java/com/se/simu/controller/SimuController.java +++ b/src/main/java/com/se/simu/controller/SimuController.java @@ -54,6 +54,9 @@ @Value("${config.outPath}") private String outPath; + @Value("${config.inPath}") + private String inPath; + @Resource ResultService resultService; @@ -401,8 +404,13 @@ FileWriter fileWriter = new FileWriter(path + tableName + "\\闄嶉洦閲�.json"); fileWriter.write(jsonObject.toJSONString()); fileWriter.close(); - SemUtils.cityJsonToSem(path + tableName + "\\闄嶉洦閲�.json", path + tableName + "\\station_rain.sem"); - return success(path + tableName + "\\station_rain.sem"); + String filePatn = inPath + "\\tongzhou\\"; + File file = new File(filePatn); + if (!file.exists()) { + file.mkdirs(); + } + SemUtils.cityJsonToSem(path + tableName + "\\闄嶉洦閲�.json", filePatn + "raingage.sem"); + return success(filePatn + "raingage.sem"); } @ApiOperation(value = "绠$偣杞琧ityjson") @@ -445,8 +453,13 @@ FileWriter fileWriter = new FileWriter(pointPath); fileWriter.write(jsonObject.toJSONString()); fileWriter.close(); - SemUtils.cityJsonToSem(pointPath, path + times + "\\point.sem"); - return success(path + times + "\\point.sem"); + 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") @@ -493,8 +506,13 @@ FileWriter fileWriter = new FileWriter(pointPath); fileWriter.write(jsonObject.toJSONString()); fileWriter.close(); - SemUtils.cityJsonToSem(pointPath, path + times + "\\line.sem"); - return success(path + times + "\\line.sem"); + String filePatn = inPath + "\\tongzhou\\"; + File file = new File(filePatn); + if (!file.exists()) { + file.mkdirs(); + } + SemUtils.cityJsonToSem(pointPath, filePatn+ "link.sem"); + return success(filePatn + "link.sem"); } @ApiOperation(value = "鍦板舰杞琧ityjson") @@ -513,8 +531,13 @@ FileWriter fileWriter = new FileWriter(path + "terrain.json"); fileWriter.write(jsonObject.toJSONString()); fileWriter.close(); - SemUtils.cityJsonToSem(path + "terrain.json", path + "terrain.sem"); - return success(path + "terrain.sem"); + String filePatn = inPath + "\\tongzhou\\"; + File file = new File(filePatn); + if (!file.exists()) { + file.mkdirs(); + } + SemUtils.cityJsonToSem(path + "terrain.json", filePatn + "terrain.sem"); + return success(filePatn + "terrain.sem"); } @ApiOperation(value = "grid杞琧ityjson") @@ -522,26 +545,75 @@ public R<String> gridToCityJson(@RequestBody List<GridDto> dtos) throws Exception { long times = System.currentTimeMillis(); String path = outPath + "\\grid\\" + times + "\\"; - File dirFile = new File(path ); + File dirFile = new File(path); if (!dirFile.exists()) { dirFile.mkdirs(); } JSONObject jsonObject = getModule("grid.json"); JSONArray array = jsonObject.getJSONArray("vertices"); - for (GridDto dto:dtos - ) { - JSONArray jsonArray=new JSONArray(); + for (GridDto dto : dtos + ) { + JSONArray jsonArray = new JSONArray(); jsonArray.add(dto.getLon()); jsonArray.add(dto.getLat()); jsonArray.add(0); array.add(jsonArray); } - jsonObject.put("vertices",array); + jsonObject.put("vertices", array); FileWriter fileWriter = new FileWriter(path + "grid.json"); fileWriter.write(jsonObject.toJSONString()); fileWriter.close(); - SemUtils.cityJsonToSem(path + "grid.json", path + "grid.sem"); - return success(path + "grid.sem"); + String filePatn = inPath + "\\tongzhou\\"; + File file = new File(filePatn); + if (!file.exists()) { + file.mkdirs(); + } + SemUtils.cityJsonToSem(path + "grid.json", filePatn + "grid.sem"); + return success(filePatn + "grid.sem"); + } + + @ApiOperation(value = "river杞瑂em") + @GetMapping(value = "/riverToSem", produces = "application/json; charset=UTF-8") + public R<String> riverToSem() throws Exception { + long times = System.currentTimeMillis(); + String path = outPath + "\\river\\" + times + "\\"; + File dirFile = new File(path); + if (!dirFile.exists()) { + dirFile.mkdirs(); + } + JSONObject jsonObject = getModule("river.json"); + FileWriter fileWriter = new FileWriter(path + "river.json"); + fileWriter.write(jsonObject.toJSONString()); + fileWriter.close(); + String filePatn = inPath + "\\tongzhou\\"; + File file = new File(filePatn); + if (!file.exists()) { + file.mkdirs(); + } + SemUtils.cityJsonToSem(path + "river.json", filePatn + "river.sem"); + return success(filePatn + "river.sem"); + } + + @ApiOperation(value = "landuse杞瑂em") + @GetMapping(value = "/landuseToSem", produces = "application/json; charset=UTF-8") + public R<String> landuseToSem() throws Exception { + long times = System.currentTimeMillis(); + String path = outPath + "\\landuse\\" + times + "\\"; + File dirFile = new File(path); + if (!dirFile.exists()) { + dirFile.mkdirs(); + } + JSONObject jsonObject = getModule("landuse.json"); + FileWriter fileWriter = new FileWriter(path + "landuse.json"); + fileWriter.write(jsonObject.toJSONString()); + fileWriter.close(); + String filePatn = inPath + "\\tongzhou\\"; + File file = new File(filePatn); + if (!file.exists()) { + file.mkdirs(); + } + SemUtils.cityJsonToSem(path + "landuse.json", filePatn + "landuse.sem"); + return success(filePatn + "landuse.sem"); } public JSONObject getModule(String moduleName) { -- Gitblit v1.9.3