From 61b6a81cad8e9d2674ef265b7814041b5ce5cdac Mon Sep 17 00:00:00 2001
From: 张洋洋 <10611411+yang-yang-z@user.noreply.gitee.com>
Date: 星期一, 20 一月 2025 09:34:04 +0800
Subject: [PATCH] [add]管线json

---
 src/main/java/com/se/simu/controller/SimuController.java |   36 +++++++++++++++++++++++++-----------
 1 files changed, 25 insertions(+), 11 deletions(-)

diff --git a/src/main/java/com/se/simu/controller/SimuController.java b/src/main/java/com/se/simu/controller/SimuController.java
index 5879100..dc355c6 100644
--- a/src/main/java/com/se/simu/controller/SimuController.java
+++ b/src/main/java/com/se/simu/controller/SimuController.java
@@ -387,7 +387,7 @@
             metry.put("type", "MultiPoint");
             metry.put("lod", 0);
             JSONArray boundarie = new JSONArray();
-            boundarie.add(jsonObject.getJSONArray("vertices").size());
+            boundarie.add(jsonObject.getJSONArray("vertices").size()-1);
             metry.put("boundaries", boundarie);
             geometry.add(metry);
             cityObject.put("geometry", geometry);
@@ -428,7 +428,7 @@
             metry.put("type", "MultiPoint");
             metry.put("lod", 0);
             JSONArray boundarie = new JSONArray();
-            boundarie.add(jsonObject.getJSONArray("vertices").size());
+            boundarie.add(jsonObject.getJSONArray("vertices").size()-1);
             metry.put("boundaries", boundarie);
             geometry.add(metry);
             cityObject.put("geometry", geometry);
@@ -467,15 +467,12 @@
             JSONArray array = JSONObject.parseObject(map.get("the_geom").toString()).getJSONArray("coordinates");
             for (int i = 0; i < array.size(); i++) {
                 JSONObject object = JSONObject.parseObject(array.get(i).toString());
-                JSONArray vertice = new JSONArray();
-                //todo 鏈潵淇敼鍧愭爣绯�
-                vertice.add(object.get("x"));
-                vertice.add(object.get("y"));
-                vertice.add(0.0);
-                jsonObject.getJSONArray("vertices").add(vertice);
-                boundarie.add(jsonObject.getJSONArray("vertices").size());
+                jsonObject.getJSONArray("vertices").add(ProjectionToGeographicUtil.getPoint(Double.valueOf(object.get("x").toString()),Double.valueOf(object.get("y").toString())));
+                boundarie.add(jsonObject.getJSONArray("vertices").size()-1);
             }
-            metry.put("boundaries", boundarie);
+            JSONArray jsonArray=new JSONArray();
+            jsonArray.add(boundarie);
+            metry.put("boundaries", jsonArray);
             cityObject.put("geometry",metry);
             cityObject.put("attributes",attribute);
             cityObject.put("attributes", attribute);
@@ -493,7 +490,24 @@
         fileWriter.close();
         return success(pointPath);
     }
-
+    @ApiOperation(value = "鍦板舰杞琧ityjson")
+    @GetMapping(value = "/terrainToCityJson", produces = "application/json; charset=UTF-8")
+    public R<String> terrainToCityJson(@RequestParam("tifPath") String tifPath) throws Exception {
+        long times = System.currentTimeMillis();
+        String path = outPath + "\\terrain\\"+times+"\\";
+        File dirFile = new File(path+"appearance");
+        if (!dirFile.exists()) {
+            dirFile.mkdirs();
+        }
+        String pngPath=path+"appearance\\terrain.png";
+        TiffToRGBUtil.tifToPng(tifPath,pngPath);
+        JSONObject jsonObject = getModule("terrainmodule.json");
+        jsonObject.put("vertices",TiffCoordinateExtractorUtil.getCoordinate(tifPath));
+        FileWriter fileWriter = new FileWriter(path + "terrain.json");
+        fileWriter.write(jsonObject.toJSONString());
+        fileWriter.close();
+        return success(path);
+    }
     public JSONObject getModule(String moduleName) {
         JSONObject jsonObject = new JSONObject();
         try {

--
Gitblit v1.9.3