张洋洋
2025-02-10 c3137476e71b28cb77f52d24b2714cee336fc2f4
[add]cityjson转sem
已添加2个文件
已修改2个文件
98 ■■■■ 文件已修改
src/main/java/com/se/simu/controller/SimuController.java 92 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/se/simu/utils/SemUtils.java 4 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/resources/landuse.json 1 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/resources/river.json 1 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
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 = "管点转cityjson")
@@ -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 = "管线转cityjson")
@@ -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 = "地形转cityjson")
@@ -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转cityjson")
@@ -540,8 +563,57 @@
        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转sem")
    @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转sem")
    @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) {
src/main/java/com/se/simu/utils/SemUtils.java
@@ -14,7 +14,7 @@
    }
    public static void semToCityJson() throws Exception {
        //sem转cityjson
        SEM sem2 = new SEM("D:\\城市内涝\\sem\\tongzhou\\tongzhou\\grid.sem");
        sem2.writeToCityJSON("D:\\城市内涝\\sem\\tongzhou\\tongzhou\\grid\\grid.json");
        SEM sem2 = new SEM("D:\\城市内涝\\sem\\tongzhou\\tongzhou\\landuse.sem");
        sem2.writeToCityJSON("D:\\城市内涝\\sem\\tongzhou\\tongzhou\\landuse\\landuse.json");
    }
}
src/main/resources/landuse.json
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1 @@
{"type":"CityJSON","metadata":{"referenceSystem":"urn:ogc:def:crs:EPSG::4326","datasetPointOfContact":{}},"version":"1.0","CityObjects":{},"vertices":[]}
src/main/resources/river.json
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1 @@
{"type":"CityJSON","version":"1.0","metadata":{"referenceSystem":"urn:ogc:def:crs:EPSG::4326","datasetPointOfContact":{}},"CityObjects":{},"vertices":[],"appearance":{"materials":[],"textures":[],"vertices-texture":[]},"geometry-templates":{"templates":[],"vertices-templates":[]}}