gisviewer-vue3-arcgis 1.0.105 → 1.0.107
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 +60 -57
- 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/trace-holo-flow.d.ts +5 -1
- package/es/src/gis-map/utils/holo-flow/trace-holo-flow.mjs +21 -15
- package/es/src/gis-map/utils/holo-flow/trace-renderer-external.d.ts +4 -1
- package/es/src/gis-map/utils/holo-flow/trace-renderer-external.mjs +105 -98
- package/es/src/gis-map/utils/holo-flow/trace-renderer-layer.d.ts +5 -2
- package/es/src/gis-map/utils/holo-flow/trace-renderer-layer.mjs +66 -51
- package/es/src/gis-map/utils/map-initializer.mjs +8 -2
- package/es/src/types/index.d.ts +3 -2
- 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/trace-holo-flow.d.ts +5 -1
- package/lib/src/gis-map/utils/holo-flow/trace-holo-flow.js +1 -1
- package/lib/src/gis-map/utils/holo-flow/trace-renderer-external.d.ts +4 -1
- package/lib/src/gis-map/utils/holo-flow/trace-renderer-external.js +1 -1
- package/lib/src/gis-map/utils/holo-flow/trace-renderer-layer.d.ts +5 -2
- package/lib/src/gis-map/utils/holo-flow/trace-renderer-layer.js +1 -1
- package/lib/src/gis-map/utils/map-initializer.js +1 -1
- package/lib/src/types/index.d.ts +3 -2
- package/package.json +1 -1
|
@@ -1,17 +1,14 @@
|
|
|
1
1
|
import * as y from "@arcgis/core/core/reactiveUtils.js";
|
|
2
2
|
import w from "@arcgis/core/geometry/SpatialReference";
|
|
3
|
-
import * as
|
|
3
|
+
import * as g from "@arcgis/core/views/3d/externalRenderers";
|
|
4
4
|
import * as h from "three";
|
|
5
5
|
import { GLTFLoader as R } from "three/examples/jsm/loaders/GLTFLoader.js";
|
|
6
|
-
import { EVehiclePlateState as
|
|
7
|
-
import
|
|
6
|
+
import { EVehiclePlateState as d } from "../../../types/index.mjs";
|
|
7
|
+
import P from "../../stores/index.mjs";
|
|
8
8
|
class k {
|
|
9
9
|
constructor(i) {
|
|
10
|
-
this.
|
|
11
|
-
color: 16777215
|
|
12
|
-
emissive: 0,
|
|
13
|
-
roughness: this.roughness,
|
|
14
|
-
metalness: this.metalness
|
|
10
|
+
this.cameraHeightThreshold = 1e3, this.roughness = 0.2, this.metalness = 0.8, this.defaultMaterial = new h.MeshPhongMaterial({
|
|
11
|
+
color: 16777215
|
|
15
12
|
}), this.materialMap = /* @__PURE__ */ new Map([
|
|
16
13
|
[1, this.createCarMaterial(16777215)],
|
|
17
14
|
[2, this.createCarMaterial(7833753)],
|
|
@@ -24,8 +21,8 @@ class k {
|
|
|
24
21
|
[9, this.createCarMaterial(2105376)],
|
|
25
22
|
[10, this.createCarMaterial(9662683)],
|
|
26
23
|
[99, this.createCarMaterial(6908265)]
|
|
27
|
-
]), this.carModelReady = !1, this.vanModelReady = !1, this.truckModelReady = !1, this.busModelReady = !1, this.bicycleModelReady = !1, this.showGroundVehicle = !0, this.showElevatedVehicle = !0, this.currentSpriteContent =
|
|
28
|
-
const e =
|
|
24
|
+
]), this.carModelReady = !1, this.vanModelReady = !1, this.truckModelReady = !1, this.busModelReady = !1, this.bicycleModelReady = !1, this.showGroundVehicle = !0, this.showElevatedVehicle = !0, this.isPaused = !1, this.currentSpriteContent = d.None, this.historyPositionMap = /* @__PURE__ */ new Map(), this.vehicleObjectMap = /* @__PURE__ */ new Map(), this.needInterpolate = !0, this.updateModel = !1;
|
|
25
|
+
const e = P.useAppDataStore;
|
|
29
26
|
this.assetsRoot = JSON.parse(
|
|
30
27
|
JSON.stringify(e.mapConfig)
|
|
31
28
|
).assetsRoot, this.view = i;
|
|
@@ -47,18 +44,18 @@ class k {
|
|
|
47
44
|
},
|
|
48
45
|
!1
|
|
49
46
|
), y.watch(
|
|
50
|
-
() => this.view.
|
|
51
|
-
(s,
|
|
52
|
-
(
|
|
47
|
+
() => this.view.camera.position.z,
|
|
48
|
+
(s, a) => {
|
|
49
|
+
(a <= this.cameraHeightThreshold && s > this.cameraHeightThreshold || a > this.cameraHeightThreshold && s <= this.cameraHeightThreshold) && (this.updateModel = !0);
|
|
53
50
|
}
|
|
54
51
|
);
|
|
55
52
|
}
|
|
56
53
|
createCarMaterial(i) {
|
|
57
|
-
return new h.
|
|
58
|
-
color: i
|
|
59
|
-
emissive:
|
|
60
|
-
roughness: this.roughness,
|
|
61
|
-
metalness: this.metalness
|
|
54
|
+
return new h.MeshPhongMaterial({
|
|
55
|
+
color: i
|
|
56
|
+
// emissive: 0xc3c3c3,
|
|
57
|
+
// roughness: this.roughness,
|
|
58
|
+
// metalness: this.metalness
|
|
62
59
|
});
|
|
63
60
|
}
|
|
64
61
|
setInterpolate(i) {
|
|
@@ -75,8 +72,8 @@ class k {
|
|
|
75
72
|
const e = this.renderer.setRenderTarget.bind(
|
|
76
73
|
this.renderer
|
|
77
74
|
);
|
|
78
|
-
this.renderer.setRenderTarget = (
|
|
79
|
-
e(
|
|
75
|
+
this.renderer.setRenderTarget = (n) => {
|
|
76
|
+
e(n), n == null && i.bindRenderTarget();
|
|
80
77
|
}, this.scene = new h.Scene();
|
|
81
78
|
const { camera: t } = i;
|
|
82
79
|
this.camera = new h.PerspectiveCamera(
|
|
@@ -85,8 +82,14 @@ class k {
|
|
|
85
82
|
0.1,
|
|
86
83
|
1e5
|
|
87
84
|
), this.ambient = new h.AmbientLight(16777215, 2e4), this.scene.add(this.ambient), this.sun = new h.DirectionalLight(16777215, 2e4);
|
|
88
|
-
const s = [121.
|
|
85
|
+
const s = [121.51925377934634, 31.893973071723785, 1e4], a = this.toRenderCoordinates(s);
|
|
89
86
|
this.sun.position.set(
|
|
87
|
+
a[0],
|
|
88
|
+
a[1],
|
|
89
|
+
a[2]
|
|
90
|
+
);
|
|
91
|
+
const r = [121.46790813287619, 31.239514870157972, 1e3], o = this.toRenderCoordinates(r);
|
|
92
|
+
this.sun.target.position.set(
|
|
90
93
|
o[0],
|
|
91
94
|
o[1],
|
|
92
95
|
o[2]
|
|
@@ -97,15 +100,15 @@ class k {
|
|
|
97
100
|
const e = i.camera;
|
|
98
101
|
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(
|
|
99
102
|
new h.Vector3(e.center[0], e.center[1], e.center[2])
|
|
100
|
-
), this.camera.projectionMatrix.fromArray(e.projectionMatrix), this.needInterpolate)
|
|
101
|
-
for (const
|
|
102
|
-
const
|
|
103
|
-
if (!
|
|
103
|
+
), this.camera.projectionMatrix.fromArray(e.projectionMatrix), !this.isPaused && this.needInterpolate)
|
|
104
|
+
for (const a of this.vehicleObjectMap.keys()) {
|
|
105
|
+
const r = (s = this.vehicleObjectMap.get(a)) == null ? void 0 : s.model;
|
|
106
|
+
if (!r)
|
|
104
107
|
continue;
|
|
105
|
-
const
|
|
106
|
-
if (
|
|
107
|
-
const n = this.toRenderCoordinates(
|
|
108
|
-
|
|
108
|
+
const o = this.computeVehiclePosition(a);
|
|
109
|
+
if (o) {
|
|
110
|
+
const n = this.toRenderCoordinates(o);
|
|
111
|
+
r.position.set(n[0], n[1], n[2]), r.rotation.y = h.MathUtils.degToRad(-o[3]);
|
|
109
112
|
}
|
|
110
113
|
}
|
|
111
114
|
const t = i.sunLight;
|
|
@@ -117,45 +120,48 @@ class k {
|
|
|
117
120
|
t.ambient.color[0],
|
|
118
121
|
t.ambient.color[1],
|
|
119
122
|
t.ambient.color[2]
|
|
120
|
-
), this.renderer.resetState(), i.bindRenderTarget(), this.renderer.render(this.scene, this.camera),
|
|
123
|
+
), this.renderer.resetState(), i.bindRenderTarget(), this.renderer.render(this.scene, this.camera), g.requestRender(this.view), i.resetWebGLState();
|
|
121
124
|
}
|
|
122
125
|
/**
|
|
123
126
|
* 新增车辆
|
|
124
127
|
* */
|
|
125
128
|
async addVehicles(i) {
|
|
126
|
-
if (!(!this.carModelReady || !this.vanModelReady || !this.truckModelReady || !this.busModelReady || !this.bicycleModelReady))
|
|
129
|
+
if (!(this.isPaused || !this.carModelReady || !this.vanModelReady || !this.truckModelReady || !this.busModelReady || !this.bicycleModelReady))
|
|
127
130
|
for (const e of i) {
|
|
128
|
-
const { vehicleId: t, localTimestamp: s } = e,
|
|
131
|
+
const { vehicleId: t, localTimestamp: s } = e, a = Number(e.x), r = Number(e.y), o = Number(e.heading);
|
|
129
132
|
this.historyPositionMap.set(t, [
|
|
130
|
-
{ pos: [
|
|
133
|
+
{ pos: [a, r, 0], heading: o, time: s }
|
|
131
134
|
]);
|
|
132
135
|
const n = this.getVehicleModel(e);
|
|
133
136
|
n.name = t, n.visible = !this.needInterpolate;
|
|
134
137
|
try {
|
|
135
138
|
const l = await this.createPlateSprite(e);
|
|
136
|
-
l && (n.add(l), l.position.set(0, 5, -4))
|
|
137
|
-
model: n,
|
|
138
|
-
data: e,
|
|
139
|
-
waitForDelete: !1,
|
|
140
|
-
isMoving: !1
|
|
141
|
-
});
|
|
139
|
+
l && (n.add(l), l.position.set(0, 5, -4));
|
|
142
140
|
} catch (l) {
|
|
143
141
|
console.log("createPlateSprite error:", l);
|
|
144
142
|
}
|
|
143
|
+
this.scene.add(n), this.vehicleObjectMap.set(t, {
|
|
144
|
+
model: n,
|
|
145
|
+
data: e,
|
|
146
|
+
waitForDelete: !1,
|
|
147
|
+
isMoving: !1
|
|
148
|
+
});
|
|
145
149
|
}
|
|
146
150
|
}
|
|
147
151
|
/**
|
|
148
152
|
* 更新车辆
|
|
149
153
|
* */
|
|
150
154
|
async updateVehicles(i) {
|
|
151
|
-
if (!this.carModelReady || !this.vanModelReady || !this.truckModelReady || !this.busModelReady || !this.bicycleModelReady)
|
|
155
|
+
if (this.isPaused || !this.carModelReady || !this.vanModelReady || !this.truckModelReady || !this.busModelReady || !this.bicycleModelReady)
|
|
152
156
|
return;
|
|
153
157
|
const e = [];
|
|
154
158
|
for (const t of i) {
|
|
155
|
-
const { vehicleId: s, localTimestamp:
|
|
159
|
+
const { vehicleId: s, localTimestamp: a } = t, r = Number(t.x), o = Number(t.y);
|
|
156
160
|
let n = Number(t.heading);
|
|
157
|
-
const l = this.vehicleObjectMap.get(s)
|
|
158
|
-
|
|
161
|
+
const l = this.vehicleObjectMap.get(s), m = this.historyPositionMap.get(
|
|
162
|
+
s
|
|
163
|
+
);
|
|
164
|
+
if (!l || !m)
|
|
159
165
|
e.push(t);
|
|
160
166
|
else {
|
|
161
167
|
if (this.updateModel || l.data.vehicleColor !== t.vehicleColor || l.data.vehicleType !== t.vehicleType) {
|
|
@@ -166,32 +172,30 @@ class k {
|
|
|
166
172
|
if (l.data.showName !== t.showName || l.data.plateColor !== t.plateColor) {
|
|
167
173
|
const c = l.model.getObjectByName("VehiclePlate");
|
|
168
174
|
c && (l.model.remove(c), this.disposeModel(c));
|
|
169
|
-
const
|
|
170
|
-
|
|
175
|
+
const p = await this.createPlateSprite(t);
|
|
176
|
+
p && (l.model.add(p), p.position.set(0, 5, -4));
|
|
171
177
|
}
|
|
172
178
|
if (l.data = t, this.needInterpolate) {
|
|
173
|
-
const c =
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
Math.abs(n - d.heading) >= 180 && (n > d.heading ? d.heading += 360 : n += 360), c.push({
|
|
177
|
-
pos: [a, r, 0],
|
|
179
|
+
const c = m[m.length - 1];
|
|
180
|
+
Math.abs(n - c.heading) >= 180 && (n > c.heading ? c.heading += 360 : n += 360), m.push({
|
|
181
|
+
pos: [r, o, 0],
|
|
178
182
|
heading: n,
|
|
179
|
-
time:
|
|
183
|
+
time: a
|
|
180
184
|
});
|
|
181
185
|
} else {
|
|
182
186
|
this.historyPositionMap.set(s, [
|
|
183
|
-
{ pos: [
|
|
187
|
+
{ pos: [r, o, 0], heading: n, time: a }
|
|
184
188
|
]);
|
|
185
|
-
const c = this.toRenderCoordinates([
|
|
189
|
+
const c = this.toRenderCoordinates([r, o, 0]);
|
|
186
190
|
l.model.position.set(c[0], c[1], c[2]), l.model.rotation.y = h.MathUtils.degToRad(-n);
|
|
187
191
|
}
|
|
188
192
|
}
|
|
189
193
|
}
|
|
190
|
-
this.addVehicles(e), this.updateModel = !1, this.needInterpolate || this.render(this.context);
|
|
194
|
+
await this.addVehicles(e), this.updateModel = !1, this.needInterpolate || this.render(this.context);
|
|
191
195
|
}
|
|
192
196
|
toRenderCoordinates(i) {
|
|
193
197
|
const e = [0, 0, 0];
|
|
194
|
-
return
|
|
198
|
+
return g.toRenderCoordinates(
|
|
195
199
|
// @ts-ignore
|
|
196
200
|
this.view,
|
|
197
201
|
i,
|
|
@@ -206,7 +210,7 @@ class k {
|
|
|
206
210
|
* 删除车辆
|
|
207
211
|
* */
|
|
208
212
|
deleteVehicles(i) {
|
|
209
|
-
i.forEach((e) => {
|
|
213
|
+
this.isPaused || i.forEach((e) => {
|
|
210
214
|
const t = this.vehicleObjectMap.get(e);
|
|
211
215
|
t && (this.needInterpolate ? t.isMoving ? t.waitForDelete = !0 : this.deleteVehicle(t) : this.deleteVehicle(t));
|
|
212
216
|
});
|
|
@@ -217,10 +221,13 @@ class k {
|
|
|
217
221
|
this.vehicleObjectMap.delete(e), this.historyPositionMap.delete(e);
|
|
218
222
|
}
|
|
219
223
|
async toggleTrafficInfo(i) {
|
|
220
|
-
i.name === "vehiclePlate" && (i.visible === !0 && this.currentSpriteContent ===
|
|
221
|
-
i.visible ? this.currentSpriteContent :
|
|
224
|
+
i.name === "vehiclePlate" && (i.visible === !0 && this.currentSpriteContent === d.None ? await this.updatePanelContent(d.PlateNumber) : await this.updatePanelContent(
|
|
225
|
+
i.visible ? this.currentSpriteContent : d.None
|
|
222
226
|
));
|
|
223
227
|
}
|
|
228
|
+
togglePause(i) {
|
|
229
|
+
this.isPaused = i;
|
|
230
|
+
}
|
|
224
231
|
/**
|
|
225
232
|
* 清除全部车辆
|
|
226
233
|
* */
|
|
@@ -243,9 +250,9 @@ class k {
|
|
|
243
250
|
const t = this.vehicleObjectMap.get(e);
|
|
244
251
|
if (t) {
|
|
245
252
|
const s = t.model.getObjectByName("VehiclePlate");
|
|
246
|
-
if (s && (t.model.remove(s), this.disposeModel(s)), i !==
|
|
247
|
-
const
|
|
248
|
-
|
|
253
|
+
if (s && (t.model.remove(s), this.disposeModel(s)), i !== d.None) {
|
|
254
|
+
const a = await this.createPlateSprite(t.data);
|
|
255
|
+
a && (t.model.add(a), a.position.set(0, 5, -4));
|
|
249
256
|
}
|
|
250
257
|
}
|
|
251
258
|
}
|
|
@@ -274,26 +281,26 @@ class k {
|
|
|
274
281
|
return;
|
|
275
282
|
const s = Date.now();
|
|
276
283
|
t.isMoving = !0, t.data.roadLayer === "1" ? t.model.visible = this.showGroundVehicle : t.model.visible = this.showElevatedVehicle, t.segmentStartTime || (t.segmentStartTime = s, t.segmentTotalTime = e[1].time - e[0].time);
|
|
277
|
-
const
|
|
278
|
-
|
|
284
|
+
const a = s - t.segmentStartTime, r = Math.min(
|
|
285
|
+
a / t.segmentTotalTime,
|
|
279
286
|
1
|
|
280
287
|
);
|
|
281
|
-
if (
|
|
288
|
+
if (r === 1)
|
|
282
289
|
if (e.shift(), e.length === 1) {
|
|
283
|
-
t.waitForDelete === !0 ? this.deleteVehicle(t) : (t.segmentStartTime = void 0, t.segmentTotalTime = void 0, t.model.visible = !1, t.isMoving = !1, console.log("
|
|
290
|
+
t.waitForDelete === !0 ? this.deleteVehicle(t) : (t.segmentStartTime = void 0, t.segmentTotalTime = void 0, t.model.visible = !1, t.isMoving = !1, console.log("hide vehicle", i));
|
|
284
291
|
return;
|
|
285
292
|
} else
|
|
286
293
|
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);
|
|
287
294
|
else {
|
|
288
|
-
const
|
|
289
|
-
return [
|
|
295
|
+
const o = e[0].pos[0] + (e[1].pos[0] - e[0].pos[0]) * r, n = e[0].pos[1] + (e[1].pos[1] - e[0].pos[1]) * r, l = e[0].heading + (e[1].heading - e[0].heading) * r;
|
|
296
|
+
return [o, n, 0, l];
|
|
290
297
|
}
|
|
291
298
|
}
|
|
292
299
|
/**
|
|
293
300
|
* 根据车辆类型、车身颜色获取模型
|
|
294
301
|
* */
|
|
295
302
|
getVehicleModel(i) {
|
|
296
|
-
if (this.view.
|
|
303
|
+
if (this.view.camera.position.z >= this.cameraHeightThreshold) {
|
|
297
304
|
const e = new h.SphereGeometry(5, 32, 32), t = new h.MeshPhysicalMaterial({
|
|
298
305
|
color: 325253,
|
|
299
306
|
emissive: 0,
|
|
@@ -325,8 +332,8 @@ class k {
|
|
|
325
332
|
}
|
|
326
333
|
const t = this.materialMap.get(i.vehicleColor) || this.defaultMaterial;
|
|
327
334
|
let s = !1;
|
|
328
|
-
e.traverse((
|
|
329
|
-
!s &&
|
|
335
|
+
e.traverse((a) => {
|
|
336
|
+
!s && a instanceof h.Mesh && (a.material = t, s = !0);
|
|
330
337
|
});
|
|
331
338
|
}
|
|
332
339
|
return e;
|
|
@@ -336,67 +343,67 @@ class k {
|
|
|
336
343
|
* 创建号牌canvas
|
|
337
344
|
* */
|
|
338
345
|
createCanvas(i, e, t) {
|
|
339
|
-
const s = document.createElement("canvas"),
|
|
340
|
-
s.width =
|
|
341
|
-
const
|
|
342
|
-
if (!
|
|
346
|
+
const s = document.createElement("canvas"), a = i.width, r = i.height;
|
|
347
|
+
s.width = a, s.height = r;
|
|
348
|
+
const o = s.getContext("2d");
|
|
349
|
+
if (!o) {
|
|
343
350
|
console.log("canvas创建失败");
|
|
344
351
|
return;
|
|
345
352
|
}
|
|
346
|
-
return
|
|
353
|
+
return o.fillStyle = "rgba(0,0,0,0.0)", o.fillRect(0, 0, a, r), o.drawImage(i, 0, 0, a, r), o.beginPath(), o.translate(a / 2, r / 2), o.fillStyle = t, o.font = "bold 32px 宋体", o.textBaseline = "middle", o.textAlign = "center", o.fillText(e, 0, 0), s;
|
|
347
354
|
}
|
|
348
355
|
createPlateSprite(i) {
|
|
349
356
|
return new Promise((e, t) => {
|
|
350
|
-
var l,
|
|
357
|
+
var l, m;
|
|
351
358
|
const s = !i.plateNo || i.plateNo === "0" || i.plateNo === "000000";
|
|
352
|
-
if (this.currentSpriteContent ===
|
|
359
|
+
if (this.currentSpriteContent === d.None || this.currentSpriteContent === d.PlateNumber && s) {
|
|
353
360
|
e(void 0);
|
|
354
361
|
return;
|
|
355
362
|
}
|
|
356
|
-
const
|
|
357
|
-
let
|
|
358
|
-
if (this.currentSpriteContent ===
|
|
363
|
+
const a = new Image();
|
|
364
|
+
let r = "", o = "", n = "";
|
|
365
|
+
if (this.currentSpriteContent === d.PlateNumber || this.currentSpriteContent === d.Mix)
|
|
359
366
|
if (s)
|
|
360
|
-
|
|
367
|
+
r = "grey", o = i.ptcId, n = "#ffffff";
|
|
361
368
|
else
|
|
362
|
-
switch (
|
|
369
|
+
switch (o = ((l = i.showName) == null ? void 0 : l.substring(0, 2)) + "•" + ((m = i.showName) == null ? void 0 : m.substring(2)), i.plateColor) {
|
|
363
370
|
case 1:
|
|
364
|
-
|
|
371
|
+
r = "blue", n = "#ffffff";
|
|
365
372
|
break;
|
|
366
373
|
case 2:
|
|
367
|
-
|
|
374
|
+
r = "yellow", n = "#000000";
|
|
368
375
|
break;
|
|
369
376
|
case 3:
|
|
370
|
-
|
|
377
|
+
r = "white", n = "#000000";
|
|
371
378
|
break;
|
|
372
379
|
case 4:
|
|
373
|
-
|
|
380
|
+
r = "black";
|
|
374
381
|
break;
|
|
375
382
|
case 5:
|
|
376
|
-
|
|
383
|
+
r = "neo_yellow", n = "#000000";
|
|
377
384
|
break;
|
|
378
385
|
case 6:
|
|
379
|
-
|
|
386
|
+
r = "neo_green", n = "#000000";
|
|
380
387
|
break;
|
|
381
388
|
default:
|
|
382
|
-
|
|
389
|
+
r = "grey", o = i.plateNo, n = "#ffffff";
|
|
383
390
|
break;
|
|
384
391
|
}
|
|
385
392
|
else
|
|
386
|
-
this.currentSpriteContent ===
|
|
387
|
-
|
|
388
|
-
const
|
|
389
|
-
if (!
|
|
393
|
+
this.currentSpriteContent === d.Id && (r = "grey", o = i.ptcId, n = "#ffffff");
|
|
394
|
+
a.src = `${this.assetsRoot}/Images/PlateBG/${r}.png`, a.onload = () => {
|
|
395
|
+
const c = this.createCanvas(a, o, n);
|
|
396
|
+
if (!c)
|
|
390
397
|
t("canvas创建失败");
|
|
391
398
|
else {
|
|
392
|
-
const
|
|
393
|
-
map:
|
|
399
|
+
const p = new h.CanvasTexture(c), M = new h.SpriteMaterial({
|
|
400
|
+
map: p,
|
|
394
401
|
transparent: !1
|
|
395
|
-
}), f = new h.Sprite(
|
|
402
|
+
}), f = new h.Sprite(M), u = 0.05, b = c.width * u, v = c.height * u;
|
|
396
403
|
f.scale.set(b, v, 1), f.name = "VehiclePlate", e(f);
|
|
397
404
|
}
|
|
398
|
-
|
|
399
|
-
console.log(`号牌背景加载失败: ${
|
|
405
|
+
a.onerror = (p) => {
|
|
406
|
+
console.log(`号牌背景加载失败: ${a.src}`, p), t(p);
|
|
400
407
|
};
|
|
401
408
|
};
|
|
402
409
|
});
|
|
@@ -3,15 +3,17 @@ export default class TraceRendererLayer implements ITraceRendererInterface {
|
|
|
3
3
|
private view;
|
|
4
4
|
private readonly vehicleLayer;
|
|
5
5
|
private mapConfig;
|
|
6
|
+
private rafSignal;
|
|
6
7
|
constructor(view: __esri.MapView);
|
|
7
8
|
private needInterpolate;
|
|
9
|
+
private isPaused;
|
|
8
10
|
private showVehiclePlate;
|
|
9
11
|
private showGroundVehicle;
|
|
10
12
|
private showElevatedVehicle;
|
|
11
13
|
private historyPositionMap;
|
|
12
14
|
private vehicleObjectMap;
|
|
13
|
-
addVehicles(objects: IVehicleTrack[]): void
|
|
14
|
-
updateVehicles(objects: IVehicleTrack[]): void
|
|
15
|
+
addVehicles(objects: IVehicleTrack[]): Promise<void>;
|
|
16
|
+
updateVehicles(objects: IVehicleTrack[]): Promise<void>;
|
|
15
17
|
deleteVehicles(idList: string[]): void;
|
|
16
18
|
clearVehicles(): void;
|
|
17
19
|
/**
|
|
@@ -28,6 +30,7 @@ export default class TraceRendererLayer implements ITraceRendererInterface {
|
|
|
28
30
|
name: string;
|
|
29
31
|
visible: boolean;
|
|
30
32
|
}): void;
|
|
33
|
+
togglePause(pause: boolean): void;
|
|
31
34
|
updatePanelContent(contentType: EVehiclePlateState): void;
|
|
32
35
|
setInterpolate(needInterpolate: boolean): void;
|
|
33
36
|
private render;
|
|
@@ -1,55 +1,67 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
class
|
|
1
|
+
import c from "@arcgis/core/Graphic";
|
|
2
|
+
import p from "@arcgis/core/layers/GraphicsLayer";
|
|
3
|
+
import m from "../../stores/index.mjs";
|
|
4
|
+
class f {
|
|
5
5
|
constructor(i) {
|
|
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 =
|
|
8
|
-
this.mapConfig = JSON.parse(JSON.stringify(e.mapConfig)), this.vehicleLayer = new
|
|
6
|
+
this.needInterpolate = !0, this.isPaused = !1, 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 = m.useAppDataStore;
|
|
8
|
+
this.mapConfig = JSON.parse(JSON.stringify(e.mapConfig)), this.vehicleLayer = new p({
|
|
9
9
|
id: "vehicleLayer"
|
|
10
|
-
}), this.view.map.add(this.vehicleLayer), requestAnimationFrame(() => this.render());
|
|
10
|
+
}), this.view.map.add(this.vehicleLayer), this.rafSignal = requestAnimationFrame(() => this.render());
|
|
11
11
|
}
|
|
12
12
|
addVehicles(i) {
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
const
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
13
|
+
return new Promise((e) => {
|
|
14
|
+
if (this.isPaused) {
|
|
15
|
+
e();
|
|
16
|
+
return;
|
|
17
|
+
}
|
|
18
|
+
const t = i.map((s) => {
|
|
19
|
+
const { vehicleId: o, heading: a, localTimestamp: h } = s, r = Number(s.x), n = Number(s.y);
|
|
20
|
+
this.historyPositionMap.set(o, [
|
|
21
|
+
{ pos: [r, n, 0], heading: a, time: h }
|
|
22
|
+
]);
|
|
23
|
+
const l = new c({
|
|
24
|
+
geometry: {
|
|
25
|
+
type: "point",
|
|
26
|
+
x: r,
|
|
27
|
+
y: n
|
|
28
|
+
},
|
|
29
|
+
attributes: {
|
|
30
|
+
...s
|
|
31
|
+
},
|
|
32
|
+
symbol: this.createCIMSymbol(s)
|
|
33
|
+
});
|
|
34
|
+
return l.visible = !1, this.vehicleObjectMap.set(o, {
|
|
35
|
+
graphic: l,
|
|
36
|
+
data: s,
|
|
37
|
+
waitForDelete: !1,
|
|
38
|
+
isMoving: !1
|
|
39
|
+
}), l;
|
|
28
40
|
});
|
|
29
|
-
|
|
30
|
-
graphic: s,
|
|
31
|
-
data: t,
|
|
32
|
-
waitForDelete: !1,
|
|
33
|
-
isMoving: !1
|
|
34
|
-
}), s;
|
|
41
|
+
this.vehicleLayer.addMany(t), e();
|
|
35
42
|
});
|
|
36
|
-
this.vehicleLayer.addMany(e);
|
|
37
43
|
}
|
|
38
44
|
updateVehicles(i) {
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
heading: n,
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
45
|
+
return new Promise((e) => {
|
|
46
|
+
if (this.isPaused) {
|
|
47
|
+
e();
|
|
48
|
+
return;
|
|
49
|
+
}
|
|
50
|
+
const t = [];
|
|
51
|
+
i.forEach((s) => {
|
|
52
|
+
const { vehicleId: o, heading: a, localTimestamp: h } = s, r = Number(s.x), n = Number(s.y), l = this.vehicleObjectMap.get(o);
|
|
53
|
+
l ? (l.data = s, this.historyPositionMap.get(
|
|
54
|
+
o
|
|
55
|
+
).push({
|
|
56
|
+
pos: [r, n, 0],
|
|
57
|
+
heading: a,
|
|
58
|
+
time: h
|
|
59
|
+
})) : t.push(s);
|
|
60
|
+
}), this.addVehicles(t), e();
|
|
61
|
+
});
|
|
50
62
|
}
|
|
51
63
|
deleteVehicles(i) {
|
|
52
|
-
i.forEach((e) => {
|
|
64
|
+
this.isPaused || i.forEach((e) => {
|
|
53
65
|
const t = this.vehicleObjectMap.get(e);
|
|
54
66
|
t && (t.waitForDelete = !0);
|
|
55
67
|
});
|
|
@@ -74,6 +86,9 @@ class u {
|
|
|
74
86
|
toggleTrafficInfo(i) {
|
|
75
87
|
i.name === "vehiclePlate" && (this.showVehiclePlate = i.visible);
|
|
76
88
|
}
|
|
89
|
+
togglePause(i) {
|
|
90
|
+
this.isPaused = i, this.isPaused ? cancelAnimationFrame(this.rafSignal) : this.rafSignal = requestAnimationFrame(() => this.render());
|
|
91
|
+
}
|
|
77
92
|
updatePanelContent(i) {
|
|
78
93
|
console.log(i);
|
|
79
94
|
}
|
|
@@ -81,18 +96,18 @@ class u {
|
|
|
81
96
|
this.needInterpolate = i;
|
|
82
97
|
}
|
|
83
98
|
render() {
|
|
84
|
-
this.vehicleObjectMap.forEach((i, e) => {
|
|
99
|
+
this.isPaused || this.vehicleObjectMap.forEach((i, e) => {
|
|
85
100
|
this.updatePosition(e);
|
|
86
|
-
}), requestAnimationFrame(() => this.render());
|
|
101
|
+
}), this.rafSignal = requestAnimationFrame(() => this.render());
|
|
87
102
|
}
|
|
88
103
|
updatePosition(i) {
|
|
89
104
|
const e = this.historyPositionMap.get(i), t = this.vehicleObjectMap.get(i);
|
|
90
105
|
if (!e || !t || !t.isMoving && e.length <= 2)
|
|
91
106
|
return;
|
|
92
107
|
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
|
|
108
|
+
const o = Date.now() - t.segmentStartTime, a = Math.min(
|
|
94
109
|
1,
|
|
95
|
-
|
|
110
|
+
o / t.segmentTotalTime
|
|
96
111
|
);
|
|
97
112
|
if (a === 1)
|
|
98
113
|
if (e.shift(), e.length === 1) {
|
|
@@ -105,12 +120,12 @@ class u {
|
|
|
105
120
|
y: e[0].pos[1]
|
|
106
121
|
};
|
|
107
122
|
else {
|
|
108
|
-
const
|
|
123
|
+
const h = e[0].pos[0] + (e[1].pos[0] - e[0].pos[0]) * a, r = e[0].pos[1] + (e[1].pos[1] - e[0].pos[1]) * a, n = e[0].heading + (e[1].heading - e[0].heading) * a;
|
|
109
124
|
t.graphic.geometry = {
|
|
110
125
|
type: "point",
|
|
111
|
-
x:
|
|
112
|
-
y:
|
|
113
|
-
}, t.data.heading =
|
|
126
|
+
x: h,
|
|
127
|
+
y: r
|
|
128
|
+
}, t.data.heading = n, t.graphic.symbol = this.createCIMSymbol(t.data);
|
|
114
129
|
}
|
|
115
130
|
}
|
|
116
131
|
/**
|
|
@@ -298,5 +313,5 @@ class u {
|
|
|
298
313
|
}
|
|
299
314
|
}
|
|
300
315
|
export {
|
|
301
|
-
|
|
316
|
+
f as default
|
|
302
317
|
};
|
|
@@ -11,7 +11,7 @@ import S from "@arcgis/core/views/MapView";
|
|
|
11
11
|
import H from "@arcgis/core/views/SceneView";
|
|
12
12
|
import I from "@turf/destination";
|
|
13
13
|
import * as O from "@turf/helpers";
|
|
14
|
-
import
|
|
14
|
+
import C from "../stores/index.mjs";
|
|
15
15
|
function y(m, t) {
|
|
16
16
|
return m.startsWith("http://") || m.startsWith("https://") ? m : t + m;
|
|
17
17
|
}
|
|
@@ -25,7 +25,7 @@ class Q {
|
|
|
25
25
|
* @returns view
|
|
26
26
|
*/
|
|
27
27
|
async initialize(t) {
|
|
28
|
-
const i =
|
|
28
|
+
const i = C.useAppDataStore, e = JSON.parse(JSON.stringify(i.mapConfig));
|
|
29
29
|
this.mapConfig = e;
|
|
30
30
|
const { container: a, markerClickCallback: r, mapClickCallback: d } = t;
|
|
31
31
|
g.assetsPath = `${e.assetsRoot}/ArcgisAssets`, g.fontsUrl = `${e.assetsRoot}/fonts`, g.apiKey = "AAPKf5a3e1044d7a4faeb3b1ec7060f5c68equIrP2KbRyL-t_b40Kk4GTWUQ1BFCyttvyQPQnWpFmBd7kp9gkrVihjfmcKBwxjW";
|
|
@@ -37,6 +37,12 @@ class Q {
|
|
|
37
37
|
}) : this.view = new H({
|
|
38
38
|
map: c,
|
|
39
39
|
container: a,
|
|
40
|
+
environment: {
|
|
41
|
+
lighting: {
|
|
42
|
+
type: "sun",
|
|
43
|
+
date: new Date("January 1, 2022 07:00:00 UTC")
|
|
44
|
+
}
|
|
45
|
+
},
|
|
40
46
|
...e == null ? void 0 : e.mapOptions
|
|
41
47
|
}), this.view.on("click", async (s) => {
|
|
42
48
|
var v, b;
|
package/es/src/types/index.d.ts
CHANGED
|
@@ -140,14 +140,15 @@ export interface IToggleTrafficInfoParams {
|
|
|
140
140
|
visible: boolean;
|
|
141
141
|
}
|
|
142
142
|
export interface ITraceRendererInterface {
|
|
143
|
-
addVehicles(objects: IVehicleTrack[]): void
|
|
144
|
-
updateVehicles(objects: IVehicleTrack[]): void
|
|
143
|
+
addVehicles(objects: IVehicleTrack[]): Promise<void>;
|
|
144
|
+
updateVehicles(objects: IVehicleTrack[]): Promise<void>;
|
|
145
145
|
deleteVehicles(idList: string[]): void;
|
|
146
146
|
clearVehicles(): void;
|
|
147
147
|
updatePanelContent(contentType: EVehiclePlateState): void;
|
|
148
148
|
toggleGroundVehicle(visible: boolean): void;
|
|
149
149
|
toggleElevatedVehicle(visible: boolean): void;
|
|
150
150
|
toggleTrafficInfo(params: IToggleTrafficInfoParams): void;
|
|
151
|
+
togglePause(pause: boolean): void;
|
|
151
152
|
setInterpolate(enable: boolean): void;
|
|
152
153
|
}
|
|
153
154
|
export declare enum EVehiclePlateState {
|
|
@@ -54,6 +54,7 @@ declare const _sfc_main: import("vue").DefineComponent<{
|
|
|
54
54
|
handleHoloSignalData: (signalData: any) => Promise<void>;
|
|
55
55
|
clearHoloSignal: () => void;
|
|
56
56
|
toggleTrafficInfo: (params: IToggleTrafficInfoParams) => void;
|
|
57
|
+
togglePause: (pause: boolean) => void;
|
|
57
58
|
toggleTrafficObject: (params: IToggleTrafficInfoParams) => void;
|
|
58
59
|
toggleVehicleInfo: (contentType: string) => void;
|
|
59
60
|
addOverlays: (params: IOverlayParam) => Promise<import("../types").IResult>;
|