gisviewer-vue3-arcgis 1.0.93 → 1.0.94
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.
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import * as
|
|
2
|
-
import { Point as
|
|
1
|
+
import * as c from "@arcgis/core/core/reactiveUtils";
|
|
2
|
+
import { Point as d } from "@arcgis/core/geometry";
|
|
3
3
|
import p from "@arcgis/core/layers/FeatureLayer";
|
|
4
4
|
import u from "../../stores/index.mjs";
|
|
5
5
|
class f {
|
|
6
|
-
constructor(
|
|
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 = (
|
|
8
|
-
const
|
|
9
|
-
this.mapConfig = JSON.parse(JSON.stringify(
|
|
6
|
+
constructor(a) {
|
|
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 = (a.type === "2d", a);
|
|
8
|
+
const e = u.useAppDataStore;
|
|
9
|
+
this.mapConfig = JSON.parse(JSON.stringify(e.mapConfig));
|
|
10
10
|
}
|
|
11
11
|
/**
|
|
12
12
|
* 初始化相位线图层
|
|
@@ -16,14 +16,14 @@ class f {
|
|
|
16
16
|
if (this.phaseLineLayer)
|
|
17
17
|
this.phaseLineLayer.visible || (this.phaseLineLayer.visible = !0);
|
|
18
18
|
else {
|
|
19
|
-
const
|
|
19
|
+
const a = `${this.mapConfig.assetsRoot}/${this.mapConfig.phaseLineLayer}`, o = (await (await fetch(a)).json()).features.map((t, s) => ({
|
|
20
20
|
geometry: {
|
|
21
21
|
type: "polyline",
|
|
22
|
-
paths: [
|
|
22
|
+
paths: [t.geometry.coordinates]
|
|
23
23
|
},
|
|
24
24
|
attributes: {
|
|
25
|
-
ObjectID:
|
|
26
|
-
id:
|
|
25
|
+
ObjectID: s + 1,
|
|
26
|
+
id: t.properties.id,
|
|
27
27
|
color: "hide"
|
|
28
28
|
}
|
|
29
29
|
}));
|
|
@@ -105,58 +105,54 @@ class f {
|
|
|
105
105
|
}), this.view.map.add(this.phaseLineLayer);
|
|
106
106
|
}
|
|
107
107
|
}
|
|
108
|
-
async handleSignalData(
|
|
109
|
-
const t =
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
o,
|
|
116
|
-
a.channelsConfig,
|
|
117
|
-
l
|
|
118
|
-
), this.currentPhaseMap.set(o, a.stagePhase));
|
|
108
|
+
async handleSignalData(a) {
|
|
109
|
+
const { crossId: e, lat: i, lon: o, rtStage: t, channelsConfig: s } = a;
|
|
110
|
+
await this.updateCountdown(e, i, o, t), !(!this.phaseLineLayer || !s) && ((!this.currentPhaseMap.has(e) || this.currentPhaseMap.get(e) !== t.stagePhase) && await this.updatePhaseLine(
|
|
111
|
+
e,
|
|
112
|
+
t.channelsConfig,
|
|
113
|
+
s
|
|
114
|
+
), this.currentPhaseMap.set(e, t.stagePhase));
|
|
119
115
|
}
|
|
120
116
|
/**
|
|
121
117
|
* 清除实时信号相关图层
|
|
122
118
|
* */
|
|
123
119
|
clearSignal() {
|
|
124
|
-
this.phaseLineLayer.visible = !1, this.countdownWatchHandel && (this.countdownWatchHandel.remove(), this.countdownWatchHandel = void 0), this.countdownCanvasMap.forEach((
|
|
125
|
-
this.view.container.removeChild(
|
|
120
|
+
this.phaseLineLayer && (this.phaseLineLayer.visible = !1), this.countdownWatchHandel && (this.countdownWatchHandel.remove(), this.countdownWatchHandel = void 0), this.countdownCanvasMap.forEach((a) => {
|
|
121
|
+
this.view.container.removeChild(a.backgroundCanvas), this.view.container.removeChild(a.countdownCanvas);
|
|
126
122
|
}), this.countdownCanvasMap.clear();
|
|
127
123
|
}
|
|
128
124
|
/**
|
|
129
125
|
* 获取显示倒计时的canvas
|
|
130
126
|
* */
|
|
131
|
-
async updateCountdown(
|
|
127
|
+
async updateCountdown(a, e, i, o) {
|
|
132
128
|
if (this.isDeletingCanvas)
|
|
133
129
|
return;
|
|
134
|
-
const
|
|
135
|
-
if (
|
|
136
|
-
this.drawCountdownText(
|
|
130
|
+
const t = this.countdownCanvasMap.get(a);
|
|
131
|
+
if (t)
|
|
132
|
+
this.drawCountdownText(t.countdownCanvas, o);
|
|
137
133
|
else {
|
|
138
|
-
const
|
|
134
|
+
const s = new d({
|
|
139
135
|
longitude: i,
|
|
140
|
-
latitude:
|
|
136
|
+
latitude: e,
|
|
141
137
|
z: 10
|
|
142
|
-
}),
|
|
143
|
-
if (
|
|
138
|
+
}), n = this.view.toScreen(s);
|
|
139
|
+
if (n.x > this.view.width || n.y > this.view.height || n.x <= 0 || n.y <= 0)
|
|
144
140
|
return;
|
|
145
141
|
this.createCountdownCanvas((l) => {
|
|
146
142
|
const h = l[0], r = l[1];
|
|
147
|
-
h.style.left =
|
|
143
|
+
h.style.left = n.x + "px", h.style.top = n.y + "px", r.style.left = n.x + "px", r.style.top = n.y + "px", this.countdownCanvasMap.set(a, {
|
|
148
144
|
backgroundCanvas: h,
|
|
149
145
|
countdownCanvas: r,
|
|
150
|
-
mapPoint:
|
|
146
|
+
mapPoint: s
|
|
151
147
|
}), this.drawCountdownText(r, o);
|
|
152
148
|
});
|
|
153
149
|
}
|
|
154
|
-
this.countdownWatchHandel || (this.countdownWatchHandel =
|
|
150
|
+
this.countdownWatchHandel || (this.countdownWatchHandel = c.watch(
|
|
155
151
|
() => this.view.extent,
|
|
156
152
|
() => {
|
|
157
|
-
this.countdownCanvasMap.forEach((
|
|
158
|
-
const
|
|
159
|
-
|
|
153
|
+
this.countdownCanvasMap.forEach((s) => {
|
|
154
|
+
const n = this.view.toScreen(s.mapPoint);
|
|
155
|
+
s.backgroundCanvas.style.left = n.x + "px", s.backgroundCanvas.style.top = n.y + "px", s.countdownCanvas.style.left = n.x + "px", s.countdownCanvas.style.top = n.y + "px";
|
|
160
156
|
});
|
|
161
157
|
}
|
|
162
158
|
));
|
|
@@ -170,21 +166,21 @@ class f {
|
|
|
170
166
|
* @param rtStage.stageAllRedTime 全红时间
|
|
171
167
|
* @param rtStage.stageYellowTime 黄灯时间
|
|
172
168
|
*/
|
|
173
|
-
drawCountdownText(
|
|
174
|
-
const i =
|
|
175
|
-
i.clearRect(0, 0,
|
|
176
|
-
`${
|
|
177
|
-
|
|
178
|
-
|
|
169
|
+
drawCountdownText(a, e) {
|
|
170
|
+
const i = a.getContext("2d");
|
|
171
|
+
i.clearRect(0, 0, a.width, a.height), i.font = "32px Digital", i.textBaseline = "middle", i.textAlign = "center", i.fillStyle = e.stageRemainingTime <= e.stageAllRedTime ? "red" : e.stageRemainingTime <= e.stageAllRedTime + e.stageYellowTime ? "yellow" : "lime", i.fillText(
|
|
172
|
+
`${e.stageID} ${e.stageRemainingTime.toFixed(0)}`,
|
|
173
|
+
a.width / 2,
|
|
174
|
+
a.height / 2
|
|
179
175
|
);
|
|
180
176
|
}
|
|
181
|
-
async updatePhaseLine(
|
|
177
|
+
async updatePhaseLine(a, e, i) {
|
|
182
178
|
const o = this.phaseLineLayer.source.filter(
|
|
183
|
-
(
|
|
179
|
+
(t) => t.getAttribute("id").includes(a)
|
|
184
180
|
);
|
|
185
|
-
o.forEach((
|
|
186
|
-
const
|
|
187
|
-
this.isLaneInChannels(
|
|
181
|
+
o.forEach((t) => {
|
|
182
|
+
const s = t.getAttribute("id");
|
|
183
|
+
this.isLaneInChannels(s, e) ? t.setAttribute("color", "green") : this.isLaneInChannels(s, i) ? t.setAttribute("color", "red") : t.setAttribute("color", "green");
|
|
188
184
|
}), await this.phaseLineLayer.applyEdits({ updateFeatures: o });
|
|
189
185
|
}
|
|
190
186
|
/**
|
|
@@ -193,24 +189,24 @@ class f {
|
|
|
193
189
|
* @param channels 通道列表
|
|
194
190
|
* @returns
|
|
195
191
|
*/
|
|
196
|
-
isLaneInChannels(
|
|
197
|
-
const i =
|
|
198
|
-
for (let
|
|
199
|
-
for (let
|
|
200
|
-
const l =
|
|
201
|
-
if (o === l[0] &&
|
|
192
|
+
isLaneInChannels(a, e) {
|
|
193
|
+
const i = a.split("+"), o = i[1], t = i[2];
|
|
194
|
+
for (let s = 0; s < e.length; s++)
|
|
195
|
+
for (let n = 0; n < e[s].laneSnList.length; n++) {
|
|
196
|
+
const l = e[s].laneSnList[n].toFixed(0);
|
|
197
|
+
if (o === l[0] && t === l[1])
|
|
202
198
|
return !0;
|
|
203
199
|
}
|
|
204
200
|
return !1;
|
|
205
201
|
}
|
|
206
|
-
createCountdownCanvas(
|
|
207
|
-
const
|
|
208
|
-
|
|
202
|
+
createCountdownCanvas(a) {
|
|
203
|
+
const e = new Image();
|
|
204
|
+
e.src = `${this.mapConfig.assetsRoot}/Images/timeboard/CountdownBG.png`, e.onload = () => {
|
|
209
205
|
const i = document.createElement("canvas");
|
|
210
|
-
i.width = this.canvasWidth, i.height = this.canvasHeight, i.style.position = "absolute", i.style.transform = "translate(-50%, -50%)", i.getContext("2d").drawImage(
|
|
211
|
-
const
|
|
212
|
-
|
|
213
|
-
},
|
|
206
|
+
i.width = this.canvasWidth, i.height = this.canvasHeight, i.style.position = "absolute", i.style.transform = "translate(-50%, -50%)", i.getContext("2d").drawImage(e, 0, 0, this.canvasWidth, this.canvasHeight), this.view.container.appendChild(i);
|
|
207
|
+
const t = document.createElement("canvas");
|
|
208
|
+
t.width = this.canvasWidth - 10, t.height = this.canvasHeight - 10, t.style.position = "absolute", t.style.transform = "translate(-50%, -50%)", this.view.container.appendChild(t), a([i, t]);
|
|
209
|
+
}, e.onerror = () => {
|
|
214
210
|
console.error("倒计时背景图加载失败");
|
|
215
211
|
};
|
|
216
212
|
}
|
|
@@ -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(
|
|
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(l){const t=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(l){for(const e in l)if(e!=="default"){const a=Object.getOwnPropertyDescriptor(l,e);Object.defineProperty(t,e,a.get?a:{enumerable:!0,get:()=>l[e]})}}return t.default=l,Object.freeze(t)}const w=g(d);class f{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((i,n)=>({geometry:{type:"polyline",paths:[i.geometry.coordinates]},attributes:{ObjectID:n+1,id:i.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{crossId:e,lat:a,lon:o,rtStage:i,channelsConfig:n}=t;await this.updateCountdown(e,a,o,i),!(!this.phaseLineLayer||!n)&&((!this.currentPhaseMap.has(e)||this.currentPhaseMap.get(e)!==i.stagePhase)&&await this.updatePhaseLine(e,i.channelsConfig,n),this.currentPhaseMap.set(e,i.stagePhase))}clearSignal(){this.phaseLineLayer&&(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 i=this.countdownCanvasMap.get(t);if(i)this.drawCountdownText(i.countdownCanvas,o);else{const n=new u.Point({longitude:a,latitude:e,z:10}),s=this.view.toScreen(n);if(s.x>this.view.width||s.y>this.view.height||s.x<=0||s.y<=0)return;this.createCountdownCanvas(r=>{const c=r[0],h=r[1];c.style.left=s.x+"px",c.style.top=s.y+"px",h.style.left=s.x+"px",h.style.top=s.y+"px",this.countdownCanvasMap.set(t,{backgroundCanvas:c,countdownCanvas:h,mapPoint:n}),this.drawCountdownText(h,o)})}this.countdownWatchHandel||(this.countdownWatchHandel=w.watch(()=>this.view.extent,()=>{this.countdownCanvasMap.forEach(n=>{const s=this.view.toScreen(n.mapPoint);n.backgroundCanvas.style.left=s.x+"px",n.backgroundCanvas.style.top=s.y+"px",n.countdownCanvas.style.left=s.x+"px",n.countdownCanvas.style.top=s.y+"px"})}))}drawCountdownText(t,e){const a=t.getContext("2d");a.clearRect(0,0,t.width,t.height),a.font="32px Digital",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(i=>i.getAttribute("id").includes(t));o.forEach(i=>{const n=i.getAttribute("id");this.isLaneInChannels(n,e)?i.setAttribute("color","green"):this.isLaneInChannels(n,a)?i.setAttribute("color","red"):i.setAttribute("color","green")}),await this.phaseLineLayer.applyEdits({updateFeatures:o})}isLaneInChannels(t,e){const a=t.split("+"),o=a[1],i=a[2];for(let n=0;n<e.length;n++)for(let s=0;s<e[n].laneSnList.length;s++){const r=e[n].laneSnList[s].toFixed(0);if(o===r[0]&&i===r[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 i=document.createElement("canvas");i.width=this.canvasWidth-10,i.height=this.canvasHeight-10,i.style.position="absolute",i.style.transform="translate(-50%, -50%)",this.view.container.appendChild(i),t([a,i])},e.onerror=()=>{console.error("倒计时背景图加载失败")}}}exports.default=f;
|