浏览代码

联级查询高亮

zpf 9 月之前
父节点
当前提交
afbb4cd069

+ 121 - 2
src/components/Query/clickQuery/MultiLevelQuery.vue

@@ -45,6 +45,7 @@ let manager_multi_level_query = null;
 let pick_entity = null;
 let pick_entity = null;
 
 
 let manager_multi_level_vector = null;
 let manager_multi_level_vector = null;
+let query_click_by_iserver = null;
 
 
 export default {
 export default {
     components: { pie },
     components: { pie },
@@ -214,6 +215,7 @@ export default {
                     },
                     },
 
 
                 })
                 })
+                console.log('longitude, latitude: ', longitude, latitude);
 
 
                 const geojsonPoint = {
                 const geojsonPoint = {
                     "type": "Point",
                     "type": "Point",
@@ -222,12 +224,15 @@ export default {
 
 
                 const wkt = wellknown.stringify(geojsonPoint);
                 const wkt = wellknown.stringify(geojsonPoint);
                 let id = store.state.vectorlayerlist[store.state.vectorlayerlist.length - 1].id
                 let id = store.state.vectorlayerlist[store.state.vectorlayerlist.length - 1].id
+                console.log('store.state.vectorlayerlist[store.state.vectorlayerlist.length - 1]: ',);
                 let obj = {
                 let obj = {
                     // "wkt": 'POINT (109.51207847188947 18.311530254307392)', //单面
                     // "wkt": 'POINT (109.51207847188947 18.311530254307392)', //单面
                     // "wkt": 'POINT (109.50728022974468 18.318266593715794)', //多面
                     // "wkt": 'POINT (109.50728022974468 18.318266593715794)', //多面
                     "wkt": wkt,
                     "wkt": wkt,
 
 
-                    "id": 'dd699f839bc04969ae2dc2e1964d0ad1',
+                    // "id": 'dd699f839bc04969ae2dc2e1964d0ad1',
+                    "id": id,
+
                 }
                 }
                 GetTableData(obj).then(res => {
                 GetTableData(obj).then(res => {
                     if (res.data.data != undefined) {
                     if (res.data.data != undefined) {
@@ -292,12 +297,96 @@ export default {
                 })
                 })
 
 
 
 
+                this.highlightResults(longitude, latitude);
 
 
                 that.handler_multi_level_query.destroy();
                 that.handler_multi_level_query.destroy();
                 that.handler_multi_level_query = null;
                 that.handler_multi_level_query = null;
             }, Cesium.ScreenSpaceEventType.LEFT_CLICK);
             }, Cesium.ScreenSpaceEventType.LEFT_CLICK);
 
 
 
 
+        },
+        async highlightResults(longitude, latitude) {
+            // 高亮结果
+            let queryByIDParameters = {
+                getFeatureMode: "BUFFER",
+                // getFeatureMode: "SPATIAL",
+                spatialQueryMode: "INTERSECT",
+                datasetNames: store.state.vectorlayerlist[store.state.vectorlayerlist.length - 1].source.split(","),
+                geometry: {
+                    parts: [1],
+                    points: [{ y: latitude, x: longitude }],
+                    type: "POINT",
+                },
+                bufferDistance: 0.00005,
+                hasGeometry: true,
+            };
+
+
+
+            let response = await axios.post(this.calcIserverURI(store.state.vectorlayerlist[store.state.vectorlayerlist.length - 1].url), queryByIDParameters);
+
+
+            const outputCoords = this.convertCoordinates(response.data.features[0].geometry.points);
+            outputCoords.push(outputCoords[0])
+
+            let f = { "type": "Polygon", "coordinates": [outputCoords] };
+            let result = turf.buffer(f, 1 / 99999, {
+                units: "kilometers",
+            });
+            let positions = [];
+            const twoDArray = result.geometry.coordinates[0];
+            const oneDArray = twoDArray.reduce((accumulator, currentValue) => accumulator.concat(currentValue), []);
+
+            positions = oneDArray;
+
+
+            if (this.isArray2D(oneDArray)) {
+                const oneDArray2 = oneDArray.reduce((accumulator, currentValue) => accumulator.concat(currentValue), []);
+                positions = oneDArray2;
+
+            } else {
+
+            }
+
+            query_click_by_iserver.entities.add({
+                polygon: {
+                    // 获取指定属性(positions,holes(图形内需要挖空的区域))
+                    hierarchy: {
+                        positions: Cesium.Cartesian3.fromDegreesArray(positions)
+                    },
+                    // 边框
+                    outline: false,
+                    // 边框颜色
+                    outlineColor: Cesium.Color.RED,
+                    // 边框尺寸
+                    outlineWidth: 10,
+                    // 填充的颜色,withAlpha透明度
+                    material: Cesium.Color.RED,
+
+                    // 是否被提供的材质填充
+                    fill: true,
+                    // 恒定高度
+                    height: 1.1,
+                    // 显示在距相机的距离处的属性,多少区间内是可以显示的
+                    // distanceDisplayCondition: new Cesium.DistanceDisplayCondition(1000, 10000000),
+                    // 是否显示
+                    show: true,
+                    // 顺序,仅当`clampToGround`为true并且支持地形上的折线时才有效。
+                    zIndex: 10
+                }
+            });
+
+
+        },
+        convertCoordinates(coordArray) {
+            return coordArray.map(coord => [coord.x, coord.y]);
+        },
+        calcIserverURI(url) {
+            let uriArr = url.split("/");
+            uriArr[5] = uriArr[5].replace("map-", "data-");
+            uriArr[7] = "data";
+            uriArr[8] = "featureResults.rjson?returnContent=true";
+            return uriArr.join("/");
         },
         },
         multiPolygonToPolygons(multiPolygon) {
         multiPolygonToPolygons(multiPolygon) {
             const polygons = [];
             const polygons = [];
@@ -327,6 +416,8 @@ export default {
             //     viewer.scene.primitives.remove(element);
             //     viewer.scene.primitives.remove(element);
 
 
             // }
             // }
+
+            this.remove_query_click_by_iserver();
         },
         },
         add_viewer_for_vector(geojson, data) {
         add_viewer_for_vector(geojson, data) {
 
 
@@ -377,7 +468,32 @@ export default {
             } else {
             } else {
                 that.add_viewer_for_vector(geojson, data);
                 that.add_viewer_for_vector(geojson, data);
             }
             }
-        }
+        },
+        remove_query_click_by_iserver() {
+            for (var i = 0; i < 10; i++) {
+                query_click_by_iserver.entities.values.forEach((res) => {
+
+                    query_click_by_iserver.entities.remove(res);
+
+                })
+            }
+        },
+        isArray2D(arr) {
+            // 首先检查arr是否是数组
+            if (!Array.isArray(arr)) {
+                return false;
+            }
+
+            // 检查数组中的每个元素是否也是数组
+            for (let i = 0; i < arr.length; i++) {
+                if (!Array.isArray(arr[i])) {
+                    return false;
+                }
+            }
+
+            // 如果所有元素都是数组,那么arr是二维数组
+            return true;
+        },
     },
     },
     beforeCreate() { }, //生命周期 - 创建之前
     beforeCreate() { }, //生命周期 - 创建之前
     created() { }, //生命周期 - 创建完成(可以访问当前this实例)
     created() { }, //生命周期 - 创建完成(可以访问当前this实例)
