소스 검색

完善线面体分割接口,优化微功能演示页面交互逻辑,优化微功能管理页面数据解析参数,支持自定义演示路由

DESKTOP-6LTVLN7\Liumouren 1 개월 전
부모
커밋
e0c03ea1b6
2개의 변경된 파일74개의 추가작업 그리고 17개의 파일을 삭제
  1. 62 13
      src/components/wgn/controlPanel.vue
  2. 12 4
      src/views/Wgn.vue

+ 62 - 13
src/components/wgn/controlPanel.vue

@@ -81,10 +81,23 @@
                   />
                 </el-select>
               </div>
-              <div v-if="['lon', 'lat', 'filePath', 'EPSILON'].includes(item)">
+              <div
+                v-if="
+                  [
+                    'lon',
+                    'lat',
+                    'lonKey',
+                    'latKey',
+                    'filePath',
+                    'EPSILON',
+                    'distance',
+                  ].includes(item)
+                "
+              >
                 {{ item }}:
                 <el-input
                   v-model="params[item]"
+                  @input="handleSelectChange(item, $event)"
                   style="width: 240px"
                   :placeholder="'请输入' + item"
                 />
@@ -153,6 +166,7 @@
             <vue-json-editor
               v-model="backData.content"
               :value="backData.content"
+              @json-change="handleJsonChange2"
               :show-btns="false"
               :mode="'code'"
               :lang="'zh'"
@@ -412,10 +426,10 @@ export default {
               value: "1.2.5.4",
               label: "缓冲区计算",
             },
-            // {
-            //   value: "1.2.5.5",
-            //   label: "线面体分割",
-            // },
+            {
+              value: "1.2.5.5",
+              label: "线面体分割",
+            },
             // {
             //   value: "1.2.5.6",
             //   label: "时空差异分析",
@@ -538,6 +552,9 @@ export default {
     handleJsonChange(jsonStr) {
       this.jsonData = jsonStr;
     },
+    handleJsonChange2(jsonStr) {
+      this.backData.content = jsonStr;
+    },
     // 搜索微功能服务
     searchServerList() {
       let requestParams = {
@@ -606,6 +623,7 @@ export default {
             this.addLine(coordinates);
             break;
           case "Polygon":
+          case "MultiPolygon":
             // 面
             this.addPolygon(coordinates);
             break;
@@ -628,6 +646,7 @@ export default {
               this.addLine(coordinates);
               break;
             case "Polygon":
+            case "MultiPolygon":
               // 面
               this.addPolygon(coordinates);
               break;
@@ -639,7 +658,8 @@ export default {
       setTimeout(() => {
         viewer.scene.requestRender();
       });
-    }, // 添加点到地图中
+    },
+    // 添加点到地图中
     addPoint(coordinates) {
       // 1. 解析点的坐标
       console.log("addPoint coordinates", coordinates);
@@ -664,7 +684,8 @@ export default {
       });
       // 3. 将点实体添加到drawnEntities中
       this.drawnEntities.push(pointEntity);
-    }, // 添加线到地图中
+    },
+    // 添加线到地图中
     addLine(coordinates) {
       // 1. 解析线的坐标
       console.log("addLine coordinates", coordinates);
@@ -715,21 +736,39 @@ export default {
     },
     // 添加面到地图中
     addPolygon(coordinates) {
-      // 2. 处理坐标格式:确保获取外部环坐标
+      // 检测是否为MultiPolygon类型(MultiPolygon的坐标是三维数组)
+      if (
+        Array.isArray(coordinates[0]) &&
+        Array.isArray(coordinates[0][0]) &&
+        Array.isArray(coordinates[0][0][0])
+      ) {
+        console.log("MultiPolygon coordinates", coordinates);
+        // 是MultiPolygon类型,遍历每个Polygon
+        coordinates.forEach((polygonCoordinates) => {
+          this.renderSinglePolygon(polygonCoordinates);
+        });
+      } else {
+        // 是单个Polygon类型
+        this.renderSinglePolygon(coordinates);
+      }
+    },
+    // 渲染单个Polygon
+    renderSinglePolygon(coordinates) {
+      // 1. 处理坐标格式:确保获取外部环坐标
       const outerRingCoordinates =
         Array.isArray(coordinates[0]) && Array.isArray(coordinates[0][0])
           ? coordinates[0]
           : coordinates;
 
-      // 3. 检测坐标是否包含Z值
+      // 2. 检测坐标是否包含Z值
       const hasZValues = outerRingCoordinates.some(
         (coord) => coord.length > 2 && typeof coord[2] === "number"
       );
 
-      // 4. 根据是否有Z值选择合适的坐标转换方法
+      // 3. 根据是否有Z值选择合适的坐标转换方法
       let positions;
       let baseHeight = 0;
-      let extrudedHeight = 100; // 默认挤压高度
+      let extrudedHeight = 0; // 默认挤压高度
 
       if (hasZValues) {
         // 包含Z值,使用带高度的坐标转换方法
@@ -759,7 +798,7 @@ export default {
         positions = SkyScenery.Cartesian3.fromDegreesArray(flatCoordinates);
       }
 
-      // 5. 创建面实体
+      // 4. 创建面实体
       const polygonEntity = viewer.entities.add({
         name: "polygon",
         polygon: {
@@ -780,7 +819,7 @@ export default {
         },
       });
 
-      // 6. 将面实体添加到drawnEntities中
+      // 5. 将面实体添加到drawnEntities中
       this.drawnEntities.push(polygonEntity);
     },
     handleSelectChange(item, value) {
@@ -1454,12 +1493,22 @@ export default {
       ) {
         requestData.outPrj = this.params.outPrj;
       }
+      if (
+        this.SceneValue &&
+        this.dmsServerItem &&
+        this.dmsServerItem.elementTypes &&
+        this.ifHasType("distance") &&
+        this.params.distance
+      ) {
+        requestData.distance = this.params.distance;
+      }
       this.jsonData = requestData;
     },
     // 发送几何数据到后台接口
     sendGeometriesToBackend() {
       // 这里使用axios发送请求,需要确保项目中已安装并导入axios
       let requestData;
+      this.backData = {};
       let requestUrl = this.dmsServerItem.apiUrl;
       if (
         this.ifHasType("point") ||

+ 12 - 4
src/views/Wgn.vue

@@ -154,11 +154,19 @@ export default {
     },
     // 在线演示微功能服务
     handleOnlineDemo(item) {
+      let routerPath = {};
       // 1. 解析目标路由(支持传参、命名路由等)
-      const routeData = this.$router.resolve({
-        path: "/wgnSingle", // 微功能
-        query: { sceneId: item.c_scene_name },
-      });
+      if (item.c_scene_name == "view") {
+        routerPath = {
+          path: item.c_url,
+        };
+      } else {
+        routerPath = {
+          path: "/wgnSingle", // 微功能
+          query: { sceneId: item.c_scene_name },
+        };
+      }
+      const routeData = this.$router.resolve(routerPath);
       // 2. 打开新窗口(_blank 表示新窗口)
       window.open(routeData.href, "_blank");
     },