gisviewer-vue3-arcgis 1.0.105 → 1.0.106
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 +3 -0
- package/es/src/gis-map/utils/holo-flow/trace-renderer-external.mjs +90 -80
- 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 +3 -0
- 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,13 +1,13 @@
|
|
|
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.zoomThreshold =
|
|
10
|
+
this.zoomThreshold = 1e3, this.roughness = 0.2, this.metalness = 0.8, this.defaultMaterial = new h.MeshPhysicalMaterial({
|
|
11
11
|
color: 16777215,
|
|
12
12
|
emissive: 0,
|
|
13
13
|
roughness: this.roughness,
|
|
@@ -24,8 +24,8 @@ class k {
|
|
|
24
24
|
[9, this.createCarMaterial(2105376)],
|
|
25
25
|
[10, this.createCarMaterial(9662683)],
|
|
26
26
|
[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 =
|
|
27
|
+
]), 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;
|
|
28
|
+
const e = P.useAppDataStore;
|
|
29
29
|
this.assetsRoot = JSON.parse(
|
|
30
30
|
JSON.stringify(e.mapConfig)
|
|
31
31
|
).assetsRoot, this.view = i;
|
|
@@ -47,7 +47,7 @@ class k {
|
|
|
47
47
|
},
|
|
48
48
|
!1
|
|
49
49
|
), y.watch(
|
|
50
|
-
() => this.view.
|
|
50
|
+
() => this.view.camera.position.z,
|
|
51
51
|
(s, o) => {
|
|
52
52
|
(o <= this.zoomThreshold && s > this.zoomThreshold || o > this.zoomThreshold && s <= this.zoomThreshold) && (this.updateModel = !0);
|
|
53
53
|
}
|
|
@@ -75,8 +75,8 @@ class k {
|
|
|
75
75
|
const e = this.renderer.setRenderTarget.bind(
|
|
76
76
|
this.renderer
|
|
77
77
|
);
|
|
78
|
-
this.renderer.setRenderTarget = (
|
|
79
|
-
e(
|
|
78
|
+
this.renderer.setRenderTarget = (n) => {
|
|
79
|
+
e(n), n == null && i.bindRenderTarget();
|
|
80
80
|
}, this.scene = new h.Scene();
|
|
81
81
|
const { camera: t } = i;
|
|
82
82
|
this.camera = new h.PerspectiveCamera(
|
|
@@ -85,11 +85,17 @@ class k {
|
|
|
85
85
|
0.1,
|
|
86
86
|
1e5
|
|
87
87
|
), this.ambient = new h.AmbientLight(16777215, 2e4), this.scene.add(this.ambient), this.sun = new h.DirectionalLight(16777215, 2e4);
|
|
88
|
-
const s = [121.
|
|
88
|
+
const s = [121.51925377934634, 31.893973071723785, 1e4], o = this.toRenderCoordinates(s);
|
|
89
89
|
this.sun.position.set(
|
|
90
90
|
o[0],
|
|
91
91
|
o[1],
|
|
92
92
|
o[2]
|
|
93
|
+
);
|
|
94
|
+
const r = [121.46790813287619, 31.239514870157972, 1e3], a = this.toRenderCoordinates(r);
|
|
95
|
+
this.sun.target.position.set(
|
|
96
|
+
a[0],
|
|
97
|
+
a[1],
|
|
98
|
+
a[2]
|
|
93
99
|
), this.scene.add(this.sun), i.resetWebGLState();
|
|
94
100
|
}
|
|
95
101
|
async render(i) {
|
|
@@ -97,15 +103,15 @@ class k {
|
|
|
97
103
|
const e = i.camera;
|
|
98
104
|
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
105
|
new h.Vector3(e.center[0], e.center[1], e.center[2])
|
|
100
|
-
), this.camera.projectionMatrix.fromArray(e.projectionMatrix), this.needInterpolate)
|
|
106
|
+
), this.camera.projectionMatrix.fromArray(e.projectionMatrix), !this.isPaused && this.needInterpolate)
|
|
101
107
|
for (const o of this.vehicleObjectMap.keys()) {
|
|
102
|
-
const
|
|
103
|
-
if (!
|
|
108
|
+
const r = (s = this.vehicleObjectMap.get(o)) == null ? void 0 : s.model;
|
|
109
|
+
if (!r)
|
|
104
110
|
continue;
|
|
105
|
-
const
|
|
106
|
-
if (
|
|
107
|
-
const n = this.toRenderCoordinates(
|
|
108
|
-
|
|
111
|
+
const a = this.computeVehiclePosition(o);
|
|
112
|
+
if (a) {
|
|
113
|
+
const n = this.toRenderCoordinates(a);
|
|
114
|
+
r.position.set(n[0], n[1], n[2]), r.rotation.y = h.MathUtils.degToRad(-a[3]);
|
|
109
115
|
}
|
|
110
116
|
}
|
|
111
117
|
const t = i.sunLight;
|
|
@@ -117,45 +123,48 @@ class k {
|
|
|
117
123
|
t.ambient.color[0],
|
|
118
124
|
t.ambient.color[1],
|
|
119
125
|
t.ambient.color[2]
|
|
120
|
-
), this.renderer.resetState(), i.bindRenderTarget(), this.renderer.render(this.scene, this.camera),
|
|
126
|
+
), this.renderer.resetState(), i.bindRenderTarget(), this.renderer.render(this.scene, this.camera), g.requestRender(this.view), i.resetWebGLState();
|
|
121
127
|
}
|
|
122
128
|
/**
|
|
123
129
|
* 新增车辆
|
|
124
130
|
* */
|
|
125
131
|
async addVehicles(i) {
|
|
126
|
-
if (!(!this.carModelReady || !this.vanModelReady || !this.truckModelReady || !this.busModelReady || !this.bicycleModelReady))
|
|
132
|
+
if (!(this.isPaused || !this.carModelReady || !this.vanModelReady || !this.truckModelReady || !this.busModelReady || !this.bicycleModelReady))
|
|
127
133
|
for (const e of i) {
|
|
128
|
-
const { vehicleId: t, localTimestamp: s } = e, o = Number(e.x),
|
|
134
|
+
const { vehicleId: t, localTimestamp: s } = e, o = Number(e.x), r = Number(e.y), a = Number(e.heading);
|
|
129
135
|
this.historyPositionMap.set(t, [
|
|
130
|
-
{ pos: [o,
|
|
136
|
+
{ pos: [o, r, 0], heading: a, time: s }
|
|
131
137
|
]);
|
|
132
138
|
const n = this.getVehicleModel(e);
|
|
133
139
|
n.name = t, n.visible = !this.needInterpolate;
|
|
134
140
|
try {
|
|
135
141
|
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
|
-
});
|
|
142
|
+
l && (n.add(l), l.position.set(0, 5, -4));
|
|
142
143
|
} catch (l) {
|
|
143
144
|
console.log("createPlateSprite error:", l);
|
|
144
145
|
}
|
|
146
|
+
this.scene.add(n), this.vehicleObjectMap.set(t, {
|
|
147
|
+
model: n,
|
|
148
|
+
data: e,
|
|
149
|
+
waitForDelete: !1,
|
|
150
|
+
isMoving: !1
|
|
151
|
+
});
|
|
145
152
|
}
|
|
146
153
|
}
|
|
147
154
|
/**
|
|
148
155
|
* 更新车辆
|
|
149
156
|
* */
|
|
150
157
|
async updateVehicles(i) {
|
|
151
|
-
if (!this.carModelReady || !this.vanModelReady || !this.truckModelReady || !this.busModelReady || !this.bicycleModelReady)
|
|
158
|
+
if (this.isPaused || !this.carModelReady || !this.vanModelReady || !this.truckModelReady || !this.busModelReady || !this.bicycleModelReady)
|
|
152
159
|
return;
|
|
153
160
|
const e = [];
|
|
154
161
|
for (const t of i) {
|
|
155
|
-
const { vehicleId: s, localTimestamp: o } = t,
|
|
162
|
+
const { vehicleId: s, localTimestamp: o } = t, r = Number(t.x), a = Number(t.y);
|
|
156
163
|
let n = Number(t.heading);
|
|
157
|
-
const l = this.vehicleObjectMap.get(s)
|
|
158
|
-
|
|
164
|
+
const l = this.vehicleObjectMap.get(s), m = this.historyPositionMap.get(
|
|
165
|
+
s
|
|
166
|
+
);
|
|
167
|
+
if (!l || !m)
|
|
159
168
|
e.push(t);
|
|
160
169
|
else {
|
|
161
170
|
if (this.updateModel || l.data.vehicleColor !== t.vehicleColor || l.data.vehicleType !== t.vehicleType) {
|
|
@@ -166,32 +175,30 @@ class k {
|
|
|
166
175
|
if (l.data.showName !== t.showName || l.data.plateColor !== t.plateColor) {
|
|
167
176
|
const c = l.model.getObjectByName("VehiclePlate");
|
|
168
177
|
c && (l.model.remove(c), this.disposeModel(c));
|
|
169
|
-
const
|
|
170
|
-
|
|
178
|
+
const p = await this.createPlateSprite(t);
|
|
179
|
+
p && (l.model.add(p), p.position.set(0, 5, -4));
|
|
171
180
|
}
|
|
172
181
|
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],
|
|
182
|
+
const c = m[m.length - 1];
|
|
183
|
+
Math.abs(n - c.heading) >= 180 && (n > c.heading ? c.heading += 360 : n += 360), m.push({
|
|
184
|
+
pos: [r, a, 0],
|
|
178
185
|
heading: n,
|
|
179
186
|
time: o
|
|
180
187
|
});
|
|
181
188
|
} else {
|
|
182
189
|
this.historyPositionMap.set(s, [
|
|
183
|
-
{ pos: [
|
|
190
|
+
{ pos: [r, a, 0], heading: n, time: o }
|
|
184
191
|
]);
|
|
185
|
-
const c = this.toRenderCoordinates([
|
|
192
|
+
const c = this.toRenderCoordinates([r, a, 0]);
|
|
186
193
|
l.model.position.set(c[0], c[1], c[2]), l.model.rotation.y = h.MathUtils.degToRad(-n);
|
|
187
194
|
}
|
|
188
195
|
}
|
|
189
196
|
}
|
|
190
|
-
this.addVehicles(e), this.updateModel = !1, this.needInterpolate || this.render(this.context);
|
|
197
|
+
await this.addVehicles(e), this.updateModel = !1, this.needInterpolate || this.render(this.context);
|
|
191
198
|
}
|
|
192
199
|
toRenderCoordinates(i) {
|
|
193
200
|
const e = [0, 0, 0];
|
|
194
|
-
return
|
|
201
|
+
return g.toRenderCoordinates(
|
|
195
202
|
// @ts-ignore
|
|
196
203
|
this.view,
|
|
197
204
|
i,
|
|
@@ -206,7 +213,7 @@ class k {
|
|
|
206
213
|
* 删除车辆
|
|
207
214
|
* */
|
|
208
215
|
deleteVehicles(i) {
|
|
209
|
-
i.forEach((e) => {
|
|
216
|
+
this.isPaused || i.forEach((e) => {
|
|
210
217
|
const t = this.vehicleObjectMap.get(e);
|
|
211
218
|
t && (this.needInterpolate ? t.isMoving ? t.waitForDelete = !0 : this.deleteVehicle(t) : this.deleteVehicle(t));
|
|
212
219
|
});
|
|
@@ -217,10 +224,13 @@ class k {
|
|
|
217
224
|
this.vehicleObjectMap.delete(e), this.historyPositionMap.delete(e);
|
|
218
225
|
}
|
|
219
226
|
async toggleTrafficInfo(i) {
|
|
220
|
-
i.name === "vehiclePlate" && (i.visible === !0 && this.currentSpriteContent ===
|
|
221
|
-
i.visible ? this.currentSpriteContent :
|
|
227
|
+
i.name === "vehiclePlate" && (i.visible === !0 && this.currentSpriteContent === d.None ? await this.updatePanelContent(d.PlateNumber) : await this.updatePanelContent(
|
|
228
|
+
i.visible ? this.currentSpriteContent : d.None
|
|
222
229
|
));
|
|
223
230
|
}
|
|
231
|
+
togglePause(i) {
|
|
232
|
+
this.isPaused = i;
|
|
233
|
+
}
|
|
224
234
|
/**
|
|
225
235
|
* 清除全部车辆
|
|
226
236
|
* */
|
|
@@ -243,7 +253,7 @@ class k {
|
|
|
243
253
|
const t = this.vehicleObjectMap.get(e);
|
|
244
254
|
if (t) {
|
|
245
255
|
const s = t.model.getObjectByName("VehiclePlate");
|
|
246
|
-
if (s && (t.model.remove(s), this.disposeModel(s)), i !==
|
|
256
|
+
if (s && (t.model.remove(s), this.disposeModel(s)), i !== d.None) {
|
|
247
257
|
const o = await this.createPlateSprite(t.data);
|
|
248
258
|
o && (t.model.add(o), o.position.set(0, 5, -4));
|
|
249
259
|
}
|
|
@@ -274,26 +284,26 @@ class k {
|
|
|
274
284
|
return;
|
|
275
285
|
const s = Date.now();
|
|
276
286
|
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 o = s - t.segmentStartTime,
|
|
287
|
+
const o = s - t.segmentStartTime, r = Math.min(
|
|
278
288
|
o / t.segmentTotalTime,
|
|
279
289
|
1
|
|
280
290
|
);
|
|
281
|
-
if (
|
|
291
|
+
if (r === 1)
|
|
282
292
|
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("
|
|
293
|
+
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
294
|
return;
|
|
285
295
|
} else
|
|
286
296
|
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
297
|
else {
|
|
288
|
-
const
|
|
289
|
-
return [
|
|
298
|
+
const a = 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;
|
|
299
|
+
return [a, n, 0, l];
|
|
290
300
|
}
|
|
291
301
|
}
|
|
292
302
|
/**
|
|
293
303
|
* 根据车辆类型、车身颜色获取模型
|
|
294
304
|
* */
|
|
295
305
|
getVehicleModel(i) {
|
|
296
|
-
if (this.view.
|
|
306
|
+
if (this.view.camera.position.z >= this.zoomThreshold) {
|
|
297
307
|
const e = new h.SphereGeometry(5, 32, 32), t = new h.MeshPhysicalMaterial({
|
|
298
308
|
color: 325253,
|
|
299
309
|
emissive: 0,
|
|
@@ -336,67 +346,67 @@ class k {
|
|
|
336
346
|
* 创建号牌canvas
|
|
337
347
|
* */
|
|
338
348
|
createCanvas(i, e, t) {
|
|
339
|
-
const s = document.createElement("canvas"), o = i.width,
|
|
340
|
-
s.width = o, s.height =
|
|
341
|
-
const
|
|
342
|
-
if (!
|
|
349
|
+
const s = document.createElement("canvas"), o = i.width, r = i.height;
|
|
350
|
+
s.width = o, s.height = r;
|
|
351
|
+
const a = s.getContext("2d");
|
|
352
|
+
if (!a) {
|
|
343
353
|
console.log("canvas创建失败");
|
|
344
354
|
return;
|
|
345
355
|
}
|
|
346
|
-
return
|
|
356
|
+
return a.fillStyle = "rgba(0,0,0,0.0)", a.fillRect(0, 0, o, r), a.drawImage(i, 0, 0, o, r), a.beginPath(), a.translate(o / 2, r / 2), a.fillStyle = t, a.font = "bold 32px 宋体", a.textBaseline = "middle", a.textAlign = "center", a.fillText(e, 0, 0), s;
|
|
347
357
|
}
|
|
348
358
|
createPlateSprite(i) {
|
|
349
359
|
return new Promise((e, t) => {
|
|
350
|
-
var l,
|
|
360
|
+
var l, m;
|
|
351
361
|
const s = !i.plateNo || i.plateNo === "0" || i.plateNo === "000000";
|
|
352
|
-
if (this.currentSpriteContent ===
|
|
362
|
+
if (this.currentSpriteContent === d.None || this.currentSpriteContent === d.PlateNumber && s) {
|
|
353
363
|
e(void 0);
|
|
354
364
|
return;
|
|
355
365
|
}
|
|
356
366
|
const o = new Image();
|
|
357
|
-
let
|
|
358
|
-
if (this.currentSpriteContent ===
|
|
367
|
+
let r = "", a = "", n = "";
|
|
368
|
+
if (this.currentSpriteContent === d.PlateNumber || this.currentSpriteContent === d.Mix)
|
|
359
369
|
if (s)
|
|
360
|
-
|
|
370
|
+
r = "grey", a = i.ptcId, n = "#ffffff";
|
|
361
371
|
else
|
|
362
|
-
switch (
|
|
372
|
+
switch (a = ((l = i.showName) == null ? void 0 : l.substring(0, 2)) + "•" + ((m = i.showName) == null ? void 0 : m.substring(2)), i.plateColor) {
|
|
363
373
|
case 1:
|
|
364
|
-
|
|
374
|
+
r = "blue", n = "#ffffff";
|
|
365
375
|
break;
|
|
366
376
|
case 2:
|
|
367
|
-
|
|
377
|
+
r = "yellow", n = "#000000";
|
|
368
378
|
break;
|
|
369
379
|
case 3:
|
|
370
|
-
|
|
380
|
+
r = "white", n = "#000000";
|
|
371
381
|
break;
|
|
372
382
|
case 4:
|
|
373
|
-
|
|
383
|
+
r = "black";
|
|
374
384
|
break;
|
|
375
385
|
case 5:
|
|
376
|
-
|
|
386
|
+
r = "neo_yellow", n = "#000000";
|
|
377
387
|
break;
|
|
378
388
|
case 6:
|
|
379
|
-
|
|
389
|
+
r = "neo_green", n = "#000000";
|
|
380
390
|
break;
|
|
381
391
|
default:
|
|
382
|
-
|
|
392
|
+
r = "grey", a = i.plateNo, n = "#ffffff";
|
|
383
393
|
break;
|
|
384
394
|
}
|
|
385
395
|
else
|
|
386
|
-
this.currentSpriteContent ===
|
|
387
|
-
o.src = `${this.assetsRoot}/Images/PlateBG/${
|
|
388
|
-
const
|
|
389
|
-
if (!
|
|
396
|
+
this.currentSpriteContent === d.Id && (r = "grey", a = i.ptcId, n = "#ffffff");
|
|
397
|
+
o.src = `${this.assetsRoot}/Images/PlateBG/${r}.png`, o.onload = () => {
|
|
398
|
+
const c = this.createCanvas(o, a, n);
|
|
399
|
+
if (!c)
|
|
390
400
|
t("canvas创建失败");
|
|
391
401
|
else {
|
|
392
|
-
const
|
|
393
|
-
map:
|
|
402
|
+
const p = new h.CanvasTexture(c), M = new h.SpriteMaterial({
|
|
403
|
+
map: p,
|
|
394
404
|
transparent: !1
|
|
395
|
-
}),
|
|
396
|
-
|
|
405
|
+
}), u = new h.Sprite(M), f = 0.05, b = c.width * f, v = c.height * f;
|
|
406
|
+
u.scale.set(b, v, 1), u.name = "VehiclePlate", e(u);
|
|
397
407
|
}
|
|
398
|
-
o.onerror = (
|
|
399
|
-
console.log(`号牌背景加载失败: ${o.src}`,
|
|
408
|
+
o.onerror = (p) => {
|
|
409
|
+
console.log(`号牌背景加载失败: ${o.src}`, p), t(p);
|
|
400
410
|
};
|
|
401
411
|
};
|
|
402
412
|
});
|
|
@@ -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 02: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>;
|
|
@@ -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"),se=require("./utils/map-initializer.js"),ce=require("./utils/open-drive-renderer/index.js"),ie=require("./utils/overlay.js"),oe=require("./utils/queue-length.js"),O=require("./utils/road-config-tool/index.js"),le=require("./utils/traffic-flow.js"),ue={class:"gis-viewer"},de=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 ae=w.default.useAppDataStore;ae.mapConfig=C,c=new se.default,s=await c.initialize({container:d.value,markerClickCallback:(m,p,g,re)=>{f("markerClick",m,p,g,re)},mapClickCallback:(m,p,g)=>{f("mapClick",m,p,g)}}),t=new y.default(s),f("mapLoaded")});const I=o.computed(()=>s),q=async e=>await c.setMapCenter(e),A=async e=>await c.setMapCamera(e),L=async e=>await c.lookAt(e),_=e=>c.setLayerVisibility(e),h=(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 le.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()},P=e=>{t==null||t.setInterpolate(e)},Q=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.togglePause(e)},J=e=>{t==null||t.toggleTrafficObject(e),r==null||r.toggleTrafficObject(e)},K=e=>{t==null||t.updatePanelContent(e)},U=async e=>(n||(n=new ie.default(s)),n.addOverlays(e)),W=e=>n==null?void 0:n.removeOverlaysByType(e),X=e=>n==null?void 0:n.removeOverlaysById(e),Y=()=>n==null?void 0:n.removeAllOverlays(),$=()=>{n==null||n.showAllOverlays()},F=e=>{l||(l=new oe.default(s)),l.updateQueueLength(e)},ee=()=>{l==null||l.removeQueueLength()},te=async(e,i)=>{u||(u=new ce.default(s)),await u.showOpenDrive(e,i)},ne=async()=>{await(u==null?void 0:u.hideOpenDrive())},v=T,f=b;return k({mapViewer:I,setLayerVisibility:_,setMapCenter:q,lookAt:L,setMapCamera:A,setMapZoomRange:D,requestCoordinateTransform:h,cancelCoordinateTransform:S,addOverlays:U,showAllOverlays:$,removeOverlaysByType:W,removeOverlaysById:X,removeAllOverlays:Y,showLaneNumber:M,clearLaneNumber:x,initializeAreaTool:V,calCrossIndicatorArea:B,calRoadIndicatorArea:H,connectCarFlow:R,disconnectCarFlow:j,handleHoloVehicleTraceData:z,clearHoloTrace:N,handleHoloSignalData:Q,clearHoloSignal:E,setInterpolate:P,toggleTrafficInfo:Z,toggleTrafficObject:J,toggleVehicleInfo:K,togglePause:G,updateQueueLength:F,removeQueueLength:ee,showOpenDrive:te,hideOpenDrive:ne}),(e,i)=>(o.openBlock(),o.createElementBlock("div",ue,[o.createElementVNode("div",{class:"gis-viewer-main",ref_key:"mapContainer",ref:d},null,512)]))}});exports.default=de;
|
|
@@ -44,6 +44,7 @@ export declare const GisMap: import("@easyest/utils/dist/lib/withinstall").SFCWi
|
|
|
44
44
|
handleHoloSignalData: (signalData: any) => Promise<void>;
|
|
45
45
|
clearHoloSignal: () => void;
|
|
46
46
|
toggleTrafficInfo: (params: import("../types").IToggleTrafficInfoParams) => void;
|
|
47
|
+
togglePause: (pause: boolean) => void;
|
|
47
48
|
toggleTrafficObject: (params: import("../types").IToggleTrafficInfoParams) => void;
|
|
48
49
|
toggleVehicleInfo: (contentType: string) => void;
|
|
49
50
|
addOverlays: (params: import("../types").IOverlayParam) => Promise<import("../types").IResult>;
|
|
@@ -12,6 +12,7 @@ export default class Index {
|
|
|
12
12
|
toggleTrafficObject(params: IToggleTrafficInfoParams): void;
|
|
13
13
|
clearHoloTrace(): void;
|
|
14
14
|
toggleTrafficInfo(params: IToggleTrafficInfoParams): void;
|
|
15
|
+
togglePause(pause: boolean): void;
|
|
15
16
|
updatePanelContent(contentType: string): void;
|
|
16
17
|
handleSignalData(data: any): Promise<void>;
|
|
17
18
|
clearHoloSignal(): void;
|