From 2953a6d4cf34e3b91005390f9874db5565092056 Mon Sep 17 00:00:00 2001 From: 张洋洋 <10611411+yang-yang-z@user.noreply.gitee.com> Date: 星期四, 23 一月 2025 15:44:48 +0800 Subject: [PATCH] [add]cityjson转sem --- src/main/java/com/se/simu/utils/TiffToRGBUtil.java | 2 libs/sem-1.1.1.jar | 0 libs/citygson-1.1.3.8.jar | 0 pom.xml | 19 +++++++++ src/main/java/com/se/simu/utils/SemUtils.java | 31 +++++++++++++++ src/main/java/com/se/simu/controller/SimuController.java | 10 ++++- 6 files changed, 59 insertions(+), 3 deletions(-) diff --git a/libs/citygson-1.1.3.8.jar b/libs/citygson-1.1.3.8.jar new file mode 100644 index 0000000..ac6a44b --- /dev/null +++ b/libs/citygson-1.1.3.8.jar Binary files differ diff --git a/libs/sem-1.1.1.jar b/libs/sem-1.1.1.jar new file mode 100644 index 0000000..45d18cd --- /dev/null +++ b/libs/sem-1.1.1.jar Binary files differ diff --git a/pom.xml b/pom.xml index e9ee0c3..5b172a8 100644 --- a/pom.xml +++ b/pom.xml @@ -308,6 +308,25 @@ <artifactId>commons-imaging</artifactId> <version>1.0-alpha2</version> </dependency> + <dependency> + <groupId>org.citygml4j</groupId> + <artifactId>citygson</artifactId> + <version>1.1.3.8</version> + <scope>system</scope> + <systemPath>${project.basedir}/libs/citygson-1.1.3.8.jar</systemPath> + </dependency> + <dependency> + <groupId>cn.smartearth</groupId> + <artifactId>sem</artifactId> + <version>1.1.1</version> + <scope>system</scope> + <systemPath>${project.basedir}/libs/sem-1.1.1.jar</systemPath> + </dependency> + <dependency> + <groupId>com.google.code.gson</groupId> + <artifactId>gson</artifactId> + <version>2.8.2</version> + </dependency> </dependencies> <repositories> <repository> diff --git a/src/main/java/com/se/simu/controller/SimuController.java b/src/main/java/com/se/simu/controller/SimuController.java index dc355c6..cf7f629 100644 --- a/src/main/java/com/se/simu/controller/SimuController.java +++ b/src/main/java/com/se/simu/controller/SimuController.java @@ -343,7 +343,7 @@ @ApiOperation(value = "tarr鏂囦欢缁勮") @GetMapping(value = "/saveZarr", produces = "application/json; charset=UTF-8") - public R<Boolean> saveZarr(@RequestParam("name") String tableName) throws IOException { + public R<Boolean> saveZarr(@RequestParam("name") String tableName) throws Exception { List<String> list = CsvToSQLiteUtils.getNameList(tableName); String path = outPath + "\\"; String rainfall = "rainfall\\"; @@ -400,6 +400,7 @@ FileWriter fileWriter = new FileWriter(path + tableName + "\\闄嶉洦閲�.json"); fileWriter.write(jsonObject.toJSONString()); fileWriter.close(); + SemUtils.cityJsonToSem(path + tableName + "\\闄嶉洦閲�.json",path + tableName + "\\闄嶉洦閲�.sem"); return success(true); } @@ -443,6 +444,7 @@ FileWriter fileWriter = new FileWriter(pointPath); fileWriter.write(jsonObject.toJSONString()); fileWriter.close(); + SemUtils.cityJsonToSem(pointPath,path + times + "\\绠$偣.sem"); return success(pointPath); } @@ -473,7 +475,9 @@ JSONArray jsonArray=new JSONArray(); jsonArray.add(boundarie); metry.put("boundaries", jsonArray); - cityObject.put("geometry",metry); + JSONArray metryArray=new JSONArray(); + metryArray.add(metry); + cityObject.put("geometry",metryArray); cityObject.put("attributes",attribute); cityObject.put("attributes", attribute); geometry.add(metry); @@ -488,6 +492,7 @@ FileWriter fileWriter = new FileWriter(pointPath); fileWriter.write(jsonObject.toJSONString()); fileWriter.close(); + SemUtils.cityJsonToSem(pointPath, path + times + "\\绠$嚎.sem"); return success(pointPath); } @ApiOperation(value = "鍦板舰杞琧ityjson") @@ -506,6 +511,7 @@ FileWriter fileWriter = new FileWriter(path + "terrain.json"); fileWriter.write(jsonObject.toJSONString()); fileWriter.close(); + SemUtils.cityJsonToSem(path + "terrain.json", path + "terrain.sem"); return success(path); } public JSONObject getModule(String moduleName) { diff --git a/src/main/java/com/se/simu/utils/SemUtils.java b/src/main/java/com/se/simu/utils/SemUtils.java new file mode 100644 index 0000000..b16bf0a --- /dev/null +++ b/src/main/java/com/se/simu/utils/SemUtils.java @@ -0,0 +1,31 @@ +package com.se.simu.utils; + + +import cn.smartearth.sem.SEM; + +public class SemUtils { + public static void main(String[] args) throws Exception { + //cityjson杞瑂em 绠$偣 瀹屾垚 +// SEM sem = SEM.fromCityJSON("D:\\out\\point\\1737602481122\\绠$偣.json"); +// sem.writeToFile("D:\\out\\point\\1737602481122\\point.sem"); + //cityjson杞瑂em 绠$嚎 +// SEM sem = SEM.fromCityJSON("D:\\out\\line\\1737615372545\\绠$嚎.json"); +// sem.writeToFile("D:\\out\\line\\1737615372545\\绠$嚎.sem"); + //cityjson杞瑂em 鍦板舰 瀹屾垚 +// SEM sem = SEM.fromCityJSON("D:\\out\\terrain\\1737603153671\\terrain.json"); +// sem.writeToFile("D:\\out\\terrain\\1737603153671\\terrain.sem"); + //cityjson杞瑂em 闄嶉洦(鎴愬姛) + SEM sem = SEM.fromCityJSON("D:\\out\\station_rain_1736399134241\\闄嶉洦閲�.json"); + sem.writeToFile("D:\\out\\station_rain_1736399134241\\闄嶉洦閲�.sem"); + } + public static void cityJsonToSem(String jsonUrl,String semUrl) throws Exception { + //cityjson杞瑂em + SEM sem = SEM.fromCityJSON(jsonUrl); + sem.writeToFile(semUrl); + } + public static void semToCityJson() throws Exception { + //sem杞琧ityjson + SEM sem2 = new SEM("C:\\XXX\\Grid.sem"); + sem2.writeToCityJSON("C:\\XXX\\Gridout.json"); + } +} diff --git a/src/main/java/com/se/simu/utils/TiffToRGBUtil.java b/src/main/java/com/se/simu/utils/TiffToRGBUtil.java index ee40227..6df3dec 100644 --- a/src/main/java/com/se/simu/utils/TiffToRGBUtil.java +++ b/src/main/java/com/se/simu/utils/TiffToRGBUtil.java @@ -1,8 +1,8 @@ package com.se.simu.utils; import org.apache.commons.imaging.*; -import org.gdal.gdal.Band; import org.gdal.gdal.Dataset; +import org.gdal.gdal.Band; import org.gdal.gdal.gdal; import org.gdal.gdalconst.gdalconstConstants; -- Gitblit v1.9.3