gisviewer-vue3-arcgis 1.0.285 → 1.0.286
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/es/src/gis-map/gis-map.vue.d.ts +2 -2
- package/es/src/gis-map/index.d.ts +2 -2
- package/es/src/gis-map/utils/holo-flow/signal-holo-flow.mjs +6 -2
- package/es/src/gis-map/utils/holo-flow/trace-renderer-external.mjs +5 -3
- package/es/src/gis-map/utils/overlay.d.ts +2 -2
- package/es/src/gis-map/utils/overlay.mjs +2 -2
- package/es/src/gis-map/utils/police-jurisdiction.mjs +1 -1
- package/es/src/gis-map/utils/signal-system/signal-system-controller.mjs +2 -2
- package/es/src/gis-map-ol/gis-map-ol.vue.d.ts +30 -1
- package/es/src/gis-map-ol/gis-map-ol.vue.mjs +69 -43
- package/es/src/gis-map-ol/index.d.ts +25 -0
- package/es/src/gis-map-ol/utils/cluster/index.d.ts +2 -0
- package/es/src/gis-map-ol/utils/cluster/pixel-cluster-calculator.d.ts +65 -0
- package/es/src/gis-map-ol/utils/cluster/pixel-cluster-calculator.mjs +122 -0
- package/es/src/gis-map-ol/utils/ol-map-initializer.d.ts +1 -0
- package/es/src/gis-map-ol/utils/ol-map-initializer.mjs +95 -41
- package/es/src/gis-map-ol/utils/overlay/cluster-point-controller.d.ts +23 -0
- package/es/src/gis-map-ol/utils/overlay/cluster-point-controller.mjs +102 -0
- package/es/src/gis-map-ol/utils/overlay/overlay-controller.d.ts +116 -0
- package/es/src/gis-map-ol/utils/overlay/overlay-controller.mjs +276 -0
- package/es/src/gis-map-ol/utils/police-area-controller.d.ts +16 -0
- package/es/src/gis-map-ol/utils/police-area-controller.mjs +155 -0
- package/es/src/gis-map-ol/utils/signal-control/signal-cross-controller.d.ts +1 -10
- package/es/src/gis-map-ol/utils/signal-control/signal-cross-controller.mjs +124 -166
- package/es/src/gis-map-ol/utils/signal-control/signal-system-controller.d.ts +49 -0
- package/es/src/gis-map-ol/utils/signal-control/signal-system-controller.mjs +127 -0
- package/es/src/gis-map-ol/utils/style/line-style.d.ts +64 -0
- package/es/src/gis-map-ol/utils/style/line-style.mjs +151 -0
- package/es/src/gis-map-ol/utils/style/point-style.d.ts +78 -0
- package/es/src/gis-map-ol/utils/style/point-style.mjs +206 -0
- package/es/src/gis-map-ol/utils/style/polygon-style.d.ts +60 -0
- package/es/src/gis-map-ol/utils/style/polygon-style.mjs +166 -0
- package/es/src/types/index.d.ts +2 -1
- package/lib/src/gis-map/gis-map.vue.d.ts +2 -2
- package/lib/src/gis-map/index.d.ts +2 -2
- package/lib/src/gis-map/utils/holo-flow/signal-holo-flow.js +1 -1
- package/lib/src/gis-map/utils/holo-flow/trace-renderer-external.js +1 -1
- package/lib/src/gis-map/utils/overlay.d.ts +2 -2
- package/lib/src/gis-map/utils/overlay.js +1 -1
- package/lib/src/gis-map/utils/police-jurisdiction.js +1 -1
- package/lib/src/gis-map/utils/signal-system/signal-system-controller.js +1 -1
- package/lib/src/gis-map-ol/gis-map-ol.vue.d.ts +30 -1
- package/lib/src/gis-map-ol/gis-map-ol.vue.js +1 -1
- package/lib/src/gis-map-ol/index.d.ts +25 -0
- package/lib/src/gis-map-ol/utils/cluster/index.d.ts +2 -0
- package/lib/src/gis-map-ol/utils/cluster/pixel-cluster-calculator.d.ts +65 -0
- package/lib/src/gis-map-ol/utils/cluster/pixel-cluster-calculator.js +1 -0
- package/lib/src/gis-map-ol/utils/ol-map-initializer.d.ts +1 -0
- package/lib/src/gis-map-ol/utils/ol-map-initializer.js +1 -1
- package/lib/src/gis-map-ol/utils/overlay/cluster-point-controller.d.ts +23 -0
- package/lib/src/gis-map-ol/utils/overlay/cluster-point-controller.js +1 -0
- package/lib/src/gis-map-ol/utils/overlay/overlay-controller.d.ts +116 -0
- package/lib/src/gis-map-ol/utils/overlay/overlay-controller.js +1 -0
- package/lib/src/gis-map-ol/utils/police-area-controller.d.ts +16 -0
- package/lib/src/gis-map-ol/utils/police-area-controller.js +1 -0
- package/lib/src/gis-map-ol/utils/signal-control/signal-cross-controller.d.ts +1 -10
- package/lib/src/gis-map-ol/utils/signal-control/signal-cross-controller.js +1 -1
- package/lib/src/gis-map-ol/utils/signal-control/signal-system-controller.d.ts +49 -0
- package/lib/src/gis-map-ol/utils/signal-control/signal-system-controller.js +1 -0
- package/lib/src/gis-map-ol/utils/style/line-style.d.ts +64 -0
- package/lib/src/gis-map-ol/utils/style/line-style.js +1 -0
- package/lib/src/gis-map-ol/utils/style/point-style.d.ts +78 -0
- package/lib/src/gis-map-ol/utils/style/point-style.js +1 -0
- package/lib/src/gis-map-ol/utils/style/polygon-style.d.ts +60 -0
- package/lib/src/gis-map-ol/utils/style/polygon-style.js +1 -0
- package/lib/src/types/index.d.ts +2 -1
- package/package.json +1 -1
|
@@ -105,8 +105,8 @@ export declare const GisMap: import("@easyest/utils/dist/lib/withinstall").SFCWi
|
|
|
105
105
|
removeAllClusterPoints: () => void;
|
|
106
106
|
addMask: (params: import("../types").IMaskParam) => void;
|
|
107
107
|
removeMask: () => void;
|
|
108
|
-
removeOverlaysByType: (types: string[]) => import("../types").IResult;
|
|
109
|
-
removeOverlaysById: (ids: string[]) => import("../types").IResult;
|
|
108
|
+
removeOverlaysByType: (types: string | string[]) => import("../types").IResult;
|
|
109
|
+
removeOverlaysById: (ids: string | string[]) => import("../types").IResult;
|
|
110
110
|
removeAllOverlays: () => import("../types").IResult;
|
|
111
111
|
showAllOverlays: () => void;
|
|
112
112
|
updateQueueLength: (params: import("../types").IQueueLengthParams[]) => void;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const d=require("@arcgis/core/core/reactiveUtils"),u=require("@arcgis/core/geometry"),p=require("@arcgis/core/layers/FeatureLayer"),g=require("vue"),y=require("../../../stores/index.js");function w(l){const e=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(l){for(const t in l)if(t!=="default"){const a=Object.getOwnPropertyDescriptor(l,t);Object.defineProperty(e,t,a.get?a:{enumerable:!0,get:()=>l[t]})}}return e.default=l,Object.freeze(e)}const f=w(d);class m{constructor(e){this.currentPhaseMap=new Map,this.countdownCanvasMap=new Map,this.lastDataTime=0,this.isDeletingCanvas=!1,this.canvasWidth=80,this.canvasHeight=40,this.view=(e.type==="2d",e);const t=y.default.useAppDataStore;this.mapConfig=g.toRaw(t.mapConfig)}async initializeLayer(){try{await this.initializePlateBackground()}catch(e){console.log("倒计时背景图片加载失败",e)}if(this.mapConfig.phaseLineLayer)if(this.phaseLineLayer)this.phaseLineLayer.visible||(this.phaseLineLayer.visible=!0);else{const e=`${this.mapConfig.assetsRoot}/${this.mapConfig.phaseLineLayer}`,s=(await(await fetch(e)).json()).features.map((i,n)=>({geometry:{type:"polyline",paths:[i.geometry.coordinates]},attributes:{ObjectID:n+1,id:i.properties.id,color:"hide"}}));this.phaseLineLayer=new p({source:s,geometryType:"polyline",objectIdField:"ObjectID",outFields:["*"],fields:[{name:"ObjectID",alias:"ObjectID",type:"oid"},{name:"color",alias:"color",type:"string"}],renderer:{type:"unique-value",field:"color",defaultSymbol:{type:"simple-line",color:"lightblue",width:"2px",style:"none"},uniqueValueInfos:[{value:"green",symbol:{type:"line-3d",symbolLayers:[{type:"path",profile:"quad",material:{color:[19,255,69,.8]},width:1,height:.5}]}},{value:"red",symbol:{type:"line-3d",symbolLayers:[{type:"path",profile:"quad",material:{color:[254,5,9,.8]},width:1,height:.5}]}},{value:"yellow",symbol:{type:"line-3d",symbolLayers:[{type:"path",profile:"quad",material:{color:[255,215,0,.8]},width:1,height:.5}]}}]}}),this.view.map.add(this.phaseLineLayer),console.log("相位线图层初始化成功")}}async initializePlateBackground(){return new Promise((e,t)=>{const a=new Image;a.src=`${this.mapConfig.assetsRoot}/Images/timeboard/CountdownBG.png`,a.onload=()=>{this.plateBackground=a,e()},a.onerror=s=>{t(s)}})}async handleHoloSignalData(e){const{crossId:t,lat:a,lon:s,rtStage:i,channelsConfig:n}=e;await this.updateCountdown(t,a,s,i),!(!this.phaseLineLayer||!n)&&((!this.currentPhaseMap.has(t)||this.currentPhaseMap.get(t)!==i.stagePhase)&&await this.updatePhaseLine(t,i.channelsConfig,n),this.currentPhaseMap.set(t,i.stagePhase))}clearSignal(){this.phaseLineLayer&&(this.phaseLineLayer.visible=!1),this.countdownWatchHandel&&(this.countdownWatchHandel.remove(),this.countdownWatchHandel=void 0),this.countdownCanvasMap.forEach(e=>{this.view.container.removeChild(e.backgroundCanvas),this.view.container.removeChild(e.countdownCanvas)}),this.countdownCanvasMap.clear()}async updateCountdown(e,t,a,s){if(this.isDeletingCanvas)return;const i=this.countdownCanvasMap.get(e);if(i)this.drawCountdownText(i.countdownCanvas,s);else try{const n=new u.Point({longitude:a,latitude:t,z:10}),o=this.view.toScreen(n),r=this.createCountdownCanvas();if(!r)return;const h=r[0],c=r[1];h.style.left=o.x+"px",h.style.top=o.y+"px",c.style.left=o.x+"px",c.style.top=o.y+"px",this.countdownCanvasMap.set(e,{backgroundCanvas:h,countdownCanvas:c,mapPoint:n}),this.drawCountdownText(c,s)}catch(n){console.log("倒计时canvas创建失败",e,n)}this.countdownWatchHandel||(this.countdownWatchHandel=f.watch(()=>this.view.extent,()=>{this.countdownCanvasMap.forEach(n=>{const o=this.view.toScreen(n.mapPoint);n.backgroundCanvas.style.left=o.x+"px",n.backgroundCanvas.style.top=o.y+"px",n.countdownCanvas.style.left=o.x+"px",n.countdownCanvas.style.top=o.y+"px"})}))}drawCountdownText(e,t){const a=e.getContext("2d");a.clearRect(0,0,e.width,e.height),a.font="24px Digital",a.textBaseline="middle",a.textAlign="center",a.fillStyle=t.stageRemainingTime<=t.stageAllRedTime?"red":t.stageRemainingTime<=t.stageAllRedTime+t.stageYellowTime?"yellow":"lime",a.fillText(t.stageRemainingTime.toFixed(0),e.width/2,e.height/2)}async updatePhaseLine(e,t,a){const s=this.phaseLineLayer.source.filter(i=>i.getAttribute("id").includes(e));s.forEach(i=>{const n=i.getAttribute("id");this.isLaneInChannels(n,t)?i.setAttribute("color","green"):this.isLaneInChannels(n,a)?i.setAttribute("color","red"):i.setAttribute("color","green")}),await this.phaseLineLayer.applyEdits({updateFeatures:s})}isLaneInChannels(e,t){const a=e.split("+"),s=a[1],i=a[2];for(let n=0;n<t.length;n++)for(let o=0;o<t[n].laneSnList.length;o++){const r=t[n].laneSnList[o].toFixed(0);if(s===r[0]&&i===r[1])return!0}return!1}createCountdownCanvas(){const e=document.createElement("canvas");e.width=this.canvasWidth,e.height=this.canvasHeight,e.style.position="absolute",e.style.transform="translate(-50%, -50%)";const t=e.getContext("2d");this.plateBackground?t.drawImage(this.plateBackground,0,0,this.canvasWidth,this.canvasHeight):(t.strokeStyle="rgba(0, 255, 0, 1)",t.lineWidth=1,t.strokeRect(0,0,this.canvasWidth,this.canvasHeight),t.fillStyle="rgba(0, 0, 0, 1)",t.fillRect(0,0,this.canvasWidth,this.canvasHeight)),this.view.container.appendChild(e);const a=document.createElement("canvas");return a.width=this.canvasWidth-10,a.height=this.canvasHeight-10,a.style.position="absolute",a.style.transform="translate(-50%, -50%)",this.view.container.appendChild(a),[e,a]}}exports.default=m;
|
|
1
|
+
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const d=require("@arcgis/core/core/reactiveUtils"),u=require("@arcgis/core/geometry"),p=require("@arcgis/core/layers/FeatureLayer"),g=require("vue"),y=require("../../../stores/index.js");function w(l){const e=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(l){for(const t in l)if(t!=="default"){const a=Object.getOwnPropertyDescriptor(l,t);Object.defineProperty(e,t,a.get?a:{enumerable:!0,get:()=>l[t]})}}return e.default=l,Object.freeze(e)}const f=w(d);class m{constructor(e){this.currentPhaseMap=new Map,this.countdownCanvasMap=new Map,this.lastDataTime=0,this.isDeletingCanvas=!1,this.canvasWidth=80,this.canvasHeight=40,this.view=(e.type==="2d",e);const t=y.default.useAppDataStore;this.mapConfig=g.toRaw(t.mapConfig)}async initializeLayer(){try{await this.initializePlateBackground()}catch(e){console.log("倒计时背景图片加载失败",e)}if(this.mapConfig.phaseLineLayer)if(this.phaseLineLayer)this.phaseLineLayer.visible||(this.phaseLineLayer.visible=!0);else{const e=`${this.mapConfig.assetsRoot}/${this.mapConfig.phaseLineLayer}`,s=(await(await fetch(e)).json()).features.map((i,n)=>({geometry:{type:"polyline",paths:[i.geometry.coordinates]},attributes:{ObjectID:n+1,id:i.properties.id,color:"hide"}}));this.phaseLineLayer=new p({source:s,geometryType:"polyline",objectIdField:"ObjectID",outFields:["*"],fields:[{name:"ObjectID",alias:"ObjectID",type:"oid"},{name:"color",alias:"color",type:"string"}],renderer:{type:"unique-value",field:"color",defaultSymbol:{type:"simple-line",color:"lightblue",width:"2px",style:"none"},uniqueValueInfos:[{value:"green",symbol:{type:"line-3d",symbolLayers:[{type:"path",profile:"quad",material:{color:[19,255,69,.8]},width:1,height:.5}]}},{value:"red",symbol:{type:"line-3d",symbolLayers:[{type:"path",profile:"quad",material:{color:[254,5,9,.8]},width:1,height:.5}]}},{value:"yellow",symbol:{type:"line-3d",symbolLayers:[{type:"path",profile:"quad",material:{color:[255,215,0,.8]},width:1,height:.5}]}}]}}),this.view.map.add(this.phaseLineLayer),console.log("相位线图层初始化成功")}}async initializePlateBackground(){return new Promise((e,t)=>{const a=new Image;a.src=`${this.mapConfig.assetsRoot}/Images/timeboard/CountdownBG.png`,a.onload=()=>{this.plateBackground=a,e()},a.onerror=s=>{t(s)}})}async handleHoloSignalData(e){const{crossId:t,lat:a,lon:s,rtStage:i,channelsConfig:n}=e;await this.updateCountdown(t,a,s,i),!(!this.phaseLineLayer||!n)&&((!this.currentPhaseMap.has(t)||this.currentPhaseMap.get(t)!==i.stagePhase)&&await this.updatePhaseLine(t,i.channelsConfig,n),this.currentPhaseMap.set(t,i.stagePhase))}clearSignal(){this.phaseLineLayer&&(this.phaseLineLayer.visible=!1),this.countdownWatchHandel&&(this.countdownWatchHandel.remove(),this.countdownWatchHandel=void 0),this.countdownCanvasMap.forEach(e=>{this.view.container.removeChild(e.backgroundCanvas),this.view.container.removeChild(e.countdownCanvas)}),this.countdownCanvasMap.clear()}async updateCountdown(e,t,a,s){if(this.isDeletingCanvas)return;const i=this.countdownCanvasMap.get(e);if(i)this.drawCountdownText(i.countdownCanvas,s);else try{const n=new u.Point({longitude:a,latitude:t,z:10}),o=this.view.toScreen(n),r=this.createCountdownCanvas();if(!r)return;const h=r[0],c=r[1];h.style.left=o.x+"px",h.style.top=o.y+"px",c.style.left=o.x+"px",c.style.top=o.y+"px",this.countdownCanvasMap.set(e,{backgroundCanvas:h,countdownCanvas:c,mapPoint:n}),this.drawCountdownText(c,s)}catch(n){console.log("倒计时canvas创建失败",e,n)}this.countdownWatchHandel||(this.countdownWatchHandel=f.watch(()=>this.view.extent,()=>{this.countdownCanvasMap.forEach(n=>{const o=this.view.toScreen(n.mapPoint);n.backgroundCanvas.style.left=o.x+"px",n.backgroundCanvas.style.top=o.y+"px",n.countdownCanvas.style.left=o.x+"px",n.countdownCanvas.style.top=o.y+"px"})}))}drawCountdownText(e,t){const a=e.getContext("2d",{willReadFrequently:!0});a.clearRect(0,0,e.width,e.height),a.font="24px Digital",a.textBaseline="middle",a.textAlign="center",a.fillStyle=t.stageRemainingTime<=t.stageAllRedTime?"red":t.stageRemainingTime<=t.stageAllRedTime+t.stageYellowTime?"yellow":"lime",a.fillText(t.stageRemainingTime.toFixed(0),e.width/2,e.height/2)}async updatePhaseLine(e,t,a){const s=this.phaseLineLayer.source.filter(i=>i.getAttribute("id").includes(e));s.forEach(i=>{const n=i.getAttribute("id");this.isLaneInChannels(n,t)?i.setAttribute("color","green"):this.isLaneInChannels(n,a)?i.setAttribute("color","red"):i.setAttribute("color","green")}),await this.phaseLineLayer.applyEdits({updateFeatures:s})}isLaneInChannels(e,t){const a=e.split("+"),s=a[1],i=a[2];for(let n=0;n<t.length;n++)for(let o=0;o<t[n].laneSnList.length;o++){const r=t[n].laneSnList[o].toFixed(0);if(s===r[0]&&i===r[1])return!0}return!1}createCountdownCanvas(){const e=document.createElement("canvas");e.width=this.canvasWidth,e.height=this.canvasHeight,e.style.position="absolute",e.style.transform="translate(-50%, -50%)";const t=e.getContext("2d",{willReadFrequently:!0});this.plateBackground?t.drawImage(this.plateBackground,0,0,this.canvasWidth,this.canvasHeight):(t.strokeStyle="rgba(0, 255, 0, 1)",t.lineWidth=1,t.strokeRect(0,0,this.canvasWidth,this.canvasHeight),t.fillStyle="rgba(0, 0, 0, 1)",t.fillRect(0,0,this.canvasWidth,this.canvasHeight)),this.view.container.appendChild(e);const a=document.createElement("canvas");return a.width=this.canvasWidth-10,a.height=this.canvasHeight-10,a.style.position="absolute",a.style.transform="translate(-50%, -50%)",this.view.container.appendChild(a),[e,a]}}exports.default=m;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const T=require("@arcgis/core/core/promiseUtils.js"),S=require("@arcgis/core/core/reactiveUtils.js"),C=require("@arcgis/core/geometry/SpatialReference"),G=require("@arcgis/core/views/3d/externalRenderers"),L=require("three"),V=require("three/examples/jsm/loaders/DRACOLoader"),f=require("three/examples/jsm/loaders/GLTFLoader"),B=require("three/examples/jsm/loaders/MTLLoader"),M=require("three/examples/jsm/loaders/OBJLoader"),R=require("vue"),x=require("../../../stores/index.js"),m=require("../../../types/index.js");function b(u){const e=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(u){for(const s in u)if(s!=="default"){const t=Object.getOwnPropertyDescriptor(u,s);Object.defineProperty(e,s,t.get?t:{enumerable:!0,get:()=>u[s]})}}return e.default=u,Object.freeze(e)}const D=b(T),I=b(S),P=b(G),o=b(L);class O{constructor(e){this.cameraHeightThreshold=1e3,this.roughness=.2,this.metalness=.8,this.defaultMaterial=new o.MeshPhongMaterial({color:16777215}),this.materialMap=new Map([[1,this.createCarMaterial(16777215)],[2,this.createCarMaterial(7833753)],[3,this.createCarMaterial(16766720)],[4,this.createCarMaterial(16758465)],[5,this.createCarMaterial(14423100)],[6,this.createCarMaterial(3329330)],[7,this.createCarMaterial(2003183)],[8,this.createCarMaterial(16032864)],[9,this.createCarMaterial(2105376)],[10,this.createCarMaterial(9662683)],[99,this.createCarMaterial(6908265)]]),this.isInitialized=!1,this.showGroundVehicle=!0,this.showElevatedVehicle=!0,this.isPaused=!1,this.currentSpriteContent=m.EVehiclePlateState.None,this.historyPositionMap=new Map,this.vehicleObjectMap=new Map,this.tabVisible=!0,this.updateModel=!1,this.appDataStore=x.default.useAppDataStore,this.logTable=[["ptcId","plateno","timestamp","localTimestamp","speed","longitude","latitude","ptcType","vehicleType","vehicleColor","plateColor","heading","fixAngle","roadLayer","step","receiveTimestamp","queueLength","status"]],this.view=e;const s=R.toRaw(this.appDataStore.mapConfig);this.assetsRoot=s.assetsRoot,document.addEventListener("visibilitychange",()=>{this.clearVehicles(),this.tabVisible=!document.hidden},!1),I.watch(()=>this.view.camera.position.z,(t,i)=>{(i<=this.cameraHeightThreshold&&t>this.cameraHeightThreshold||i>this.cameraHeightThreshold&&t<=this.cameraHeightThreshold)&&(this.updateModel=!0)})}createCarMaterial(e){return new o.MeshPhongMaterial({color:e})}getLog(){return this.logTable}async init(){await D.eachAlways([new Promise(e=>{const s=new V.DRACOLoader;s.setDecoderPath(`${this.assetsRoot}/js/libs/draco/`),s.setDecoderConfig({type:"wasm"}),s.preload();const t=new f.GLTFLoader;t.setDRACOLoader(s),t.load(`${this.assetsRoot}/3DModels/carDraco.glb`,i=>{const a=i.scene,r=new o.Box3().setFromObject(a).getSize(new o.Vector3);this.carModel=new o.Object3D,this.carModel.rotation.x=o.MathUtils.degToRad(90),this.carModel.add(a),a.position.set(0,0,r.z/2),e()})}),new Promise(e=>{new f.GLTFLoader().load(`${this.assetsRoot}/3DModels/van.glb`,t=>{const i=t.scene,l=new o.Box3().setFromObject(i).getSize(new o.Vector3);this.vanModel=new o.Object3D,this.vanModel.rotation.x=o.MathUtils.degToRad(90),this.vanModel.add(i),i.position.set(0,0,l.z/2),e()})}),new Promise(e=>{new f.GLTFLoader().load(`${this.assetsRoot}/3DModels/truck.glb`,t=>{const i=t.scene;i.scale.set(1.2,1,1.5);const l=new o.Box3().setFromObject(i).getSize(new o.Vector3);this.truckModel=new o.Object3D,this.truckModel.rotation.x=o.MathUtils.degToRad(90),this.truckModel.add(i),i.position.set(0,0,l.z/2),e()})}),new Promise(e=>{new f.GLTFLoader().load(`${this.assetsRoot}/3DModels/bus.glb`,t=>{const i=t.scene,l=new o.Box3().setFromObject(i).getSize(new o.Vector3);this.busModel=new o.Object3D,this.busModel.rotation.x=o.MathUtils.degToRad(90),this.busModel.add(i),i.position.set(0,0,l.z/2),e()})}),new Promise(e=>{new B.MTLLoader().load(`${this.assetsRoot}/3DModels/bicycle.mtl`,t=>{t.preload();const i=new M.OBJLoader;i.setMaterials(t),i.load(`${this.assetsRoot}/3DModels/bicycle.obj`,a=>{this.bicycleModel=a,this.bicycleModel.rotation.x=o.MathUtils.degToRad(90),e()})})}),new Promise(e=>{new M.OBJLoader().load(`${this.assetsRoot}/3DModels/male.obj`,t=>{t.scale.set(.01,.01,.01),this.passengerModel=t,this.passengerModel.rotation.x=o.MathUtils.degToRad(90),this.passengerModel.rotation.y=o.MathUtils.degToRad(180),e()})}),new Promise(e=>{this.bluePlateBG=new Image,this.bluePlateBG.src=`${this.assetsRoot}/Images/PlateBG/blue.png`,this.bluePlateBG.onload=()=>{e()}}),new Promise(e=>{this.yellowPlateBG=new Image,this.yellowPlateBG.src=`${this.assetsRoot}/Images/PlateBG/yellow.png`,this.yellowPlateBG.onload=()=>{e()}}),new Promise(e=>{this.whitePlateBG=new Image,this.whitePlateBG.src=`${this.assetsRoot}/Images/PlateBG/white.png`,this.whitePlateBG.onload=()=>{e()}}),new Promise(e=>{this.blackPlateBG=new Image,this.blackPlateBG.src=`${this.assetsRoot}/Images/PlateBG/black.png`,this.blackPlateBG.onload=()=>{e()}}),new Promise(e=>{this.neoYellowPlateBG=new Image,this.neoYellowPlateBG.src=`${this.assetsRoot}/Images/PlateBG/neo_yellow.png`,this.neoYellowPlateBG.onload=()=>{e()}}),new Promise(e=>{this.neoGreenPlateBG=new Image,this.neoGreenPlateBG.src=`${this.assetsRoot}/Images/PlateBG/neo_green.png`,this.neoGreenPlateBG.onload=()=>{e()}}),new Promise(e=>{this.greyPlateBG=new Image,this.greyPlateBG.src=`${this.assetsRoot}/Images/PlateBG/grey.png`,this.greyPlateBG.onload=()=>{e()}})]),this.isInitialized=!0}setInterpolate(e){this.clearVehicles(),this.tabVisible=e}async setup(e){this.context=e,this.renderer=new o.WebGLRenderer({context:e.gl,premultipliedAlpha:!0,logarithmicDepthBuffer:!0,antialias:!0,powerPreference:"high-performance"}),this.renderer.shadowMap.enabled=!0,this.renderer.setPixelRatio(window.devicePixelRatio),this.renderer.setViewport(0,0,this.view.width,this.view.height),this.renderer.autoClearDepth=!1,this.renderer.autoClearStencil=!1,this.renderer.autoClearColor=!1;const s=this.renderer.setRenderTarget.bind(this.renderer);this.renderer.setRenderTarget=i=>{s(i),i==null&&e.bindRenderTarget()},this.scene=new o.Scene;const{camera:t}=e;this.camera=new o.PerspectiveCamera(t.fovY,t.aspect,.1,1e5),this.ambient=new o.AmbientLight(16777215,2),this.scene.add(this.ambient),this.sun=new o.DirectionalLight(16777215,2),this.scene.add(this.sun),e.resetWebGLState()}async render(e){var i;const s=e.camera;if(this.camera.position.set(s.eye[0],s.eye[1],s.eye[2]),this.camera.up.set(s.up[0],s.up[1],s.up[2]),this.camera.lookAt(new o.Vector3(s.center[0],s.center[1],s.center[2])),this.camera.projectionMatrix.fromArray(s.projectionMatrix),!this.isPaused&&this.tabVisible)for(const a of this.vehicleObjectMap.keys()){const l=(i=this.vehicleObjectMap.get(a))==null?void 0:i.model;if(!l)continue;const r=this.computeVehiclePosition(a);if(r){const d=this.toRenderCoordinates(r);l.position.set(d[0],d[1],d[2]),l.rotation.y=o.MathUtils.degToRad(-r[3])}}const t=e.sunLight;this.sun.position.set(t.direction[0],t.direction[1],t.direction[2]),this.sun.intensity=t.diffuse.intensity,this.sun.color=new o.Color(t.diffuse.color[0],t.diffuse.color[1],t.diffuse.color[2]),this.ambient.intensity=t.ambient.intensity,this.ambient.color=new o.Color(t.ambient.color[0],t.ambient.color[1],t.ambient.color[2]),this.renderer.resetState(),e.bindRenderTarget(),this.renderer.render(this.scene,this.camera),P.requestRender(this.view),e.resetWebGLState()}async addVehicles(e){if(this.isPaused||!this.isInitialized||!this.tabVisible)return;const s=Date.now();for(const t of e){if(this.historyPositionMap.has(t.vehicleId))continue;this.appDataStore.saveTrackLog&&this.logTable.push([t.ptcId,t.plateNo,t.timestamp,t.localTimestamp,t.speed,t.x,t.y,t.ptcType,t.vehicleType,t.vehicleColor,t.plateColor,t.heading,t.fixAngle,t.roadLayer,t.step,s,0,0]);const{vehicleId:i,localTimestamp:a}=t,l=Number(t.x),r=Number(t.y),d=Number(t.heading);this.historyPositionMap.set(i,[{pos:[l,r,0],heading:d,time:a}]);const h=this.getVehicleModel(t);h.name=i,h.visible=!1;try{const n=await this.createPlateSprite(t);n&&(h.add(n),n.position.set(0,5,-4))}catch(n){console.log("createPlateSprite error:",n)}this.scene.add(h),this.vehicleObjectMap.set(i,{model:h,data:t,waitForDelete:!1,isMoving:!1})}}async updateVehicles(e){if(this.isPaused||!this.isInitialized||!this.tabVisible)return;const s=[],t=Date.now();for(const i of e){const{vehicleId:a,localTimestamp:l}=i,r=Number(i.x),d=Number(i.y);let h=Number(i.heading);const n=this.vehicleObjectMap.get(a),p=this.historyPositionMap.get(a);if(!n||!p)s.push(i);else{if(this.appDataStore.saveTrackLog&&this.logTable.push([i.ptcId,i.plateNo,i.timestamp,i.localTimestamp,i.speed,i.x,i.y,i.ptcType,i.vehicleType,i.vehicleColor,i.plateColor,i.heading,i.fixAngle,i.roadLayer,i.step,t,p.length,1]),this.updateModel||n.data.vehicleColor!==i.vehicleColor||n.data.vehicleType!==i.vehicleType){this.scene.remove(n.model),this.disposeModel(n.model),n.model=this.getVehicleModel(i),n.model.visible=!0;const c=await this.createPlateSprite(i);c&&(n.model.add(c),c.position.set(0,5,-4)),this.scene.add(n.model)}if(n.data.showName!==i.showName||n.data.plateColor!==i.plateColor){const c=n.model.getObjectByName("VehiclePlate");c&&(n.model.remove(c),this.disposeModel(c));const g=await this.createPlateSprite(i);g&&(n.model.add(g),g.position.set(0,5,-4))}if(n.data=i,this.tabVisible){const c=p[p.length-1];Math.abs(h-c.heading)>=180&&(h>c.heading?c.heading+=360:h+=360),p.push({pos:[r,d,0],heading:h,time:l})}else{this.historyPositionMap.set(a,[{pos:[r,d,0],heading:h,time:l}]);const c=this.toRenderCoordinates([r,d,0]);n.model.position.set(c[0],c[1],c[2]),n.model.rotation.y=o.MathUtils.degToRad(-h)}}}await this.addVehicles(s),this.updateModel=!1}toRenderCoordinates(e){const s=[0,0,0];return P.toRenderCoordinates(this.view,e,0,C.WGS84,s,0,1),s}deleteVehicles(e){if(this.isPaused)return;const s=Date.now();e.forEach(t=>{if(this.appDataStore.saveTrackLog){const a=this.historyPositionMap.get(t);this.logTable.push([t,"","","","","","","","","","","","","","",s,a?a.length:0,2])}const i=this.vehicleObjectMap.get(t);i&&(this.tabVisible?i.isMoving?i.waitForDelete=!0:this.deleteVehicle(i):this.deleteVehicle(i))})}deleteVehicle(e){e.model.visible=!1,this.disposeModel(e.model),this.scene.remove(e.model);const s=e.data.vehicleId;this.vehicleObjectMap.delete(s),this.historyPositionMap.delete(s)}async toggleTrafficInfo(e){e.name==="vehiclePlate"&&(e.visible===!0&&this.currentSpriteContent===m.EVehiclePlateState.None?await this.updatePanelContent(m.EVehiclePlateState.PlateNumber):await this.updatePanelContent(e.visible?this.currentSpriteContent:m.EVehiclePlateState.None))}togglePause(e){this.isPaused=e}clearVehicles(){for(const e of this.vehicleObjectMap.values())this.disposeModel(e.model),this.scene.remove(e.model);this.vehicleObjectMap.clear(),this.historyPositionMap.clear()}async updatePanelContent(e){this.currentSpriteContent=e;for(const s of this.vehicleObjectMap.values()){const t=s.model.getObjectByName("VehiclePlate");if(t&&(s.model.remove(t),this.disposeModel(t)),e!==m.EVehiclePlateState.None){const i=await this.createPlateSprite(s.data);i&&(s.model.add(i),i.position.set(0,5,-4))}}}toggleGroundVehicle(e){this.showGroundVehicle=e}toggleElevatedVehicle(e){this.showElevatedVehicle=e}disposeModel(e){e.traverse(s=>{if(s instanceof o.Mesh)try{s.geometry.dispose(),s.material.dispose()}catch{}})}computeVehiclePosition(e){const s=this.historyPositionMap.get(e),t=this.vehicleObjectMap.get(e);if(!t||!s||!t.isMoving&&s.length<=2)return;const i=Date.now();t.isMoving=!0,t.data.roadLayer==="1"?t.model.visible=this.showGroundVehicle:t.model.visible=this.showElevatedVehicle,t.segmentStartTime||(t.segmentStartTime=i,t.segmentTotalTime=s[1].time-s[0].time);const a=i-t.segmentStartTime,l=Math.min(a/t.segmentTotalTime,1);if(l===1)if(s.shift(),s.length===1){t.waitForDelete===!0?this.deleteVehicle(t):(t.segmentStartTime=void 0,t.segmentTotalTime=void 0,t.model.visible=!1,t.isMoving=!1,console.log("hide vehicle",e));return}else{t.segmentStartTime=Date.now();const r=a-t.segmentTotalTime;return t.segmentTotalTime=s[1].time-s[0].time-r,Math.abs(s[1].heading-s[0].heading)>180&&(s[1].heading>s[0].heading?s[0].heading+=360:s[1].heading+=360),s[0].pos.concat(s[0].heading)}else if(s.length>=2){const r=s[0].pos[0]+(s[1].pos[0]-s[0].pos[0])*l,d=s[0].pos[1]+(s[1].pos[1]-s[0].pos[1])*l,h=s[0].heading+(s[1].heading-s[0].heading)*l;return[r,d,0,h]}else return}getVehicleModel(e){if(this.view.camera.position.z>=this.cameraHeightThreshold){const s=new o.SphereGeometry(5,32,32),t=new o.MeshPhysicalMaterial({color:325253,emissive:0,roughness:this.roughness,metalness:this.metalness});return new o.Mesh(s,t)}else{let s;if(e.ptcType===2)s=this.bicycleModel.clone();else if(e.ptcType===3)s=this.passengerModel.clone();else{switch(e.vehicleType){case 10:s=this.carModel.clone();break;case 20:s=this.vanModel.clone();break;case 25:s=this.truckModel.clone();break;case 50:s=this.busModel.clone();break;default:s=this.carModel.clone();break}const t=this.materialMap.get(e.vehicleColor)||this.defaultMaterial;let i=!1;s.traverse(a=>{!i&&a instanceof o.Mesh&&(a.material=t,i=!0)})}return s}}createCanvas(e,s,t){const i=document.createElement("canvas"),a=e.width,l=e.height;i.width=a,i.height=l;const r=i.getContext("2d");if(!r){console.log("canvas创建失败");return}return r.fillStyle="rgba(0,0,0,0.0)",r.fillRect(0,0,a,l),r.drawImage(e,0,0,a,l),r.beginPath(),r.translate(a/2,l/2),r.fillStyle=t,r.font="bold 32px 宋体",r.textBaseline="middle",r.textAlign="center",r.fillText(s,0,0),i}createPlateSprite(e){return new Promise((s,t)=>{var h,n;const i=!e.plateNo||e.plateNo==="0"||e.plateNo==="000000";if(this.currentSpriteContent===m.EVehiclePlateState.None||this.currentSpriteContent===m.EVehiclePlateState.PlateNumber&&i){s(void 0);return}let a=new Image,l="",r="";if(this.currentSpriteContent===m.EVehiclePlateState.PlateNumber||this.currentSpriteContent===m.EVehiclePlateState.Mix)if(i)a=this.greyPlateBG,l=e.ptcId,r="#ffffff";else switch(l=((h=e.showName)==null?void 0:h.substring(0,2))+"•"+((n=e.showName)==null?void 0:n.substring(2)),e.plateColor){case 1:a=this.bluePlateBG,r="#ffffff";break;case 2:a=this.yellowPlateBG,r="#000000";break;case 3:a=this.whitePlateBG,r="#000000";break;case 4:a=this.blackPlateBG,r="#ffffff";break;case 5:a=this.neoYellowPlateBG,r="#000000";break;case 6:a=this.neoGreenPlateBG,r="#000000";break;default:a=this.greyPlateBG,l=e.plateNo,r="#ffffff";break}else this.currentSpriteContent===m.EVehiclePlateState.Id&&(a=this.greyPlateBG,l=e.ptcId,r="#ffffff");const d=this.createCanvas(a,l,r);if(d){const p=new o.CanvasTexture(d),c=new o.SpriteMaterial({map:p,transparent:!1}),g=new o.Sprite(c),w=.05,v=d.width*w,y=d.height*w;g.scale.set(v,y,1),g.name="VehiclePlate",s(g)}else{t("canvas创建失败");return}a.onerror=p=>{console.log(`号牌背景加载失败: ${a.src}`,p),t(p)}})}}exports.default=O;
|
|
1
|
+
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const T=require("@arcgis/core/core/promiseUtils.js"),S=require("@arcgis/core/core/reactiveUtils.js"),C=require("@arcgis/core/geometry/SpatialReference"),G=require("@arcgis/core/views/3d/externalRenderers"),L=require("three"),R=require("three/examples/jsm/loaders/DRACOLoader"),f=require("three/examples/jsm/loaders/GLTFLoader"),V=require("three/examples/jsm/loaders/MTLLoader"),M=require("three/examples/jsm/loaders/OBJLoader"),B=require("vue"),x=require("../../../stores/index.js"),m=require("../../../types/index.js");function b(u){const e=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(u){for(const s in u)if(s!=="default"){const t=Object.getOwnPropertyDescriptor(u,s);Object.defineProperty(e,s,t.get?t:{enumerable:!0,get:()=>u[s]})}}return e.default=u,Object.freeze(e)}const D=b(T),I=b(S),P=b(G),o=b(L);class O{constructor(e){this.cameraHeightThreshold=1e3,this.roughness=.2,this.metalness=.8,this.defaultMaterial=new o.MeshPhongMaterial({color:16777215}),this.materialMap=new Map([[1,this.createCarMaterial(16777215)],[2,this.createCarMaterial(7833753)],[3,this.createCarMaterial(16766720)],[4,this.createCarMaterial(16758465)],[5,this.createCarMaterial(14423100)],[6,this.createCarMaterial(3329330)],[7,this.createCarMaterial(2003183)],[8,this.createCarMaterial(16032864)],[9,this.createCarMaterial(2105376)],[10,this.createCarMaterial(9662683)],[99,this.createCarMaterial(6908265)]]),this.isInitialized=!1,this.showGroundVehicle=!0,this.showElevatedVehicle=!0,this.isPaused=!1,this.currentSpriteContent=m.EVehiclePlateState.None,this.historyPositionMap=new Map,this.vehicleObjectMap=new Map,this.tabVisible=!0,this.updateModel=!1,this.appDataStore=x.default.useAppDataStore,this.logTable=[["ptcId","plateno","timestamp","localTimestamp","speed","longitude","latitude","ptcType","vehicleType","vehicleColor","plateColor","heading","fixAngle","roadLayer","step","receiveTimestamp","queueLength","status"]],this.view=e;const s=B.toRaw(this.appDataStore.mapConfig);this.assetsRoot=s.assetsRoot,document.addEventListener("visibilitychange",()=>{this.clearVehicles(),this.tabVisible=!document.hidden},!1),I.watch(()=>this.view.camera.position.z,(t,i)=>{(i<=this.cameraHeightThreshold&&t>this.cameraHeightThreshold||i>this.cameraHeightThreshold&&t<=this.cameraHeightThreshold)&&(this.updateModel=!0)})}createCarMaterial(e){return new o.MeshPhongMaterial({color:e})}getLog(){return this.logTable}async init(){await D.eachAlways([new Promise(e=>{const s=new R.DRACOLoader;s.setDecoderPath(`${this.assetsRoot}/js/libs/draco/`),s.setDecoderConfig({type:"wasm"}),s.preload();const t=new f.GLTFLoader;t.setDRACOLoader(s),t.load(`${this.assetsRoot}/3DModels/carDraco.glb`,i=>{const a=i.scene,r=new o.Box3().setFromObject(a).getSize(new o.Vector3);this.carModel=new o.Object3D,this.carModel.rotation.x=o.MathUtils.degToRad(90),this.carModel.add(a),a.position.set(0,0,r.z/2),e()})}),new Promise(e=>{new f.GLTFLoader().load(`${this.assetsRoot}/3DModels/van.glb`,t=>{const i=t.scene,l=new o.Box3().setFromObject(i).getSize(new o.Vector3);this.vanModel=new o.Object3D,this.vanModel.rotation.x=o.MathUtils.degToRad(90),this.vanModel.add(i),i.position.set(0,0,l.z/2),e()})}),new Promise(e=>{new f.GLTFLoader().load(`${this.assetsRoot}/3DModels/truck.glb`,t=>{const i=t.scene;i.scale.set(1.2,1,1.5);const l=new o.Box3().setFromObject(i).getSize(new o.Vector3);this.truckModel=new o.Object3D,this.truckModel.rotation.x=o.MathUtils.degToRad(90),this.truckModel.add(i),i.position.set(0,0,l.z/2),e()})}),new Promise(e=>{new f.GLTFLoader().load(`${this.assetsRoot}/3DModels/bus.glb`,t=>{const i=t.scene,l=new o.Box3().setFromObject(i).getSize(new o.Vector3);this.busModel=new o.Object3D,this.busModel.rotation.x=o.MathUtils.degToRad(90),this.busModel.add(i),i.position.set(0,0,l.z/2),e()})}),new Promise(e=>{new V.MTLLoader().load(`${this.assetsRoot}/3DModels/bicycle.mtl`,t=>{t.preload();const i=new M.OBJLoader;i.setMaterials(t),i.load(`${this.assetsRoot}/3DModels/bicycle.obj`,a=>{this.bicycleModel=a,this.bicycleModel.rotation.x=o.MathUtils.degToRad(90),e()})})}),new Promise(e=>{new M.OBJLoader().load(`${this.assetsRoot}/3DModels/male.obj`,t=>{t.scale.set(.01,.01,.01),this.passengerModel=t,this.passengerModel.rotation.x=o.MathUtils.degToRad(90),this.passengerModel.rotation.y=o.MathUtils.degToRad(180),e()})}),new Promise(e=>{this.bluePlateBG=new Image,this.bluePlateBG.src=`${this.assetsRoot}/Images/PlateBG/blue.png`,this.bluePlateBG.onload=()=>{e()}}),new Promise(e=>{this.yellowPlateBG=new Image,this.yellowPlateBG.src=`${this.assetsRoot}/Images/PlateBG/yellow.png`,this.yellowPlateBG.onload=()=>{e()}}),new Promise(e=>{this.whitePlateBG=new Image,this.whitePlateBG.src=`${this.assetsRoot}/Images/PlateBG/white.png`,this.whitePlateBG.onload=()=>{e()}}),new Promise(e=>{this.blackPlateBG=new Image,this.blackPlateBG.src=`${this.assetsRoot}/Images/PlateBG/black.png`,this.blackPlateBG.onload=()=>{e()}}),new Promise(e=>{this.neoYellowPlateBG=new Image,this.neoYellowPlateBG.src=`${this.assetsRoot}/Images/PlateBG/neo_yellow.png`,this.neoYellowPlateBG.onload=()=>{e()}}),new Promise(e=>{this.neoGreenPlateBG=new Image,this.neoGreenPlateBG.src=`${this.assetsRoot}/Images/PlateBG/neo_green.png`,this.neoGreenPlateBG.onload=()=>{e()}}),new Promise(e=>{this.greyPlateBG=new Image,this.greyPlateBG.src=`${this.assetsRoot}/Images/PlateBG/grey.png`,this.greyPlateBG.onload=()=>{e()}})]),this.isInitialized=!0}setInterpolate(e){this.clearVehicles(),this.tabVisible=e}async setup(e){this.context=e,this.renderer=new o.WebGLRenderer({context:e.gl,premultipliedAlpha:!0,logarithmicDepthBuffer:!0,antialias:!0,powerPreference:"high-performance"}),this.renderer.shadowMap.enabled=!0,this.renderer.setPixelRatio(window.devicePixelRatio),this.renderer.setViewport(0,0,this.view.width,this.view.height),this.renderer.autoClearDepth=!1,this.renderer.autoClearStencil=!1,this.renderer.autoClearColor=!1;const s=this.renderer.setRenderTarget.bind(this.renderer);this.renderer.setRenderTarget=i=>{s(i),i==null&&e.bindRenderTarget()},this.scene=new o.Scene;const{camera:t}=e;this.camera=new o.PerspectiveCamera(t.fovY,t.aspect,.1,1e5),this.ambient=new o.AmbientLight(16777215,2),this.scene.add(this.ambient),this.sun=new o.DirectionalLight(16777215,2),this.scene.add(this.sun),e.resetWebGLState()}async render(e){var i;const s=e.camera;if(this.camera.position.set(s.eye[0],s.eye[1],s.eye[2]),this.camera.up.set(s.up[0],s.up[1],s.up[2]),this.camera.lookAt(new o.Vector3(s.center[0],s.center[1],s.center[2])),this.camera.projectionMatrix.fromArray(s.projectionMatrix),!this.isPaused&&this.tabVisible)for(const a of this.vehicleObjectMap.keys()){const l=(i=this.vehicleObjectMap.get(a))==null?void 0:i.model;if(!l)continue;const r=this.computeVehiclePosition(a);if(r){const d=this.toRenderCoordinates(r);l.position.set(d[0],d[1],d[2]),l.rotation.y=o.MathUtils.degToRad(-r[3])}}const t=e.sunLight;this.sun.position.set(t.direction[0],t.direction[1],t.direction[2]),this.sun.intensity=t.diffuse.intensity,this.sun.color=new o.Color(t.diffuse.color[0],t.diffuse.color[1],t.diffuse.color[2]),this.ambient.intensity=t.ambient.intensity,this.ambient.color=new o.Color(t.ambient.color[0],t.ambient.color[1],t.ambient.color[2]),this.renderer.resetState(),e.bindRenderTarget(),this.renderer.render(this.scene,this.camera),P.requestRender(this.view),e.resetWebGLState()}async addVehicles(e){if(this.isPaused||!this.isInitialized||!this.tabVisible)return;const s=Date.now();for(const t of e){if(this.historyPositionMap.has(t.vehicleId))continue;this.appDataStore.saveTrackLog&&this.logTable.push([t.ptcId,t.plateNo,t.timestamp,t.localTimestamp,t.speed,t.x,t.y,t.ptcType,t.vehicleType,t.vehicleColor,t.plateColor,t.heading,t.fixAngle,t.roadLayer,t.step,s,0,0]);const{vehicleId:i,localTimestamp:a}=t,l=Number(t.x),r=Number(t.y),d=Number(t.heading);this.historyPositionMap.set(i,[{pos:[l,r,0],heading:d,time:a}]);const h=this.getVehicleModel(t);h.name=i,h.visible=!1;try{const n=await this.createPlateSprite(t);n&&(h.add(n),n.position.set(0,5,-4))}catch(n){console.log("createPlateSprite error:",n)}this.scene.add(h),this.vehicleObjectMap.set(i,{model:h,data:t,waitForDelete:!1,isMoving:!1})}}async updateVehicles(e){if(this.isPaused||!this.isInitialized||!this.tabVisible)return;const s=[],t=Date.now();for(const i of e){const{vehicleId:a,localTimestamp:l}=i,r=Number(i.x),d=Number(i.y);let h=Number(i.heading);const n=this.vehicleObjectMap.get(a),p=this.historyPositionMap.get(a);if(!n||!p)s.push(i);else{if(this.appDataStore.saveTrackLog&&this.logTable.push([i.ptcId,i.plateNo,i.timestamp,i.localTimestamp,i.speed,i.x,i.y,i.ptcType,i.vehicleType,i.vehicleColor,i.plateColor,i.heading,i.fixAngle,i.roadLayer,i.step,t,p.length,1]),this.updateModel||n.data.vehicleColor!==i.vehicleColor||n.data.vehicleType!==i.vehicleType){this.scene.remove(n.model),this.disposeModel(n.model),n.model=this.getVehicleModel(i),n.model.visible=!0;const c=await this.createPlateSprite(i);c&&(n.model.add(c),c.position.set(0,5,-4)),this.scene.add(n.model)}if(n.data.showName!==i.showName||n.data.plateColor!==i.plateColor){const c=n.model.getObjectByName("VehiclePlate");c&&(n.model.remove(c),this.disposeModel(c));const g=await this.createPlateSprite(i);g&&(n.model.add(g),g.position.set(0,5,-4))}if(n.data=i,this.tabVisible){const c=p[p.length-1];Math.abs(h-c.heading)>=180&&(h>c.heading?c.heading+=360:h+=360),p.push({pos:[r,d,0],heading:h,time:l})}else{this.historyPositionMap.set(a,[{pos:[r,d,0],heading:h,time:l}]);const c=this.toRenderCoordinates([r,d,0]);n.model.position.set(c[0],c[1],c[2]),n.model.rotation.y=o.MathUtils.degToRad(-h)}}}await this.addVehicles(s),this.updateModel=!1}toRenderCoordinates(e){const s=[0,0,0];return P.toRenderCoordinates(this.view,e,0,C.WGS84,s,0,1),s}deleteVehicles(e){if(this.isPaused)return;const s=Date.now();e.forEach(t=>{if(this.appDataStore.saveTrackLog){const a=this.historyPositionMap.get(t);this.logTable.push([t,"","","","","","","","","","","","","","",s,a?a.length:0,2])}const i=this.vehicleObjectMap.get(t);i&&(this.tabVisible?i.isMoving?i.waitForDelete=!0:this.deleteVehicle(i):this.deleteVehicle(i))})}deleteVehicle(e){e.model.visible=!1,this.disposeModel(e.model),this.scene.remove(e.model);const s=e.data.vehicleId;this.vehicleObjectMap.delete(s),this.historyPositionMap.delete(s)}async toggleTrafficInfo(e){e.name==="vehiclePlate"&&(e.visible===!0&&this.currentSpriteContent===m.EVehiclePlateState.None?await this.updatePanelContent(m.EVehiclePlateState.PlateNumber):await this.updatePanelContent(e.visible?this.currentSpriteContent:m.EVehiclePlateState.None))}togglePause(e){this.isPaused=e}clearVehicles(){for(const e of this.vehicleObjectMap.values())this.disposeModel(e.model),this.scene.remove(e.model);this.vehicleObjectMap.clear(),this.historyPositionMap.clear()}async updatePanelContent(e){this.currentSpriteContent=e;for(const s of this.vehicleObjectMap.values()){const t=s.model.getObjectByName("VehiclePlate");if(t&&(s.model.remove(t),this.disposeModel(t)),e!==m.EVehiclePlateState.None){const i=await this.createPlateSprite(s.data);i&&(s.model.add(i),i.position.set(0,5,-4))}}}toggleGroundVehicle(e){this.showGroundVehicle=e}toggleElevatedVehicle(e){this.showElevatedVehicle=e}disposeModel(e){e.traverse(s=>{if(s instanceof o.Mesh)try{s.geometry.dispose(),s.material.dispose()}catch{}})}computeVehiclePosition(e){const s=this.historyPositionMap.get(e),t=this.vehicleObjectMap.get(e);if(!t||!s||!t.isMoving&&s.length<=2)return;const i=Date.now();t.isMoving=!0,t.data.roadLayer==="1"?t.model.visible=this.showGroundVehicle:t.model.visible=this.showElevatedVehicle,t.segmentStartTime||(t.segmentStartTime=i,t.segmentTotalTime=s[1].time-s[0].time);const a=i-t.segmentStartTime,l=Math.min(a/t.segmentTotalTime,1);if(l===1)if(s.shift(),s.length===1){t.waitForDelete===!0?this.deleteVehicle(t):(t.segmentStartTime=void 0,t.segmentTotalTime=void 0,t.model.visible=!1,t.isMoving=!1,console.log("hide vehicle",e));return}else{t.segmentStartTime=Date.now();const r=a-t.segmentTotalTime;return t.segmentTotalTime=s[1].time-s[0].time-r,Math.abs(s[1].heading-s[0].heading)>180&&(s[1].heading>s[0].heading?s[0].heading+=360:s[1].heading+=360),s[0].pos.concat(s[0].heading)}else if(s.length>=2){const r=s[0].pos[0]+(s[1].pos[0]-s[0].pos[0])*l,d=s[0].pos[1]+(s[1].pos[1]-s[0].pos[1])*l,h=s[0].heading+(s[1].heading-s[0].heading)*l;return[r,d,0,h]}else return}getVehicleModel(e){if(this.view.camera.position.z>=this.cameraHeightThreshold){const s=new o.SphereGeometry(5,32,32),t=new o.MeshPhysicalMaterial({color:325253,emissive:0,roughness:this.roughness,metalness:this.metalness});return new o.Mesh(s,t)}else{let s;if(e.ptcType===2)s=this.bicycleModel.clone();else if(e.ptcType===3)s=this.passengerModel.clone();else{switch(e.vehicleType){case 10:s=this.carModel.clone();break;case 20:s=this.vanModel.clone();break;case 25:s=this.truckModel.clone();break;case 50:s=this.busModel.clone();break;default:s=this.carModel.clone();break}const t=this.materialMap.get(e.vehicleColor)||this.defaultMaterial;let i=!1;s.traverse(a=>{!i&&a instanceof o.Mesh&&(a.material=t,i=!0)})}return s}}createCanvas(e,s,t){const i=document.createElement("canvas"),a=e.width,l=e.height;i.width=a,i.height=l;const r=i.getContext("2d",{willReadFrequently:!0});if(!r){console.log("canvas创建失败");return}return r.fillStyle="rgba(0,0,0,0.0)",r.fillRect(0,0,a,l),r.drawImage(e,0,0,a,l),r.beginPath(),r.translate(a/2,l/2),r.fillStyle=t,r.font="bold 32px 宋体",r.textBaseline="middle",r.textAlign="center",r.fillText(s,0,0),i}createPlateSprite(e){return new Promise((s,t)=>{var h,n;const i=!e.plateNo||e.plateNo==="0"||e.plateNo==="000000";if(this.currentSpriteContent===m.EVehiclePlateState.None||this.currentSpriteContent===m.EVehiclePlateState.PlateNumber&&i){s(void 0);return}let a=new Image,l="",r="";if(this.currentSpriteContent===m.EVehiclePlateState.PlateNumber||this.currentSpriteContent===m.EVehiclePlateState.Mix)if(i)a=this.greyPlateBG,l=e.ptcId,r="#ffffff";else switch(l=((h=e.showName)==null?void 0:h.substring(0,2))+"•"+((n=e.showName)==null?void 0:n.substring(2)),e.plateColor){case 1:a=this.bluePlateBG,r="#ffffff";break;case 2:a=this.yellowPlateBG,r="#000000";break;case 3:a=this.whitePlateBG,r="#000000";break;case 4:a=this.blackPlateBG,r="#ffffff";break;case 5:a=this.neoYellowPlateBG,r="#000000";break;case 6:a=this.neoGreenPlateBG,r="#000000";break;default:a=this.greyPlateBG,l=e.plateNo,r="#ffffff";break}else this.currentSpriteContent===m.EVehiclePlateState.Id&&(a=this.greyPlateBG,l=e.ptcId,r="#ffffff");const d=this.createCanvas(a,l,r);if(d){const p=new o.CanvasTexture(d),c=new o.SpriteMaterial({map:p,transparent:!1}),g=new o.Sprite(c),w=.05,v=d.width*w,y=d.height*w;g.scale.set(v,y,1),g.name="VehiclePlate",s(g)}else{t("canvas创建失败");return}a.onerror=p=>{console.log(`号牌背景加载失败: ${a.src}`,p),t(p)}})}}exports.default=O;
|
|
@@ -22,12 +22,12 @@ export default class Overlay {
|
|
|
22
22
|
* 按type移除覆盖物
|
|
23
23
|
* @param types
|
|
24
24
|
*/
|
|
25
|
-
removeOverlaysByType(types: string[]): IResult;
|
|
25
|
+
removeOverlaysByType(types: string[] | string): IResult;
|
|
26
26
|
/**
|
|
27
27
|
* 按id移除覆盖物
|
|
28
28
|
* @param ids
|
|
29
29
|
*/
|
|
30
|
-
removeOverlaysById(ids: string[]): IResult;
|
|
30
|
+
removeOverlaysById(ids: string[] | string): IResult;
|
|
31
31
|
/**
|
|
32
32
|
* 按id显示或隐藏覆盖物
|
|
33
33
|
* @param ids
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const c=require("@arcgis/core/geometry"),v=require("@arcgis/core/geometry/geometryEngine"),u=require("@arcgis/core/Graphic"),h=require("@arcgis/core/layers/FeatureLayer"),g=require("@arcgis/core/layers/GraphicsLayer");function f(
|
|
1
|
+
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const c=require("@arcgis/core/geometry"),v=require("@arcgis/core/geometry/geometryEngine"),u=require("@arcgis/core/Graphic"),h=require("@arcgis/core/layers/FeatureLayer"),g=require("@arcgis/core/layers/GraphicsLayer");function f(a){const e=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(a){for(const t in a)if(t!=="default"){const i=Object.getOwnPropertyDescriptor(a,t);Object.defineProperty(e,t,i.get?i:{enumerable:!0,get:()=>a[t]})}}return e.default=a,Object.freeze(e)}const n=f(v);class m{constructor(e,t){this.defaultPointSymbol={type:"simple-marker",style:"circle",color:"yellow",size:10},this.view=e,this.overlayLayer=new g({...t}),this.view.map.layers.add(this.overlayLayer)}addMask(e){this.removeMask();const t=e.maskColor||[100,100,100,.8],i=e.maskSize||100;let r=new c.Polygon({rings:[e.geometry.rings[0]]});const s=r.centroid,o=n.geodesicBuffer(s,i,"kilometers");let l=n.difference(o,r);if(e.geometry.rings.length>1)for(let y=1;y<e.geometry.rings.length;y++)r=new c.Polygon({rings:[e.geometry.rings[y]]}),l=n.difference(l,r);const d=new u({geometry:l,symbol:{type:"simple-fill",color:t,outline:{style:"long-dash",color:"white"}},attributes:{type:"mask"}});this.overlayLayer.add(d)}removeMask(){const e=this.overlayLayer.graphics.find(t=>t.getAttribute("type")==="mask");e&&this.overlayLayer.remove(e)}addOverlays(e){let t=0,i=0;e.defaultVisible==null&&(e.defaultVisible=!0);for(const r of e.overlays){r.properties?(r.properties.type||(r.properties.type=e.type),r.properties.id||(r.properties.id=r.id)):r.properties={type:e.type,id:r.id};const s=r.symbol||e.defaultSymbol||this.defaultPointSymbol,o=r.visible==null?e.defaultVisible:r.visible;this.addOverlay(r,s,r.properties,o).message==="add"?t++:i++}return{status:0,message:`新增${t}, 更新${i}`}}removeOverlaysByType(e){const t=this.overlayLayer.graphics.filter(i=>{const r=i.getAttribute("type");return Array.isArray(e)?e.includes(r):r===e});return this.overlayLayer.graphics.removeMany(t),{status:0,message:`删除${t.length}`}}removeOverlaysById(e){const t=this.overlayLayer.graphics.filter(i=>{const r=i.getAttribute("id");return Array.isArray(e)?e.includes(r):r===e});return this.overlayLayer.graphics.removeMany(t),{status:0,message:`删除${t.length}`}}isShowOverlaysByIds(e,t){this.overlayLayer.graphics.map(i=>{const r=i.getAttribute("id");e.includes(r)?i.visible=t:i.visible=!t})}showAllOverlays(){this.overlayLayer.graphics.forEach(e=>{e.visible=!0})}removeAllOverlays(){const e=this.overlayLayer.graphics.length;return this.overlayLayer.removeAll(),{status:0,message:`删除${e}`}}destroy(){this.view.map.remove(this.overlayLayer),this.overlayLayer.destroy()}removeGraphics(e){Array.isArray(e)||(e=[e]),this.overlayLayer.graphics.removeMany(e)}async findGraphic(e){var r;return(r=(await this.view.hitTest(e)).results)==null?void 0:r.filter(s=>s.type==="graphic"&&s.graphic.layer===this.overlayLayer)}hideLayer(){this.overlayLayer.visible=!1}showLayer(){this.overlayLayer.visible=!0}addOverlay(e,t,i,r){let s,o=!0;return e.id&&(s=this.overlayLayer.graphics.find(l=>l.getAttribute("id")===e.id)),s?s.visible=r:(s=new u({visible:r}),this.overlayLayer.add(s),o=!1),s.geometry=e.geometry,s.symbol=t,s.attributes=i,{status:0,message:o?"add":"update"}}addClusterPoint(e){this.clusterLayer||(this.clusterLayer=new h({id:"clusterPointLayer",source:[],outFields:["*"],geometryType:"point"}),this.view.map.add(this.clusterLayer))}}exports.default=m;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const h=require("@arcgis/core/geometry"),E=require("@arcgis/core/geometry/geometryEngine.js"),c=require("@arcgis/core/Graphic"),L=require("@arcgis/core/layers/GraphicsLayer"),f=require("axios"),S=require("vue"),b=require("../../stores/index.js"),w=require("./common-utils.js");function F(n){const s=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(n){for(const e in n)if(e!=="default"){const r=Object.getOwnPropertyDescriptor(n,e);Object.defineProperty(s,e,r.get?r:{enumerable:!0,get:()=>n[e]})}}return s.default=n,Object.freeze(s)}const d=F(E);class C{constructor(s){this.view=s,this.maskLayer=new L({id:"police-jurisdiction"}),this.view.map.add(this.maskLayer);const e=b.default.useAppDataStore,r=S.toRaw(e.mapConfig);this.geoServer=r.geoServer}async showJurisdiction(s){return this.geoServer?s.type.toLowerCase()==="zd"?await this.showZD(s.id):s.type.toLowerCase()==="dd"?await this.showDD(s.id):{status:0,message:"ok"}:{status:-1,message:"未配置GeoServer"}}async showZD(s){let e=await f.get(`${this.geoServer}/zd_edpass/wms`,{params:{service:"WFS",version:"1.1.0",request:"GetFeature",typename:"zd_edpass:VIEW_SH_ZD",outputFormat:"application/json",CQL_FILTER:`ZD_CODE = ${s}`}});if(e.status!==200)return{status:-1,message:e.status+" "+e.statusText};const{features:r}=e.data;if(!r||r.length===0)return{status:-1,message:"未查询到数据"};this.maskLayer.removeAll();const m=r[0].geometry.coordinates,o=[];m.forEach(t=>{const i=new h.Polygon({rings:t});o.push(i)});const p=o[0].centroid,y=d.geodesicBuffer(p,
|
|
1
|
+
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const h=require("@arcgis/core/geometry"),E=require("@arcgis/core/geometry/geometryEngine.js"),c=require("@arcgis/core/Graphic"),L=require("@arcgis/core/layers/GraphicsLayer"),f=require("axios"),S=require("vue"),b=require("../../stores/index.js"),w=require("./common-utils.js");function F(n){const s=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(n){for(const e in n)if(e!=="default"){const r=Object.getOwnPropertyDescriptor(n,e);Object.defineProperty(s,e,r.get?r:{enumerable:!0,get:()=>n[e]})}}return s.default=n,Object.freeze(s)}const d=F(E);class C{constructor(s){this.view=s,this.maskLayer=new L({id:"police-jurisdiction"}),this.view.map.add(this.maskLayer);const e=b.default.useAppDataStore,r=S.toRaw(e.mapConfig);this.geoServer=r.geoServer}async showJurisdiction(s){return this.geoServer?s.type.toLowerCase()==="zd"?await this.showZD(s.id):s.type.toLowerCase()==="dd"?await this.showDD(s.id):{status:0,message:"ok"}:{status:-1,message:"未配置GeoServer"}}async showZD(s){let e=await f.get(`${this.geoServer}/zd_edpass/wms`,{params:{service:"WFS",version:"1.1.0",request:"GetFeature",typename:"zd_edpass:VIEW_SH_ZD",outputFormat:"application/json",CQL_FILTER:`ZD_CODE = ${s}`}});if(e.status!==200)return{status:-1,message:e.status+" "+e.statusText};const{features:r}=e.data;if(!r||r.length===0)return{status:-1,message:"未查询到数据"};this.maskLayer.removeAll();const m=r[0].geometry.coordinates,o=[];m.forEach(t=>{const i=new h.Polygon({rings:t});o.push(i)});const p=o[0].centroid,y=d.geodesicBuffer(p,500,"kilometers");let a=d.difference(y,o[0]);for(let t=1;t<o.length;t++)a=d.difference(a,o[t]);const g=new c({geometry:a,symbol:{type:"simple-fill",color:[100,100,100,.8],outline:{width:0}},attributes:{type:"mask"}});this.maskLayer.add(g);const l=o.map(t=>new c({geometry:t,symbol:{type:"simple-line",style:"solid",color:[240,156,69],width:2}}));if(this.maskLayer.addMany(l),await w.default.viewGoto(this.view,l),e=await f.get(`${this.geoServer}/zd_edpass/wms`,{params:{service:"WFS",version:"1.1.0",request:"GetFeature",typename:"zd_edpass:VW_DWD_GEO_SH_DD",outputFormat:"application/json",CQL_FILTER:`ZD_CODE = ${s}`}}),e.status===200){const{features:t}=e.data;if(t&&t.length>0){const i=[];t.forEach(u=>{u.geometry.coordinates.forEach(D=>{const k=new h.Polygon({rings:D}),G=new c({geometry:k,symbol:{type:"simple-line",style:"dash",color:[240,156,69],width:1}});i.push(G)});const _=u.properties.DD_NAME,v=new c({geometry:{type:"point",longitude:u.properties.CENTER_X,latitude:u.properties.CENTER_Y},symbol:{type:"text",color:[240,156,69],haloColor:[255,255,255],haloSize:"2px",text:_,font:{size:"14px",weight:"bold",family:"msyh"}}});i.push(v)}),this.maskLayer.addMany(i)}}return{status:0,message:"ok"}}async showDD(s){this.maskLayer.removeAll();const e=await f.get(`${this.geoServer}/zd_edpass/wms`,{params:{service:"WFS",version:"1.1.0",request:"GetFeature",typename:"zd_edpass:VW_DWD_GEO_SH_DD",outputFormat:"application/json",CQL_FILTER:`DD_CODE = ${s}`}});if(console.log(e),e.status!==200)return{status:-1,message:e.status+" "+e.statusText};const{features:r}=e.data;if(!r||r.length===0)return{status:-1,message:"未查询到数据"};const m=r[0].geometry.coordinates,o=[];m.forEach(t=>{const i=new h.Polygon({rings:t});o.push(i)});const p=o[0].centroid,y=d.geodesicBuffer(p,100,"kilometers");let a=d.difference(y,o[0]);for(let t=1;t<o.length;t++)a=d.difference(a,o[t]);const g=new c({geometry:a,symbol:{type:"simple-fill",color:[100,100,100,.8],outline:{width:0}}});this.maskLayer.add(g);const l=o.map(t=>new c({geometry:t,symbol:{type:"simple-line",style:"dash",color:[240,156,69],width:1}}));return this.maskLayer.addMany(l),await w.default.viewGoto(this.view,l),{status:0,message:"ok"}}clearJurisdiction(){this.maskLayer.removeAll()}}exports.default=C;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const i=require("@arcgis/core/Graphic"),n=require("@arcgis/core/layers/GraphicsLayer"),o=require("../common-utils.js");class h{constructor(e){this.view=e,this.signalSystemLayer=new n({title:"信控系统图层"}),this.view.map.add(this.signalSystemLayer)}async showSignalSystems(e){return e.areaList.forEach(s=>{this.showSystem(s)}),await o.default.viewGoto(this.view,this.signalSystemLayer.graphics.toArray()),{status:0,message:"success"}}async showSubSignalSystems(e){return e.areaList.forEach(s=>{this.showSubSystem(s)}),await o.default.viewGoto(this.view,this.signalSystemLayer.graphics.toArray()),{status:0,message:"success"}}removeSubSignalSystems(e){return e?this.signalSystemLayer.graphics.filter(s=>s.getAttribute("subCode")===e).forEach(s=>{this.signalSystemLayer.remove(s)}):this.signalSystemLayer.removeAll(),{status:0,message:"success"}}removeSignalSystems(e){return e?this.signalSystemLayer.graphics.filter(s=>s.getAttribute("areaCode")===e).forEach(s=>{this.signalSystemLayer.remove(s)}):this.signalSystemLayer.removeAll(),{status:0,message:"success"}}showSystem(e){if(e.shape){let s;if(typeof e.shape=="string"?s=JSON.parse(e.shape):s=e.shape,s){const t=new i({geometry:{type:"polyline",paths:[s]},symbol:e.lineSymbol||{type:"simple-line",style:"dash",color:[17,113,191],width:2},attributes:{areaCode:e.areaCode,type:"signal-system-border"}});this.signalSystemLayer.add(t)}}e.children.forEach(s=>{this.showSubSystem(s,e.areaCode)})}showSubSystem(e,s){if(e.subShape){let t;typeof e.subShape=="string"?t=JSON.parse(e.subShape):t=e.subShape;const a=t.map((r,l)=>new i({geometry:{type:"polyline",paths:[r]},symbol:e.roadSymbol||{type:"simple-line",color:[23,151,255],width:3},attributes:{type:"signal-sub-system",id:e.subAreaCode+"_"+l,subCode:e.subAreaCode,areaCode:s||""}}));this.signalSystemLayer.addMany(a)}if(e.children){const t=e.children.map(a=>new i({geometry:{type:"point",longitude:a.x,latitude:a.y},symbol:a.symbol||e.nodeSymbol||{type:"simple-marker",color:[23,151,255,.8],size:10,outline:{color:[23,151,255],width:2}},attributes:{...a,type:"signal-sub-system-node",subCode:e.subAreaCode,areaCode:s||""}}));this.signalSystemLayer.addMany(t)}}}exports.default=h;
|
|
1
|
+
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const i=require("@arcgis/core/Graphic"),n=require("@arcgis/core/layers/GraphicsLayer"),o=require("../common-utils.js");class h{constructor(e){this.view=e,this.signalSystemLayer=new n({title:"信控系统图层"}),this.view.map.add(this.signalSystemLayer)}async showSignalSystems(e){return e.areaList.forEach(s=>{this.showSystem(s)}),await o.default.viewGoto(this.view,this.signalSystemLayer.graphics.toArray()),{status:0,message:"success"}}async showSubSignalSystems(e){return e.areaList.forEach(s=>{this.showSubSystem(s)}),await o.default.viewGoto(this.view,this.signalSystemLayer.graphics.toArray()),{status:0,message:"success"}}removeSubSignalSystems(e){return e?this.signalSystemLayer.graphics.filter(s=>s.getAttribute("subCode")===e).forEach(s=>{this.signalSystemLayer.remove(s)}):this.signalSystemLayer.removeAll(),{status:0,message:"success"}}removeSignalSystems(e){return e?this.signalSystemLayer.graphics.filter(s=>s.getAttribute("areaCode")===e).forEach(s=>{this.signalSystemLayer.remove(s)}):this.signalSystemLayer.removeAll(),{status:0,message:"success"}}showSystem(e){if(e.shape){let s;if(typeof e.shape=="string"?s=JSON.parse(e.shape):s=e.shape,s){const t=new i({geometry:{type:"polyline",paths:[s]},symbol:e.lineSymbol||{type:"simple-line",style:"dash",color:[17,113,191],width:2},attributes:{areaCode:e.areaCode,type:"signal-system-border"}});this.signalSystemLayer.add(t)}}e.children.forEach(s=>{this.showSubSystem(s,e.areaCode)})}showSubSystem(e,s){if(e.subShape){let t;typeof e.subShape=="string"?t=JSON.parse(e.subShape):t=e.subShape;const a=t.map((r,l)=>new i({geometry:{type:"polyline",paths:[r]},symbol:e.roadSymbol||{type:"simple-line",color:[23,151,255],width:3},attributes:{type:"signal-sub-system",id:e.subAreaCode+"_"+l,subCode:e.subAreaCode,areaCode:s||""}}));this.signalSystemLayer.addMany(a)}if(e.children){const t=e.children.map(a=>new i({geometry:{type:"point",longitude:Number(a.x),latitude:Number(a.y)},symbol:a.symbol||e.nodeSymbol||{type:"simple-marker",color:[23,151,255,.8],size:10,outline:{color:[23,151,255],width:2}},attributes:{...a,type:"signal-sub-system-node",subCode:e.subAreaCode,areaCode:s||""}}));this.signalSystemLayer.addMany(t)}}}exports.default=h;
|
|
@@ -1,8 +1,12 @@
|
|
|
1
1
|
import { default as OlMap } from 'ol/Map';
|
|
2
2
|
import type { EventsKey } from 'ol/events';
|
|
3
|
-
import { ILayerVisibleParams, ISetMapCameraParams, ISetMapCenterParams, IShowSignalCrossParams } from '../types';
|
|
3
|
+
import { IClusterPointParams, ILayerVisibleParams, IOverlayParam, ISetMapCameraParams, ISetMapCenterParams, IShowJurisdictionParams, IShowSignalCrossParams, IShowSignalSystemParams, IShowSubSignalSystemParams } from '../types';
|
|
4
4
|
import OlMapInitializer from './utils/ol-map-initializer';
|
|
5
|
+
import ClusterPointController from './utils/overlay/cluster-point-controller';
|
|
6
|
+
import PoliceAreaController from './utils/police-area-controller';
|
|
5
7
|
import SignalCrossController from './utils/signal-control/signal-cross-controller';
|
|
8
|
+
import SignalSystemController from './utils/signal-control/signal-system-controller';
|
|
9
|
+
import OverlayController from './utils/overlay/overlay-controller';
|
|
6
10
|
declare const _sfc_main: import("vue").DefineComponent<{
|
|
7
11
|
config: {
|
|
8
12
|
type: StringConstructor;
|
|
@@ -20,6 +24,10 @@ declare const _sfc_main: import("vue").DefineComponent<{
|
|
|
20
24
|
lastEmittedZoomInt: number | null;
|
|
21
25
|
emitZoomIfChanged: (z: number) => void;
|
|
22
26
|
signalCrossController: SignalCrossController;
|
|
27
|
+
signalSystemController: SignalSystemController;
|
|
28
|
+
clusterPointController: ClusterPointController;
|
|
29
|
+
policeAreaController: PoliceAreaController;
|
|
30
|
+
overlayController: OverlayController;
|
|
23
31
|
setMapCenter: (params: ISetMapCenterParams) => Promise<import("../types").IResult>;
|
|
24
32
|
setMapCamera: (params: ISetMapCameraParams) => Promise<import("../types").IResult>;
|
|
25
33
|
setLayerVisibility: (params: ILayerVisibleParams) => Promise<import("../types").IResult>;
|
|
@@ -30,6 +38,27 @@ declare const _sfc_main: import("vue").DefineComponent<{
|
|
|
30
38
|
message: string;
|
|
31
39
|
};
|
|
32
40
|
clearSignalCross: () => void;
|
|
41
|
+
showSignalSystem: (params: IShowSignalSystemParams) => Promise<import("../types").IResult> | {
|
|
42
|
+
status: number;
|
|
43
|
+
message: string;
|
|
44
|
+
};
|
|
45
|
+
removeSignalSystem: (areaCode?: string | undefined) => void | {
|
|
46
|
+
success: boolean;
|
|
47
|
+
message: string;
|
|
48
|
+
};
|
|
49
|
+
showSubSignalSystem: (params: IShowSubSignalSystemParams) => Promise<import("../types").IResult>;
|
|
50
|
+
removeSubSignalSystem: (subCode?: string | undefined) => void | {
|
|
51
|
+
success: boolean;
|
|
52
|
+
message: string;
|
|
53
|
+
};
|
|
54
|
+
addClusterPoints: (params: IClusterPointParams) => void;
|
|
55
|
+
removeAllClusterPoints: () => void;
|
|
56
|
+
showPoliceArea: (params: IShowJurisdictionParams) => Promise<void>;
|
|
57
|
+
clearPoliceArea: () => void;
|
|
58
|
+
addOverlays: (params: IOverlayParam) => import("../types").IResult;
|
|
59
|
+
removeOverlaysById: (ids: string[] | string) => void;
|
|
60
|
+
removeOverlaysByType: (type: string[] | string) => void;
|
|
61
|
+
removeAllOverlays: () => void;
|
|
33
62
|
props: any;
|
|
34
63
|
emit: (event: "mapLoaded" | "markerClick" | "mapClick" | "update:zoom", ...args: any[]) => void;
|
|
35
64
|
}, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, ("mapLoaded" | "markerClick" | "mapClick" | "update:zoom")[], "mapLoaded" | "markerClick" | "mapClick" | "update:zoom", import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<{
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const
|
|
1
|
+
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const s=require("vue"),U=require("ol/Observable"),D=require("../stores/index.js"),G=require("./utils/ol-map-initializer.js"),H=require("./utils/overlay/cluster-point-controller.js"),S=require("./utils/police-area-controller.js"),Q=require("./utils/signal-control/signal-cross-controller.js"),v=require("./utils/signal-control/signal-system-controller.js"),W=require("./utils/overlay/overlay-controller.js"),X={class:"gis-viewer"},Y=s.defineComponent({__name:"gis-map-ol",props:{config:{},assetsRoot:{}},emits:["mapLoaded","markerClick","mapClick","update:zoom"],setup(w,{expose:h,emit:b}){const g=s.ref(null);let i,t,u=[],f=null;const y=e=>{if(!Number.isFinite(e))return;const l=Math.round(e);l!==f&&(f=l,m("update:zoom",l))};let n,o,c,a,r;s.onMounted(async()=>{D.registerStore();const e=s.getCurrentInstance(),{$gisviewerAssetsRoot:l}=e.appContext.config.globalProperties,C=await(await fetch(d.config)).json();C.assetsRoot=d.assetsRoot||l,i=new G.default,t=i.initialize({container:g.value,mapConfig:C,markerClickCallback:(j,J,K,F)=>{m("markerClick",j,J,K,F)}});const p=t.getView();u.push(p.on("change:resolution",()=>{y(p.getZoom())})),y(t.getView().getZoom()),m("mapLoaded"),a=new S.default(t),await a.initialize()});const M=async e=>await i.setMapCenter(e),k=async e=>await i.setMapCamera(e),_=async e=>await i.setLayerVisibility(e),O=e=>i.setMapZoom({zoom:e}),P=e=>(n||(n=new Q.default(t)),n.showSignalCross(e)),q=e=>n?n.changeShowName(e):{success:!1,message:"SignalCrossController未初始化"},A=()=>{n&&n.clearSignalCross()},B=e=>(o||(o=new v.default(t)),o.showSignalSystem(e)),I=e=>o?o.removeSignalSystem(e):{success:!1,message:"SignalSystemController未初始化"},z=e=>(o||(o=new v.default(t)),o.showSubSignalSystem(e)),Z=e=>o?o.removeSubSignalSystem(e):{success:!1,message:"SignalSystemController未初始化"},$=e=>(c||(c=new H.default(t)),c.addClusterPoints(e)),x=()=>{c&&c.removeAllClusterPoints()},E=async e=>(a||(a=new S.default(t)),await a.showJurisdiction(e)),V=()=>{a&&a.clearJurisdiction()},L=e=>(r||(r=new W.default(t)),r.addOverlays(e)),N=e=>{r&&r.removeOverlaysById(e)},R=e=>{r&&r.removeOverlaysByType(e)},T=()=>{r&&r.removeAllOverlays()};s.onBeforeUnmount(()=>{u.forEach(e=>U.unByKey(e)),u=[]});const d=w,m=b;return h({setMapCenter:M,setMapCamera:k,setMapZoom:O,setLayerVisibility:_,showSignalCross:P,showSignalSystem:B,removeSignalSystem:I,showSubSignalSystem:z,removeSubSignalSystem:Z,clearSignalCross:A,changeSignalCrossShowName:q,addClusterPoints:$,removeAllClusterPoints:x,showPoliceArea:E,clearPoliceArea:V,addOverlays:L,removeOverlaysById:N,removeOverlaysByType:R,removeAllOverlays:T}),(e,l)=>(s.openBlock(),s.createElementBlock("div",X,[s.createElementVNode("div",{id:"divCMap",class:"gis-viewer-main",ref_key:"mapContainer",ref:g},null,512)]))}});exports.default=Y;
|
|
@@ -15,6 +15,10 @@ export declare const GisMapOl: import("@easyest/utils/dist/lib/withinstall").SFC
|
|
|
15
15
|
lastEmittedZoomInt: number | null;
|
|
16
16
|
emitZoomIfChanged: (z: number) => void;
|
|
17
17
|
signalCrossController: import("./utils/signal-control/signal-cross-controller").default;
|
|
18
|
+
signalSystemController: import("./utils/signal-control/signal-system-controller").default;
|
|
19
|
+
clusterPointController: import("./utils/overlay/cluster-point-controller").default;
|
|
20
|
+
policeAreaController: import("./utils/police-area-controller").default;
|
|
21
|
+
overlayController: import("./utils/overlay/overlay-controller").default;
|
|
18
22
|
setMapCenter: (params: import("../types").ISetMapCenterParams) => Promise<import("../types").IResult>;
|
|
19
23
|
setMapCamera: (params: import("../types").ISetMapCameraParams) => Promise<import("../types").IResult>;
|
|
20
24
|
setLayerVisibility: (params: import("../types").ILayerVisibleParams) => Promise<import("../types").IResult>;
|
|
@@ -25,6 +29,27 @@ export declare const GisMapOl: import("@easyest/utils/dist/lib/withinstall").SFC
|
|
|
25
29
|
message: string;
|
|
26
30
|
};
|
|
27
31
|
clearSignalCross: () => void;
|
|
32
|
+
showSignalSystem: (params: import("../types").IShowSignalSystemParams) => Promise<import("../types").IResult> | {
|
|
33
|
+
status: number;
|
|
34
|
+
message: string;
|
|
35
|
+
};
|
|
36
|
+
removeSignalSystem: (areaCode?: string | undefined) => void | {
|
|
37
|
+
success: boolean;
|
|
38
|
+
message: string;
|
|
39
|
+
};
|
|
40
|
+
showSubSignalSystem: (params: import("../types").IShowSubSignalSystemParams) => Promise<import("../types").IResult>;
|
|
41
|
+
removeSubSignalSystem: (subCode?: string | undefined) => void | {
|
|
42
|
+
success: boolean;
|
|
43
|
+
message: string;
|
|
44
|
+
};
|
|
45
|
+
addClusterPoints: (params: import("../types").IClusterPointParams) => void;
|
|
46
|
+
removeAllClusterPoints: () => void;
|
|
47
|
+
showPoliceArea: (params: import("../types").IShowJurisdictionParams) => Promise<void>;
|
|
48
|
+
clearPoliceArea: () => void;
|
|
49
|
+
addOverlays: (params: import("../types").IOverlayParam) => import("../types").IResult;
|
|
50
|
+
removeOverlaysById: (ids: string | string[]) => void;
|
|
51
|
+
removeOverlaysByType: (type: string | string[]) => void;
|
|
52
|
+
removeAllOverlays: () => void;
|
|
28
53
|
props: any;
|
|
29
54
|
emit: (event: "mapLoaded" | "markerClick" | "mapClick" | "update:zoom", ...args: any[]) => void;
|
|
30
55
|
}, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, ("mapLoaded" | "markerClick" | "mapClick" | "update:zoom")[], "mapLoaded" | "markerClick" | "mapClick" | "update:zoom", import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<{
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import type { default as OlMap } from 'ol/Map';
|
|
2
|
+
import { ICluster, IClusterLocation } from '../../../types';
|
|
3
|
+
export interface IPixelClusterOptions {
|
|
4
|
+
/** 聚合半径(像素),默认 120 */
|
|
5
|
+
clusterRadius?: number;
|
|
6
|
+
/** 最小聚合点数,默认 2 */
|
|
7
|
+
minClusterPoints?: number;
|
|
8
|
+
/** 最大聚合符号大小,默认 40 */
|
|
9
|
+
maxClusterSymbolSize?: number;
|
|
10
|
+
/** 最小聚合符号大小,默认 20 */
|
|
11
|
+
minClusterSymbolSize?: number;
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* 像素聚合计算器
|
|
15
|
+
* 基于屏幕像素距离进行点聚合
|
|
16
|
+
*/
|
|
17
|
+
export declare class PixelClusterCalculator {
|
|
18
|
+
private map;
|
|
19
|
+
private options;
|
|
20
|
+
private clusteredLocations;
|
|
21
|
+
constructor(map: OlMap, options?: IPixelClusterOptions);
|
|
22
|
+
/**
|
|
23
|
+
* 计算聚合结果
|
|
24
|
+
* @param locations 原始点位数组
|
|
25
|
+
* @returns 聚合结果
|
|
26
|
+
*/
|
|
27
|
+
calculate(locations: IClusterLocation[]): ICluster[];
|
|
28
|
+
/**
|
|
29
|
+
* 计算聚合符号大小
|
|
30
|
+
* @param clusters 聚合结果
|
|
31
|
+
* @returns 带有符号大小信息的聚合结果
|
|
32
|
+
*/
|
|
33
|
+
calculateSymbolSizes(clusters: ICluster[]): (ICluster & {
|
|
34
|
+
symbolSize?: number;
|
|
35
|
+
})[];
|
|
36
|
+
/**
|
|
37
|
+
* 更新配置
|
|
38
|
+
*/
|
|
39
|
+
updateOptions(options: Partial<IPixelClusterOptions>): void;
|
|
40
|
+
/**
|
|
41
|
+
* 获取当前配置
|
|
42
|
+
*/
|
|
43
|
+
getOptions(): Required<IPixelClusterOptions>;
|
|
44
|
+
/**
|
|
45
|
+
* 将地理坐标转换为屏幕坐标
|
|
46
|
+
*/
|
|
47
|
+
private locationToScreen;
|
|
48
|
+
/**
|
|
49
|
+
* 基于像素距离的聚合算法
|
|
50
|
+
*/
|
|
51
|
+
private doPixelCluster;
|
|
52
|
+
/**
|
|
53
|
+
* 获取指定点的邻近点
|
|
54
|
+
*/
|
|
55
|
+
private getNeighbors;
|
|
56
|
+
/**
|
|
57
|
+
* 计算两点之间的屏幕距离
|
|
58
|
+
*/
|
|
59
|
+
private getDistance;
|
|
60
|
+
/**
|
|
61
|
+
* 根据聚合结果创建聚合对象
|
|
62
|
+
*/
|
|
63
|
+
private createClusters;
|
|
64
|
+
}
|
|
65
|
+
export default PixelClusterCalculator;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const p={clusterRadius:120,minClusterPoints:2,maxClusterSymbolSize:40,minClusterSymbolSize:20};class c{constructor(s,t){this.clusteredLocations=[],this.map=s,this.options={...p,...t}}calculate(s){return this.locationToScreen(s),this.doPixelCluster(this.options.clusterRadius)}calculateSymbolSizes(s){let t=Number.MIN_VALUE,i=Number.MAX_VALUE;return s.forEach(e=>{e.count>1&&(i=Math.min(i,e.count),t=Math.max(t,e.count))}),s.map(e=>{if(e.id!==-1&&e.center){let r=i===t?(this.options.maxClusterSymbolSize+this.options.minClusterSymbolSize)/2:this.options.minClusterSymbolSize+(e.count-i)/(t-i)*(this.options.maxClusterSymbolSize-this.options.minClusterSymbolSize);return r*=.75,{...e,symbolSize:r}}return e})}updateOptions(s){this.options={...this.options,...s}}getOptions(){return{...this.options}}locationToScreen(s){this.clusteredLocations=[],s.forEach(t=>{const i=this.map.getPixelFromCoordinate([t.x,t.y]),[e,r]=i||[NaN,NaN];Number.isFinite(e)&&Number.isFinite(r)&&e>0&&r>0&&(t.properties=t.properties||{},t.properties.screenX=e,t.properties.screenY=r,t.visited=!1,t.clusterId=void 0,this.clusteredLocations.push(t))})}doPixelCluster(s){let t=0;for(let i=0;i<this.clusteredLocations.length;i++){const e=this.clusteredLocations[i];if(e.visited)continue;e.visited=!0;const r=this.getNeighbors(e,s);r.length<this.options.minClusterPoints?e.clusterId=-1:(r.forEach(o=>{o.visited=!0,o.clusterId=t}),e.clusterId=t,t++)}return this.createClusters()}getNeighbors(s,t){return this.clusteredLocations.filter(i=>i.id===s.id||i.visited?!1:this.getDistance(s,i)<=t)}getDistance(s,t){var i,e,r,o;return Math.sqrt(Math.pow((((i=s.properties)==null?void 0:i.screenX)??0)-(((e=t.properties)==null?void 0:e.screenX)??0),2)+Math.pow((((r=s.properties)==null?void 0:r.screenY)??0)-(((o=t.properties)==null?void 0:o.screenY)??0),2))}createClusters(){const s={},t=[];for(const e of this.clusteredLocations)e.clusterId===void 0||e.clusterId===-1?t.push(e):(s[e.clusterId]||(s[e.clusterId]=[]),s[e.clusterId].push(e));const i=Object.keys(s).map(e=>{const r=s[Number(e)],o=r.length,l=r.reduce((n,u)=>n+u.x,0),a=r.reduce((n,u)=>n+u.y,0),d=l/o,h=a/o;return{id:Number(e),items:r,count:o,center:{x:d,y:h}}});return t.length>0&&i.push({id:-1,items:t,count:t.length,center:null}),i}}exports.PixelClusterCalculator=c;exports.default=c;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const
|
|
1
|
+
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const p=require("ol/layer/Image"),u=require("ol/layer/Tile"),l=require("ol/Map");require("ol/ol.css");const d=require("ol/proj"),n=require("ol/source"),g=require("ol/tilegrid"),w=require("ol/tilegrid/WMTS"),f=require("ol/View");class S{constructor(){this.mapConfig={},this.pointerMoveRaf=null}initialize(e){return this.mapConfig=e.mapConfig||{},this.markerClick=e.markerClickCallback,this.map=this.createMap(e.container),this.mapConfig.baseLayers&&this.loadLayers(this.mapConfig.baseLayers),this.map}processUrl(e){return e&&(e.startsWith("http://")||e.startsWith("https://")?e:e.startsWith("{{")?e.replace("{{geoServer}}",this.mapConfig.geoServer):e)}loadLayers(e){if(!this.map)return;const i=1/0,s=16384;e.forEach(t=>{var o,a;(o=t.source)!=null&&o.url&&(t.source.url=this.processUrl(t.source.url));let r;switch(t.type.toLowerCase()){case"webtile":{console.log(t),r=new u({preload:i,cacheSize:s,source:new n.XYZ({url:t.source.url,projection:t.source.projection||"EPSG:4326",tileSize:t.source.tileSize||256})});break}case"gwc-wms":{r=new u({preload:i,cacheSize:s,source:new n.TileWMS({...t.source,tileGrid:new g.TileGrid({...t.source.tileGrid})}),...t.options});break}case"wmts":{const c=t.source.matrixSet||"",m=Array.from({length:22},(z,h)=>`${c}:${h}`);r=new u({preload:i,cacheSize:s,source:new n.WMTS({...t.source,format:"image/png",projection:new d.Projection({code:t.source.projection||"EPSG:4326"}),tileGrid:new w({resolutions:[1.4078260157100582,.703913007855028,.35195650392751515,.17597825196375638,.08798912598187819,.043994562990939096,.021997281495469548,.010998640747734774,.005499320373868577,.0027496601869330985,.001374830093467739,.0006874150467326798,.0003437075233663399,.00017185376168316996,8592688084158498e-20,4296344042198222e-20,2148172021099111e-20,10740860104305824e-21,53704300533426425e-22,2685215025481591e-21,13426075127407955e-22,6713037563703978e-22],matrixIds:m,tileSize:256,origin:[-400,400]})}),...t.options});break}case"image-wms":{r=new p({source:new n.ImageWMS({...t.source}),...t.options});break}}r&&(r.set("id",t.id),r.set("group",t.group),(a=this.map)==null||a.addLayer(r))})}createMap(e){const i=this.mapConfig.view;this.mapView=new f({...i}),this.mapConfig.camera?this.mapConfig.camera.home=i:this.mapConfig.camera={home:i};const s=new l({target:e,view:this.mapView});return s.on("pointermove",t=>{t.dragging||this.pointerMoveRaf===null&&(this.pointerMoveRaf=requestAnimationFrame(()=>{const r=s.hasFeatureAtPixel(t.pixel),o=s.getTargetElement();o&&(o.style.cursor=r?"pointer":""),this.pointerMoveRaf=null}))}),s.on("click",t=>{const r=s.forEachFeatureAtPixel(t.pixel,o=>o);if(r&&this.markerClick){const o=r.get("type")??"",a=r.get("id")??"",c=r.getProperties();this.markerClick(o,a,c,t)}}),s}async setMapCenter(e){return this.map?new Promise(i=>{e.duration&&e.duration>0?this.mapView.animate({center:e.center||this.mapView.getCenter(),zoom:e.zoom||this.mapView.getZoom(),duration:e.duration*1e3},()=>{i({status:0,message:"成功"})}):(e.zoom&&this.mapView.setZoom(e.zoom),e.center&&this.mapView.setCenter(e.center),i({status:0,message:"成功"}))}):{status:-1,message:"地图未初始化"}}setMapZoom(e){return this.map?(this.mapView.setZoom(e.zoom),{status:0,message:"成功"}):{status:-1,message:"地图未初始化"}}async setMapCamera(e){if(!this.map)return{status:-1,message:"地图未初始化"};const i=this.mapConfig.camera[e.name];return i?await this.setMapCenter({center:i.center,zoom:e.zoom||i.zoom,duration:e.duration||0}):{status:-1,message:`未找到名称为 ${e.name} 的相机视图`}}async setLayerVisibility(e){const i=this.map.getLayers().getArray().filter(s=>s.get("id")===e.id||s.get("group")===e.id);return i.length>0?(i.forEach(s=>s.setVisible(e.visible)),{status:0,message:"成功"}):{status:-1,message:`未找到ID为 ${e.id} 的图层`}}}exports.default=S;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { default as OlMap } from 'ol/Map';
|
|
2
|
+
import { IClusterPointParams } from '../../../types';
|
|
3
|
+
export default class ClusterPointController {
|
|
4
|
+
private map;
|
|
5
|
+
private clusterLayer;
|
|
6
|
+
private source;
|
|
7
|
+
private view;
|
|
8
|
+
private clusterCalculator;
|
|
9
|
+
private countBackgroundColor;
|
|
10
|
+
private countFontColor;
|
|
11
|
+
private locations;
|
|
12
|
+
private clusterMarkUrl;
|
|
13
|
+
private viewChangeKey;
|
|
14
|
+
private mapMoveKey;
|
|
15
|
+
private resolutionChangeTimeout;
|
|
16
|
+
constructor(map: OlMap);
|
|
17
|
+
addClusterPoints(params: IClusterPointParams): void;
|
|
18
|
+
removeAllClusterPoints(): void;
|
|
19
|
+
private configureVectorLayerStyle;
|
|
20
|
+
private getClusterStyle;
|
|
21
|
+
private showClusterResult;
|
|
22
|
+
private calculateCluster;
|
|
23
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const r=require("ol/Feature"),i=require("ol/geom/Point"),h=require("ol/layer/Vector"),l=require("ol/Observable"),y=require("ol/source/Vector"),n=require("ol/style/Fill"),g=require("ol/style/Icon"),C=require("ol/style/Stroke"),u=require("ol/style/Style"),m=require("ol/style/Text"),d=require("../cluster/pixel-cluster-calculator.js"),c=require("../style/point-style.js");class S{constructor(t){this.countBackgroundColor=[2,72,200,.8],this.countFontColor=[255,255,255,1],this.locations=[],this.clusterMarkUrl="",this.viewChangeKey=null,this.mapMoveKey=null,this.resolutionChangeTimeout=null,this.map=t,this.view=t.getView(),this.clusterCalculator=new d.PixelClusterCalculator(t),this.source=new y,this.clusterLayer=new h({source:this.source}),this.clusterLayer.set("id","cluster-points-layer"),this.map.addLayer(this.clusterLayer),this.configureVectorLayerStyle()}addClusterPoints(t){var e;this.clusterMarkUrl=((e=t.clusterSymbol)==null?void 0:e.url)||"/GisViewerAssets/Images/cross/gis_xhj_blue.png",this.countBackgroundColor=t.countBackgroundColor||this.countBackgroundColor,this.countFontColor=t.countFontColor||this.countFontColor,this.locations=t.points,this.locations.forEach(o=>{o.symbol=o.symbol||t.pointSymbol}),this.viewChangeKey||(this.viewChangeKey=this.view.on("change:resolution",()=>{this.resolutionChangeTimeout&&clearTimeout(this.resolutionChangeTimeout),this.resolutionChangeTimeout=setTimeout(()=>{this.calculateCluster()},150)})),this.mapMoveKey||(this.mapMoveKey=this.map.on("moveend",()=>{this.calculateCluster()})),this.calculateCluster()}removeAllClusterPoints(){this.source.clear(),this.viewChangeKey&&(l.unByKey(this.viewChangeKey),this.viewChangeKey=null),this.mapMoveKey&&(l.unByKey(this.mapMoveKey),this.mapMoveKey=null),this.resolutionChangeTimeout&&(clearTimeout(this.resolutionChangeTimeout),this.resolutionChangeTimeout=null)}configureVectorLayerStyle(){const t=this.view.getResolutionForZoom(18);this.clusterLayer.setStyle((e,o)=>{const s=e.get("type");if(o<=t)return c.getPointStyle(e.getProperties().symbol);if(s==="cluster-point")return c.getPointStyle(e.getProperties().symbol);if(s==="cluster-cluster")return this.getClusterStyle(e.getProperties())})}getClusterStyle(t){const e=t.clusterSymbolSize,o=new g({src:this.clusterMarkUrl,scale:e/32}),s=-(e+10),a=new m({text:String(t.count??0),font:"16px Arial Unicode MS",fill:new n({color:this.countFontColor}),backgroundFill:new n({color:this.countBackgroundColor}),backgroundStroke:new C({color:[this.countBackgroundColor[0],this.countBackgroundColor[1],this.countBackgroundColor[2],.5],width:4}),padding:[1,2,1,2],offsetY:s,textAlign:"center",justify:"center",textBaseline:"middle"});return[new u({image:o}),new u({text:a})]}showClusterResult(t){this.source.clear(),t.forEach(e=>{if(e.id!==-1&&e.center&&e.symbolSize){const o=new r({geometry:new i([e.center.x,e.center.y]),type:"cluster-cluster",count:e.count,clusterSymbolSize:e.symbolSize});this.source.addFeature(o)}else e.items.forEach(o=>{const s=new r({...o.properties,geometry:new i([o.x,o.y]),type:"cluster-point",symbol:o.symbol});this.source.addFeature(s)})}),this.clusterLayer.changed()}calculateCluster(){const t=this.clusterCalculator.calculate(this.locations),e=this.clusterCalculator.calculateSymbolSizes(t);this.showClusterResult(e)}}exports.default=S;
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
import Feature from 'ol/Feature';
|
|
2
|
+
import { Geometry } from 'ol/geom';
|
|
3
|
+
import VectorLayer from 'ol/layer/Vector';
|
|
4
|
+
import { default as OlMap } from 'ol/Map';
|
|
5
|
+
import VectorSource from 'ol/source/Vector';
|
|
6
|
+
import { ILineSymbol, IOverlayParam, IPointSymbol, IPolygonSymbol, IResult } from '../../../types';
|
|
7
|
+
interface IOverlayOptions {
|
|
8
|
+
id?: string;
|
|
9
|
+
}
|
|
10
|
+
export default class OverlayController {
|
|
11
|
+
private map;
|
|
12
|
+
overlayLayer: VectorLayer<VectorSource<Feature<Geometry>>>;
|
|
13
|
+
private vectorSource;
|
|
14
|
+
constructor(map: OlMap, options?: IOverlayOptions);
|
|
15
|
+
private defaultPointSymbol;
|
|
16
|
+
/**
|
|
17
|
+
* 添加覆盖物
|
|
18
|
+
* @param params
|
|
19
|
+
*/
|
|
20
|
+
addOverlays(params: IOverlayParam): IResult;
|
|
21
|
+
/**
|
|
22
|
+
* 添加或更新单个覆盖物
|
|
23
|
+
* @param overlay 覆盖物对象
|
|
24
|
+
* @param symbol 符号
|
|
25
|
+
* @param properties 属性
|
|
26
|
+
* @param visible 是否可见
|
|
27
|
+
*/
|
|
28
|
+
private addOverlay;
|
|
29
|
+
/**
|
|
30
|
+
* 创建几何对象
|
|
31
|
+
* @param geometryConfig 几何配置
|
|
32
|
+
*/
|
|
33
|
+
private createGeometry;
|
|
34
|
+
/**
|
|
35
|
+
* 获取样式
|
|
36
|
+
* @param geometryType 几何类型
|
|
37
|
+
* @param symbol 符号配置
|
|
38
|
+
* @param attributes 属性
|
|
39
|
+
*/
|
|
40
|
+
private getStyle;
|
|
41
|
+
/**
|
|
42
|
+
* 按type移除覆盖物
|
|
43
|
+
* @param types
|
|
44
|
+
*/
|
|
45
|
+
removeOverlaysByType(types: string[] | string): IResult;
|
|
46
|
+
/**
|
|
47
|
+
* 按id移除覆盖物
|
|
48
|
+
* @param ids
|
|
49
|
+
*/
|
|
50
|
+
removeOverlaysById(ids: string[] | string): IResult;
|
|
51
|
+
/**
|
|
52
|
+
* 按id显示或隐藏覆盖物
|
|
53
|
+
* @param ids
|
|
54
|
+
* @param isShow
|
|
55
|
+
*/
|
|
56
|
+
isShowOverlaysByIds(ids: string[], isShow: boolean): void;
|
|
57
|
+
/**
|
|
58
|
+
* 显示全部覆盖物
|
|
59
|
+
*/
|
|
60
|
+
showAllOverlays(): void;
|
|
61
|
+
/**
|
|
62
|
+
* 删除全部覆盖物
|
|
63
|
+
* @returns
|
|
64
|
+
*/
|
|
65
|
+
removeAllOverlays(): IResult;
|
|
66
|
+
/**
|
|
67
|
+
* 更新覆盖物符号
|
|
68
|
+
* @param ids 覆盖物id数组
|
|
69
|
+
* @param symbol 新的符号配置
|
|
70
|
+
*/
|
|
71
|
+
updateOverlaysSymbol(ids: string[], symbol: IPointSymbol | ILineSymbol | IPolygonSymbol): IResult;
|
|
72
|
+
/**
|
|
73
|
+
* 按type更新覆盖物符号
|
|
74
|
+
* @param types 类型数组
|
|
75
|
+
* @param symbol 新的符号配置
|
|
76
|
+
*/
|
|
77
|
+
updateOverlaysSymbolByType(types: string[], symbol: IPointSymbol | ILineSymbol | IPolygonSymbol): IResult;
|
|
78
|
+
/**
|
|
79
|
+
* 获取几何类型字符串
|
|
80
|
+
* @param geometry
|
|
81
|
+
*/
|
|
82
|
+
private getGeometryType;
|
|
83
|
+
/**
|
|
84
|
+
* 按id获取覆盖物Feature
|
|
85
|
+
* @param id
|
|
86
|
+
*/
|
|
87
|
+
getOverlayById(id: string): Feature<Geometry> | undefined;
|
|
88
|
+
/**
|
|
89
|
+
* 按type获取覆盖物Feature数组
|
|
90
|
+
* @param type
|
|
91
|
+
*/
|
|
92
|
+
getOverlaysByType(type: string): Feature<Geometry>[];
|
|
93
|
+
/**
|
|
94
|
+
* 隐藏图层
|
|
95
|
+
*/
|
|
96
|
+
hideLayer(): void;
|
|
97
|
+
/**
|
|
98
|
+
* 显示图层
|
|
99
|
+
*/
|
|
100
|
+
showLayer(): void;
|
|
101
|
+
/**
|
|
102
|
+
* 删除指定的Feature
|
|
103
|
+
* @param features
|
|
104
|
+
*/
|
|
105
|
+
removeFeatures(features: Feature<Geometry> | Feature<Geometry>[]): void;
|
|
106
|
+
/**
|
|
107
|
+
* 查找屏幕坐标处的覆盖物
|
|
108
|
+
* @param pixel 屏幕像素坐标 [x, y]
|
|
109
|
+
*/
|
|
110
|
+
findFeaturesAtPixel(pixel: number[]): Feature<Geometry>[];
|
|
111
|
+
/**
|
|
112
|
+
* 销毁
|
|
113
|
+
*/
|
|
114
|
+
destroy(): void;
|
|
115
|
+
}
|
|
116
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const u=require("ol/Feature"),a=require("ol/geom"),d=require("ol/layer/Vector"),h=require("ol/source/Vector"),c=require("ol/style/Style"),v=require("../style/line-style.js"),p=require("../style/point-style.js"),g=require("../style/polygon-style.js");class S{constructor(e,s){this.defaultPointSymbol={type:"simple-marker",style:"circle",color:"yellow",size:10},this.map=e,this.vectorSource=new h,this.overlayLayer=new d({source:this.vectorSource,properties:{id:(s==null?void 0:s.id)??"overlay-layer"}}),this.map.addLayer(this.overlayLayer)}addOverlays(e){let s=0,r=0;e.defaultVisible=e.defaultVisible??!0;for(const t of e.overlays){t.properties?(t.properties.type||(t.properties.type=e.type),t.properties.id||(t.properties.id=t.id)):t.properties={type:e.type,id:t.id};const i=t.symbol||e.defaultSymbol||this.defaultPointSymbol,l=t.visible==null?e.defaultVisible:t.visible;this.addOverlay(t,i,t.properties,l).message==="add"?s++:r++}return e.needZoom===!0&&this.map.getView().fit(this.vectorSource.getExtent(),{padding:[50,50,50,50]}),{status:0,message:`新增${s}, 更新${r}`}}addOverlay(e,s,r,t){let i,l=!0;e.id&&(i=this.vectorSource.getFeatures().find(o=>o.get("id")===e.id));const n=this.createGeometry(e.geometry);if(!n)return{status:-1,message:"不支持的几何类型"};i?(i.setGeometry(n),l=!1):(i=new u({geometry:n}),this.vectorSource.addFeature(i),l=!0);const y=this.getStyle(e.geometry.type,s,r);return y&&i.setStyle(y),i.setProperties(r),t||i.setStyle(new c({})),i.set("_visible",t),i.set("_originalStyle",y),{status:0,message:l?"add":"update"}}createGeometry(e){var r;switch((r=e.type)==null?void 0:r.toLowerCase()){case"point":return new a.Point([e.x,e.y]);case"line":case"polyline":if(e.paths&&e.paths.length>0){const t=e.paths[0];return Array.isArray(t)&&Array.isArray(t[0])?e.paths.length===1?new a.LineString(e.paths[0]):new a.MultiLineString(e.paths):new a.LineString(e.paths)}return null;case"polygon":return e.rings&&e.rings.length>0?new a.Polygon(e.rings):null;default:return null}}getStyle(e,s,r){switch(e==null?void 0:e.toLowerCase()){case"point":return p.getPointStyle(s,r);case"line":case"polyline":return v.getLineStyle(s,r);case"polygon":return g.getPolygonStyle(s,r);default:return null}}removeOverlaysByType(e){const r=this.vectorSource.getFeatures().filter(t=>{const i=t.get("type");return Array.isArray(e)?e.includes(i):i===e});return r.forEach(t=>{this.vectorSource.removeFeature(t)}),{status:0,message:`删除${r.length}`}}removeOverlaysById(e){const r=this.vectorSource.getFeatures().filter(t=>{const i=t.get("id");return Array.isArray(e)?e.includes(i):i===e});return r.forEach(t=>{this.vectorSource.removeFeature(t)}),{status:0,message:`删除${r.length}`}}isShowOverlaysByIds(e,s){this.vectorSource.getFeatures().forEach(r=>{const t=r.get("id");if(e.includes(t)){if(s){const i=r.get("_originalStyle");i&&r.setStyle(i)}else r.setStyle(new c({}));r.set("_visible",s)}else{if(s)r.setStyle(new c({}));else{const i=r.get("_originalStyle");i&&r.setStyle(i)}r.set("_visible",!s)}})}showAllOverlays(){this.vectorSource.getFeatures().forEach(e=>{const s=e.get("_originalStyle");s&&e.setStyle(s),e.set("_visible",!0)})}removeAllOverlays(){const e=this.vectorSource.getFeatures().length;return this.vectorSource.clear(),{status:0,message:`删除${e}`}}updateOverlaysSymbol(e,s){let r=0;return this.vectorSource.getFeatures().forEach(t=>{const i=t.get("id");if(e.includes(i)){const l=t.getGeometry();if(l){const n=this.getGeometryType(l),y=t.getProperties(),o=this.getStyle(n,s,y);o&&(t.setStyle(o),t.set("_originalStyle",o),r++)}}}),{status:0,message:`更新${r}个覆盖物符号`}}updateOverlaysSymbolByType(e,s){let r=0;return this.vectorSource.getFeatures().forEach(t=>{const i=t.get("type");if(e.includes(i)){const l=t.getGeometry();if(l){const n=this.getGeometryType(l),y=t.getProperties(),o=this.getStyle(n,s,y);o&&(t.setStyle(o),t.set("_originalStyle",o),r++)}}}),{status:0,message:`更新${r}个覆盖物符号`}}getGeometryType(e){return e instanceof a.Point?"point":e instanceof a.LineString?"polyline":e instanceof a.Polygon?"polygon":""}getOverlayById(e){return this.vectorSource.getFeatures().find(s=>s.get("id")===e)}getOverlaysByType(e){return this.vectorSource.getFeatures().filter(s=>s.get("type")===e)}hideLayer(){this.overlayLayer.setVisible(!1)}showLayer(){this.overlayLayer.setVisible(!0)}removeFeatures(e){Array.isArray(e)||(e=[e]),e.forEach(s=>{this.vectorSource.removeFeature(s)})}findFeaturesAtPixel(e){const s=[];return this.map.forEachFeatureAtPixel(e,(r,t)=>{t===this.overlayLayer&&r instanceof u&&s.push(r)},{layerFilter:r=>r===this.overlayLayer}),s}destroy(){this.vectorSource.clear(),this.map.removeLayer(this.overlayLayer),this.overlayLayer.dispose()}}exports.default=S;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { default as OlMap } from 'ol/Map';
|
|
2
|
+
import { IShowJurisdictionParams } from '../../types';
|
|
3
|
+
export default class PoliceAreaController {
|
|
4
|
+
private map;
|
|
5
|
+
private source;
|
|
6
|
+
private policeAreaLayer;
|
|
7
|
+
private zdBoundaryLayer;
|
|
8
|
+
private initialized;
|
|
9
|
+
private ddMap;
|
|
10
|
+
private zdMap;
|
|
11
|
+
constructor(map: OlMap);
|
|
12
|
+
initialize(): Promise<void>;
|
|
13
|
+
private isMultiPolygon;
|
|
14
|
+
showJurisdiction(params: IShowJurisdictionParams): Promise<void>;
|
|
15
|
+
clearJurisdiction(): void;
|
|
16
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const u=require("ol/Feature"),c=require("ol/geom"),f=require("ol/layer/Vector"),z=require("ol/source/Vector"),i=require("ol/style"),M=require("./style/line-style.js");class S{constructor(s){this.initialized=!1,this.ddMap=new Map,this.zdMap=new Map,this.map=s,this.source=new z,this.policeAreaLayer=new f({source:this.source}),this.policeAreaLayer.set("id","police-area-layer"),this.map.addLayer(this.policeAreaLayer),this.zdBoundaryLayer=new f({source:new z}),this.zdBoundaryLayer.set("id","zd-boundary-layer"),this.map.addLayer(this.zdBoundaryLayer)}async initialize(){(await(await fetch("/GisViewerAssets/ShangHai/Layers/dd.json")).json()).features.forEach(t=>{this.ddMap.set(t.properties.DD_CODE,{name:t.properties.DD_NAME,coordinates:t.geometry.coordinates,zdCode:t.properties.ZD_CODE})}),(await(await fetch("/GisViewerAssets/ShangHai/Layers/zd.json")).json()).features.forEach(t=>{this.zdMap.set(t.properties.ZD_CODE,{name:t.properties.ZD_NAME,coordinates:t.geometry.coordinates})}),this.zdMap.forEach((t,h)=>{var n;const e=[];this.isMultiPolygon(t.coordinates)?t.coordinates.forEach(d=>{d.forEach(y=>e.push(y))}):t.coordinates.forEach(d=>{e.push(d)});const o=new c.Polygon(e),a=new u({geometry:o,type:"zd-boundary",id:h,name:t.name});a.setStyle(new i.Style({stroke:new i.Stroke({color:"rgba(30, 144, 255, 0.8)",width:2,lineDash:[10,20]})})),(n=this.zdBoundaryLayer.getSource())==null||n.addFeature(a)})}isMultiPolygon(s){return Array.isArray(s)&&Array.isArray(s[0])&&Array.isArray(s[0][0])&&Array.isArray(s[0][0][0])}async showJurisdiction(s){this.initialized||(await this.initialize(),this.initialized=!0),this.source.clear();const l=[[[-180,-90],[-180,90],[180,90],[180,-90],[-180,-90]]],r=[],p=e=>{this.isMultiPolygon(e)?e.forEach(o=>{o.forEach(a=>{r.push(a)})}):e.forEach(o=>{r.push(o)})};if(s.type==="zd"){const e=this.zdMap.get(s.id);e&&p(e.coordinates),this.ddMap.forEach((o,a)=>{if(o.zdCode===s.id){const n=[];this.isMultiPolygon(o.coordinates)?o.coordinates.forEach(g=>{g.forEach(E=>n.push(E))}):o.coordinates.forEach(g=>{n.push(g)});const d=new c.Polygon(n),y=new u({geometry:d,type:"dd-boundary",id:a,name:o.name});y.setStyle(M.getLineStyle({type:"simple-line",style:"dash",width:2,color:[30,144,255,.8]})),this.source.addFeature(y);const m=d.getInteriorPoint().getCoordinates(),w=new u({geometry:new c.Point(m),type:"dd-label",id:a,name:o.name});w.setStyle(new i.Style({text:new i.Text({text:o.name,font:"bold 14px sans-serif",fill:new i.Fill({color:"rgba(30, 144, 255, 1)"}),stroke:new i.Stroke({color:"#fff",width:3})})})),this.source.addFeature(w)}})}else if(s.type==="dd"){const e=this.ddMap.get(s.id);e&&p(e.coordinates)}console.log("holesToCut:",r),r.forEach(e=>{l.push(e)});const t=new c.Polygon(l),h=new u({geometry:t});if(console.log("maskCoords:",l),h.setStyle(new i.Style({fill:new i.Fill({color:"rgba(128, 128, 128, 0.6)"}),stroke:new i.Stroke({color:"rgba(30, 144, 255, 1)",width:2})})),this.source.addFeature(h),r.length>0){const o=new c.Polygon(r).getExtent();this.map.getView().fit(o,{padding:[50,50,50,50]})}}clearJurisdiction(){this.source.clear()}}exports.default=S;
|