Browse Source

数据查询

zpf 11 months ago
parent
commit
82a9354dcb
2 changed files with 63 additions and 46 deletions
  1. 15 12
      src/components/Query/clickQuery/MultiLevelQuery.vue
  2. 48 34
      src/views/cockpit/tdsy.vue

+ 15 - 12
src/components/Query/clickQuery/MultiLevelQuery.vue

@@ -30,6 +30,8 @@
 <script>
 //这里可以导入其他文件(比如:组件,工具js,第三方插件js,json文件,图片文件等等)
 import { GetTableData } from '@/api/cockpitNew'
+import * as wellknown from "wellknown";
+
 export default {
     components: {},
     data() {
@@ -51,10 +53,7 @@ export default {
             console.log(tab, event);
         },
         init_handler() {
-            let obj = {
-                "wkt": 'POINT(109.5139541 18.3146153)',
-                "id": 'dd699f839bc04969ae2dc2e1964d0ad1',
-            }
+
             const that = this;
             if (that.handler_multi_level_query == null) {
                 that.handler_multi_level_query = new Cesium.ScreenSpaceEventHandler(viewer.scene.canvas);
@@ -78,17 +77,21 @@ export default {
                 if (!position) {
                     position = Cesium.Cartesian3.fromDegrees(0, 0, 0);
                 }
-                if (Cesium.defined(pickObj)) {
-                    console.log('pickObj:111 ', pickObj);
-
-                    GetTableData(obj).then(res => {
-                        console.log('res: ', res);
-                    })
-
-                } else {
 
+                const geojsonPoint = {
+                    "type": "Point",
+                    "coordinates": [longitude, latitude] // 注意经纬度顺序  
+                };
 
+                const wkt = wellknown.stringify(geojsonPoint);
+                let obj = {
+                    "wkt": wkt,
+                    "id": 'dd699f839bc04969ae2dc2e1964d0ad1',
                 }
+                GetTableData(obj).then(res => {
+                    console.log('res: ', res);
+                })
+
                 that.handler_multi_level_query.destroy();
                 that.handler_multi_level_query = null;
             }, Cesium.ScreenSpaceEventType.LEFT_CLICK);

+ 48 - 34
src/views/cockpit/tdsy.vue

@@ -838,54 +838,68 @@ export default {
 
     },
     draw_vector_tdgy_gy_jd() {
-
+      console.log(this.vector_data, "this.vector_data");
       this.vector_data.forEach((res) => {
         res.type = '国有建设用地完成项目'
-        res.geom.coordinates[0].forEach((res_coordinates) => {
+        if (res.geom) {
+          res.geom.coordinates.forEach((res_coordinates) => {
+            console.log('res_coordinates: ', res_coordinates);
+            let arrayt = [];
+            if (res_coordinates.length == 1) {
+              arrayt = res_coordinates[0]
+            }else{
+              arrayt = res_coordinates
+            }
 
-          const twoDArray = res_coordinates;
-          const oneDArray = twoDArray.reduce((accumulator, currentValue) => accumulator.concat(currentValue), []);
+            const twoDArray = arrayt;
+            const oneDArray = twoDArray.reduce((accumulator, currentValue) => accumulator.concat(currentValue), []);
+            console.log('oneDArray: ', oneDArray);
 
 
-          this.gy_jd_entity.entities.add({
-            // position: Cesium.Cartesian3.fromDegrees(res_coordinates[0], res_coordinates[1], 0),
-            properties: res,
-            name: "国有建设用地完成项目",
-            polygon: {
-              zIndex: 1,
-              hierarchy: {
-                positions: Cesium.Cartesian3.fromDegreesArrayHeights(oneDArray),
-              },
-              // outline: false,
-              // material: Cesium.Color.fromCssColorString(xzqh_color),
-
-              height: 0,
-              extrudedHeight: 0,
-              outline: true,
-              // outlineColor : Cesium.Color.BLACK
-              outlineColor: Cesium.Color.fromCssColorString('#55A1E3'),
-            }
+            this.gy_jd_entity.entities.add({
+              // position: Cesium.Cartesian3.fromDegrees(res_coordinates[0], res_coordinates[1], 0),
+              properties: res,
+              name: "国有建设用地完成项目",
+              polygon: {
+                zIndex: 1,
+                hierarchy: {
+                  positions: Cesium.Cartesian3.fromDegreesArrayHeights(oneDArray),
+                },
+                // outline: false,
+                // material: Cesium.Color.fromCssColorString(xzqh_color),
+
+                height: 0,
+                extrudedHeight: 0,
+                outline: true,
+                // outlineColor : Cesium.Color.BLACK
+                outlineColor: Cesium.Color.fromCssColorString('#55A1E3'),
+              }
+            })
           })
-        })
+        }
       })
 
+
     },
     switch_vector_tdgy_gy_jd(flag) {
       this.gy_jd_entity.show = flag
     },
     async init_vector(params) {
-      // const that = this;
-      // let obj = {
-      //   jscType: 'jsc_tdgy_gy_zbmx',
-      //   id: params ? params.id : '4602'
-      // };
-      // let data = await QueryList(obj);
-      // data.data.map((res) => {
-      //   res.geom = parse(res.geom.split(";")[1]);
-      // })
-      // this.vector_data = data.data;
+      const that = this;
+      let obj = {
+        jscType: 'jsc_tdgy_gy_zbmx',
+        id: params ? params.id : '4602'
+      };
+      let data = await QueryList(obj);
+      data.data.map((res) => {
+        if (res.geom) {
+          res.geom = parse(res.geom.split(";")[1]);
+        }
+
+      })
+      this.vector_data = data.data;
 
-      // this.draw_vector_tdgy_gy_jd();
+      this.draw_vector_tdgy_gy_jd();
     }
   },
   mounted() {