Bladeren bron

webstrom-mac推送-车辆图片

zhiyuan-007 1 maand geleden
bovenliggende
commit
9d581d436d

+ 177 - 36
src/components/mapJK.vue

@@ -53,7 +53,7 @@ import routeList from '../config/routeList.json'
 import {
   getAvoidRoute,
   getBuildingPoint,
-  getNoFlyPointInterface, getPowerInterface, getPowerPoint, getProxyToken,
+  getNoFlyPointInterface, getPowerInterface, getPowerPoint, getPowerPointByPolygon, getProxyToken,
   getRiverPointInterface,
   getRoadPointInterface, gridBaseInfo
 } from "../service/http.js";
@@ -64,11 +64,13 @@ import AddGraphicsEvent from "../units/map/AddGraphicsEvent.js";
 import GeometryMeshEffect from "../units/map/GeometryMeshEffect.js";
 import QueryIn2D from "../units/map/QueryIn2D.js";
 import AddFlowPathEvent from "../units/map/AddFlowPathEvent.js";
+import MoveCarEvent from "../units/map/MoveCarEvent.js";
 export default {
   name: "mapJK",
   setup(){
     let socket = null;
     let virtualSocket = null;
+    let flyPointSocket = null;
     const ctx = getCurrentInstance();
     const bus = ctx?.appContext.config.globalProperties.$bus;
     let MapReady = null;
@@ -101,6 +103,7 @@ export default {
     let currentShowGridId = null;
     let realFlyPointDataQueue = [];
     let addFlowPathEvent = null;
+    let moveCarEvent = null;
     onMounted(() =>{
       bus.on('CreateMap',() =>{
         MapReady = $.Deferred();
@@ -305,6 +308,12 @@ export default {
           case "FlowPathEffect":
             flowPathEffect(params);
             break;
+          case "MoveCar":
+            moveCar(params);
+            break;
+          case "GetOccupyCube":
+            getOccupyCube(params);
+            break;
         }
       }
       function setBackground(params){
@@ -357,10 +366,10 @@ export default {
         let where = params.where;
         let url;
         let layerId;
-        if (type == "区县") {
+        if (type === "区县") {
           url = await returnProxyUrl(dojoConfig["queryurl_qx_3857"]) + '/0'
           layerId = 0;
-        } else if (type == "街道") {
+        } else if (type === "街道") {
           url = await returnProxyUrl(dojoConfig["queryurl_jd_3857"]) + '/0'
           layerId = 0;
         }
@@ -703,17 +712,17 @@ export default {
             m_handles.remove(scale_handle_id);
           }
           let addScaleEvent;
-          if(scale_handle_id == "scale_handle_cube"){
+          if(scale_handle_id === "scale_handle_cube"){
             addScaleEvent = new AddScaleEvent({
               m_view,
               callBackFunction:showCubeWithScaleEventsReturn
             });
-          }else if(scale_handle_id == "scale_handle_tileLayerChange"){
+          }else if(scale_handle_id === "scale_handle_tileLayerChange"){
             addScaleEvent = new AddScaleEvent({
               m_view,
               callBackFunction:showTileLayersWithScaleEventsReturn
             });
-          }else if(scale_handle_id == "scale_handle_sceneLayerLayerChange"){
+          }else if(scale_handle_id === "scale_handle_sceneLayerLayerChange"){
             addScaleEvent = new AddScaleEvent({
               m_view,
               callBackFunction:showSceneLayersWithScaleEventsReturn
@@ -759,7 +768,7 @@ export default {
       function showCubeWithScaleEventsReturn(scaleValue){
         switch (true) {
           case (scaleValue > 1500000):  //15级以上隐藏
-            getRealPower2({
+            getCurrentRealPower({
               status:'hide'
             })
             break;
@@ -886,7 +895,7 @@ export default {
 
       function showThreeCube(params){
         let status = params.status;
-        if(status == "hide"){
+        if(status === "hide"){
           if(addThreeCubeEvent){
             addThreeCubeEvent.clear();
             addThreeCubeEvent = null;
@@ -914,7 +923,7 @@ export default {
         if(depthTest == undefined){
           depthTest = true;
         }
-        if(status == "hide"){
+        if(status === "hide"){
           if(addThreeCubeDetailInstance[id]){
             addThreeCubeDetailInstance[id].clear();
             addThreeCubeDetailInstance[id] = null;
@@ -1004,7 +1013,7 @@ export default {
           addThreeCubeEvent.clear();
           addThreeCubeEvent = null;
         }
-        if(status == "hide"){
+        if(status === "hide"){
           return
         }
         let level = params.level;
@@ -1025,7 +1034,7 @@ export default {
           addThreeCubeEvent.clear();
           addThreeCubeEvent = null;
         }
-        if(status == "hide"){
+        if(status === "hide"){
           return
         }
         let level = params.level;
@@ -1056,7 +1065,7 @@ export default {
           addThreeCubeEvent.clear();
           addThreeCubeEvent = null;
         }
-        if(status == "hide"){
+        if(status === "hide"){
           return
         }
         let level = params.level;
@@ -1077,7 +1086,7 @@ export default {
           addThreeCubeEvent.clear();
           addThreeCubeEvent = null;
         }
-        if(status == "hide"){
+        if(status === "hide"){
           return
         }
         let level = params.level;
@@ -1098,7 +1107,7 @@ export default {
           addThreeCubeEvent.clear();
           addThreeCubeEvent = null;
         }
-        if(status == "hide"){
+        if(status === "hide"){
           return
         }
         let level = params.level;
@@ -1130,7 +1139,7 @@ export default {
           addThreeCubeEvent.clear();
           addThreeCubeEvent = null;
         }
-        if(status == "hide"){
+        if(status === "hide"){
           return
         }
         let level = params.level;
@@ -1151,7 +1160,7 @@ export default {
           addThreeCubeEvent.clear();
           addThreeCubeEvent = null;
         }
-        if(status == "hide"){
+        if(status === "hide"){
           return
         }
         let level = params.level;
@@ -1182,7 +1191,7 @@ export default {
           addThreeNetEvent.clear();
           addThreeNetEvent = null;
         }
-        if(status == "hide"){
+        if(status === "hide"){
           return
         }
         let size = params.size;
@@ -1460,7 +1469,7 @@ export default {
       }
       function threeGrid(params){
         let status = params.status;
-        if(status == "hide"){
+        if(status === "hide"){
           if(addThreeGridEvent){
             addThreeGridEvent.clear();
             addThreeGridEvent = null;
@@ -1509,7 +1518,7 @@ export default {
           limitHeightAnalysisEvent.clear();
           limitHeightAnalysisEvent =null;
         }
-        if(status == "hide"){
+        if(status === "hide"){
           return
         }
         limitHeightAnalysisEvent = new LimitHeightAnalysis({
@@ -1529,7 +1538,7 @@ export default {
         if (f_layer) {
           m_map.remove(f_layer);
         }
-        if(status == "hide"){
+        if(status === "hide"){
           return
         }
         let geometryMeshPrismEffect = new GeometryMeshPrismEffect({
@@ -1550,7 +1559,7 @@ export default {
         if (f_layer) {
           m_map.remove(f_layer);
         }
-        if(status == "hide"){
+        if(status === "hide"){
           return
         }
         let geometryMeshEffect = new GeometryMeshEffect({
@@ -1652,7 +1661,7 @@ export default {
           pathPipeInstance[id].clear();
           pathPipeInstance[id] = null;
         }
-        if(status == "hide"){
+        if(status === "hide"){
           return
         }
         //优化数据
@@ -1672,7 +1681,7 @@ export default {
         let id = params.id;
         let uavid = params.uavid;
         let status = params.status;
-        if(status == "hide"){
+        if(status === "hide"){
           if(flyGLTFInstances[uavid]){
             flyGLTFInstances[uavid].clear();
             delete flyGLTFInstances[uavid];
@@ -1706,7 +1715,7 @@ export default {
       function getVirtualFlyPoint(params){
         let status = params.status;
         const connectVirtualWebSocket = (status) => {
-          if(status == "show"){
+          if(status === "show"){
             if(virtualSocket){
               virtualSocket.send(JSON.stringify(params.flyList));
             }else{
@@ -1794,7 +1803,7 @@ export default {
             })
             messages.forEach(message => {
               message.routeInfoVO.speed = message.routeInfoVO.speed * 1 +(Math.random() * 2).toFixed(2) * 1
-              if(message.overall == "SAFE"){
+              if(message.overall === "SAFE"){
                 addGraphics({
                   "id": message.uavid+'_conflict',
                   "status": "hide"
@@ -2071,7 +2080,7 @@ export default {
         let maxZ = params.maxZ;
         let size = params.size;
         let fields = params.fields;
-        if(status == "hide"){
+        if(status === "hide"){
           showThreeCubeDetail({
             id:params.id,
             status:"hide"
@@ -2094,7 +2103,7 @@ export default {
         });
       }
 
-      // 递归获取权重数据
+      // 无极变化-获取权重数据
       function getCurrentPowerPoints(params) {
         getPowerPoint({
           x: params.x,
@@ -2123,6 +2132,7 @@ export default {
 
 
 
+      //获取当前场景
       function getRealPower2(params){
         let id = params.id;
         let lastId = params.lastId;
@@ -2134,7 +2144,7 @@ export default {
         let maxZ = params.maxZ;
         let size = params.size;
         let fields = params.fields;
-        if(status == "hide"){
+        if(status === "hide"){
           showThreeCubeDetail({
             id:params.id,
             status:"hide"
@@ -2163,7 +2173,7 @@ export default {
         });
       }
 
-      // 递归获取权重数据
+      // 获取当前场景-递归获取权重数据
       function getSixPowerPoints(params) {
         getPowerPoint({
           x: params.x,
@@ -2175,7 +2185,7 @@ export default {
           fields: params.fields,
           scrollId: params.scrollId,
         }).then(res =>{
-          if(currentShowGridId == params.id){
+          if(currentShowGridId === params.id){
             if(res.data.data.list?.length >= 100000 && res.data.data.scrollId){
               // res.data.data.list.forEach((point) =>{
               //   point.color = [0, 1, 1];
@@ -2207,6 +2217,9 @@ export default {
       }
 
 
+
+
+
       //需要添加初始路径(手动绘制和自动绘制)结果
       function draw(params){
         let id = params.id;
@@ -2225,7 +2238,7 @@ export default {
             addDrawEvent = null;
           }
         }
-        if(status == "hide"){
+        if(status === "hide"){
           return
         }
         if(!addDrawEvent){
@@ -2360,7 +2373,7 @@ export default {
         if (f_layer) {
           m_map.remove(f_layer);
         }
-        if(status == "hide"){
+        if(status === "hide"){
           return
         }
         // params.paths = Path.paths
@@ -2377,7 +2390,7 @@ export default {
         if (f_layer) {
           m_map.remove(f_layer);
         }
-        if(status == "hide"){
+        if(status === "hide"){
           return
         }
         symbolPointCubeEvent = new SymbolPointCubeEvent({
@@ -2391,7 +2404,7 @@ export default {
       function addGraphics(params){
         let status = params.status;
         let id = params.id;
-        if(status == "hide"){
+        if(status === "hide"){
           let idGraphic = m_view.graphics.find(item => item.id === id);
           if(idGraphic){
             m_view.graphics.remove(idGraphic);
@@ -2419,7 +2432,7 @@ export default {
         if (f_layer) {
           m_map.remove(f_layer);
         }
-        if(status == "hide"){
+        if(status === "hide"){
           return
         }
         //params.data = Path.paths_point;
@@ -2444,7 +2457,7 @@ export default {
         if (t_layer) {
           m_map.remove(t_layer);
         }
-        if(status == "hide"){
+        if(status === "hide"){
           return
         }
         let showText = false;
@@ -2478,6 +2491,134 @@ export default {
       }
 
 
+      function moveCar(params){
+        let status = params.status;
+        const connectFlyPointWebSocket = (status) => {
+          if(status === "show"){
+            if(flyPointSocket){
+              flyPointSocket.send(JSON.stringify(params.flyList));
+            }else{
+              flyPointSocket = new WebSocket('ws://58.34.215.19:8100/flight/data/webSocket');
+              flyPointSocket.onopen = () => {
+                console.log('WebSocket 连接成功');
+                flyPointSocket.send(JSON.stringify(params.flyList));
+              };
+              flyPointSocket.onmessage = (messageEvent) => {
+                let messages = JSON.parse(messageEvent.data).data;
+                debugger
+                // if(moveCarEvent){
+                //   moveCarEvent.update(messages)
+                // }else{
+                //   moveCarEvent = new MoveCarEvent({
+                //     view:m_view,
+                //     map:m_map,
+                //     paths:params.paths
+                //   });
+                // }
+              };
+
+              flyPointSocket.onerror = (error) => {
+                console.error('WebSocket 出错:', error);
+              };
+
+              flyPointSocket.onclose = () => {
+                console.log('WebSocket 连接已关闭');
+              };
+            }
+          }else{
+            if(flyPointSocket){
+              // if(moveCarEvent){
+              //   moveCarEvent.clear();
+              //   moveCarEvent = null;
+              // }
+              flyPointSocket.close();
+            }
+          }
+        };
+        connectFlyPointWebSocket(status);
+      }
+
+
+      //获取当前场景
+      function getOccupyCube(params){
+        let id = params.id;
+        let lastId = params.lastId;
+        let status = params.status;
+        let level = params.level;
+        let minZ = params.minZ;
+        let maxZ = params.maxZ;
+        let fields = params.fields;
+        if(status === "hide"){
+          showThreeCubeDetail({
+            id:params.id,
+            status:"hide"
+          });
+          currentShowGridId = null;
+          return
+        }
+        showThreeCubeDetail({
+          id:params.lastId,
+          status:"hide"
+        });
+        currentShowGridId = id;
+        getSixPowerByPolygon({
+          id,
+          lastId,
+          status,
+          minZ,
+          maxZ,
+          level,
+          fields,
+          scrollId:""
+        });
+      }
+
+      // 获取当前场景-递归获取权重数据
+      function getSixPowerByPolygon(params) {
+        getPowerPointByPolygon({
+          minZ:params.minZ,
+          maxZ:params.maxZ,
+          level: params.level,
+          fields: params.fields,
+          scrollId: params.scrollId,
+        }).then(res =>{
+          debugger
+          if(currentShowGridId === params.id){
+            if(res.data.data.list?.length >= 100000 && res.data.data.scrollId){
+              debugger
+              let size = {
+                x:res.data.data.list[0].boxSize.latLength,
+                y:res.data.data.list[0].boxSize.lonLength,
+                z:res.data.data.list[0].boxSize.height
+              }
+              showThreeCubeDetail({
+                "id":params.id,
+                "status":params.status,
+                "size":size,
+                "points":res.data.data.list,
+              })
+              params.scrollId = res.data.data.scrollId;
+              getSixPowerByPolygon(params);
+            }else{
+              if(res.data.data.list?.length > 0){
+                let size = {
+                  x:res.data.data.list[0].boxSize.latLength,
+                  y:res.data.data.list[0].boxSize.lonLength,
+                  z:res.data.data.list[0].boxSize.height
+                }
+                showThreeCubeDetail({
+                  "id":params.id,
+                  "status":params.status,
+                  "size":size,
+                  "points":res.data.data.list,
+                })
+              }
+            }
+          }
+        })
+      }
+
+
     })
   }
 }

+ 27 - 1
src/config/basicTool.json

@@ -42,7 +42,7 @@
             "title":"BaseMap",
             "visible": true,
             "opacity": 1,
-            "url": "https://cimweb.zjw.sh.cegn.cn:2008/MapServiceProxy/eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJleHAiOjE3NDAyMDMwNjYsImtleSI6IjkzNDkzMzIxIiwic2VydmljZU5vIjoiRDkwMDEwMDcxMjAyMzA4MDEiLCJ1c2VybmFtZSI6InB0Z2wifQ.6qN-J1km7S4bOGLQBgz4gzV_M50yJzdLR2UJPeFOjpI",
+            "url": "https://cimweb.zjw.sh.cegn.cn:2008/MapServiceProxy/eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJleHAiOjE3NDAzNjM4NDksImtleSI6IjkzNDkzMzIxIiwic2VydmljZU5vIjoiRDkwMDEwMDcxMjAyMzA4MDEiLCJ1c2VybmFtZSI6InB0Z2wifQ.Ts_25l_fc7zp0t6W30I7ot0bj9ziQGiWhQv12MlB700",
             "token": ""
           }
         }
@@ -2076,6 +2076,32 @@
             "token": ""
           }
         }
+      },
+      {
+        "code": "1-47",
+        "title": "多车移动",
+        "data": {
+          "ActionName": "MoveCar",
+          "Parameters": {
+            "status": "show",
+            "token": ""
+          }
+        }
+      },
+      {
+        "code": "1-48",
+        "title": "获取占用网格",
+        "data": {
+          "ActionName": "GetOccupyCube",
+          "Parameters": {
+            "id" : "1",
+            "status" : "show",
+            "level" : 23,
+            "minZ" : 0,
+            "maxZ" : 40,
+            "token": ""
+          }
+        }
       }
     ]
   }

+ 0 - 0
src/config/moveCar.json


+ 12 - 12
src/service/http.js

@@ -76,33 +76,33 @@ export function getPowerPointByPolygon(params){
                         [
                             [
                                 [
-                                    -1590.3017918809733,
-                                    6677.077964639487,
+                                    4130.976404781395,
+                                    7414.170031254575,
                                     0
                                 ],
                                 [
-                                    2201.7080968161385,
-                                    10732.428201519228,
+                                    4230.5636578285,
+                                    7461.1376642530695,
                                     0
                                 ],
                                 [
-                                    7456.713054320092,
-                                    6853.834924224613,
+                                    4282.768409661947,
+                                    7356.489302356174,
                                     0
                                 ],
                                 [
-                                    5328.421628395957,
-                                    3430.2107042326584,
+                                    4219.073065521287,
+                                    7284.442400386499,
                                     0
                                 ],
                                 [
-                                    3081.4337327171834,
-                                    6940.070702330807,
+                                    4192.363664967816,
+                                    7365.681086452302,
                                     0
                                 ],
                                 [
-                                    -1590.3017918809733,
-                                    6677.077964639487,
+                                    4130.976404781395,
+                                    7414.170031254575,
                                     0
                                 ]
                             ]

+ 0 - 1
src/units/map/FeaturePolygonPlottingEvent.js

@@ -5,7 +5,6 @@ import GraphicsLayer from "@arcgis/core/layers/GraphicsLayer.js";
 import Polyline from "@arcgis/core/geometry/Polyline.js";
 import {SimpleLineSymbol, TextSymbol} from "@arcgis/core/symbols.js";
 import Point from "@arcgis/core/geometry/Point.js";
-import * as geometryEngine from "@arcgis/core/geometry/geometryEngine.js"
 class FeaturePolygonPlottingEvent {
     constructor(options) {
         this.view = options.view;

+ 55 - 0
src/units/map/MoveCarEvent.js

@@ -0,0 +1,55 @@
+import GraphicsLayer from "@arcgis/core/layers/GraphicsLayer.js";
+import Graphic from "@arcgis/core/Graphic.js";
+import Point from "@arcgis/core/geometry/Point.js";
+class MoveCarEvent {
+    constructor(options) {
+        this.view = options.view;
+        this.paths = options.paths;
+        this.graphicsLayer = null;
+        this.ready();
+    }
+     ready(){
+        this.graphicsLayer = new GraphicsLayer({
+            id:"moveCar",
+            title:"汽车移动",
+        });
+        this.view.map.add(this.graphicsLayer);
+        this.setGraphics(this.paths);
+     }
+     update(paths){
+        //更新点位geometry以及attribute信息
+         this.graphicsLayer.removeAll();
+         this.setGraphics(paths);
+     }
+     setGraphics(paths){
+         for(let key in paths){
+             this.graphicsLayer.add(new Graphic({
+                 geometry:new Point({
+                     x:paths[key].point.x,
+                     y:paths[key].point.y,
+                     z:paths[key].point.z,
+                     spatialReference:this.view.spatialReference,
+                 }),
+                 symbolLayers:[{
+                     type:"point-3d",
+                     resource:{
+                         href:"gltf/wrj.glb"
+                     },
+                     depth:6
+                 }],
+                 attributes:{
+                     id:paths[key].id,
+                     name:paths[key].name
+                 },
+             }));
+         }
+     }
+     clear(){
+         this.graphicsLayer.removeAll();
+         this.view.map.remove(this.graphicsLayer);
+         this.graphicsLayer = null;
+     }
+
+}
+
+export default MoveCarEvent;

+ 132 - 0
src/units/map/MoveCarFeatureEvent.js

@@ -0,0 +1,132 @@
+import FeatureLayer from "@arcgis/core/layers/FeatureLayer";
+import Point from "@arcgis/core/geometry/Point.js";
+import Graphic from "@arcgis/core/Graphic.js";
+import dangerIcon from "../../assets/预警.png";
+import levelFrIcon from "../../assets/三维_点.png";
+
+
+class MoveCarFeatureEvent{
+    constructor(options) {
+        this.view = options.view;
+        this.data = options.data;
+        this.featureLayer = null;
+        this.ready();
+    }
+    ready(){
+        let resultPointGraphics = [];
+        this.data.forEach((item) =>{
+            let point = new Point({
+                type: "point", // autocasts as new Point()
+                x: item.geometry.x,
+                y: item.geometry.y,
+                z: item.geometry.z,
+                spatialReference: this.view.spatialReference
+            })
+            let graphic = new Graphic({
+                geometry: point,
+                attributes: item.attributes
+            });
+            resultPointGraphics.push(graphic);
+        })
+        this.featureLayer = new FeatureLayer({
+            id:"MoveCarFeature",
+            source: resultPointGraphics,  //还要添加各类的图片renderer
+            objectIdField: "ObjectID", // 必须字段,定义唯一标识
+            fields: [
+                { name: "ObjectID", type: "oid" },
+                { name: "type", type: "string" },
+                { name: "name", type: "string" }
+            ],
+            renderer: {
+                type: "unique-value", // 基于唯一值的渲染器
+                field: "type", // 按照 id 字段渲染
+                uniqueValueInfos: [
+                    {
+                        value: "1", // 唯一值对应 id
+                        symbol: {
+                            type: "polygon-3d",
+                            symbolLayers: [
+                                {
+                                    type: "icon",
+                                    resource: {
+                                        href: dangerIcon
+                                    },
+                                    size: 50,
+                                    outline: {
+                                        color: "white",
+                                        size: 2
+                                    }
+                                }
+                            ]
+                        }
+                    },
+                    {
+                        value: "2", // 唯一值对应 id
+                        symbol: {
+                            type: "polygon-3d",
+                            symbolLayers: [
+                                {
+                                    type: "icon",
+                                    resource: {
+                                        href: levelFrIcon
+                                    },
+                                    size: 50,
+                                    outline: {
+                                        color: "white",
+                                        size: 2
+                                    }
+                                }
+                            ]
+                        }
+                    }
+                ],
+            },
+            elevationInfo: { mode: "relative-to-ground" }, // 相对于建筑高度
+            labelingInfo: [{
+                labelExpressionInfo: {
+                    value: "{name}"
+                },
+                labelPlacement: "above-center", // 可以调整为 “above-center” 或 “below-center”等
+                symbol: {
+                    type: "label-3d", // autocasts as new LabelSymbol3D()
+                    symbolLayers: [
+                        {
+                            type: "text", // autocasts as new TextSymbol3DLayer()
+                            material: [35, 250, 250, 1],
+                            font: {  // autocasts as new Font()
+                                size: 12,
+                                weight: "bold"
+                            },
+                        }
+                    ],
+                }
+            }]
+        });
+        this.view.map.add(this.featureLayer);
+    }
+    update(data){
+        let resultPointGraphics = [];
+        data.forEach((item) =>{
+            let point = new Point({
+                type: "point", // autocasts as new Point()
+                x: item.geometry.x,
+                y: item.geometry.y,
+                z: item.geometry.z,
+                spatialReference: this.view.spatialReference
+            })
+            let graphic = new Graphic({
+                geometry: point,
+                attributes: item.attributes
+            });
+            resultPointGraphics.push(graphic);
+        })
+        this.featureLayer.source = resultPointGraphics;
+        this.featureLayer.refresh()
+    }
+    clear(){
+        this.view.map.remove(this.featureLayer);
+        this.featureLayer= null;
+    }
+}
+
+export default MoveCarFeatureEvent