gisviewer-vue3-arcgis 1.0.92 → 1.0.93
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.
|
@@ -4,7 +4,7 @@ import p from "@arcgis/core/layers/FeatureLayer";
|
|
|
4
4
|
import u from "../../stores/index.mjs";
|
|
5
5
|
class f {
|
|
6
6
|
constructor(e) {
|
|
7
|
-
this.currentPhaseMap = /* @__PURE__ */ new Map(), this.countdownCanvasMap = /* @__PURE__ */ new Map(), this.lastDataTime = 0, this.isDeletingCanvas = !1, this.canvasWidth =
|
|
7
|
+
this.currentPhaseMap = /* @__PURE__ */ new Map(), this.countdownCanvasMap = /* @__PURE__ */ new Map(), this.lastDataTime = 0, this.isDeletingCanvas = !1, this.canvasWidth = 120, this.canvasHeight = 50, this.view = (e.type === "2d", e);
|
|
8
8
|
const t = u.useAppDataStore;
|
|
9
9
|
this.mapConfig = JSON.parse(JSON.stringify(t.mapConfig));
|
|
10
10
|
}
|
|
@@ -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"),y=require("../../stores/index.js");function g(r){const t=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(r){for(const e in r)if(e!=="default"){const a=Object.getOwnPropertyDescriptor(r,e);Object.defineProperty(t,e,a.get?a:{enumerable:!0,get:()=>r[e]})}}return t.default=r,Object.freeze(t)}const w=g(d);class m{constructor(t){this.currentPhaseMap=new Map,this.countdownCanvasMap=new Map,this.lastDataTime=0,this.isDeletingCanvas=!1,this.canvasWidth=
|
|
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"),y=require("../../stores/index.js");function g(r){const t=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(r){for(const e in r)if(e!=="default"){const a=Object.getOwnPropertyDescriptor(r,e);Object.defineProperty(t,e,a.get?a:{enumerable:!0,get:()=>r[e]})}}return t.default=r,Object.freeze(t)}const w=g(d);class m{constructor(t){this.currentPhaseMap=new Map,this.countdownCanvasMap=new Map,this.lastDataTime=0,this.isDeletingCanvas=!1,this.canvasWidth=120,this.canvasHeight=50,this.view=(t.type==="2d",t);const e=y.default.useAppDataStore;this.mapConfig=JSON.parse(JSON.stringify(e.mapConfig))}async initializeLayer(){if(this.mapConfig.phaseLineLayer)if(this.phaseLineLayer)this.phaseLineLayer.visible||(this.phaseLineLayer.visible=!0);else{const t=`${this.mapConfig.assetsRoot}/${this.mapConfig.phaseLineLayer}`,o=(await(await fetch(t)).json()).features.map((n,s)=>({geometry:{type:"polyline",paths:[n.geometry.coordinates]},attributes:{ObjectID:s+1,id:n.properties.id,color:"hide"}}));this.phaseLineLayer=new p({source:o,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)}}async handleSignalData(t){const e=new Date().getTime();if(e-this.lastDataTime<100)return;this.lastDataTime=e;const{crossId:o,lat:n,lon:s,rtStage:i,channelsConfig:l}=t;await this.updateCountdown(o,n,s,i),!(!this.phaseLineLayer||!l)&&((!this.currentPhaseMap.has(o)||this.currentPhaseMap.get(o)!==i.stagePhase)&&await this.updatePhaseLine(o,i.channelsConfig,l),this.currentPhaseMap.set(o,i.stagePhase))}clearSignal(){this.phaseLineLayer.visible=!1,this.countdownWatchHandel&&(this.countdownWatchHandel.remove(),this.countdownWatchHandel=void 0),this.countdownCanvasMap.forEach(t=>{this.view.container.removeChild(t.backgroundCanvas),this.view.container.removeChild(t.countdownCanvas)}),this.countdownCanvasMap.clear()}async updateCountdown(t,e,a,o){if(this.isDeletingCanvas)return;const n=this.countdownCanvasMap.get(t);if(n)this.drawCountdownText(n.countdownCanvas,o);else{const s=new u.Point({longitude:a,latitude:e,z:10}),i=this.view.toScreen(s);if(i.x>this.view.width||i.y>this.view.height||i.x<=0||i.y<=0)return;this.createCountdownCanvas(l=>{const c=l[0],h=l[1];c.style.left=i.x+"px",c.style.top=i.y+"px",h.style.left=i.x+"px",h.style.top=i.y+"px",this.countdownCanvasMap.set(t,{backgroundCanvas:c,countdownCanvas:h,mapPoint:s}),this.drawCountdownText(h,o)})}this.countdownWatchHandel||(this.countdownWatchHandel=w.watch(()=>this.view.extent,()=>{this.countdownCanvasMap.forEach(s=>{const i=this.view.toScreen(s.mapPoint);i.x>this.view.width||i.y>this.view.height||i.x<=0||i.y<=0?(this.isDeletingCanvas=!0,this.view.container.removeChild(s.backgroundCanvas),this.view.container.removeChild(s.countdownCanvas),this.countdownCanvasMap.delete(t),this.isDeletingCanvas=!1):(s.backgroundCanvas.style.left=i.x+"px",s.backgroundCanvas.style.top=i.y+"px",s.countdownCanvas.style.left=i.x+"px",s.countdownCanvas.style.top=i.y+"px")})}))}drawCountdownText(t,e){const a=t.getContext("2d");a.clearRect(0,0,t.width,t.height),a.font="32px LESLIE",a.textBaseline="middle",a.textAlign="center",a.fillStyle=e.stageRemainingTime<=e.stageAllRedTime?"red":e.stageRemainingTime<=e.stageAllRedTime+e.stageYellowTime?"yellow":"lime",a.fillText(`${e.stageID} ${e.stageRemainingTime.toFixed(0)}`,t.width/2,t.height/2)}async updatePhaseLine(t,e,a){const o=this.phaseLineLayer.source.filter(n=>n.getAttribute("id").includes(t));o.forEach(n=>{const s=n.getAttribute("id");this.isLaneInChannels(s,e)?n.setAttribute("color","green"):this.isLaneInChannels(s,a)?n.setAttribute("color","red"):n.setAttribute("color","green")}),await this.phaseLineLayer.applyEdits({updateFeatures:o})}isLaneInChannels(t,e){const a=t.split("+"),o=a[1],n=a[2];for(let s=0;s<e.length;s++)for(let i=0;i<e[s].laneSnList.length;i++){const l=e[s].laneSnList[i].toFixed(0);if(o===l[0]&&n===l[1])return!0}return!1}createCountdownCanvas(t){const e=new Image;e.src=`${this.mapConfig.assetsRoot}/Images/timeboard/CountdownBG.png`,e.onload=()=>{const a=document.createElement("canvas");a.width=this.canvasWidth,a.height=this.canvasHeight,a.style.position="absolute",a.style.transform="translate(-50%, -50%)",a.getContext("2d").drawImage(e,0,0,this.canvasWidth,this.canvasHeight),this.view.container.appendChild(a);const n=document.createElement("canvas");n.width=this.canvasWidth-10,n.height=this.canvasHeight-10,n.style.position="absolute",n.style.transform="translate(-50%, -50%)",this.view.container.appendChild(n),t([a,n])},e.onerror=()=>{console.error("倒计时背景图加载失败")}}}exports.default=m;
|