gisviewer-vue3-arcgis 1.0.97 → 1.0.99
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/utils/holo-flow/signal-holo-flow.mjs +1 -1
- package/es/src/gis-map/utils/holo-flow/trace-holo-flow.mjs +33 -33
- package/es/src/gis-map/utils/holo-flow/trace-layer-renderer.d.ts +2 -2
- package/es/src/gis-map/utils/holo-flow/trace-layer-renderer.mjs +30 -30
- package/lib/src/gis-map/utils/holo-flow/signal-holo-flow.js +1 -1
- package/lib/src/gis-map/utils/holo-flow/trace-holo-flow.js +1 -1
- package/lib/src/gis-map/utils/holo-flow/trace-layer-renderer.d.ts +2 -2
- package/lib/src/gis-map/utils/holo-flow/trace-layer-renderer.js +1 -1
- package/package.json +1 -1
|
@@ -216,7 +216,7 @@ class f {
|
|
|
216
216
|
createCountdownCanvas() {
|
|
217
217
|
return new Promise((e, a) => {
|
|
218
218
|
const i = new Image();
|
|
219
|
-
i.src = `${this.mapConfig.assetsRoot}/Images/timeboard/CountdownBG.png`, i.onload = () => {
|
|
219
|
+
i.src = `${this.mapConfig.assetsRoot}/Images/timeboard/CountdownBG.png`, console.log(i.src), i.onload = () => {
|
|
220
220
|
const n = document.createElement("canvas");
|
|
221
221
|
n.width = this.canvasWidth, n.height = this.canvasHeight, n.style.position = "absolute", n.style.transform = "translate(-50%, -50%)", n.getContext(
|
|
222
222
|
"2d"
|
|
@@ -1,45 +1,45 @@
|
|
|
1
1
|
import * as u from "@arcgis/core/views/3d/externalRenderers";
|
|
2
2
|
import T from "../../stores/index.mjs";
|
|
3
|
-
import
|
|
4
|
-
import
|
|
5
|
-
class
|
|
3
|
+
import g from "./trace-external-renderer.mjs";
|
|
4
|
+
import f from "./trace-layer-renderer.mjs";
|
|
5
|
+
class L {
|
|
6
6
|
constructor(e) {
|
|
7
7
|
this.lastDataTime = 0, this.view = e;
|
|
8
|
-
const
|
|
9
|
-
this.mapConfig = JSON.parse(JSON.stringify(
|
|
8
|
+
const s = T.useAppDataStore;
|
|
9
|
+
this.mapConfig = JSON.parse(JSON.stringify(s.mapConfig)), e.type === "3d" ? (this.traceRenderer = new g(e), u.add(
|
|
10
10
|
e,
|
|
11
11
|
this.traceRenderer
|
|
12
|
-
)) : this.traceRenderer = new
|
|
12
|
+
)) : this.traceRenderer = new f(e);
|
|
13
13
|
}
|
|
14
14
|
/**
|
|
15
15
|
* 处理全息流轨迹数据
|
|
16
16
|
* */
|
|
17
17
|
handleVehicleTraceData(e) {
|
|
18
|
-
const
|
|
19
|
-
if (
|
|
18
|
+
const s = new Date().getTime();
|
|
19
|
+
if (s - this.lastDataTime < 100)
|
|
20
20
|
return;
|
|
21
|
-
this.lastDataTime =
|
|
22
|
-
const { newVehList:
|
|
23
|
-
if (
|
|
24
|
-
for (const
|
|
25
|
-
|
|
26
|
-
const t = this.buildVehicleTrackData(
|
|
27
|
-
t && h.push(t);
|
|
21
|
+
this.lastDataTime = s;
|
|
22
|
+
const { newVehList: i, updateVehList: n, deleteVehList: o, jgsj: l } = e, a = e.crossId || "", h = [], c = [], p = [], d = [];
|
|
23
|
+
if (i && i.length > 0) {
|
|
24
|
+
for (const r of i) {
|
|
25
|
+
r.localTimestamp || (r.localTimestamp = l || s);
|
|
26
|
+
const t = this.buildVehicleTrackData(r, a);
|
|
27
|
+
t && (h.push(t), p.push(t.ptcId));
|
|
28
28
|
}
|
|
29
29
|
this.traceRenderer.addVehicles(h);
|
|
30
30
|
}
|
|
31
31
|
if (n && n.length > 0) {
|
|
32
|
-
for (const
|
|
33
|
-
const t = this.buildVehicleTrackData(
|
|
34
|
-
t &&
|
|
32
|
+
for (const r of n) {
|
|
33
|
+
const t = this.buildVehicleTrackData(r, a);
|
|
34
|
+
t && (c.push(t), d.push(t.ptcId));
|
|
35
35
|
}
|
|
36
|
-
this.traceRenderer.updateVehicles(
|
|
36
|
+
this.traceRenderer.updateVehicles(c);
|
|
37
37
|
}
|
|
38
38
|
if (o && o.length > 0) {
|
|
39
|
-
const
|
|
39
|
+
const r = o.map(
|
|
40
40
|
(t) => a + "-" + (t.ptcId || t.vehno || t.vehNo)
|
|
41
41
|
);
|
|
42
|
-
this.traceRenderer.deleteVehicles(
|
|
42
|
+
this.traceRenderer.deleteVehicles(r), console.log("deleteVehList", r);
|
|
43
43
|
}
|
|
44
44
|
}
|
|
45
45
|
/**
|
|
@@ -57,27 +57,27 @@ class N {
|
|
|
57
57
|
toggleElevatedVehicle(e) {
|
|
58
58
|
this.traceRenderer.toggleElevatedVehicle(e);
|
|
59
59
|
}
|
|
60
|
-
buildVehicleTrackData(e,
|
|
61
|
-
const
|
|
60
|
+
buildVehicleTrackData(e, s) {
|
|
61
|
+
const m = e.longitude, i = e.latitude, n = e.ptcId, o = Number(e.ptcType), l = e.heading, a = Number(e.vehicleType), h = Number(e.vehicleColor), c = e.plateNo || e.plateno, p = Number(e.plateColor), d = e.timestamp, r = e.localTimestamp, t = String(e.roadLayer) || "1";
|
|
62
62
|
if (!(o < 0 || o > 8))
|
|
63
63
|
return {
|
|
64
64
|
ptcId: n,
|
|
65
|
-
crossId:
|
|
66
|
-
x:
|
|
67
|
-
y:
|
|
65
|
+
crossId: s,
|
|
66
|
+
x: m,
|
|
67
|
+
y: i,
|
|
68
68
|
ptcType: o,
|
|
69
69
|
vehicleType: a,
|
|
70
70
|
heading: o === 2 ? -l : l,
|
|
71
71
|
vehicleColor: h,
|
|
72
|
-
showName:
|
|
73
|
-
plateNo:
|
|
74
|
-
plateColor:
|
|
75
|
-
timestamp:
|
|
76
|
-
localTimestamp:
|
|
77
|
-
roadLayer:
|
|
72
|
+
showName: c && c !== "" && c !== "0" && c !== "000000" ? c : "",
|
|
73
|
+
plateNo: c,
|
|
74
|
+
plateColor: p,
|
|
75
|
+
timestamp: d,
|
|
76
|
+
localTimestamp: r,
|
|
77
|
+
roadLayer: t
|
|
78
78
|
};
|
|
79
79
|
}
|
|
80
80
|
}
|
|
81
81
|
export {
|
|
82
|
-
|
|
82
|
+
L as default
|
|
83
83
|
};
|
|
@@ -3,10 +3,10 @@ export default class TraceLayerRenderer implements ITraceRendererInterface {
|
|
|
3
3
|
private view;
|
|
4
4
|
private readonly vehicleLayer;
|
|
5
5
|
private mapConfig;
|
|
6
|
-
private showGroundVehicle;
|
|
7
|
-
private showElevatedVehicle;
|
|
8
6
|
constructor(view: __esri.MapView);
|
|
9
7
|
private showVehiclePlate;
|
|
8
|
+
private showGroundVehicle;
|
|
9
|
+
private showElevatedVehicle;
|
|
10
10
|
private historyPositionMap;
|
|
11
11
|
private vehicleObjectMap;
|
|
12
12
|
addVehicles(objects: IVehicleTrack[]): void;
|
|
@@ -3,7 +3,7 @@ import y from "@arcgis/core/layers/GraphicsLayer";
|
|
|
3
3
|
import d from "../../stores/index.mjs";
|
|
4
4
|
class C {
|
|
5
5
|
constructor(i) {
|
|
6
|
-
this.
|
|
6
|
+
this.showVehiclePlate = !1, this.showGroundVehicle = !0, this.showElevatedVehicle = !0, this.historyPositionMap = /* @__PURE__ */ new Map(), this.vehicleObjectMap = /* @__PURE__ */ new Map(), this.view = i;
|
|
7
7
|
const e = d.useAppDataStore;
|
|
8
8
|
this.mapConfig = JSON.parse(JSON.stringify(e.mapConfig)), this.vehicleLayer = new y({
|
|
9
9
|
id: "vehicleLayer"
|
|
@@ -11,14 +11,14 @@ class C {
|
|
|
11
11
|
}
|
|
12
12
|
addVehicles(i) {
|
|
13
13
|
const e = i.map((t) => {
|
|
14
|
-
const { crossId:
|
|
15
|
-
this.historyPositionMap.set(
|
|
16
|
-
{ pos: [
|
|
14
|
+
const { crossId: h, ptcId: l, localTimestamp: o } = t, s = Number(t.x), r = Number(t.y), a = Number(t.heading), c = `${h}-${l}`;
|
|
15
|
+
this.historyPositionMap.set(c, [
|
|
16
|
+
{ pos: [s, r, 0], heading: a, time: Date.now() }
|
|
17
17
|
]);
|
|
18
|
-
const
|
|
18
|
+
const n = new g({
|
|
19
19
|
geometry: {
|
|
20
20
|
type: "point",
|
|
21
|
-
x:
|
|
21
|
+
x: s,
|
|
22
22
|
y: r
|
|
23
23
|
},
|
|
24
24
|
attributes: {
|
|
@@ -26,25 +26,26 @@ class C {
|
|
|
26
26
|
},
|
|
27
27
|
symbol: this.createCIMSymbol(t)
|
|
28
28
|
});
|
|
29
|
-
return
|
|
30
|
-
graphic:
|
|
31
|
-
data: t
|
|
32
|
-
|
|
29
|
+
return n.visible = !1, this.vehicleObjectMap.set(c, {
|
|
30
|
+
graphic: n,
|
|
31
|
+
data: t,
|
|
32
|
+
waitForDelete: !1
|
|
33
|
+
}), n;
|
|
33
34
|
});
|
|
34
35
|
this.vehicleLayer.addMany(e);
|
|
35
36
|
}
|
|
36
37
|
updateVehicles(i) {
|
|
37
38
|
const e = [];
|
|
38
39
|
i.forEach((t) => {
|
|
39
|
-
const { crossId:
|
|
40
|
-
let
|
|
41
|
-
const
|
|
42
|
-
if (
|
|
43
|
-
|
|
40
|
+
const { crossId: h, ptcId: l, localTimestamp: o } = t, s = Number(t.x), r = Number(t.y);
|
|
41
|
+
let a = Number(t.heading);
|
|
42
|
+
const c = `${h}-${l}`, n = this.vehicleObjectMap.get(c);
|
|
43
|
+
if (n) {
|
|
44
|
+
n.data = t;
|
|
44
45
|
const p = this.historyPositionMap.get(
|
|
45
|
-
|
|
46
|
+
c
|
|
46
47
|
), m = p[p.length - 1];
|
|
47
|
-
Math.abs(
|
|
48
|
+
Math.abs(a - m.heading) >= 180 && (a > m.heading ? m.heading += 360 : a += 360), p.push({ pos: [s, r, 0], heading: a, time: Date.now() });
|
|
48
49
|
} else
|
|
49
50
|
e.push(t);
|
|
50
51
|
}), this.addVehicles(e);
|
|
@@ -52,7 +53,7 @@ class C {
|
|
|
52
53
|
deleteVehicles(i) {
|
|
53
54
|
i.forEach((e) => {
|
|
54
55
|
const t = this.vehicleObjectMap.get(e);
|
|
55
|
-
t && (
|
|
56
|
+
t && (t.waitForDelete = !0);
|
|
56
57
|
});
|
|
57
58
|
}
|
|
58
59
|
clearVehicles() {
|
|
@@ -82,20 +83,19 @@ class C {
|
|
|
82
83
|
}
|
|
83
84
|
updatePosition(i) {
|
|
84
85
|
const e = this.historyPositionMap.get(i), t = this.vehicleObjectMap.get(i);
|
|
85
|
-
if (!e || !t || e.length
|
|
86
|
+
if (!e || !t || e.length <= 1)
|
|
86
87
|
return;
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
const c = o - t.segmentStartTime, a = Math.min(
|
|
88
|
+
(t.graphic.getAttribute("roadLayer") || "1") === "1" ? t.graphic.visible = this.showGroundVehicle : t.graphic.visible = this.showElevatedVehicle, t.segmentStartTime || (t.segmentStartTime = Date.now(), t.segmentTotalTime = e[1].time - e[0].time);
|
|
89
|
+
const l = Date.now() - t.segmentStartTime, o = Math.min(
|
|
90
90
|
1,
|
|
91
|
-
|
|
91
|
+
l / t.segmentTotalTime
|
|
92
92
|
);
|
|
93
|
-
if (
|
|
93
|
+
if (o === 1)
|
|
94
94
|
if (e.shift(), e.length === 1) {
|
|
95
|
-
t.segmentStartTime = void 0, t.segmentTotalTime = void 0;
|
|
95
|
+
t.waitForDelete ? (this.vehicleLayer.remove(t.graphic), this.vehicleObjectMap.delete(i), this.historyPositionMap.delete(i)) : (t.segmentStartTime = void 0, t.segmentTotalTime = void 0);
|
|
96
96
|
return;
|
|
97
97
|
} else
|
|
98
|
-
t.segmentStartTime =
|
|
98
|
+
t.segmentStartTime = Date.now(), t.segmentTotalTime = e[1].time - e[0].time, Math.abs(
|
|
99
99
|
e[1].heading - e[0].heading
|
|
100
100
|
) >= 180 && (e[1].heading > e[0].heading ? e[0].heading += 360 : e[1].heading += 360), t.graphic.geometry = {
|
|
101
101
|
type: "point",
|
|
@@ -103,12 +103,12 @@ class C {
|
|
|
103
103
|
y: e[0].pos[1]
|
|
104
104
|
};
|
|
105
105
|
else {
|
|
106
|
-
const
|
|
106
|
+
const s = e[0].pos[0] + (e[1].pos[0] - e[0].pos[0]) * o, r = e[0].pos[1] + (e[1].pos[1] - e[0].pos[1]) * o, a = e[0].heading + (e[1].heading - e[0].heading) * o;
|
|
107
107
|
t.graphic.geometry = {
|
|
108
108
|
type: "point",
|
|
109
|
-
x:
|
|
110
|
-
y:
|
|
111
|
-
}, t.data.heading =
|
|
109
|
+
x: s,
|
|
110
|
+
y: r
|
|
111
|
+
}, t.data.heading = a, t.graphic.symbol = this.createCIMSymbol(t.data);
|
|
112
112
|
}
|
|
113
113
|
}
|
|
114
114
|
/**
|
|
@@ -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("../../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/CountdownBG.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;
|
|
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/CountdownBG.png`,console.log(n.src),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;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const f=require("@arcgis/core/views/3d/externalRenderers"),g=require("../../stores/index.js"),T=require("./trace-external-renderer.js"),b=require("./trace-layer-renderer.js");function V(o){const e=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(o){for(const
|
|
1
|
+
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const f=require("@arcgis/core/views/3d/externalRenderers"),g=require("../../stores/index.js"),T=require("./trace-external-renderer.js"),b=require("./trace-layer-renderer.js");function V(o){const e=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(o){for(const r in o)if(r!=="default"){const i=Object.getOwnPropertyDescriptor(o,r);Object.defineProperty(e,r,i.get?i:{enumerable:!0,get:()=>o[r]})}}return e.default=o,Object.freeze(e)}const y=V(f);class R{constructor(e){this.lastDataTime=0,this.view=e;const r=g.default.useAppDataStore;this.mapConfig=JSON.parse(JSON.stringify(r.mapConfig)),e.type==="3d"?(this.traceRenderer=new T.default(e),y.add(e,this.traceRenderer)):this.traceRenderer=new b.default(e)}handleVehicleTraceData(e){const r=new Date().getTime();if(r-this.lastDataTime<100)return;this.lastDataTime=r;const{newVehList:a,updateVehList:l,deleteVehList:s,jgsj:h}=e,d=e.crossId||"",u=[],n=[],p=[],m=[];if(a&&a.length>0){for(const c of a){c.localTimestamp||(c.localTimestamp=h||r);const t=this.buildVehicleTrackData(c,d);t&&(u.push(t),p.push(t.ptcId))}this.traceRenderer.addVehicles(u)}if(l&&l.length>0){for(const c of l){const t=this.buildVehicleTrackData(c,d);t&&(n.push(t),m.push(t.ptcId))}this.traceRenderer.updateVehicles(n)}if(s&&s.length>0){const c=s.map(t=>d+"-"+(t.ptcId||t.vehno||t.vehNo));this.traceRenderer.deleteVehicles(c),console.log("deleteVehList",c)}}clearTrace(){this.traceRenderer.clearVehicles()}updatePanelContent(e){this.traceRenderer.updatePanelContent(e)}toggleGroundVehicle(e){this.traceRenderer.toggleGroundVehicle(e)}toggleElevatedVehicle(e){this.traceRenderer.toggleElevatedVehicle(e)}buildVehicleTrackData(e,r){const i=e.longitude,a=e.latitude,l=e.ptcId,s=Number(e.ptcType),h=e.heading,d=Number(e.vehicleType),u=Number(e.vehicleColor),n=e.plateNo||e.plateno,p=Number(e.plateColor),m=e.timestamp,c=e.localTimestamp,t=String(e.roadLayer)||"1";if(!(s<0||s>8))return{ptcId:l,crossId:r,x:i,y:a,ptcType:s,vehicleType:d,heading:s===2?-h:h,vehicleColor:u,showName:n&&n!==""&&n!=="0"&&n!=="000000"?n:"",plateNo:n,plateColor:p,timestamp:m,localTimestamp:c,roadLayer:t}}}exports.default=R;
|
|
@@ -3,10 +3,10 @@ export default class TraceLayerRenderer implements ITraceRendererInterface {
|
|
|
3
3
|
private view;
|
|
4
4
|
private readonly vehicleLayer;
|
|
5
5
|
private mapConfig;
|
|
6
|
-
private showGroundVehicle;
|
|
7
|
-
private showElevatedVehicle;
|
|
8
6
|
constructor(view: __esri.MapView);
|
|
9
7
|
private showVehiclePlate;
|
|
8
|
+
private showGroundVehicle;
|
|
9
|
+
private showElevatedVehicle;
|
|
10
10
|
private historyPositionMap;
|
|
11
11
|
private vehicleObjectMap;
|
|
12
12
|
addVehicles(objects: IVehicleTrack[]): void;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const g=require("@arcgis/core/Graphic"),d=require("@arcgis/core/layers/GraphicsLayer"),y=require("../../stores/index.js");class b{constructor(i){this.
|
|
1
|
+
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const g=require("@arcgis/core/Graphic"),d=require("@arcgis/core/layers/GraphicsLayer"),y=require("../../stores/index.js");class b{constructor(i){this.showVehiclePlate=!1,this.showGroundVehicle=!0,this.showElevatedVehicle=!0,this.historyPositionMap=new Map,this.vehicleObjectMap=new Map,this.view=i;const e=y.default.useAppDataStore;this.mapConfig=JSON.parse(JSON.stringify(e.mapConfig)),this.vehicleLayer=new d({id:"vehicleLayer"}),this.view.map.add(this.vehicleLayer),requestAnimationFrame(()=>this.render())}addVehicles(i){const e=i.map(t=>{const{crossId:h,ptcId:l,localTimestamp:o}=t,s=Number(t.x),r=Number(t.y),a=Number(t.heading),c=`${h}-${l}`;this.historyPositionMap.set(c,[{pos:[s,r,0],heading:a,time:Date.now()}]);const n=new g({geometry:{type:"point",x:s,y:r},attributes:{...t},symbol:this.createCIMSymbol(t)});return n.visible=!1,this.vehicleObjectMap.set(c,{graphic:n,data:t,waitForDelete:!1}),n});this.vehicleLayer.addMany(e)}updateVehicles(i){const e=[];i.forEach(t=>{const{crossId:h,ptcId:l,localTimestamp:o}=t,s=Number(t.x),r=Number(t.y);let a=Number(t.heading);const c=`${h}-${l}`,n=this.vehicleObjectMap.get(c);if(n){n.data=t;const p=this.historyPositionMap.get(c),m=p[p.length-1];Math.abs(a-m.heading)>=180&&(a>m.heading?m.heading+=360:a+=360),p.push({pos:[s,r,0],heading:a,time:Date.now()})}else e.push(t)}),this.addVehicles(e)}deleteVehicles(i){i.forEach(e=>{const t=this.vehicleObjectMap.get(e);t&&(t.waitForDelete=!0)})}clearVehicles(){this.vehicleLayer.removeAll(),this.vehicleObjectMap.clear(),this.historyPositionMap.clear()}updatePanelContent(i){console.log(i)}toggleGroundVehicle(i){this.showGroundVehicle=i}toggleElevatedVehicle(i){this.showElevatedVehicle=i}render(){this.vehicleObjectMap.forEach((i,e)=>{this.updatePosition(e)}),requestAnimationFrame(()=>this.render())}updatePosition(i){const e=this.historyPositionMap.get(i),t=this.vehicleObjectMap.get(i);if(!e||!t||e.length<=1)return;(t.graphic.getAttribute("roadLayer")||"1")==="1"?t.graphic.visible=this.showGroundVehicle:t.graphic.visible=this.showElevatedVehicle,t.segmentStartTime||(t.segmentStartTime=Date.now(),t.segmentTotalTime=e[1].time-e[0].time);const l=Date.now()-t.segmentStartTime,o=Math.min(1,l/t.segmentTotalTime);if(o===1)if(e.shift(),e.length===1){t.waitForDelete?(this.vehicleLayer.remove(t.graphic),this.vehicleObjectMap.delete(i),this.historyPositionMap.delete(i)):(t.segmentStartTime=void 0,t.segmentTotalTime=void 0);return}else t.segmentStartTime=Date.now(),t.segmentTotalTime=e[1].time-e[0].time,Math.abs(e[1].heading-e[0].heading)>=180&&(e[1].heading>e[0].heading?e[0].heading+=360:e[1].heading+=360),t.graphic.geometry={type:"point",x:e[0].pos[0],y:e[0].pos[1]};else{const s=e[0].pos[0]+(e[1].pos[0]-e[0].pos[0])*o,r=e[0].pos[1]+(e[1].pos[1]-e[0].pos[1])*o,a=e[0].heading+(e[1].heading-e[0].heading)*o;t.graphic.geometry={type:"point",x:s,y:r},t.data.heading=a,t.graphic.symbol=this.createCIMSymbol(t.data)}}createCIMSymbol(i){const e=this.getPlateFontColor(i.plateColor);return{type:"cim",data:{type:"CIMSymbolReference",primitiveOverrides:[{type:"CIMPrimitiveOverride",primitiveName:"textGraphic",propertyName:"TextString",valueExpressionInfo:{type:"CIMExpressionInfo",title:"Custom",expression:"$feature.showName",returnType:"Default"}}],symbol:{type:"CIMPointSymbol",symbolLayers:[{type:"CIMVectorMarker",enable:this.showVehiclePlate,size:32,colorLocked:!0,anchorPointUnits:"Relative",frame:{xmin:-8,ymin:-8,xmax:8,ymax:8},markerGraphics:[{type:"CIMMarkerGraphic",primitiveName:"textGraphic",geometry:{x:0,y:0},symbol:{type:"CIMTextSymbol",height:4,horizontalAlignment:"Center",offsetX:0,offsetY:8,haloSize:1,haloSymbol:{type:"CIMPolygonSymbol",symbolLayers:[{type:"CIMSolidFill",enable:!0,color:e.backgroundColor}]},symbol:{type:"CIMPolygonSymbol",symbolLayers:[{type:"CIMSolidFill",enable:!0,color:e.fillColor}]},verticalAlignment:"Center"},textString:""}],scaleSymbolsProportionally:!0,respectFrame:!0},{type:"CIMPictureMarker",enable:!0,anchorPoint:{x:0,y:0},anchorPointUnits:"Relative",size:30,rotation:i.heading,rotateClockwise:!0,textureFilter:"Picture",url:`${this.mapConfig.assetsRoot}Images/car/${this.getCarPic(i.vehicleColor)}`}]}}}}getCarPic(i){if(this.view.zoom<=15)return"point.png";let e="grey";switch(typeof i=="string"&&(i=i.toLowerCase()),i){case"a":case 1:e="white";break;case"b":case 2:e="grey";break;case"c":case 3:e="yellow";break;case"d":case 4:e="pink";break;case"e":case 5:e="red";break;case"f":case 10:e="purple";break;case"g":case 6:e="green";break;case"h":case 7:e="blue";break;case"i":case 8:e="brown";break;case"j":case 9:e="black";break}return e+".png"}getPlateFontColor(i){let e=[255,255,255,255],t=[169,169,169,255];switch(i){case 0:e=[0,0,0,255],t=[255,255,255,255];break;case 1:e=[0,0,0,255],t=[244,164,96,255];break;case 2:e=[255,255,255,255],t=[65,105,225,255];break;case 3:e=[255,255,255,255],t=[0,0,0,255];break;case 15:e=[244,164,96,255],t=[0,250,154,255];break;case 16:e=[0,0,0,255],t=[0,250,154,255];break}return{fillColor:e,backgroundColor:t}}}exports.default=b;
|