gisviewer-vue3-arcgis 1.0.113 → 1.0.115

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.
@@ -1,17 +1,16 @@
1
- import * as w from "@arcgis/core/core/promiseUtils.js";
1
+ import * as P from "@arcgis/core/core/promiseUtils.js";
2
2
  import * as b from "@arcgis/core/core/reactiveUtils.js";
3
3
  import v from "@arcgis/core/geometry/SpatialReference";
4
4
  import * as u from "@arcgis/core/views/3d/externalRenderers";
5
5
  import * as l from "three";
6
6
  import { GLTFLoader as y } from "three/examples/jsm/loaders/GLTFLoader";
7
- import { EVehiclePlateState as d } from "../../../types/index.mjs";
8
- import G from "../../stores/index.mjs";
9
- import C from "./vehicle-pool.mjs";
10
- class N {
7
+ import { EVehiclePlateState as m } from "../../../types/index.mjs";
8
+ import T from "../../stores/index.mjs";
9
+ class I {
11
10
  constructor(i) {
12
11
  this.cameraHeightThreshold = 1e3, this.roughness = 0.2, this.metalness = 0.8, this.defaultMaterial = new l.MeshPhongMaterial({
13
12
  color: 16777215
14
- }), this.vehiclePool = new C(), this.materialMap = /* @__PURE__ */ new Map([
13
+ }), this.materialMap = /* @__PURE__ */ new Map([
15
14
  [1, this.createCarMaterial(16777215)],
16
15
  [2, this.createCarMaterial(7833753)],
17
16
  [3, this.createCarMaterial(16766720)],
@@ -23,17 +22,37 @@ class N {
23
22
  [9, this.createCarMaterial(2105376)],
24
23
  [10, this.createCarMaterial(9662683)],
25
24
  [99, this.createCarMaterial(6908265)]
26
- ]), this.isInitialized = !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;
27
- const e = G.useAppDataStore;
28
- this.assetsRoot = JSON.parse(
29
- JSON.stringify(e.mapConfig)
25
+ ]), this.isInitialized = !1, this.showGroundVehicle = !0, this.showElevatedVehicle = !0, this.isPaused = !1, this.currentSpriteContent = m.None, this.historyPositionMap = /* @__PURE__ */ new Map(), this.vehicleObjectMap = /* @__PURE__ */ new Map(), this.needInterpolate = !0, this.updateModel = !1, this.appDataStore = T.useAppDataStore, this.logTable = [
26
+ [
27
+ "ptcId",
28
+ "plateno",
29
+ "timestamp",
30
+ "localTimestamp",
31
+ "speed",
32
+ "longitude",
33
+ "latitude",
34
+ "ptcType",
35
+ "vehicleType",
36
+ "vehicleColor",
37
+ "plateColor",
38
+ "heading",
39
+ "fixAngle",
40
+ "roadLayer",
41
+ "step",
42
+ "receiveTimestamp",
43
+ "queueLength",
44
+ "status"
45
+ ]
46
+ ], this.assetsRoot = JSON.parse(
47
+ JSON.stringify(this.appDataStore.mapConfig)
30
48
  ).assetsRoot, this.view = i, b.watch(
31
49
  () => this.view.camera.position.z,
32
- (t, o) => {
33
- (o <= this.cameraHeightThreshold && t > this.cameraHeightThreshold || o > this.cameraHeightThreshold && t <= this.cameraHeightThreshold) && (this.updateModel = !0);
50
+ (e, t) => {
51
+ (t <= this.cameraHeightThreshold && e > this.cameraHeightThreshold || t > this.cameraHeightThreshold && e <= this.cameraHeightThreshold) && (this.updateModel = !0);
34
52
  }
35
53
  );
36
54
  }
55
+ // private readonly vehiclePool = new VehiclePool();
37
56
  createCarMaterial(i) {
38
57
  return new l.MeshPhongMaterial({
39
58
  color: i
@@ -42,9 +61,12 @@ class N {
42
61
  // metalness: this.metalness
43
62
  });
44
63
  }
64
+ getLog() {
65
+ return this.logTable;
66
+ }
45
67
  async init() {
46
68
  const i = new y();
47
- await w.eachAlways([
69
+ await P.eachAlways([
48
70
  new Promise((e) => {
49
71
  i.load(`${this.assetsRoot}/3DModels/car.glb`, (t) => {
50
72
  this.carModel = t.scene, this.carModel.rotation.x = l.MathUtils.degToRad(90), e();
@@ -121,8 +143,8 @@ class N {
121
143
  const e = this.renderer.setRenderTarget.bind(
122
144
  this.renderer
123
145
  );
124
- this.renderer.setRenderTarget = (o) => {
125
- e(o), o == null && i.bindRenderTarget();
146
+ this.renderer.setRenderTarget = (s) => {
147
+ e(s), s == null && i.bindRenderTarget();
126
148
  }, this.scene = new l.Scene();
127
149
  const { camera: t } = i;
128
150
  this.camera = new l.PerspectiveCamera(
@@ -133,19 +155,19 @@ class N {
133
155
  ), this.ambient = new l.AmbientLight(16777215, 2), this.scene.add(this.ambient), this.sun = new l.DirectionalLight(16777215, 2), this.scene.add(this.sun), i.resetWebGLState();
134
156
  }
135
157
  async render(i) {
136
- var o;
158
+ var s;
137
159
  const e = i.camera;
138
160
  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(
139
161
  new l.Vector3(e.center[0], e.center[1], e.center[2])
140
162
  ), this.camera.projectionMatrix.fromArray(e.projectionMatrix), !this.isPaused && this.needInterpolate)
141
- for (const s of this.vehicleObjectMap.keys()) {
142
- const n = (o = this.vehicleObjectMap.get(s)) == null ? void 0 : o.model;
163
+ for (const a of this.vehicleObjectMap.keys()) {
164
+ const n = (s = this.vehicleObjectMap.get(a)) == null ? void 0 : s.model;
143
165
  if (!n)
144
166
  continue;
145
- const a = this.computeVehiclePosition(s);
146
- if (a) {
147
- const h = this.toRenderCoordinates(a);
148
- n.position.set(h[0], h[1], h[2]), n.rotation.y = l.MathUtils.degToRad(-a[3]);
167
+ const o = this.computeVehiclePosition(a);
168
+ if (o) {
169
+ const d = this.toRenderCoordinates(o);
170
+ n.position.set(d[0], d[1], d[2]), n.rotation.y = l.MathUtils.degToRad(-o[3]);
149
171
  }
150
172
  }
151
173
  const t = i.sunLight;
@@ -163,27 +185,49 @@ class N {
163
185
  * 新增车辆
164
186
  * */
165
187
  async addVehicles(i) {
166
- if (!(this.isPaused || !this.isInitialized))
167
- for (const e of i) {
168
- const { vehicleId: t, localTimestamp: o } = e, s = Number(e.x), n = Number(e.y), a = Number(e.heading);
169
- this.historyPositionMap.set(t, [
170
- { pos: [s, n, 0], heading: a, time: o }
171
- ]);
172
- const h = this.getVehicleModel(e);
173
- h.name = t, h.visible = !1;
174
- try {
175
- const r = await this.createPlateSprite(e);
176
- r && (h.add(r), r.position.set(0, 5, -4));
177
- } catch (r) {
178
- console.log("createPlateSprite error:", r);
179
- }
180
- this.scene.add(h), this.vehicleObjectMap.set(t, {
181
- model: h,
182
- data: e,
183
- waitForDelete: !1,
184
- isMoving: !1
185
- });
188
+ if (this.isPaused || !this.isInitialized)
189
+ return;
190
+ const e = Date.now();
191
+ for (const t of i) {
192
+ this.appDataStore.saveTrackLog && this.logTable.push([
193
+ t.ptcId,
194
+ t.plateNo,
195
+ t.timestamp,
196
+ t.localTimestamp,
197
+ t.speed,
198
+ t.x,
199
+ t.y,
200
+ t.ptcType,
201
+ t.vehicleType,
202
+ t.vehicleColor,
203
+ t.plateColor,
204
+ t.heading,
205
+ t.fixAngle,
206
+ t.roadLayer,
207
+ t.step,
208
+ e,
209
+ 0,
210
+ 0
211
+ ]);
212
+ const { vehicleId: s, localTimestamp: a } = t, n = Number(t.x), o = Number(t.y), d = Number(t.heading);
213
+ this.historyPositionMap.set(s, [
214
+ { pos: [n, o, 0], heading: d, time: a }
215
+ ]);
216
+ const h = this.getVehicleModel(t);
217
+ h.name = s, h.visible = !1;
218
+ try {
219
+ const r = await this.createPlateSprite(t);
220
+ r && (h.add(r), r.position.set(0, 5, -4));
221
+ } catch (r) {
222
+ console.log("createPlateSprite error:", r);
186
223
  }
224
+ this.scene.add(h), this.vehicleObjectMap.set(s, {
225
+ model: h,
226
+ data: t,
227
+ waitForDelete: !1,
228
+ isMoving: !1
229
+ });
230
+ }
187
231
  }
188
232
  /**
189
233
  * 更新车辆
@@ -191,39 +235,58 @@ class N {
191
235
  async updateVehicles(i) {
192
236
  if (this.isPaused || !this.isInitialized)
193
237
  return;
194
- const e = [];
195
- for (const t of i) {
196
- const { vehicleId: o, timestamp: s } = t, n = Number(t.x), a = Number(t.y);
197
- let h = Number(t.heading);
198
- const r = this.vehicleObjectMap.get(o), m = this.historyPositionMap.get(
199
- o
238
+ const e = [], t = Date.now();
239
+ for (const s of i) {
240
+ const { vehicleId: a, timestamp: n } = s, o = Number(s.x), d = Number(s.y);
241
+ let h = Number(s.heading);
242
+ const r = this.vehicleObjectMap.get(a), p = this.historyPositionMap.get(
243
+ a
200
244
  );
201
- if (!r || !m)
202
- e.push(t);
245
+ if (!r || !p)
246
+ e.push(s);
203
247
  else {
204
- if (this.updateModel || r.data.vehicleColor !== t.vehicleColor || r.data.vehicleType !== t.vehicleType) {
205
- this.vehiclePool.recycleInstance(r.model), r.model = this.getVehicleModel(t), r.model.visible = !0;
206
- const c = await this.createPlateSprite(t);
248
+ if (this.appDataStore.saveTrackLog && this.logTable.push([
249
+ s.ptcId,
250
+ s.plateNo,
251
+ s.timestamp,
252
+ s.localTimestamp,
253
+ s.speed,
254
+ s.x,
255
+ s.y,
256
+ s.ptcType,
257
+ s.vehicleType,
258
+ s.vehicleColor,
259
+ s.plateColor,
260
+ s.heading,
261
+ s.fixAngle,
262
+ s.roadLayer,
263
+ s.step,
264
+ t,
265
+ p.length,
266
+ 1
267
+ ]), this.updateModel || r.data.vehicleColor !== s.vehicleColor || r.data.vehicleType !== s.vehicleType) {
268
+ this.scene.remove(r.model), this.disposeModel(r.model), r.model = this.getVehicleModel(s), r.model.visible = !0;
269
+ const c = await this.createPlateSprite(s);
207
270
  c && (r.model.add(c), c.position.set(0, 5, -4)), this.scene.add(r.model);
208
271
  }
209
- if (r.data.showName !== t.showName || r.data.plateColor !== t.plateColor) {
272
+ if (r.data.showName !== s.showName || r.data.plateColor !== s.plateColor) {
210
273
  const c = r.model.getObjectByName("VehiclePlate");
211
274
  c && (r.model.remove(c), this.disposeModel(c));
212
- const p = await this.createPlateSprite(t);
213
- p && (r.model.add(p), p.position.set(0, 5, -4));
275
+ const g = await this.createPlateSprite(s);
276
+ g && (r.model.add(g), g.position.set(0, 5, -4));
214
277
  }
215
- if (r.data = t, this.needInterpolate) {
216
- const c = m[m.length - 1];
217
- Math.abs(h - c.heading) >= 180 && (h > c.heading ? c.heading += 360 : h += 360), m.push({
218
- pos: [n, a, 0],
278
+ if (r.data = s, this.needInterpolate) {
279
+ const c = p[p.length - 1];
280
+ Math.abs(h - c.heading) >= 180 && (h > c.heading ? c.heading += 360 : h += 360), p.push({
281
+ pos: [o, d, 0],
219
282
  heading: h,
220
- time: s
283
+ time: n
221
284
  });
222
285
  } else {
223
- this.historyPositionMap.set(o, [
224
- { pos: [n, a, 0], heading: h, time: s }
286
+ this.historyPositionMap.set(a, [
287
+ { pos: [o, d, 0], heading: h, time: n }
225
288
  ]);
226
- const c = this.toRenderCoordinates([n, a, 0]);
289
+ const c = this.toRenderCoordinates([o, d, 0]);
227
290
  r.model.position.set(c[0], c[1], c[2]), r.model.rotation.y = l.MathUtils.degToRad(-h);
228
291
  }
229
292
  }
@@ -247,19 +310,45 @@ class N {
247
310
  * 删除车辆
248
311
  * */
249
312
  deleteVehicles(i) {
250
- this.isPaused || i.forEach((e) => {
251
- const t = this.vehicleObjectMap.get(e);
252
- t && (this.needInterpolate ? t.isMoving ? t.waitForDelete = !0 : this.deleteVehicle(t) : this.deleteVehicle(t));
313
+ if (this.isPaused)
314
+ return;
315
+ const e = Date.now();
316
+ i.forEach((t) => {
317
+ if (this.appDataStore.saveTrackLog) {
318
+ const a = this.historyPositionMap.get(t);
319
+ this.logTable.push([
320
+ t,
321
+ "",
322
+ "",
323
+ "",
324
+ "",
325
+ "",
326
+ "",
327
+ "",
328
+ "",
329
+ "",
330
+ "",
331
+ "",
332
+ "",
333
+ "",
334
+ "",
335
+ e,
336
+ a ? a.length : 0,
337
+ 2
338
+ ]);
339
+ }
340
+ const s = this.vehicleObjectMap.get(t);
341
+ s && (this.needInterpolate ? s.isMoving ? s.waitForDelete = !0 : this.deleteVehicle(s) : this.deleteVehicle(s));
253
342
  });
254
343
  }
255
344
  deleteVehicle(i) {
256
- this.vehiclePool.recycleInstance(i.model);
345
+ this.scene.remove(i.model), this.disposeModel(i.model);
257
346
  const e = i.data.vehicleId;
258
347
  this.vehicleObjectMap.delete(e), this.historyPositionMap.delete(e);
259
348
  }
260
349
  async toggleTrafficInfo(i) {
261
- i.name === "vehiclePlate" && (i.visible === !0 && this.currentSpriteContent === d.None ? await this.updatePanelContent(d.PlateNumber) : await this.updatePanelContent(
262
- i.visible ? this.currentSpriteContent : d.None
350
+ i.name === "vehiclePlate" && (i.visible === !0 && this.currentSpriteContent === m.None ? await this.updatePanelContent(m.PlateNumber) : await this.updatePanelContent(
351
+ i.visible ? this.currentSpriteContent : m.None
263
352
  ));
264
353
  }
265
354
  togglePause(i) {
@@ -271,7 +360,7 @@ class N {
271
360
  clearVehicles() {
272
361
  for (const i of this.vehicleObjectMap.keys()) {
273
362
  const e = this.vehicleObjectMap.get(i);
274
- e && this.vehiclePool.recycleInstance(e.model);
363
+ e && (this.scene.remove(e.model), this.disposeModel(e.model));
275
364
  }
276
365
  this.vehicleObjectMap.clear(), this.historyPositionMap.clear();
277
366
  }
@@ -286,10 +375,10 @@ class N {
286
375
  for (const e of this.vehicleObjectMap.keys()) {
287
376
  const t = this.vehicleObjectMap.get(e);
288
377
  if (t) {
289
- const o = t.model.getObjectByName("VehiclePlate");
290
- if (o && (t.model.remove(o), this.disposeModel(o)), i !== d.None) {
291
- const s = await this.createPlateSprite(t.data);
292
- s && (t.model.add(s), s.position.set(0, 5, -4));
378
+ const s = t.model.getObjectByName("VehiclePlate");
379
+ if (s && (t.model.remove(s), this.disposeModel(s)), i !== m.None) {
380
+ const a = await this.createPlateSprite(t.data);
381
+ a && (t.model.add(a), a.position.set(0, 5, -4));
293
382
  }
294
383
  }
295
384
  }
@@ -316,21 +405,24 @@ class N {
316
405
  const e = this.historyPositionMap.get(i), t = this.vehicleObjectMap.get(i);
317
406
  if (!t || !e || !t.isMoving && e.length <= 2)
318
407
  return;
319
- const o = Date.now();
320
- t.isMoving = !0, t.data.roadLayer === "1" ? t.model.visible = this.showGroundVehicle : t.model.visible = this.showElevatedVehicle, t.segmentStartTime || (t.segmentStartTime = o, t.segmentTotalTime = e[1].time - e[0].time);
321
- const s = o - t.segmentStartTime, n = Math.min(
322
- s / t.segmentTotalTime,
408
+ const s = Date.now();
409
+ 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);
410
+ const a = s - t.segmentStartTime, n = Math.min(
411
+ a / t.segmentTotalTime,
323
412
  1
324
413
  );
325
414
  if (n === 1)
326
415
  if (e.shift(), e.length === 1) {
327
416
  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));
328
417
  return;
329
- } else
330
- 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);
418
+ } else {
419
+ const o = a - t.segmentTotalTime;
420
+ return t.segmentStartTime = Date.now(), t.segmentTotalTime = e[1].time - e[0].time - // 补偿损耗时间
421
+ (o > 0 ? o : 0), (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);
422
+ }
331
423
  else if (e.length >= 2) {
332
- const a = e[0].pos[0] + (e[1].pos[0] - e[0].pos[0]) * n, h = e[0].pos[1] + (e[1].pos[1] - e[0].pos[1]) * n, r = e[0].heading + (e[1].heading - e[0].heading) * n;
333
- return [a, h, 0, r];
424
+ const o = e[0].pos[0] + (e[1].pos[0] - e[0].pos[0]) * n, d = e[0].pos[1] + (e[1].pos[1] - e[0].pos[1]) * n, h = e[0].heading + (e[1].heading - e[0].heading) * n;
425
+ return [o, d, 0, h];
334
426
  } else
335
427
  return;
336
428
  }
@@ -369,9 +461,9 @@ class N {
369
461
  break;
370
462
  }
371
463
  const t = this.materialMap.get(i.vehicleColor) || this.defaultMaterial;
372
- let o = !1;
373
- e.traverse((s) => {
374
- !o && s instanceof l.Mesh && (s.material = t, o = !0);
464
+ let s = !1;
465
+ e.traverse((a) => {
466
+ !s && a instanceof l.Mesh && (a.material = t, s = !0);
375
467
  });
376
468
  }
377
469
  return e;
@@ -381,70 +473,70 @@ class N {
381
473
  * 创建号牌canvas
382
474
  * */
383
475
  createCanvas(i, e, t) {
384
- const o = document.createElement("canvas"), s = i.width, n = i.height;
385
- o.width = s, o.height = n;
386
- const a = o.getContext("2d");
387
- if (!a) {
476
+ const s = document.createElement("canvas"), a = i.width, n = i.height;
477
+ s.width = a, s.height = n;
478
+ const o = s.getContext("2d");
479
+ if (!o) {
388
480
  console.log("canvas创建失败");
389
481
  return;
390
482
  }
391
- return a.fillStyle = "rgba(0,0,0,0.0)", a.fillRect(0, 0, s, n), a.drawImage(i, 0, 0, s, n), a.beginPath(), a.translate(s / 2, n / 2), a.fillStyle = t, a.font = "bold 32px 宋体", a.textBaseline = "middle", a.textAlign = "center", a.fillText(e, 0, 0), o;
483
+ return o.fillStyle = "rgba(0,0,0,0.0)", o.fillRect(0, 0, a, n), o.drawImage(i, 0, 0, a, n), o.beginPath(), o.translate(a / 2, n / 2), o.fillStyle = t, o.font = "bold 32px 宋体", o.textBaseline = "middle", o.textAlign = "center", o.fillText(e, 0, 0), s;
392
484
  }
393
485
  createPlateSprite(i) {
394
486
  return new Promise((e, t) => {
395
- var r, m;
396
- const o = !i.plateNo || i.plateNo === "0" || i.plateNo === "000000";
397
- if (this.currentSpriteContent === d.None || this.currentSpriteContent === d.PlateNumber && o) {
487
+ var h, r;
488
+ const s = !i.plateNo || i.plateNo === "0" || i.plateNo === "000000";
489
+ if (this.currentSpriteContent === m.None || this.currentSpriteContent === m.PlateNumber && s) {
398
490
  e(void 0);
399
491
  return;
400
492
  }
401
- let s = new Image(), n = "", a = "";
402
- if (this.currentSpriteContent === d.PlateNumber || this.currentSpriteContent === d.Mix)
403
- if (o)
404
- s = this.greyPlateBG, n = i.ptcId, a = "#ffffff";
493
+ let a = new Image(), n = "", o = "";
494
+ if (this.currentSpriteContent === m.PlateNumber || this.currentSpriteContent === m.Mix)
495
+ if (s)
496
+ a = this.greyPlateBG, n = i.ptcId, o = "#ffffff";
405
497
  else
406
- switch (n = ((r = i.showName) == null ? void 0 : r.substring(0, 2)) + "•" + ((m = i.showName) == null ? void 0 : m.substring(2)), i.plateColor) {
498
+ switch (n = ((h = i.showName) == null ? void 0 : h.substring(0, 2)) + "•" + ((r = i.showName) == null ? void 0 : r.substring(2)), i.plateColor) {
407
499
  case 1:
408
- s = this.bluePlateBG, a = "#ffffff";
500
+ a = this.bluePlateBG, o = "#ffffff";
409
501
  break;
410
502
  case 2:
411
- s = this.yellowPlateBG, a = "#000000";
503
+ a = this.yellowPlateBG, o = "#000000";
412
504
  break;
413
505
  case 3:
414
- s = this.whitePlateBG, a = "#000000";
506
+ a = this.whitePlateBG, o = "#000000";
415
507
  break;
416
508
  case 4:
417
- s = this.blackPlateBG, a = "#ffffff";
509
+ a = this.blackPlateBG, o = "#ffffff";
418
510
  break;
419
511
  case 5:
420
- s = this.neoYellowPlateBG, a = "#000000";
512
+ a = this.neoYellowPlateBG, o = "#000000";
421
513
  break;
422
514
  case 6:
423
- s = this.neoGreenPlateBG, a = "#000000";
515
+ a = this.neoGreenPlateBG, o = "#000000";
424
516
  break;
425
517
  default:
426
- s = this.greyPlateBG, n = i.plateNo, a = "#ffffff";
518
+ a = this.greyPlateBG, n = i.plateNo, o = "#ffffff";
427
519
  break;
428
520
  }
429
521
  else
430
- this.currentSpriteContent === d.Id && (s = this.greyPlateBG, n = i.ptcId, a = "#ffffff");
431
- const h = this.createCanvas(s, n, a);
432
- if (h) {
433
- const c = new l.CanvasTexture(h), p = new l.SpriteMaterial({
434
- map: c,
522
+ this.currentSpriteContent === m.Id && (a = this.greyPlateBG, n = i.ptcId, o = "#ffffff");
523
+ const d = this.createCanvas(a, n, o);
524
+ if (d) {
525
+ const p = new l.CanvasTexture(d), c = new l.SpriteMaterial({
526
+ map: p,
435
527
  transparent: !1
436
- }), g = new l.Sprite(p), f = 0.05, M = h.width * f, P = h.height * f;
437
- g.scale.set(M, P, 1), g.name = "VehiclePlate", e(g);
528
+ }), g = new l.Sprite(c), f = 0.05, w = d.width * f, M = d.height * f;
529
+ g.scale.set(w, M, 1), g.name = "VehiclePlate", e(g);
438
530
  } else {
439
531
  t("canvas创建失败");
440
532
  return;
441
533
  }
442
- s.onerror = (c) => {
443
- console.log(`号牌背景加载失败: ${s.src}`, c), t(c);
534
+ a.onerror = (p) => {
535
+ console.log(`号牌背景加载失败: ${a.src}`, p), t(p);
444
536
  };
445
537
  });
446
538
  }
447
539
  }
448
540
  export {
449
- N as default
541
+ I as default
450
542
  };
@@ -4,7 +4,10 @@ export default class TraceRendererLayer implements ITraceRendererInterface {
4
4
  private readonly vehicleLayer;
5
5
  private mapConfig;
6
6
  private rafSignal;
7
+ private appDataStore;
8
+ private logTable;
7
9
  constructor(view: __esri.MapView);
10
+ getLog(): (string | number)[][];
8
11
  init(): Promise<void>;
9
12
  private needInterpolate;
10
13
  private isPaused;
@@ -3,12 +3,39 @@ import p from "@arcgis/core/layers/GraphicsLayer";
3
3
  import m from "../../stores/index.mjs";
4
4
  class f {
5
5
  constructor(i) {
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({
6
+ this.appDataStore = m.useAppDataStore, this.logTable = [
7
+ [
8
+ "uuid",
9
+ "ptcId",
10
+ "plateno",
11
+ "timestamp",
12
+ "localTimestamp",
13
+ "timestamp_str",
14
+ "speed",
15
+ "laneNo",
16
+ "objHeight",
17
+ "objLength",
18
+ "latitude",
19
+ "longitude",
20
+ "ptcType",
21
+ "vehicleType",
22
+ "vehicleColor",
23
+ "plateColor",
24
+ "sbdm",
25
+ "heading",
26
+ "fixAngle",
27
+ "roadLayer",
28
+ "status",
29
+ "step",
30
+ "receiveTimestamp"
31
+ ]
32
+ ], 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, this.mapConfig = JSON.parse(JSON.stringify(this.appDataStore.mapConfig)), this.vehicleLayer = new p({
9
33
  id: "vehicleLayer"
10
34
  }), this.view.map.add(this.vehicleLayer), this.rafSignal = requestAnimationFrame(() => this.render());
11
35
  }
36
+ getLog() {
37
+ return this.logTable;
38
+ }
12
39
  async init() {
13
40
  console.log("init");
14
41
  }
@@ -19,27 +46,27 @@ class f {
19
46
  return;
20
47
  }
21
48
  const t = i.map((s) => {
22
- const { vehicleId: o, heading: a, localTimestamp: h } = s, r = Number(s.x), n = Number(s.y);
49
+ const { vehicleId: o, heading: a, localTimestamp: h } = s, r = Number(s.x), l = Number(s.y);
23
50
  this.historyPositionMap.set(o, [
24
- { pos: [r, n, 0], heading: a, time: h }
51
+ { pos: [r, l, 0], heading: a, time: h }
25
52
  ]);
26
- const l = new c({
53
+ const n = new c({
27
54
  geometry: {
28
55
  type: "point",
29
56
  x: r,
30
- y: n
57
+ y: l
31
58
  },
32
59
  attributes: {
33
60
  ...s
34
61
  },
35
62
  symbol: this.createCIMSymbol(s)
36
63
  });
37
- return l.visible = !1, this.vehicleObjectMap.set(o, {
38
- graphic: l,
64
+ return n.visible = !1, this.vehicleObjectMap.set(o, {
65
+ graphic: n,
39
66
  data: s,
40
67
  waitForDelete: !1,
41
68
  isMoving: !1
42
- }), l;
69
+ }), n;
43
70
  });
44
71
  this.vehicleLayer.addMany(t), e();
45
72
  });
@@ -52,11 +79,11 @@ class f {
52
79
  }
53
80
  const t = [];
54
81
  i.forEach((s) => {
55
- const { vehicleId: o, heading: a, localTimestamp: h } = s, r = Number(s.x), n = Number(s.y), l = this.vehicleObjectMap.get(o);
56
- l ? (l.data = s, this.historyPositionMap.get(
82
+ const { vehicleId: o, heading: a, localTimestamp: h } = s, r = Number(s.x), l = Number(s.y), n = this.vehicleObjectMap.get(o);
83
+ n ? (n.data = s, this.historyPositionMap.get(
57
84
  o
58
85
  ).push({
59
- pos: [r, n, 0],
86
+ pos: [r, l, 0],
60
87
  heading: a,
61
88
  time: h
62
89
  })) : t.push(s);
@@ -123,12 +150,12 @@ class f {
123
150
  y: e[0].pos[1]
124
151
  };
125
152
  else {
126
- 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;
153
+ 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, l = e[0].heading + (e[1].heading - e[0].heading) * a;
127
154
  t.graphic.geometry = {
128
155
  type: "point",
129
156
  x: h,
130
157
  y: r
131
- }, t.data.heading = n, t.graphic.symbol = this.createCIMSymbol(t.data);
158
+ }, t.data.heading = l, t.graphic.symbol = this.createCIMSymbol(t.data);
132
159
  }
133
160
  }
134
161
  /**
@@ -37,6 +37,7 @@ export interface IVehicleTrack {
37
37
  speed?: number;
38
38
  plateNo?: string;
39
39
  roadLayer?: string;
40
+ step?: number;
40
41
  }
41
42
  export interface IVehicleRecord {
42
43
  model: Three.Group | Three.Mesh;
@@ -151,6 +152,7 @@ export interface IToggleTrafficInfoParams {
151
152
  }
152
153
  export interface ITraceRendererInterface {
153
154
  init(): Promise<void>;
155
+ getLog(): (string | number | undefined)[][];
154
156
  addVehicles(objects: IVehicleTrack[]): Promise<void>;
155
157
  updateVehicles(objects: IVehicleTrack[]): Promise<void>;
156
158
  deleteVehicles(idList: string[]): void;
@@ -3,8 +3,6 @@ export default class TraceHoloFlow {
3
3
  private readonly traceRenderer;
4
4
  constructor(view: __esri.View);
5
5
  init(): Promise<void>;
6
- private appDataStore;
7
- private logTable;
8
6
  downloadLog(): void;
9
7
  /**
10
8
  * 处理全息流轨迹数据
@@ -1,2 +1,2 @@
1
- "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const g=require("@arcgis/core/views/3d/externalRenderers"),m=require("../../stores/index.js"),b=require("./trace-renderer-external.js"),f=require("./trace-renderer-layer.js");function T(l){const e=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(l){for(const r in l)if(r!=="default"){const n=Object.getOwnPropertyDescriptor(l,r);Object.defineProperty(e,r,n.get?n:{enumerable:!0,get:()=>l[r]})}}return e.default=l,Object.freeze(e)}const y=T(g);class v{constructor(e){this.appDataStore=m.default.useAppDataStore,this.logTable=[["uuid","ptcId","plateno","timestamp","localTimestamp","timestamp_str","speed","laneNo","objHeight","objLength","latitude","longitude","ptcType","vehicleType","vehicleColor","plateColor","sbdm","heading","fixAngle","roadLayer","status","step","receiveTimestamp"]],e.type==="3d"?(this.traceRenderer=new b.default(e),y.add(e,this.traceRenderer)):this.traceRenderer=new f.default(e)}async init(){await this.traceRenderer.init()}downloadLog(){const e=this.logTable.map(c=>c.join(",")).join(`
2
- `).replace(/null/g,""),r=new Blob([e],{type:"text/csv;charset=utf-8;"}),n=URL.createObjectURL(r),a=document.createElement("a");a.setAttribute("href",n),a.setAttribute("download","trace-log.csv"),a.style.visibility="hidden",document.body.appendChild(a),a.click(),document.body.removeChild(a)}async handleVehicleTraceData(e){const{newVehList:r,updateVehList:n,deleteVehList:a,jgsj:c}=e,i=e.crossId||"",s=[],d=[],h=Date.now();if(r&&r.length>0){for(const t of r){t.localTimestamp||(t.localTimestamp=c||Date.now()),this.appDataStore.saveTrackLog&&this.logTable.push([t.uuid,t.ptcId,t.plateno,t.timestamp,t.localTimestamp,t.timestamp_str,t.speed,t.laneNo,t.objHeight,t.objLength,t.latitude,t.longitude,t.ptcType,t.vehicleType,t.vehicleColor,t.plateColor,t.sbdm,t.heading,t.fixAngle,t.roadLayer,t.status,t.step,h]);const o=this.buildVehicleTrackData(t,i);o&&s.push(o)}await this.traceRenderer.addVehicles(s)}if(n&&n.length>0){const t=Date.now();for(const o of n){this.appDataStore.saveTrackLog&&this.logTable.push([o.uuid,o.ptcId,o.plateno,o.timestamp,o.localTimestamp,o.timestamp_str,o.speed,o.laneNo,o.objHeight,o.objLength,o.latitude,o.longitude,o.ptcType,o.vehicleType,o.vehicleColor,o.plateColor,o.sbdm,o.heading,o.fixAngle,o.roadLayer,o.status,o.step,t]);const p=this.buildVehicleTrackData(o,i);p&&d.push(p)}await this.traceRenderer.updateVehicles(d)}if(a&&a.length>0){const t=a.map(o=>i+"-"+(o.ptcId||o.vehno||o.vehNo));this.traceRenderer.deleteVehicles(t)}}toggleTrafficInfo(e){this.traceRenderer.toggleTrafficInfo(e)}clearTrace(){this.traceRenderer.clearVehicles()}togglePause(e){this.traceRenderer.togglePause(e)}updatePanelContent(e){this.traceRenderer.updatePanelContent(e)}toggleGroundVehicle(e){this.traceRenderer.toggleGroundVehicle(e)}toggleElevatedVehicle(e){this.traceRenderer.toggleElevatedVehicle(e)}setInterpolate(e){this.traceRenderer.setInterpolate(e)}buildVehicleTrackData(e,r){const n=e.longitude,a=e.latitude,c=e.ptcId,i=Number(e.ptcType),s=e.heading,d=Number(e.vehicleType),h=Number(e.vehicleColor),t=e.plateNo||e.plateno,o=Number(e.plateColor),p=e.timestamp,u=e.roadLayer?String(e.roadLayer):"1";if(!(i<0||i>8))return{ptcId:c,crossId:r,vehicleId:r+"-"+c,x:n,y:a,ptcType:i,vehicleType:d,heading:i===2?-s:s,vehicleColor:h,showName:t&&t!==""&&t!=="0"&&t!=="000000"?t:"",plateNo:t,plateColor:o,timestamp:p,localTimestamp:Date.now(),roadLayer:u}}}exports.default=v;
1
+ "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const m=require("@arcgis/core/views/3d/externalRenderers"),b=require("./trace-renderer-external.js"),y=require("./trace-renderer-layer.js");function R(i){const e=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(i){for(const r in i)if(r!=="default"){const n=Object.getOwnPropertyDescriptor(i,r);Object.defineProperty(e,r,n.get?n:{enumerable:!0,get:()=>i[r]})}}return e.default=i,Object.freeze(e)}const T=R(m);class v{constructor(e){e.type==="3d"?(this.traceRenderer=new b.default(e),T.add(e,this.traceRenderer)):this.traceRenderer=new y.default(e)}async init(){await this.traceRenderer.init()}downloadLog(){const e=this.traceRenderer.getLog().map(s=>s.join(",")).join(`
2
+ `).replace(/null/g,""),r=new Blob([e],{type:"text/csv;charset=utf-8;"}),n=URL.createObjectURL(r),c=document.createElement("a");c.setAttribute("href",n),c.setAttribute("download","trace-log.csv"),c.style.visibility="hidden",document.body.appendChild(c),c.click(),document.body.removeChild(c)}async handleVehicleTraceData(e){const{newVehList:r,updateVehList:n,deleteVehList:c,jgsj:s}=e,l=e.crossId||"",a=[],d=[];if(r&&r.length>0){for(const o of r){o.localTimestamp||(o.localTimestamp=s||Date.now());const t=this.buildVehicleTrackData(o,l);t&&a.push(t)}await this.traceRenderer.addVehicles(a)}if(n&&n.length>0){for(const o of n){const t=this.buildVehicleTrackData(o,l);t&&d.push(t)}await this.traceRenderer.updateVehicles(d)}if(c&&c.length>0){const o=c.map(t=>l+"-"+(t.ptcId||t.vehno||t.vehNo));this.traceRenderer.deleteVehicles(o)}}toggleTrafficInfo(e){this.traceRenderer.toggleTrafficInfo(e)}clearTrace(){this.traceRenderer.clearVehicles()}togglePause(e){this.traceRenderer.togglePause(e)}updatePanelContent(e){this.traceRenderer.updatePanelContent(e)}toggleGroundVehicle(e){this.traceRenderer.toggleGroundVehicle(e)}toggleElevatedVehicle(e){this.traceRenderer.toggleElevatedVehicle(e)}setInterpolate(e){this.traceRenderer.setInterpolate(e)}buildVehicleTrackData(e,r){const n=e.longitude,c=e.latitude,s=e.ptcId,l=Number(e.ptcType),a=e.heading,d=Number(e.vehicleType),o=Number(e.vehicleColor),t=e.plateNo||e.plateno,h=Number(e.plateColor),u=e.timestamp,p=e.localTimestamp,g=e.roadLayer?String(e.roadLayer):"1",f=e.step;if(!(l<0||l>8))return{ptcId:s,crossId:r,vehicleId:r+"-"+s,x:n,y:c,ptcType:l,vehicleType:d,heading:l===2?-a:a,vehicleColor:o,showName:t&&t!==""&&t!=="0"&&t!=="000000"?t:"",plateNo:t,plateColor:h,timestamp:u,localTimestamp:p,roadLayer:g,step:f}}}exports.default=v;