gisviewer-vue3-arcgis 1.0.95 → 1.0.96
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.
|
@@ -27,7 +27,7 @@ export default class SignalHoloFlow {
|
|
|
27
27
|
private updateCountdown;
|
|
28
28
|
/**
|
|
29
29
|
* 在倒计时面板上写入倒计时时间
|
|
30
|
-
* @param
|
|
30
|
+
* @param canvas 倒计时面板canvas
|
|
31
31
|
* @param rtStage 相位数据
|
|
32
32
|
* @param rtStage.stageID 相位名
|
|
33
33
|
* @param rtStage.stageRemainingTime 剩余时间
|
|
@@ -35,6 +35,8 @@ export default class SignalHoloFlow {
|
|
|
35
35
|
* @param rtStage.stageYellowTime 黄灯时间
|
|
36
36
|
*/
|
|
37
37
|
private drawCountdownText;
|
|
38
|
+
private drawCircle;
|
|
39
|
+
private ctxDraw;
|
|
38
40
|
private updatePhaseLine;
|
|
39
41
|
/**
|
|
40
42
|
* 车道是否在通道中
|
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import * as
|
|
2
|
-
import { Point as
|
|
1
|
+
import * as d from "@arcgis/core/core/reactiveUtils";
|
|
2
|
+
import { Point as c } 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 =
|
|
8
|
-
const
|
|
9
|
-
this.mapConfig = JSON.parse(JSON.stringify(
|
|
6
|
+
constructor(e) {
|
|
7
|
+
this.currentPhaseMap = /* @__PURE__ */ new Map(), this.countdownCanvasMap = /* @__PURE__ */ new Map(), this.lastDataTime = 0, this.isDeletingCanvas = !1, this.canvasWidth = 80, this.canvasHeight = 40, this.view = (e.type === "2d", e);
|
|
8
|
+
const a = u.useAppDataStore;
|
|
9
|
+
this.mapConfig = JSON.parse(JSON.stringify(a.mapConfig));
|
|
10
10
|
}
|
|
11
11
|
/**
|
|
12
12
|
* 初始化相位线图层
|
|
@@ -16,19 +16,19 @@ class f {
|
|
|
16
16
|
if (this.phaseLineLayer)
|
|
17
17
|
this.phaseLineLayer.visible || (this.phaseLineLayer.visible = !0);
|
|
18
18
|
else {
|
|
19
|
-
const
|
|
19
|
+
const e = `${this.mapConfig.assetsRoot}/${this.mapConfig.phaseLineLayer}`, n = (await (await fetch(e)).json()).features.map((s, t) => ({
|
|
20
20
|
geometry: {
|
|
21
21
|
type: "polyline",
|
|
22
|
-
paths: [
|
|
22
|
+
paths: [s.geometry.coordinates]
|
|
23
23
|
},
|
|
24
24
|
attributes: {
|
|
25
|
-
ObjectID:
|
|
26
|
-
id:
|
|
25
|
+
ObjectID: t + 1,
|
|
26
|
+
id: s.properties.id,
|
|
27
27
|
color: "hide"
|
|
28
28
|
}
|
|
29
29
|
}));
|
|
30
30
|
this.phaseLineLayer = new p({
|
|
31
|
-
source:
|
|
31
|
+
source: n,
|
|
32
32
|
geometryType: "polyline",
|
|
33
33
|
objectIdField: "ObjectID",
|
|
34
34
|
outFields: ["*"],
|
|
@@ -105,81 +105,97 @@ class f {
|
|
|
105
105
|
}), this.view.map.add(this.phaseLineLayer);
|
|
106
106
|
}
|
|
107
107
|
}
|
|
108
|
-
async handleSignalData(
|
|
109
|
-
const { crossId:
|
|
110
|
-
await this.updateCountdown(
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
), this.currentPhaseMap.set(
|
|
108
|
+
async handleSignalData(e) {
|
|
109
|
+
const { crossId: a, lat: i, lon: n, rtStage: s, channelsConfig: t } = e;
|
|
110
|
+
await this.updateCountdown(a, i, n, s), !(!this.phaseLineLayer || !t) && ((!this.currentPhaseMap.has(a) || this.currentPhaseMap.get(a) !== s.stagePhase) && await this.updatePhaseLine(
|
|
111
|
+
a,
|
|
112
|
+
s.channelsConfig,
|
|
113
|
+
t
|
|
114
|
+
), this.currentPhaseMap.set(a, s.stagePhase));
|
|
115
115
|
}
|
|
116
116
|
/**
|
|
117
117
|
* 清除实时信号相关图层
|
|
118
118
|
* */
|
|
119
119
|
clearSignal() {
|
|
120
|
-
this.phaseLineLayer && (this.phaseLineLayer.visible = !1), this.countdownWatchHandel && (this.countdownWatchHandel.remove(), this.countdownWatchHandel = void 0), this.countdownCanvasMap.forEach((
|
|
121
|
-
this.view.container.removeChild(
|
|
120
|
+
this.phaseLineLayer && (this.phaseLineLayer.visible = !1), this.countdownWatchHandel && (this.countdownWatchHandel.remove(), this.countdownWatchHandel = void 0), this.countdownCanvasMap.forEach((e) => {
|
|
121
|
+
this.view.container.removeChild(e.backgroundCanvas), this.view.container.removeChild(e.countdownCanvas);
|
|
122
122
|
}), this.countdownCanvasMap.clear();
|
|
123
123
|
}
|
|
124
124
|
/**
|
|
125
125
|
* 获取显示倒计时的canvas
|
|
126
126
|
* */
|
|
127
|
-
async updateCountdown(
|
|
127
|
+
async updateCountdown(e, a, i, n) {
|
|
128
128
|
if (this.isDeletingCanvas)
|
|
129
129
|
return;
|
|
130
|
-
const
|
|
131
|
-
if (
|
|
132
|
-
this.drawCountdownText(
|
|
133
|
-
else
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
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, {
|
|
130
|
+
const s = this.countdownCanvasMap.get(e);
|
|
131
|
+
if (s)
|
|
132
|
+
this.drawCountdownText(s.countdownCanvas, n);
|
|
133
|
+
else
|
|
134
|
+
try {
|
|
135
|
+
const t = new c({
|
|
136
|
+
longitude: i,
|
|
137
|
+
latitude: a,
|
|
138
|
+
z: 10
|
|
139
|
+
}), o = this.view.toScreen(t), l = await this.createCountdownCanvas(), h = l[0], r = l[1];
|
|
140
|
+
h.style.left = o.x + "px", h.style.top = o.y + "px", r.style.left = o.x + "px", r.style.top = o.y + "px", this.countdownCanvasMap.set(e, {
|
|
142
141
|
backgroundCanvas: h,
|
|
143
142
|
countdownCanvas: r,
|
|
144
|
-
mapPoint:
|
|
145
|
-
}), this.drawCountdownText(r,
|
|
146
|
-
})
|
|
147
|
-
|
|
148
|
-
|
|
143
|
+
mapPoint: t
|
|
144
|
+
}), this.drawCountdownText(r, n);
|
|
145
|
+
} catch (t) {
|
|
146
|
+
console.log("倒计时canvas创建失败", e, t);
|
|
147
|
+
}
|
|
148
|
+
this.countdownWatchHandel || (this.countdownWatchHandel = d.watch(
|
|
149
149
|
() => this.view.extent,
|
|
150
150
|
() => {
|
|
151
|
-
this.countdownCanvasMap.forEach((
|
|
152
|
-
const
|
|
153
|
-
|
|
151
|
+
this.countdownCanvasMap.forEach((t) => {
|
|
152
|
+
const o = this.view.toScreen(t.mapPoint);
|
|
153
|
+
t.backgroundCanvas.style.left = o.x + "px", t.backgroundCanvas.style.top = o.y + "px", t.countdownCanvas.style.left = o.x + "px", t.countdownCanvas.style.top = o.y + "px";
|
|
154
154
|
});
|
|
155
155
|
}
|
|
156
156
|
));
|
|
157
157
|
}
|
|
158
158
|
/**
|
|
159
159
|
* 在倒计时面板上写入倒计时时间
|
|
160
|
-
* @param
|
|
160
|
+
* @param canvas 倒计时面板canvas
|
|
161
161
|
* @param rtStage 相位数据
|
|
162
162
|
* @param rtStage.stageID 相位名
|
|
163
163
|
* @param rtStage.stageRemainingTime 剩余时间
|
|
164
164
|
* @param rtStage.stageAllRedTime 全红时间
|
|
165
165
|
* @param rtStage.stageYellowTime 黄灯时间
|
|
166
166
|
*/
|
|
167
|
-
drawCountdownText(
|
|
168
|
-
const i =
|
|
169
|
-
i.clearRect(0, 0,
|
|
170
|
-
`${
|
|
171
|
-
|
|
172
|
-
|
|
167
|
+
drawCountdownText(e, a) {
|
|
168
|
+
const i = e.getContext("2d");
|
|
169
|
+
i.clearRect(0, 0, e.width, e.height), i.font = "24px Digital", i.textBaseline = "middle", i.textAlign = "center", i.fillStyle = a.stageRemainingTime <= a.stageAllRedTime ? "red" : a.stageRemainingTime <= a.stageAllRedTime + a.stageYellowTime ? "yellow" : "lime", i.fillText(
|
|
170
|
+
`${a.stageID} ${a.stageRemainingTime.toFixed(0)}`,
|
|
171
|
+
e.width / 2,
|
|
172
|
+
e.height / 2
|
|
173
|
+
);
|
|
174
|
+
}
|
|
175
|
+
drawCircle(e, a) {
|
|
176
|
+
console.log(a);
|
|
177
|
+
const i = e.getContext("2d");
|
|
178
|
+
i.clearRect(0, 0, e.width, e.height), this.ctxDraw(
|
|
179
|
+
i,
|
|
180
|
+
"lime",
|
|
181
|
+
e.width / 2,
|
|
182
|
+
e.height / 2,
|
|
183
|
+
20,
|
|
184
|
+
-Math.PI / 2,
|
|
185
|
+
-Math.PI / 2 + 2 * 0.6 * Math.PI
|
|
173
186
|
);
|
|
174
187
|
}
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
188
|
+
ctxDraw(e, a, i, n, s, t, o) {
|
|
189
|
+
e.save, e.beginPath(), e.lineWidth = 4, e.strokeStyle = a, e.arc(i, n, s, t, o), e.stroke(), e.closePath(), e.font = "26px Digital", e.textBaseline = "middle", e.textAlign = "center", e.fillText("A", i, n), e.restore();
|
|
190
|
+
}
|
|
191
|
+
async updatePhaseLine(e, a, i) {
|
|
192
|
+
const n = this.phaseLineLayer.source.filter(
|
|
193
|
+
(s) => s.getAttribute("id").includes(e)
|
|
178
194
|
);
|
|
179
|
-
|
|
180
|
-
const
|
|
181
|
-
this.isLaneInChannels(
|
|
182
|
-
}), await this.phaseLineLayer.applyEdits({ updateFeatures:
|
|
195
|
+
n.forEach((s) => {
|
|
196
|
+
const t = s.getAttribute("id");
|
|
197
|
+
this.isLaneInChannels(t, a) ? s.setAttribute("color", "green") : this.isLaneInChannels(t, i) ? s.setAttribute("color", "red") : s.setAttribute("color", "green");
|
|
198
|
+
}), await this.phaseLineLayer.applyEdits({ updateFeatures: n });
|
|
183
199
|
}
|
|
184
200
|
/**
|
|
185
201
|
* 车道是否在通道中
|
|
@@ -187,26 +203,30 @@ class f {
|
|
|
187
203
|
* @param channels 通道列表
|
|
188
204
|
* @returns
|
|
189
205
|
*/
|
|
190
|
-
isLaneInChannels(
|
|
191
|
-
const i =
|
|
192
|
-
for (let
|
|
193
|
-
for (let
|
|
194
|
-
const l =
|
|
195
|
-
if (
|
|
206
|
+
isLaneInChannels(e, a) {
|
|
207
|
+
const i = e.split("+"), n = i[1], s = i[2];
|
|
208
|
+
for (let t = 0; t < a.length; t++)
|
|
209
|
+
for (let o = 0; o < a[t].laneSnList.length; o++) {
|
|
210
|
+
const l = a[t].laneSnList[o].toFixed(0);
|
|
211
|
+
if (n === l[0] && s === l[1])
|
|
196
212
|
return !0;
|
|
197
213
|
}
|
|
198
214
|
return !1;
|
|
199
215
|
}
|
|
200
|
-
createCountdownCanvas(
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
216
|
+
createCountdownCanvas() {
|
|
217
|
+
return new Promise((e, a) => {
|
|
218
|
+
const i = new Image();
|
|
219
|
+
i.src = `${this.mapConfig.assetsRoot}/Images/timeboard/CountdownBG1.png`, i.onload = () => {
|
|
220
|
+
const n = document.createElement("canvas");
|
|
221
|
+
n.width = this.canvasWidth, n.height = this.canvasHeight, n.style.position = "absolute", n.style.transform = "translate(-50%, -50%)", n.getContext(
|
|
222
|
+
"2d"
|
|
223
|
+
).drawImage(i, 0, 0, this.canvasWidth, this.canvasHeight), this.view.container.appendChild(n);
|
|
224
|
+
const t = document.createElement("canvas");
|
|
225
|
+
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), e([n, t]);
|
|
226
|
+
}, i.onerror = (n) => {
|
|
227
|
+
a(n);
|
|
228
|
+
};
|
|
229
|
+
});
|
|
210
230
|
}
|
|
211
231
|
}
|
|
212
232
|
export {
|
|
@@ -27,7 +27,7 @@ export default class SignalHoloFlow {
|
|
|
27
27
|
private updateCountdown;
|
|
28
28
|
/**
|
|
29
29
|
* 在倒计时面板上写入倒计时时间
|
|
30
|
-
* @param
|
|
30
|
+
* @param canvas 倒计时面板canvas
|
|
31
31
|
* @param rtStage 相位数据
|
|
32
32
|
* @param rtStage.stageID 相位名
|
|
33
33
|
* @param rtStage.stageRemainingTime 剩余时间
|
|
@@ -35,6 +35,8 @@ export default class SignalHoloFlow {
|
|
|
35
35
|
* @param rtStage.stageYellowTime 黄灯时间
|
|
36
36
|
*/
|
|
37
37
|
private drawCountdownText;
|
|
38
|
+
private drawCircle;
|
|
39
|
+
private ctxDraw;
|
|
38
40
|
private updatePhaseLine;
|
|
39
41
|
/**
|
|
40
42
|
* 车道是否在通道中
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const d=require("@arcgis/core/core/reactiveUtils"),
|
|
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("../../stores/index.js");function y(l){const e=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(l){for(const t in l)if(t!=="default"){const n=Object.getOwnPropertyDescriptor(l,t);Object.defineProperty(e,t,n.get?n:{enumerable:!0,get:()=>l[t]})}}return e.default=l,Object.freeze(e)}const w=y(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=g.default.useAppDataStore;this.mapConfig=JSON.parse(JSON.stringify(t.mapConfig))}async initializeLayer(){if(this.mapConfig.phaseLineLayer)if(this.phaseLineLayer)this.phaseLineLayer.visible||(this.phaseLineLayer.visible=!0);else{const e=`${this.mapConfig.assetsRoot}/${this.mapConfig.phaseLineLayer}`,i=(await(await fetch(e)).json()).features.map((s,a)=>({geometry:{type:"polyline",paths:[s.geometry.coordinates]},attributes:{ObjectID:a+1,id:s.properties.id,color:"hide"}}));this.phaseLineLayer=new p({source:i,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(e){const{crossId:t,lat:n,lon:i,rtStage:s,channelsConfig:a}=e;await this.updateCountdown(t,n,i,s),!(!this.phaseLineLayer||!a)&&((!this.currentPhaseMap.has(t)||this.currentPhaseMap.get(t)!==s.stagePhase)&&await this.updatePhaseLine(t,s.channelsConfig,a),this.currentPhaseMap.set(t,s.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,n,i){if(this.isDeletingCanvas)return;const s=this.countdownCanvasMap.get(e);if(s)this.drawCountdownText(s.countdownCanvas,i);else try{const a=new u.Point({longitude:n,latitude:t,z:10}),o=this.view.toScreen(a),r=await this.createCountdownCanvas(),c=r[0],h=r[1];c.style.left=o.x+"px",c.style.top=o.y+"px",h.style.left=o.x+"px",h.style.top=o.y+"px",this.countdownCanvasMap.set(e,{backgroundCanvas:c,countdownCanvas:h,mapPoint:a}),this.drawCountdownText(h,i)}catch(a){console.log("倒计时canvas创建失败",e,a)}this.countdownWatchHandel||(this.countdownWatchHandel=w.watch(()=>this.view.extent,()=>{this.countdownCanvasMap.forEach(a=>{const o=this.view.toScreen(a.mapPoint);a.backgroundCanvas.style.left=o.x+"px",a.backgroundCanvas.style.top=o.y+"px",a.countdownCanvas.style.left=o.x+"px",a.countdownCanvas.style.top=o.y+"px"})}))}drawCountdownText(e,t){const n=e.getContext("2d");n.clearRect(0,0,e.width,e.height),n.font="24px Digital",n.textBaseline="middle",n.textAlign="center",n.fillStyle=t.stageRemainingTime<=t.stageAllRedTime?"red":t.stageRemainingTime<=t.stageAllRedTime+t.stageYellowTime?"yellow":"lime",n.fillText(`${t.stageID} ${t.stageRemainingTime.toFixed(0)}`,e.width/2,e.height/2)}drawCircle(e,t){console.log(t);const n=e.getContext("2d");n.clearRect(0,0,e.width,e.height),this.ctxDraw(n,"lime",e.width/2,e.height/2,20,-Math.PI/2,-Math.PI/2+2*.6*Math.PI)}ctxDraw(e,t,n,i,s,a,o){e.save,e.beginPath(),e.lineWidth=4,e.strokeStyle=t,e.arc(n,i,s,a,o),e.stroke(),e.closePath(),e.font="26px Digital",e.textBaseline="middle",e.textAlign="center",e.fillText("A",n,i),e.restore()}async updatePhaseLine(e,t,n){const i=this.phaseLineLayer.source.filter(s=>s.getAttribute("id").includes(e));i.forEach(s=>{const a=s.getAttribute("id");this.isLaneInChannels(a,t)?s.setAttribute("color","green"):this.isLaneInChannels(a,n)?s.setAttribute("color","red"):s.setAttribute("color","green")}),await this.phaseLineLayer.applyEdits({updateFeatures:i})}isLaneInChannels(e,t){const n=e.split("+"),i=n[1],s=n[2];for(let a=0;a<t.length;a++)for(let o=0;o<t[a].laneSnList.length;o++){const r=t[a].laneSnList[o].toFixed(0);if(i===r[0]&&s===r[1])return!0}return!1}createCountdownCanvas(){return new Promise((e,t)=>{const n=new Image;n.src=`${this.mapConfig.assetsRoot}/Images/timeboard/CountdownBG1.png`,n.onload=()=>{const i=document.createElement("canvas");i.width=this.canvasWidth,i.height=this.canvasHeight,i.style.position="absolute",i.style.transform="translate(-50%, -50%)",i.getContext("2d").drawImage(n,0,0,this.canvasWidth,this.canvasHeight),this.view.container.appendChild(i);const a=document.createElement("canvas");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([i,a])},n.onerror=i=>{t(i)}})}}exports.default=m;
|