Selaa lähdekoodia

差异分析结果查询mou结果空间分析范围,并优化矢量回执方法,支持传入参数为数组

lkk 1 kuukausi sitten
vanhempi
commit
b0d8d86a0f
1 muutettua tiedostoa jossa 59 lisäystä ja 19 poistoa
  1. 59 19
      website/src/views/ghfxpj/gtkjfxyy/ghcyfx.vue

+ 59 - 19
website/src/views/ghfxpj/gtkjfxyy/ghcyfx.vue

@@ -72,7 +72,11 @@ import Stroke from "ol/style/Stroke";
 import { Style, Icon } from "ol/style";
 import { fromLonLat } from "ol/proj";
 import { get as getProjection } from "ol/proj";
-import { getAttributesById, intersects } from "@/api/ghfxpj/cyfxApi.js";
+import {
+  getAttributesById,
+  intersects,
+  getGeomById,
+} from "@/api/ghfxpj/cyfxApi.js";
 
 export default {
   components: {
@@ -179,32 +183,59 @@ export default {
         }
       },
       postion(data) {
+        // 先清除已有图层
         ghcyfx.delPos();
+
+        // 定义高亮样式
         let highlightStyle = new Style({
           stroke: new Stroke({
             color: "rgba(255, 0, 0, 1)",
             width: 2,
           }),
         });
-        let geomData = data;
-        if (typeof geomData === "string") {
-          geomData = parse(geomData);
-        }
-        let features = new GeoJSON().readFeatures(geomData, {
-          dataProjection: getProjection("EPSG:4326"),
-          featureProjection: getProjection("EPSG:3857"),
-        });
-        ghcyfx.itemObj = new VectorLayer({
-          source: new VectorSource({ features }),
-          style: highlightStyle,
-          zIndex: 9999,
-        });
-        let extent = ghcyfx.itemObj.getSource().getExtent();
-        arcMap.addLayer(ghcyfx.itemObj);
-        arcMap.map.getView().fit(extent, {
-          duration: 2000,
-          callback: null,
+
+        // 处理数据为数组的情况
+        let geomArray = Array.isArray(data) ? data : [data];
+        let allFeatures = [];
+
+        geomArray.forEach((geomItem) => {
+          try {
+            let geomData = geomItem;
+            // 解析WKT格式字符串
+            if (typeof geomData === "string") {
+              geomData = parse(geomData);
+            }
+
+            // 读取要素并转换投影
+            let features = new GeoJSON().readFeatures(geomData, {
+              dataProjection: getProjection("EPSG:4326"),
+              featureProjection: getProjection("EPSG:3857"),
+            });
+
+            allFeatures.push(...features);
+          } catch (error) {
+            console.error("解析地理数据出错", error, "数据项:", geomItem);
+          }
         });
+
+        // 创建矢量图层并添加要素
+        if (allFeatures.length > 0) {
+          ghcyfx.itemObj = new VectorLayer({
+            source: new VectorSource({ features: allFeatures }),
+            style: highlightStyle,
+            zIndex: 9999,
+          });
+
+          // 添加图层并调整视图范围
+          arcMap.addLayer(ghcyfx.itemObj);
+          const extent = ghcyfx.itemObj.getSource().getExtent();
+          if (extent) {
+            arcMap.map.getView().fit(extent, {
+              duration: 2000,
+              callback: null,
+            });
+          }
+        }
       },
       dblClick(row, column, cell, event) {
         intersects({ id: ghcyfx.transfer.id, objectid: row["编号"] }).then(
@@ -227,6 +258,15 @@ export default {
           ghcyfx.showTable = false;
           ghcyfx.delPos();
         }
+        if (newvalue.showBrowsing) {
+          getGeomById({ id: newvalue.id }).then((res) => {
+            if (res.statuscode === 200) {
+              ghcyfx.postion(res.data);
+            }
+          });
+        } else {
+          ghcyfx.delPos();
+        }
       }
     );
     watch(