Răsfoiți Sursa

针对Polygon和MultiPolygon坐标采取不同处理方式

Bella 2 ani în urmă
părinte
comite
6500e13014
2 a modificat fișierele cu 50 adăugiri și 50 ștergeri
  1. 16 21
      src/components/map/MapHolder.vue
  2. 34 29
      src/views/ComprehensiveAnalysis.vue

+ 16 - 21
src/components/map/MapHolder.vue

@@ -699,7 +699,6 @@ export default {
      * @sourceType 土地资源/林地资源/生态资源/水资源/全部
      */
     addSinglePolygon(geometry, cid, color, uniqueId, mainType, sourceType) {
-      // debugger;
       let uniqueIdList = [];
       if (this.$store.state.selectSelectDataMap["singlePolygon"][uniqueId]) {
         uniqueIdList =
@@ -715,27 +714,23 @@ export default {
       this.$store.state.selectSelectDataMap["singlePolygon"][uniqueId] =
         uniqueIdList;
       let coordinates = "";
-
       // 当前数据坐标系为WGS84
-      let coord = JSON.parse(geometry).geometry.coordinates[0];
-      coordinates = coord.map((v) => {
-        return [v[1], v[0]];
-      });
-      // if (uniqueId === "一般耕地_47") {
-      //   let coord = JSON.parse(geometry).geometry.coordinates[0];
-      //   coordinates = coord.map((v) => {
-      //     return [v[1], v[0]];
-      //   });
-      // } else {
-      //   coordinates = JSON.parse(geometry).geometry.coordinates[0];
-      //   coordinates = coordinates.map((v) => {
-      //     let data = transformCoord.shcj_to_wgs84(v[1], [v[0]]);
-      //     data = [data[1], data[0]];
-      //     return data;
-      //   });
-      // }
-      // 纬经度
-      // [22474.568725585938, -16689.47381591797]
+      let targetGeometry = JSON.parse(geometry).geometry;
+      if (targetGeometry.type === "Polygon") {
+        let coord = targetGeometry.coordinates[0];
+        coordinates = coord.map((v) => {
+          return [v[1], v[0]];
+        });
+      }
+
+      if (targetGeometry.type === "MultiPolygon ") {
+        let coord = targetGeometry.coordinates[0][0];
+        coordinates = coord.map((v) => {
+          return v.map((e) => {
+            return [e[1], e[0]];
+          });
+        });
+      }
       // x,y转换
       let polygon = L.polygon(coordinates, {
         color: color,

+ 34 - 29
src/views/ComprehensiveAnalysis.vue

@@ -349,7 +349,6 @@ export default {
         pageSizes: [5, 10, 20, 30],
         total: 50,
         currentChange: (val) => {
-          // debugger;
           let columnId = this.enteredColumnId;
           let currentPageSize = this.currentPageSize;
           let panelId = this.enteredPanelId;
@@ -692,6 +691,7 @@ export default {
      * @sourceType 土地资源/林地资源/生态资源/水资源/全部
      */
     displaySingleLayer(columnId, id, mainType, sourceType) {
+      debugger;
       // if (id !== "永久基本农田_50") {
       let uniqueId = id;
       this.layerIdMap.set(uniqueId, uniqueId);
@@ -715,7 +715,7 @@ export default {
         layerParams = {
           columnId: columnId,
           states: "0,1,2,3",
-          pageSize: 500,
+          pageSize: 800,
           page: 0,
         };
         this.$Post(this.urlsCollection.selectContentList, layerParams).then(
@@ -798,7 +798,10 @@ export default {
                 );
               }
 
-              if (mainType === "预设模型") {
+              if (
+                mainType === "预设模型" &&
+                this.originalDataMap.get(uniqueId).length > 0
+              ) {
                 this.originalDataMap.get(uniqueId).map((ele) => {
                   let cid = ele.id;
                   let geometry = ele.c_content;
@@ -864,32 +867,36 @@ export default {
           // 激活当前展开面板
           this.activeNames = ["myLabel", uniqueId];
           // 已经请求过接口无需二次请求
-          this.originalData[uniqueId] = this.originalDataMap
-            .get(uniqueId)
-            .map((ele) => {
-              return {
-                id: ele.id,
-                column_name: ele.column_name,
-                // 是否疑点
-                c_boolean: ele.c_boolean ? "是" : "否",
-                // 行政区划
-                c_xzqh: ele.c_xzqh,
-                // 空间信息
-                c_content: ele.c_content,
-                // 疑点修改时间
-                c_date_time: ele.c_date_time,
-                // 修改人员名称
-                // c_editor_name: ele.c_editor_name,
-                // 标题
-                title: ele.title,
-                column_id: ele.column_id,
-                content: ele.content,
-                secret_level: ele.secret_level,
-              };
-            });
+          if (this.originalDataMap.get(uniqueId).length > 0) {
+            this.originalData[uniqueId] = this.originalDataMap
+              .get(uniqueId)
+              .map((ele) => {
+                return {
+                  id: ele.id,
+                  column_name: ele.column_name,
+                  // 是否疑点
+                  c_boolean: ele.c_boolean ? "是" : "否",
+                  // 行政区划
+                  c_xzqh: ele.c_xzqh,
+                  // 空间信息
+                  c_content: ele.c_content,
+                  // 疑点修改时间
+                  c_date_time: ele.c_date_time,
+                  // 修改人员名称
+                  // c_editor_name: ele.c_editor_name,
+                  // 标题
+                  title: ele.title,
+                  column_id: ele.column_id,
+                  content: ele.content,
+                  secret_level: ele.secret_level,
+                };
+              });
+          }
         }
 
-        this.currentTotal += this.originalDataMap.get(uniqueId).length;
+        if (this.originalDataMap.get(uniqueId).length > 0) {
+          this.currentTotal += this.originalDataMap.get(uniqueId).length;
+        }
       }
     },
     /**
@@ -1323,7 +1330,6 @@ export default {
             };
             this.$Post(this.urlsCollection.selectContentList, params).then(
               (res) => {
-                // debugger;
                 if (res.code === 202 && res.content === "数据不存在") {
                   this.$message.info("当前用户无权限!");
                   layerAuthorityMap.set(data.id, "无权限");
@@ -1420,7 +1426,6 @@ export default {
           this.$refs.tree.setCheckedKeys([data.id]);
         }
       });
-      // debugger;
       let uniqueId = data.id;
       // 我的模型图层组初始化
       if (!map2DViewer.analysisGroups[uniqueId]) {