gisviewer-vue3-arcgis 1.0.91 → 1.0.92
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.
|
@@ -28,10 +28,11 @@ export default class SignalHoloFlow {
|
|
|
28
28
|
/**
|
|
29
29
|
* 在倒计时面板上写入倒计时时间
|
|
30
30
|
* @param countdownCanvas 倒计时面板canvas
|
|
31
|
-
* @param
|
|
32
|
-
* @param
|
|
33
|
-
* @param
|
|
34
|
-
* @param
|
|
31
|
+
* @param rtStage 相位数据
|
|
32
|
+
* @param rtStage.stageID 相位名
|
|
33
|
+
* @param rtStage.stageRemainingTime 剩余时间
|
|
34
|
+
* @param rtStage.stageAllRedTime 全红时间
|
|
35
|
+
* @param rtStage.stageYellowTime 黄灯时间
|
|
35
36
|
*/
|
|
36
37
|
private drawCountdownText;
|
|
37
38
|
private updatePhaseLine;
|
|
@@ -5,8 +5,8 @@ import u from "../../stores/index.mjs";
|
|
|
5
5
|
class f {
|
|
6
6
|
constructor(e) {
|
|
7
7
|
this.currentPhaseMap = /* @__PURE__ */ new Map(), this.countdownCanvasMap = /* @__PURE__ */ new Map(), this.lastDataTime = 0, this.isDeletingCanvas = !1, this.canvasWidth = 80, this.canvasHeight = 50, this.view = (e.type === "2d", e);
|
|
8
|
-
const
|
|
9
|
-
this.mapConfig = JSON.parse(JSON.stringify(
|
|
8
|
+
const t = u.useAppDataStore;
|
|
9
|
+
this.mapConfig = JSON.parse(JSON.stringify(t.mapConfig));
|
|
10
10
|
}
|
|
11
11
|
/**
|
|
12
12
|
* 初始化相位线图层
|
|
@@ -106,16 +106,16 @@ class f {
|
|
|
106
106
|
}
|
|
107
107
|
}
|
|
108
108
|
async handleSignalData(e) {
|
|
109
|
-
const
|
|
110
|
-
if (
|
|
109
|
+
const t = new Date().getTime();
|
|
110
|
+
if (t - this.lastDataTime < 100)
|
|
111
111
|
return;
|
|
112
|
-
this.lastDataTime =
|
|
113
|
-
const { crossId: o, lat: s, lon: n, rtStage:
|
|
114
|
-
await this.updateCountdown(o, s, n,
|
|
112
|
+
this.lastDataTime = t;
|
|
113
|
+
const { crossId: o, lat: s, lon: n, rtStage: a, channelsConfig: l } = e;
|
|
114
|
+
await this.updateCountdown(o, s, n, a), !(!this.phaseLineLayer || !l) && ((!this.currentPhaseMap.has(o) || this.currentPhaseMap.get(o) !== a.stagePhase) && await this.updatePhaseLine(
|
|
115
115
|
o,
|
|
116
|
-
|
|
116
|
+
a.channelsConfig,
|
|
117
117
|
l
|
|
118
|
-
), this.currentPhaseMap.set(o,
|
|
118
|
+
), this.currentPhaseMap.set(o, a.stagePhase));
|
|
119
119
|
}
|
|
120
120
|
/**
|
|
121
121
|
* 清除实时信号相关图层
|
|
@@ -128,7 +128,7 @@ class f {
|
|
|
128
128
|
/**
|
|
129
129
|
* 获取显示倒计时的canvas
|
|
130
130
|
* */
|
|
131
|
-
async updateCountdown(e,
|
|
131
|
+
async updateCountdown(e, t, i, o) {
|
|
132
132
|
if (this.isDeletingCanvas)
|
|
133
133
|
return;
|
|
134
134
|
const s = this.countdownCanvasMap.get(e);
|
|
@@ -137,14 +137,14 @@ class f {
|
|
|
137
137
|
else {
|
|
138
138
|
const n = new c({
|
|
139
139
|
longitude: i,
|
|
140
|
-
latitude:
|
|
140
|
+
latitude: t,
|
|
141
141
|
z: 10
|
|
142
|
-
}),
|
|
143
|
-
if (
|
|
142
|
+
}), a = this.view.toScreen(n);
|
|
143
|
+
if (a.x > this.view.width || a.y > this.view.height || a.x <= 0 || a.y <= 0)
|
|
144
144
|
return;
|
|
145
145
|
this.createCountdownCanvas((l) => {
|
|
146
146
|
const h = l[0], r = l[1];
|
|
147
|
-
h.style.left =
|
|
147
|
+
h.style.left = a.x + "px", h.style.top = a.y + "px", r.style.left = a.x + "px", r.style.top = a.y + "px", this.countdownCanvasMap.set(e, {
|
|
148
148
|
backgroundCanvas: h,
|
|
149
149
|
countdownCanvas: r,
|
|
150
150
|
mapPoint: n
|
|
@@ -155,8 +155,8 @@ class f {
|
|
|
155
155
|
() => this.view.extent,
|
|
156
156
|
() => {
|
|
157
157
|
this.countdownCanvasMap.forEach((n) => {
|
|
158
|
-
const
|
|
159
|
-
|
|
158
|
+
const a = this.view.toScreen(n.mapPoint);
|
|
159
|
+
a.x > this.view.width || a.y > this.view.height || a.x <= 0 || a.y <= 0 ? (this.isDeletingCanvas = !0, this.view.container.removeChild(n.backgroundCanvas), this.view.container.removeChild(n.countdownCanvas), this.countdownCanvasMap.delete(e), this.isDeletingCanvas = !1) : (n.backgroundCanvas.style.left = a.x + "px", n.backgroundCanvas.style.top = a.y + "px", n.countdownCanvas.style.left = a.x + "px", n.countdownCanvas.style.top = a.y + "px");
|
|
160
160
|
});
|
|
161
161
|
}
|
|
162
162
|
));
|
|
@@ -164,26 +164,27 @@ class f {
|
|
|
164
164
|
/**
|
|
165
165
|
* 在倒计时面板上写入倒计时时间
|
|
166
166
|
* @param countdownCanvas 倒计时面板canvas
|
|
167
|
-
* @param
|
|
168
|
-
* @param
|
|
169
|
-
* @param
|
|
170
|
-
* @param
|
|
167
|
+
* @param rtStage 相位数据
|
|
168
|
+
* @param rtStage.stageID 相位名
|
|
169
|
+
* @param rtStage.stageRemainingTime 剩余时间
|
|
170
|
+
* @param rtStage.stageAllRedTime 全红时间
|
|
171
|
+
* @param rtStage.stageYellowTime 黄灯时间
|
|
171
172
|
*/
|
|
172
|
-
drawCountdownText(e,
|
|
173
|
+
drawCountdownText(e, t) {
|
|
173
174
|
const i = e.getContext("2d");
|
|
174
|
-
i.clearRect(0, 0, e.width, e.height), i.font = "32px LESLIE", i.textBaseline = "middle", i.textAlign = "center", i.fillStyle =
|
|
175
|
-
|
|
175
|
+
i.clearRect(0, 0, e.width, e.height), i.font = "32px LESLIE", i.textBaseline = "middle", i.textAlign = "center", i.fillStyle = t.stageRemainingTime <= t.stageAllRedTime ? "red" : t.stageRemainingTime <= t.stageAllRedTime + t.stageYellowTime ? "yellow" : "lime", i.fillText(
|
|
176
|
+
`${t.stageID} ${t.stageRemainingTime.toFixed(0)}`,
|
|
176
177
|
e.width / 2,
|
|
177
178
|
e.height / 2
|
|
178
179
|
);
|
|
179
180
|
}
|
|
180
|
-
async updatePhaseLine(e,
|
|
181
|
+
async updatePhaseLine(e, t, i) {
|
|
181
182
|
const o = this.phaseLineLayer.source.filter(
|
|
182
183
|
(s) => s.getAttribute("id").includes(e)
|
|
183
184
|
);
|
|
184
185
|
o.forEach((s) => {
|
|
185
186
|
const n = s.getAttribute("id");
|
|
186
|
-
this.isLaneInChannels(n,
|
|
187
|
+
this.isLaneInChannels(n, t) ? s.setAttribute("color", "green") : this.isLaneInChannels(n, i) ? s.setAttribute("color", "red") : s.setAttribute("color", "green");
|
|
187
188
|
}), await this.phaseLineLayer.applyEdits({ updateFeatures: o });
|
|
188
189
|
}
|
|
189
190
|
/**
|
|
@@ -192,24 +193,24 @@ class f {
|
|
|
192
193
|
* @param channels 通道列表
|
|
193
194
|
* @returns
|
|
194
195
|
*/
|
|
195
|
-
isLaneInChannels(e,
|
|
196
|
+
isLaneInChannels(e, t) {
|
|
196
197
|
const i = e.split("+"), o = i[1], s = i[2];
|
|
197
|
-
for (let n = 0; n <
|
|
198
|
-
for (let
|
|
199
|
-
const l =
|
|
198
|
+
for (let n = 0; n < t.length; n++)
|
|
199
|
+
for (let a = 0; a < t[n].laneSnList.length; a++) {
|
|
200
|
+
const l = t[n].laneSnList[a].toFixed(0);
|
|
200
201
|
if (o === l[0] && s === l[1])
|
|
201
202
|
return !0;
|
|
202
203
|
}
|
|
203
204
|
return !1;
|
|
204
205
|
}
|
|
205
206
|
createCountdownCanvas(e) {
|
|
206
|
-
const
|
|
207
|
-
|
|
207
|
+
const t = new Image();
|
|
208
|
+
t.src = `${this.mapConfig.assetsRoot}/Images/timeboard/CountdownBG.png`, t.onload = () => {
|
|
208
209
|
const i = document.createElement("canvas");
|
|
209
|
-
i.width = this.canvasWidth, i.height = this.canvasHeight, i.style.position = "absolute", i.style.transform = "translate(-50%, -50%)", i.getContext("2d").drawImage(
|
|
210
|
+
i.width = this.canvasWidth, i.height = this.canvasHeight, i.style.position = "absolute", i.style.transform = "translate(-50%, -50%)", i.getContext("2d").drawImage(t, 0, 0, this.canvasWidth, this.canvasHeight), this.view.container.appendChild(i);
|
|
210
211
|
const s = document.createElement("canvas");
|
|
211
212
|
s.width = this.canvasWidth - 10, s.height = this.canvasHeight - 10, s.style.position = "absolute", s.style.transform = "translate(-50%, -50%)", this.view.container.appendChild(s), e([i, s]);
|
|
212
|
-
},
|
|
213
|
+
}, t.onerror = () => {
|
|
213
214
|
console.error("倒计时背景图加载失败");
|
|
214
215
|
};
|
|
215
216
|
}
|
|
@@ -28,10 +28,11 @@ export default class SignalHoloFlow {
|
|
|
28
28
|
/**
|
|
29
29
|
* 在倒计时面板上写入倒计时时间
|
|
30
30
|
* @param countdownCanvas 倒计时面板canvas
|
|
31
|
-
* @param
|
|
32
|
-
* @param
|
|
33
|
-
* @param
|
|
34
|
-
* @param
|
|
31
|
+
* @param rtStage 相位数据
|
|
32
|
+
* @param rtStage.stageID 相位名
|
|
33
|
+
* @param rtStage.stageRemainingTime 剩余时间
|
|
34
|
+
* @param rtStage.stageAllRedTime 全红时间
|
|
35
|
+
* @param rtStage.stageYellowTime 黄灯时间
|
|
35
36
|
*/
|
|
36
37
|
private drawCountdownText;
|
|
37
38
|
private updatePhaseLine;
|
|
@@ -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"),
|
|
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=80,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;
|