@@ -397,6 +513,9 @@ export default {
 
 
             pick_entity = new Cesium.CustomDataSource("pick_entity");
             pick_entity = new Cesium.CustomDataSource("pick_entity");
             viewer.dataSources.add(pick_entity);
             viewer.dataSources.add(pick_entity);
+
+            query_click_by_iserver = new Cesium.CustomDataSource("query_click_by_iserver");
+            viewer.dataSources.add(query_click_by_iserver);
         })
         })
 
 
     }, //生命周期 - 挂在完成
     }, //生命周期 - 挂在完成

+ 0 - 1
src/views/cockpit/bjxm.vue

@@ -151,7 +151,6 @@ export default {
       let xAxis = [];
       let xAxis = [];
       let bat_data = [];
       let bat_data = [];
       let line_data = [];
       let line_data = [];
-      console.log('data.data: ', data.data);
 
 
       data.data.forEach(element => {
       data.data.forEach(element => {
 
 

+ 0 - 1
src/views/cockpit/common/VectorSpace/BoxCommonVector.vue

@@ -411,7 +411,6 @@ export default {
                 }
                 }
             });
             });
             this.active_dableData = data.data
             this.active_dableData = data.data
-            console.log('data.data: ', data.data);
             this.tableData = data.data
             this.tableData = data.data
         },
         },