gisviewer-vue3-arcgis 1.0.101 → 1.0.103
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/gis-map.vue.d.ts +1 -0
- package/es/src/gis-map/gis-map.vue.mjs +52 -49
- package/es/src/gis-map/index.d.ts +1 -0
- package/es/src/gis-map/utils/holo-flow/index.d.ts +1 -0
- package/es/src/gis-map/utils/holo-flow/index.mjs +4 -0
- 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.d.ts +1 -0
- package/es/src/gis-map/utils/holo-flow/trace-holo-flow.mjs +38 -38
- package/es/src/gis-map/utils/holo-flow/{trace-external-renderer.d.ts → trace-renderer-external.d.ts} +13 -5
- package/es/src/gis-map/utils/holo-flow/trace-renderer-external.mjs +381 -0
- package/es/src/gis-map/utils/holo-flow/{trace-layer-renderer.d.ts → trace-renderer-layer.d.ts} +4 -2
- package/es/src/gis-map/utils/holo-flow/{trace-layer-renderer.mjs → trace-renderer-layer.mjs} +35 -31
- package/es/src/types/index.d.ts +2 -0
- package/lib/src/gis-map/gis-map.vue.d.ts +1 -0
- package/lib/src/gis-map/gis-map.vue.js +1 -1
- package/lib/src/gis-map/index.d.ts +1 -0
- package/lib/src/gis-map/utils/holo-flow/index.d.ts +1 -0
- package/lib/src/gis-map/utils/holo-flow/index.js +1 -1
- 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.d.ts +1 -0
- package/lib/src/gis-map/utils/holo-flow/trace-holo-flow.js +1 -1
- package/lib/src/gis-map/utils/holo-flow/{trace-external-renderer.d.ts → trace-renderer-external.d.ts} +13 -5
- package/lib/src/gis-map/utils/holo-flow/trace-renderer-external.js +1 -0
- package/lib/src/gis-map/utils/holo-flow/{trace-layer-renderer.d.ts → trace-renderer-layer.d.ts} +4 -2
- package/lib/src/gis-map/utils/holo-flow/trace-renderer-layer.js +1 -0
- package/lib/src/types/index.d.ts +2 -0
- package/package.json +1 -1
- package/es/src/gis-map/utils/holo-flow/trace-external-renderer.mjs +0 -322
- package/lib/src/gis-map/utils/holo-flow/trace-external-renderer.js +0 -1
- package/lib/src/gis-map/utils/holo-flow/trace-layer-renderer.js +0 -1
|
@@ -0,0 +1,381 @@
|
|
|
1
|
+
import w from "@arcgis/core/geometry/SpatialReference";
|
|
2
|
+
import * as g from "@arcgis/core/views/3d/externalRenderers";
|
|
3
|
+
import * as o from "three";
|
|
4
|
+
import { GLTFLoader as u } from "three/examples/jsm/loaders/GLTFLoader.js";
|
|
5
|
+
import { EVehiclePlateState as p } from "../../../types/index.mjs";
|
|
6
|
+
import R from "../../stores/index.mjs";
|
|
7
|
+
class k {
|
|
8
|
+
constructor(i) {
|
|
9
|
+
this.defaultMaterial = new o.MeshBasicMaterial({
|
|
10
|
+
color: 6908265
|
|
11
|
+
}), this.materialMap = /* @__PURE__ */ new Map([
|
|
12
|
+
[1, new o.MeshBasicMaterial({ color: 16777215 })],
|
|
13
|
+
[2, new o.MeshBasicMaterial({ color: 7833753 })],
|
|
14
|
+
[3, new o.MeshBasicMaterial({ color: 16766720 })],
|
|
15
|
+
[4, new o.MeshBasicMaterial({ color: 16758465 })],
|
|
16
|
+
[5, new o.MeshBasicMaterial({ color: 14423100 })],
|
|
17
|
+
[6, new o.MeshBasicMaterial({ color: 3329330 })],
|
|
18
|
+
[7, new o.MeshBasicMaterial({ color: 2003183 })],
|
|
19
|
+
[8, new o.MeshBasicMaterial({ color: 16032864 })],
|
|
20
|
+
[9, new o.MeshBasicMaterial({ color: 2105376 })],
|
|
21
|
+
[10, new o.MeshBasicMaterial({ color: 9662683 })],
|
|
22
|
+
[99, new o.MeshBasicMaterial({ color: 6908265 })]
|
|
23
|
+
]), this.carModelReady = !1, this.vanModelReady = !1, this.truckModelReady = !1, this.busModelReady = !1, this.bicycleModelReady = !1, this.currentSpriteContent = p.None, this.historyPositionMap = /* @__PURE__ */ new Map(), this.vehicleObjectMap = /* @__PURE__ */ new Map(), this.needInterpolate = !0;
|
|
24
|
+
const e = R.useAppDataStore;
|
|
25
|
+
this.assetsRoot = JSON.parse(
|
|
26
|
+
JSON.stringify(e.mapConfig)
|
|
27
|
+
).assetsRoot, this.view = i;
|
|
28
|
+
const t = new u();
|
|
29
|
+
t.load(`${this.assetsRoot}/3DModels/car.glb`, (s) => {
|
|
30
|
+
this.carModel = s.scene, this.carModel.rotation.x = o.MathUtils.degToRad(90), this.carModelReady = !0;
|
|
31
|
+
}), t.load(`${this.assetsRoot}/3DModels/van.glb`, (s) => {
|
|
32
|
+
this.vanModel = s.scene, this.vanModel.rotation.x = o.MathUtils.degToRad(90), this.vanModelReady = !0;
|
|
33
|
+
}), t.load(`${this.assetsRoot}/3DModels/truck.glb`, (s) => {
|
|
34
|
+
this.truckModel = s.scene, this.truckModel.scale.set(1.2, 1, 1.5), this.truckModel.rotation.x = o.MathUtils.degToRad(90), this.truckModelReady = !0;
|
|
35
|
+
}), t.load(`${this.assetsRoot}/3DModels/bus.glb`, (s) => {
|
|
36
|
+
this.busModel = s.scene, this.busModel.rotation.x = o.MathUtils.degToRad(90), this.busModelReady = !0;
|
|
37
|
+
}), t.load(`${this.assetsRoot}/3DModels/bicycle.glb`, (s) => {
|
|
38
|
+
this.bicycleModel = s.scene, this.bicycleModel.rotation.x = o.MathUtils.degToRad(90), this.bicycleModel.rotation.y = o.MathUtils.degToRad(180), this.bicycleModelReady = !0;
|
|
39
|
+
}), document.addEventListener(
|
|
40
|
+
"visibilitychange",
|
|
41
|
+
() => {
|
|
42
|
+
this.clearVehicles(), this.needInterpolate = !document.hidden;
|
|
43
|
+
},
|
|
44
|
+
!1
|
|
45
|
+
);
|
|
46
|
+
}
|
|
47
|
+
setInterpolate(i) {
|
|
48
|
+
this.clearVehicles(), this.needInterpolate = i;
|
|
49
|
+
}
|
|
50
|
+
async setup(i) {
|
|
51
|
+
this.context = i, this.renderer = new o.WebGLRenderer({
|
|
52
|
+
context: i.gl,
|
|
53
|
+
premultipliedAlpha: !0,
|
|
54
|
+
logarithmicDepthBuffer: !0,
|
|
55
|
+
antialias: !0,
|
|
56
|
+
powerPreference: "high-performance"
|
|
57
|
+
}), this.renderer.setPixelRatio(window.devicePixelRatio), this.renderer.setViewport(0, 0, this.view.width, this.view.height), this.renderer.autoClearDepth = !1, this.renderer.autoClearStencil = !1, this.renderer.autoClearColor = !1;
|
|
58
|
+
const e = this.renderer.setRenderTarget.bind(
|
|
59
|
+
this.renderer
|
|
60
|
+
);
|
|
61
|
+
this.renderer.setRenderTarget = (t) => {
|
|
62
|
+
e(t), t == null && i.bindRenderTarget();
|
|
63
|
+
}, this.scene = new o.Scene(), this.camera = new o.PerspectiveCamera(), this.ambient = new o.AmbientLight(16777215, 0.5), this.scene.add(this.ambient), this.sun = new o.DirectionalLight(16777215, 0.5), this.scene.add(this.sun), i.resetWebGLState();
|
|
64
|
+
}
|
|
65
|
+
geometryTest() {
|
|
66
|
+
new u().load(`${this.assetsRoot}/3DModels/car.glb`, (e) => {
|
|
67
|
+
this.mesh = e.scene, this.mesh.rotation.x = o.MathUtils.degToRad(90);
|
|
68
|
+
const t = [121.46892831020403, 31.239681632841354, 0], s = this.toRenderCoordinates(t);
|
|
69
|
+
this.mesh.position.set(s[0], s[1], s[2]), this.scene.add(this.mesh), new o.TextureLoader().load(
|
|
70
|
+
`${this.assetsRoot}/Images/PlateBG/grey.png`,
|
|
71
|
+
(r) => {
|
|
72
|
+
const n = new o.SpriteMaterial({
|
|
73
|
+
map: r,
|
|
74
|
+
transparent: !1
|
|
75
|
+
}), a = new o.Sprite(n);
|
|
76
|
+
a.scale.set(5, 2.5, 1), a.position.set(0, 5, -4), this.mesh.add(a), console.log(this.mesh.visible, a.visible);
|
|
77
|
+
}
|
|
78
|
+
);
|
|
79
|
+
});
|
|
80
|
+
}
|
|
81
|
+
async render(i) {
|
|
82
|
+
var s;
|
|
83
|
+
const e = i.camera;
|
|
84
|
+
if (this.camera.position.set(e.eye[0], e.eye[1], e.eye[2]), this.camera.up.set(e.up[0], e.up[1], e.up[2]), this.camera.lookAt(
|
|
85
|
+
new o.Vector3(e.center[0], e.center[1], e.center[2])
|
|
86
|
+
), this.camera.projectionMatrix.fromArray(e.projectionMatrix), this.needInterpolate)
|
|
87
|
+
for (const l of this.vehicleObjectMap.keys()) {
|
|
88
|
+
const r = (s = this.vehicleObjectMap.get(l)) == null ? void 0 : s.model;
|
|
89
|
+
if (!r)
|
|
90
|
+
continue;
|
|
91
|
+
const n = this.computeVehiclePosition(l);
|
|
92
|
+
if (n) {
|
|
93
|
+
const a = this.toRenderCoordinates(n);
|
|
94
|
+
r.position.set(a[0], a[1], a[2]), r.rotation.y = o.MathUtils.degToRad(-n[3]);
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
const t = i.sunLight;
|
|
98
|
+
this.sun.position.set(t.direction[0], t.direction[1], t.direction[2]), this.sun.intensity = t.diffuse.intensity, this.sun.color = new o.Color(
|
|
99
|
+
t.diffuse.color[0],
|
|
100
|
+
t.diffuse.color[1],
|
|
101
|
+
t.diffuse.color[2]
|
|
102
|
+
), this.ambient.intensity = t.ambient.intensity, this.ambient.color = new o.Color(
|
|
103
|
+
t.ambient.color[0],
|
|
104
|
+
t.ambient.color[1],
|
|
105
|
+
t.ambient.color[2]
|
|
106
|
+
), this.renderer.resetState(), i.bindRenderTarget(), this.renderer.render(this.scene, this.camera), g.requestRender(this.view), i.resetWebGLState();
|
|
107
|
+
}
|
|
108
|
+
/**
|
|
109
|
+
* 新增车辆
|
|
110
|
+
* */
|
|
111
|
+
async addVehicles(i) {
|
|
112
|
+
if (!(!this.carModelReady || !this.vanModelReady || !this.truckModelReady || !this.busModelReady || !this.bicycleModelReady))
|
|
113
|
+
for (const e of i) {
|
|
114
|
+
const { vehicleId: t, localTimestamp: s } = e, l = Number(e.x), r = Number(e.y), n = Number(e.heading);
|
|
115
|
+
this.historyPositionMap.set(t, [
|
|
116
|
+
{ pos: [l, r, 0], heading: n, time: s }
|
|
117
|
+
]);
|
|
118
|
+
const a = this.getVehicleModel(e);
|
|
119
|
+
a.name = t, a.visible = !this.needInterpolate;
|
|
120
|
+
try {
|
|
121
|
+
const c = await this.createPlateSprite(e);
|
|
122
|
+
c && (a.add(c), c.position.set(0, 5, -4)), this.scene.add(a), this.vehicleObjectMap.set(t, {
|
|
123
|
+
model: a,
|
|
124
|
+
data: e,
|
|
125
|
+
waitForDelete: !1,
|
|
126
|
+
isMoving: !1
|
|
127
|
+
});
|
|
128
|
+
} catch (c) {
|
|
129
|
+
console.log("createPlateSprite error:", c);
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
/**
|
|
134
|
+
* 更新车辆
|
|
135
|
+
* */
|
|
136
|
+
async updateVehicles(i) {
|
|
137
|
+
if (!this.carModelReady || !this.vanModelReady || !this.truckModelReady || !this.busModelReady || !this.bicycleModelReady)
|
|
138
|
+
return;
|
|
139
|
+
const e = [];
|
|
140
|
+
for (const t of i) {
|
|
141
|
+
const { vehicleId: s, localTimestamp: l } = t, r = Number(t.x), n = Number(t.y);
|
|
142
|
+
let a = Number(t.heading);
|
|
143
|
+
const c = this.vehicleObjectMap.get(s);
|
|
144
|
+
if (!c)
|
|
145
|
+
e.push(t);
|
|
146
|
+
else {
|
|
147
|
+
if (c.data.vehicleColor !== t.vehicleColor || c.data.vehicleType !== t.vehicleType) {
|
|
148
|
+
this.scene.remove(c.model), this.disposeModel(c.model), c.model = this.getVehicleModel(t);
|
|
149
|
+
const h = await this.createPlateSprite(t);
|
|
150
|
+
h && (c.model.add(h), h.position.set(0, 5, -4)), this.scene.add(c.model);
|
|
151
|
+
}
|
|
152
|
+
if (c.data.showName !== t.showName || c.data.plateColor !== t.plateColor) {
|
|
153
|
+
const h = c.model.getObjectByName("VehiclePlate");
|
|
154
|
+
h && (c.model.remove(h), this.disposeModel(h));
|
|
155
|
+
const d = await this.createPlateSprite(t);
|
|
156
|
+
d && (c.model.add(d), d.position.set(0, 5, -4));
|
|
157
|
+
}
|
|
158
|
+
if (c.data = t, this.needInterpolate) {
|
|
159
|
+
const h = this.historyPositionMap.get(
|
|
160
|
+
s
|
|
161
|
+
), d = h[h.length - 1];
|
|
162
|
+
Math.abs(a - d.heading) >= 180 && (a > d.heading ? d.heading += 360 : a += 360), h.push({
|
|
163
|
+
pos: [r, n, 0],
|
|
164
|
+
heading: a,
|
|
165
|
+
time: l
|
|
166
|
+
});
|
|
167
|
+
} else {
|
|
168
|
+
this.historyPositionMap.set(s, [
|
|
169
|
+
{ pos: [r, n, 0], heading: a, time: l }
|
|
170
|
+
]);
|
|
171
|
+
const h = this.toRenderCoordinates([r, n, 0]);
|
|
172
|
+
c.model.position.set(h[0], h[1], h[2]), c.model.rotation.y = o.MathUtils.degToRad(-a);
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
this.addVehicles(e), this.needInterpolate || this.render(this.context);
|
|
177
|
+
}
|
|
178
|
+
toRenderCoordinates(i) {
|
|
179
|
+
const e = [0, 0, 0];
|
|
180
|
+
return g.toRenderCoordinates(
|
|
181
|
+
// @ts-ignore
|
|
182
|
+
this.view,
|
|
183
|
+
i,
|
|
184
|
+
0,
|
|
185
|
+
w.WGS84,
|
|
186
|
+
e,
|
|
187
|
+
0,
|
|
188
|
+
1
|
|
189
|
+
), e;
|
|
190
|
+
}
|
|
191
|
+
/**
|
|
192
|
+
* 删除车辆
|
|
193
|
+
* */
|
|
194
|
+
deleteVehicles(i) {
|
|
195
|
+
i.forEach((e) => {
|
|
196
|
+
const t = this.vehicleObjectMap.get(e);
|
|
197
|
+
t && (this.needInterpolate ? t.isMoving ? t.waitForDelete = !0 : this.deleteVehicle(t) : this.deleteVehicle(t));
|
|
198
|
+
});
|
|
199
|
+
}
|
|
200
|
+
deleteVehicle(i) {
|
|
201
|
+
this.scene.remove(i.model), this.disposeModel(i.model);
|
|
202
|
+
const e = i.data.vehicleId;
|
|
203
|
+
this.vehicleObjectMap.delete(e), this.historyPositionMap.delete(e);
|
|
204
|
+
}
|
|
205
|
+
async toggleTrafficInfo(i) {
|
|
206
|
+
i.name === "vehiclePlate" && (i.visible === !0 && this.currentSpriteContent === p.None ? await this.updatePanelContent(p.Id) : await this.updatePanelContent(
|
|
207
|
+
i.visible ? this.currentSpriteContent : p.None
|
|
208
|
+
));
|
|
209
|
+
}
|
|
210
|
+
/**
|
|
211
|
+
* 清除全部车辆
|
|
212
|
+
* */
|
|
213
|
+
clearVehicles() {
|
|
214
|
+
for (const i of this.vehicleObjectMap.keys()) {
|
|
215
|
+
const e = this.vehicleObjectMap.get(i);
|
|
216
|
+
e && (this.disposeModel(e.model), this.scene.remove(e.model));
|
|
217
|
+
}
|
|
218
|
+
this.vehicleObjectMap.clear(), this.historyPositionMap.clear();
|
|
219
|
+
}
|
|
220
|
+
/**
|
|
221
|
+
* 设置号牌显示状态
|
|
222
|
+
* @param contentType
|
|
223
|
+
* @returns
|
|
224
|
+
*/
|
|
225
|
+
async updatePanelContent(i) {
|
|
226
|
+
if (i !== this.currentSpriteContent) {
|
|
227
|
+
this.currentSpriteContent = i;
|
|
228
|
+
for (const e of this.vehicleObjectMap.keys()) {
|
|
229
|
+
const t = this.vehicleObjectMap.get(e);
|
|
230
|
+
if (t) {
|
|
231
|
+
const s = t.model.getObjectByName("VehiclePlate");
|
|
232
|
+
if (s && (t.model.remove(s), this.disposeModel(s)), i !== p.None) {
|
|
233
|
+
const l = await this.createPlateSprite(t.data);
|
|
234
|
+
l && (t.model.add(l), l.position.set(0, 5, -4));
|
|
235
|
+
}
|
|
236
|
+
}
|
|
237
|
+
}
|
|
238
|
+
}
|
|
239
|
+
}
|
|
240
|
+
toggleGroundVehicle(i) {
|
|
241
|
+
}
|
|
242
|
+
toggleElevatedVehicle(i) {
|
|
243
|
+
}
|
|
244
|
+
/**
|
|
245
|
+
* 释放模型资源
|
|
246
|
+
* */
|
|
247
|
+
disposeModel(i) {
|
|
248
|
+
i.traverse((e) => {
|
|
249
|
+
e instanceof o.Mesh && (e.geometry.dispose(), e.material.dispose());
|
|
250
|
+
});
|
|
251
|
+
}
|
|
252
|
+
/**
|
|
253
|
+
* 计算车辆位置
|
|
254
|
+
* */
|
|
255
|
+
computeVehiclePosition(i) {
|
|
256
|
+
const e = this.historyPositionMap.get(i), t = this.vehicleObjectMap.get(i);
|
|
257
|
+
if (!t || !e || !t.isMoving && e.length <= 2)
|
|
258
|
+
return;
|
|
259
|
+
const s = Date.now();
|
|
260
|
+
t.model.visible = !0, t.isMoving = !0, t.segmentStartTime || (t.segmentStartTime = s, t.segmentTotalTime = e[1].time - e[0].time);
|
|
261
|
+
const l = s - t.segmentStartTime, r = Math.min(
|
|
262
|
+
l / t.segmentTotalTime,
|
|
263
|
+
1
|
|
264
|
+
);
|
|
265
|
+
if (r === 1)
|
|
266
|
+
if (e.shift(), e.length === 1) {
|
|
267
|
+
t.waitForDelete === !0 ? this.deleteVehicle(t) : (t.segmentStartTime = void 0, t.segmentTotalTime = void 0, t.model.visible = !1, t.isMoving = !1, console.log("pause vehicle", i));
|
|
268
|
+
return;
|
|
269
|
+
} else
|
|
270
|
+
return t.segmentStartTime = Date.now(), t.segmentTotalTime = e[1].time - e[0].time, (e[1].heading >= 270 && e[0].heading <= 90 || e[1].heading <= 90 && e[0].heading >= 270) && (e[1].heading > e[0].heading ? e[0].heading += 360 : e[1].heading += 360), e[0].pos.concat(e[0].heading);
|
|
271
|
+
else {
|
|
272
|
+
const n = e[0].pos[0] + (e[1].pos[0] - e[0].pos[0]) * r, a = e[0].pos[1] + (e[1].pos[1] - e[0].pos[1]) * r, c = e[0].heading + (e[1].heading - e[0].heading) * r;
|
|
273
|
+
return [n, a, 0, c];
|
|
274
|
+
}
|
|
275
|
+
}
|
|
276
|
+
/**
|
|
277
|
+
* 根据车辆类型、车身颜色获取模型
|
|
278
|
+
* */
|
|
279
|
+
getVehicleModel(i) {
|
|
280
|
+
let e;
|
|
281
|
+
if (i.ptcType === 2)
|
|
282
|
+
e = this.bicycleModel.clone();
|
|
283
|
+
else {
|
|
284
|
+
switch (i.vehicleType) {
|
|
285
|
+
case 10:
|
|
286
|
+
e = this.carModel.clone();
|
|
287
|
+
break;
|
|
288
|
+
case 20:
|
|
289
|
+
e = this.vanModel.clone();
|
|
290
|
+
break;
|
|
291
|
+
case 25:
|
|
292
|
+
e = this.truckModel.clone();
|
|
293
|
+
break;
|
|
294
|
+
case 50:
|
|
295
|
+
e = this.busModel.clone();
|
|
296
|
+
break;
|
|
297
|
+
default:
|
|
298
|
+
e = this.carModel.clone();
|
|
299
|
+
break;
|
|
300
|
+
}
|
|
301
|
+
const t = this.materialMap.get(i.vehicleColor) || this.defaultMaterial;
|
|
302
|
+
let s = !1;
|
|
303
|
+
e.traverse((l) => {
|
|
304
|
+
!s && l instanceof o.Mesh && (l.material = t, s = !0);
|
|
305
|
+
});
|
|
306
|
+
}
|
|
307
|
+
return e;
|
|
308
|
+
}
|
|
309
|
+
/**
|
|
310
|
+
* 创建号牌canvas
|
|
311
|
+
* */
|
|
312
|
+
createCanvas(i, e, t) {
|
|
313
|
+
const s = document.createElement("canvas"), l = i.width, r = i.height;
|
|
314
|
+
s.width = l, s.height = r;
|
|
315
|
+
const n = s.getContext("2d");
|
|
316
|
+
if (!n) {
|
|
317
|
+
console.log("canvas创建失败");
|
|
318
|
+
return;
|
|
319
|
+
}
|
|
320
|
+
return n.fillStyle = "rgba(0,0,0,0.0)", n.fillRect(0, 0, l, r), n.drawImage(i, 0, 0, l, r), n.beginPath(), n.translate(l / 2, r / 2), n.fillStyle = t, n.font = "bold 32px 宋体", n.textBaseline = "middle", n.textAlign = "center", n.fillText(e, 0, 0), s;
|
|
321
|
+
}
|
|
322
|
+
createPlateSprite(i) {
|
|
323
|
+
return new Promise((e, t) => {
|
|
324
|
+
var c, h;
|
|
325
|
+
const s = !i.plateNo || i.plateNo === "0" || i.plateNo === "000000";
|
|
326
|
+
if (this.currentSpriteContent === p.None || this.currentSpriteContent === p.PlateNumber && s) {
|
|
327
|
+
e(void 0);
|
|
328
|
+
return;
|
|
329
|
+
}
|
|
330
|
+
const l = new Image();
|
|
331
|
+
let r = "", n = "", a = "";
|
|
332
|
+
if (this.currentSpriteContent === p.PlateNumber || this.currentSpriteContent === p.Mix)
|
|
333
|
+
if (s)
|
|
334
|
+
r = "grey", n = i.ptcId, a = "#ffffff";
|
|
335
|
+
else
|
|
336
|
+
switch (n = ((c = i.showName) == null ? void 0 : c.substring(0, 2)) + "•" + ((h = i.showName) == null ? void 0 : h.substring(2)), i.plateColor) {
|
|
337
|
+
case 1:
|
|
338
|
+
r = "blue", a = "#ffffff";
|
|
339
|
+
break;
|
|
340
|
+
case 2:
|
|
341
|
+
r = "yellow", a = "#000000";
|
|
342
|
+
break;
|
|
343
|
+
case 3:
|
|
344
|
+
r = "white", a = "#000000";
|
|
345
|
+
break;
|
|
346
|
+
case 4:
|
|
347
|
+
r = "black";
|
|
348
|
+
break;
|
|
349
|
+
case 5:
|
|
350
|
+
r = "neo_yellow", a = "#000000";
|
|
351
|
+
break;
|
|
352
|
+
case 6:
|
|
353
|
+
r = "neo_green", a = "#000000";
|
|
354
|
+
break;
|
|
355
|
+
default:
|
|
356
|
+
r = "grey", n = i.plateNo, a = "#ffffff";
|
|
357
|
+
break;
|
|
358
|
+
}
|
|
359
|
+
else
|
|
360
|
+
this.currentSpriteContent === p.Id && (r = "grey", n = i.ptcId, a = "#ffffff");
|
|
361
|
+
l.src = `${this.assetsRoot}/Images/PlateBG/${r}.png`, l.onload = () => {
|
|
362
|
+
const d = this.createCanvas(l, n, a);
|
|
363
|
+
if (!d)
|
|
364
|
+
t("canvas创建失败");
|
|
365
|
+
else {
|
|
366
|
+
const f = new o.CanvasTexture(d), b = new o.SpriteMaterial({
|
|
367
|
+
map: f,
|
|
368
|
+
transparent: !1
|
|
369
|
+
}), m = new o.Sprite(b), M = 0.05, y = d.width * M, v = d.height * M;
|
|
370
|
+
m.scale.set(y, v, 1), m.name = "VehiclePlate", e(m);
|
|
371
|
+
}
|
|
372
|
+
l.onerror = (f) => {
|
|
373
|
+
console.log(`号牌背景加载失败: ${l.src}`, f), t(f);
|
|
374
|
+
};
|
|
375
|
+
};
|
|
376
|
+
});
|
|
377
|
+
}
|
|
378
|
+
}
|
|
379
|
+
export {
|
|
380
|
+
k as default
|
|
381
|
+
};
|
package/es/src/gis-map/utils/holo-flow/{trace-layer-renderer.d.ts → trace-renderer-layer.d.ts}
RENAMED
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import { EVehiclePlateState, ITraceRendererInterface, IVehicleTrack } from '../../../types';
|
|
2
|
-
export default class
|
|
2
|
+
export default class TraceRendererLayer implements ITraceRendererInterface {
|
|
3
3
|
private view;
|
|
4
4
|
private readonly vehicleLayer;
|
|
5
5
|
private mapConfig;
|
|
6
6
|
constructor(view: __esri.MapView);
|
|
7
|
+
private needInterpolate;
|
|
7
8
|
private showVehiclePlate;
|
|
8
9
|
private showGroundVehicle;
|
|
9
10
|
private showElevatedVehicle;
|
|
@@ -13,7 +14,6 @@ export default class TraceLayerRenderer implements ITraceRendererInterface {
|
|
|
13
14
|
updateVehicles(objects: IVehicleTrack[]): void;
|
|
14
15
|
deleteVehicles(idList: string[]): void;
|
|
15
16
|
clearVehicles(): void;
|
|
16
|
-
updatePanelContent(contentType: EVehiclePlateState): void;
|
|
17
17
|
/**
|
|
18
18
|
* 设置地面车辆显示隐藏
|
|
19
19
|
* @param visible
|
|
@@ -28,6 +28,8 @@ export default class TraceLayerRenderer implements ITraceRendererInterface {
|
|
|
28
28
|
name: string;
|
|
29
29
|
visible: boolean;
|
|
30
30
|
}): void;
|
|
31
|
+
updatePanelContent(contentType: EVehiclePlateState): void;
|
|
32
|
+
setInterpolate(needInterpolate: boolean): void;
|
|
31
33
|
private render;
|
|
32
34
|
private updatePosition;
|
|
33
35
|
/**
|
package/es/src/gis-map/utils/holo-flow/{trace-layer-renderer.mjs → trace-renderer-layer.mjs}
RENAMED
|
@@ -1,49 +1,50 @@
|
|
|
1
1
|
import h from "@arcgis/core/Graphic";
|
|
2
|
-
import
|
|
3
|
-
import
|
|
2
|
+
import c from "@arcgis/core/layers/GraphicsLayer";
|
|
3
|
+
import p from "../../stores/index.mjs";
|
|
4
4
|
class u {
|
|
5
5
|
constructor(i) {
|
|
6
|
-
this.showVehiclePlate = !1, this.showGroundVehicle = !0, this.showElevatedVehicle = !0, this.historyPositionMap = /* @__PURE__ */ new Map(), this.vehicleObjectMap = /* @__PURE__ */ new Map(), this.view = i;
|
|
7
|
-
const e =
|
|
8
|
-
this.mapConfig = JSON.parse(JSON.stringify(e.mapConfig)), this.vehicleLayer = new
|
|
6
|
+
this.needInterpolate = !0, this.showVehiclePlate = !1, this.showGroundVehicle = !0, this.showElevatedVehicle = !0, this.historyPositionMap = /* @__PURE__ */ new Map(), this.vehicleObjectMap = /* @__PURE__ */ new Map(), this.view = i;
|
|
7
|
+
const e = p.useAppDataStore;
|
|
8
|
+
this.mapConfig = JSON.parse(JSON.stringify(e.mapConfig)), this.vehicleLayer = new c({
|
|
9
9
|
id: "vehicleLayer"
|
|
10
10
|
}), this.view.map.add(this.vehicleLayer), requestAnimationFrame(() => this.render());
|
|
11
11
|
}
|
|
12
12
|
addVehicles(i) {
|
|
13
13
|
const e = i.map((t) => {
|
|
14
|
-
const {
|
|
15
|
-
this.historyPositionMap.set(
|
|
16
|
-
{ pos: [
|
|
14
|
+
const { vehicleId: o, heading: n, localTimestamp: a } = t, r = Number(t.x), l = Number(t.y);
|
|
15
|
+
this.historyPositionMap.set(o, [
|
|
16
|
+
{ pos: [r, l, 0], heading: n, time: a }
|
|
17
17
|
]);
|
|
18
|
-
const
|
|
18
|
+
const s = new h({
|
|
19
19
|
geometry: {
|
|
20
20
|
type: "point",
|
|
21
|
-
x:
|
|
22
|
-
y:
|
|
21
|
+
x: r,
|
|
22
|
+
y: l
|
|
23
23
|
},
|
|
24
24
|
attributes: {
|
|
25
25
|
...t
|
|
26
26
|
},
|
|
27
27
|
symbol: this.createCIMSymbol(t)
|
|
28
28
|
});
|
|
29
|
-
return
|
|
30
|
-
graphic:
|
|
29
|
+
return s.visible = !1, this.vehicleObjectMap.set(o, {
|
|
30
|
+
graphic: s,
|
|
31
31
|
data: t,
|
|
32
|
-
waitForDelete: !1
|
|
33
|
-
|
|
32
|
+
waitForDelete: !1,
|
|
33
|
+
isMoving: !1
|
|
34
|
+
}), s;
|
|
34
35
|
});
|
|
35
36
|
this.vehicleLayer.addMany(e);
|
|
36
37
|
}
|
|
37
38
|
updateVehicles(i) {
|
|
38
39
|
const e = [];
|
|
39
40
|
i.forEach((t) => {
|
|
40
|
-
const {
|
|
41
|
+
const { vehicleId: o, heading: n, localTimestamp: a } = t, r = Number(t.x), l = Number(t.y), s = this.vehicleObjectMap.get(o);
|
|
41
42
|
s ? (s.data = t, this.historyPositionMap.get(
|
|
42
|
-
|
|
43
|
+
o
|
|
43
44
|
).push({
|
|
44
|
-
pos: [
|
|
45
|
-
heading:
|
|
46
|
-
time:
|
|
45
|
+
pos: [r, l, 0],
|
|
46
|
+
heading: n,
|
|
47
|
+
time: a
|
|
47
48
|
})) : e.push(t);
|
|
48
49
|
}), this.addVehicles(e);
|
|
49
50
|
}
|
|
@@ -56,9 +57,6 @@ class u {
|
|
|
56
57
|
clearVehicles() {
|
|
57
58
|
this.vehicleLayer.removeAll(), this.vehicleObjectMap.clear(), this.historyPositionMap.clear();
|
|
58
59
|
}
|
|
59
|
-
updatePanelContent(i) {
|
|
60
|
-
console.log(i);
|
|
61
|
-
}
|
|
62
60
|
/**
|
|
63
61
|
* 设置地面车辆显示隐藏
|
|
64
62
|
* @param visible
|
|
@@ -76,6 +74,12 @@ class u {
|
|
|
76
74
|
toggleTrafficInfo(i) {
|
|
77
75
|
i.name === "vehiclePlate" && (this.showVehiclePlate = i.visible);
|
|
78
76
|
}
|
|
77
|
+
updatePanelContent(i) {
|
|
78
|
+
console.log(i);
|
|
79
|
+
}
|
|
80
|
+
setInterpolate(i) {
|
|
81
|
+
this.needInterpolate = i;
|
|
82
|
+
}
|
|
79
83
|
render() {
|
|
80
84
|
this.vehicleObjectMap.forEach((i, e) => {
|
|
81
85
|
this.updatePosition(e);
|
|
@@ -83,16 +87,16 @@ class u {
|
|
|
83
87
|
}
|
|
84
88
|
updatePosition(i) {
|
|
85
89
|
const e = this.historyPositionMap.get(i), t = this.vehicleObjectMap.get(i);
|
|
86
|
-
if (!e || !t || e.length <=
|
|
90
|
+
if (!e || !t || !t.isMoving && e.length <= 2)
|
|
87
91
|
return;
|
|
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 n = Date.now() - t.segmentStartTime,
|
|
92
|
+
t.isMoving = !0, (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);
|
|
93
|
+
const n = Date.now() - t.segmentStartTime, a = Math.min(
|
|
90
94
|
1,
|
|
91
95
|
n / t.segmentTotalTime
|
|
92
96
|
);
|
|
93
|
-
if (
|
|
97
|
+
if (a === 1)
|
|
94
98
|
if (e.shift(), e.length === 1) {
|
|
95
|
-
t.waitForDelete ? (this.vehicleLayer.remove(t.graphic), this.vehicleObjectMap.delete(i), this.historyPositionMap.delete(i)) : (t.segmentStartTime = void 0, t.segmentTotalTime = void 0);
|
|
99
|
+
t.waitForDelete ? (this.vehicleLayer.remove(t.graphic), this.vehicleObjectMap.delete(i), this.historyPositionMap.delete(i)) : (t.segmentStartTime = void 0, t.segmentTotalTime = void 0, t.graphic.visible = !1, t.isMoving = !1);
|
|
96
100
|
return;
|
|
97
101
|
} else
|
|
98
102
|
t.segmentStartTime = Date.now(), t.segmentTotalTime = e[1].time - e[0].time, (e[1].heading >= 270 && e[0].heading <= 90 || e[1].heading <= 90 && e[0].heading >= 270) && (e[1].heading > e[0].heading ? e[0].heading += 360 : e[1].heading += 360), t.graphic.geometry = {
|
|
@@ -101,11 +105,11 @@ class u {
|
|
|
101
105
|
y: e[0].pos[1]
|
|
102
106
|
};
|
|
103
107
|
else {
|
|
104
|
-
const
|
|
108
|
+
const r = e[0].pos[0] + (e[1].pos[0] - e[0].pos[0]) * a, l = e[0].pos[1] + (e[1].pos[1] - e[0].pos[1]) * a, s = e[0].heading + (e[1].heading - e[0].heading) * a;
|
|
105
109
|
t.graphic.geometry = {
|
|
106
110
|
type: "point",
|
|
107
|
-
x:
|
|
108
|
-
y:
|
|
111
|
+
x: r,
|
|
112
|
+
y: l
|
|
109
113
|
}, t.data.heading = s, t.graphic.symbol = this.createCIMSymbol(t.data);
|
|
110
114
|
}
|
|
111
115
|
}
|
package/es/src/types/index.d.ts
CHANGED
|
@@ -22,6 +22,7 @@ export interface IVehicleTrack {
|
|
|
22
22
|
localTimestamp: number;
|
|
23
23
|
crossId?: string;
|
|
24
24
|
ptcId: string;
|
|
25
|
+
vehicleId: string;
|
|
25
26
|
x: number;
|
|
26
27
|
y: number;
|
|
27
28
|
ptcType: number;
|
|
@@ -147,6 +148,7 @@ export interface ITraceRendererInterface {
|
|
|
147
148
|
toggleGroundVehicle(visible: boolean): void;
|
|
148
149
|
toggleElevatedVehicle(visible: boolean): void;
|
|
149
150
|
toggleTrafficInfo(params: IToggleTrafficInfoParams): void;
|
|
151
|
+
setInterpolate(enable: boolean): void;
|
|
150
152
|
}
|
|
151
153
|
export declare enum EVehiclePlateState {
|
|
152
154
|
None = 0,
|
|
@@ -50,6 +50,7 @@ declare const _sfc_main: import("vue").DefineComponent<{
|
|
|
50
50
|
disconnectCarFlow: () => void;
|
|
51
51
|
handleHoloVehicleTraceData: (vehicleTrace: any) => void;
|
|
52
52
|
clearHoloTrace: () => void;
|
|
53
|
+
setInterpolate: (enable: boolean) => void;
|
|
53
54
|
handleHoloSignalData: (signalData: any) => Promise<void>;
|
|
54
55
|
clearHoloSignal: () => void;
|
|
55
56
|
toggleTrafficInfo: (params: IToggleTrafficInfoParams) => void;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const o=require("vue"),w=require("./stores/index.js");require("./style/index.css");const y=require("./utils/holo-flow/index.js"),
|
|
1
|
+
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const o=require("vue"),w=require("./stores/index.js");require("./style/index.css");const y=require("./utils/holo-flow/index.js"),re=require("./utils/map-initializer.js"),se=require("./utils/open-drive-renderer/index.js"),ce=require("./utils/overlay.js"),ie=require("./utils/queue-length.js"),O=require("./utils/road-config-tool/index.js"),oe=require("./utils/traffic-flow.js"),le={class:"gis-viewer"},ue=o.defineComponent({__name:"gis-map",props:{config:{},assetsRoot:{}},emits:["mapLoaded","markerClick","mapClick"],setup(T,{expose:k,emit:b}){const d=o.ref(null);let s,c,a,r,t,n,l,u;w.registerStore(),o.onMounted(async()=>{if(!d.value)return;const e=o.getCurrentInstance(),{$gisviewerAssetsRoot:i}=e.appContext.config.globalProperties,C=await(await fetch(v.config)).json();C.assetsRoot=v.assetsRoot||i;const ne=w.default.useAppDataStore;ne.mapConfig=C,c=new re.default,s=await c.initialize({container:d.value,markerClickCallback:(m,p,g,ae)=>{f("markerClick",m,p,g,ae)},mapClickCallback:(m,p,g)=>{f("mapClick",m,p,g)}}),t=new y.default(s),f("mapLoaded")});const I=o.computed(()=>s),h=async e=>await c.setMapCenter(e),q=async e=>await c.setMapCamera(e),A=async e=>await c.lookAt(e),L=e=>c.setLayerVisibility(e),_=(e,i)=>c.requestCoordinateTransform(e,i),S=e=>{c.cancelCoordinateTransform(e)},D=e=>{c.setMapZoomRange(e)},M=e=>(a||(a=new O.default(s)),a.showLaneNumber(e)),x=()=>{a==null||a.clearLaneNumber()},V=async e=>(a||(a=new O.default(s)),await a.initializeSearch(e)),B=async()=>a==null?void 0:a.calCrossIndicatorArea(),H=async()=>{},R=async(e,i)=>{r||(r=new oe.default(s)),r.connectTrafficFlow(e,i)},j=()=>{r==null||r.disconnectTrafficFlow()},z=e=>{t||(t=new y.default(s)),t.handleVehicleTraceData(e)},N=()=>{t==null||t.clearHoloTrace()},Q=e=>{t==null||t.setInterpolate(e)},P=async e=>{t||(t=new y.default(s)),await t.handleSignalData(e)},E=()=>{t==null||t.clearHoloSignal()},Z=e=>{r==null||r.toggleTrafficInfo(e),t==null||t.toggleTrafficInfo(e)},G=e=>{t==null||t.toggleTrafficObject(e),r==null||r.toggleTrafficObject(e)},J=e=>{t==null||t.updatePanelContent(e)},K=async e=>(n||(n=new ce.default(s)),n.addOverlays(e)),U=e=>n==null?void 0:n.removeOverlaysByType(e),W=e=>n==null?void 0:n.removeOverlaysById(e),X=()=>n==null?void 0:n.removeAllOverlays(),Y=()=>{n==null||n.showAllOverlays()},$=e=>{l||(l=new ie.default(s)),l.updateQueueLength(e)},F=()=>{l==null||l.removeQueueLength()},ee=async(e,i)=>{u||(u=new se.default(s)),await u.showOpenDrive(e,i)},te=async()=>{await(u==null?void 0:u.hideOpenDrive())},v=T,f=b;return k({mapViewer:I,setLayerVisibility:L,setMapCenter:h,lookAt:A,setMapCamera:q,setMapZoomRange:D,requestCoordinateTransform:_,cancelCoordinateTransform:S,addOverlays:K,showAllOverlays:Y,removeOverlaysByType:U,removeOverlaysById:W,removeAllOverlays:X,showLaneNumber:M,clearLaneNumber:x,initializeAreaTool:V,calCrossIndicatorArea:B,calRoadIndicatorArea:H,connectCarFlow:R,disconnectCarFlow:j,handleHoloVehicleTraceData:z,clearHoloTrace:N,handleHoloSignalData:P,clearHoloSignal:E,setInterpolate:Q,toggleTrafficInfo:Z,toggleTrafficObject:G,toggleVehicleInfo:J,updateQueueLength:$,removeQueueLength:F,showOpenDrive:ee,hideOpenDrive:te}),(e,i)=>(o.openBlock(),o.createElementBlock("div",le,[o.createElementVNode("div",{class:"gis-viewer-main",ref_key:"mapContainer",ref:d},null,512)]))}});exports.default=ue;
|
|
@@ -40,6 +40,7 @@ export declare const GisMap: import("@easyest/utils/dist/lib/withinstall").SFCWi
|
|
|
40
40
|
disconnectCarFlow: () => void;
|
|
41
41
|
handleHoloVehicleTraceData: (vehicleTrace: any) => void;
|
|
42
42
|
clearHoloTrace: () => void;
|
|
43
|
+
setInterpolate: (enable: boolean) => void;
|
|
43
44
|
handleHoloSignalData: (signalData: any) => Promise<void>;
|
|
44
45
|
clearHoloSignal: () => void;
|
|
45
46
|
toggleTrafficInfo: (params: import("../types").IToggleTrafficInfoParams) => void;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const
|
|
1
|
+
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const a=require("../../../types/index.js"),o=require("./signal-holo-flow.js"),i=require("./trace-holo-flow.js");class c{constructor(e){this.view=e}handleVehicleTraceData(e){this.traceHoloFlow||(this.traceHoloFlow=new i.default(this.view)),this.traceHoloFlow.handleVehicleTraceData(e)}toggleTrafficObject(e){var l,t;switch(e.name.toLowerCase()){case"groundVehicle".toLowerCase():(l=this.traceHoloFlow)==null||l.toggleGroundVehicle(e.visible);break;case"elevatedVehicle".toLowerCase():(t=this.traceHoloFlow)==null||t.toggleElevatedVehicle(e.visible);break}}clearHoloTrace(){var e;(e=this.traceHoloFlow)==null||e.clearTrace()}toggleTrafficInfo(e){var l;(l=this.traceHoloFlow)==null||l.toggleTrafficInfo(e)}updatePanelContent(e){var t;let l=a.EVehiclePlateState.None;switch(e){case"none":l=a.EVehiclePlateState.None;break;case"plateNumber":l=a.EVehiclePlateState.PlateNumber;break;case"vehicleId":l=a.EVehiclePlateState.Id;break;case"mix":l=a.EVehiclePlateState.Mix;break}(t=this.traceHoloFlow)==null||t.updatePanelContent(l)}async handleSignalData(e){this.signalHoloFlow||(this.signalHoloFlow=new o.default(this.view)),await this.signalHoloFlow.initializeLayer(),await this.signalHoloFlow.handleSignalData(e)}clearHoloSignal(){var e;(e=this.signalHoloFlow)==null||e.clearSignal()}setInterpolate(e){var l;(l=this.traceHoloFlow)==null||l.setInterpolate(e)}}exports.default=c;
|
|
@@ -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`,
|
|
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;
|
|
@@ -21,5 +21,6 @@ export default class TraceHoloFlow {
|
|
|
21
21
|
updatePanelContent(contentType: EVehiclePlateState): void;
|
|
22
22
|
toggleGroundVehicle(visible: boolean): void;
|
|
23
23
|
toggleElevatedVehicle(visible: boolean): void;
|
|
24
|
+
setInterpolate(enable: boolean): void;
|
|
24
25
|
private buildVehicleTrackData;
|
|
25
26
|
}
|