gisviewer-vue3-arcgis 1.0.114 → 1.0.116

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.
Files changed (61) hide show
  1. package/es/src/gis-map/gis-map.vue.d.ts +5 -3
  2. package/es/src/gis-map/gis-map.vue.mjs +93 -92
  3. package/es/src/gis-map/index.d.ts +4 -2
  4. package/es/src/gis-map/stores/appData.d.ts +3 -0
  5. package/es/src/gis-map/stores/appData.mjs +7 -4
  6. package/es/src/gis-map/utils/common-utils.d.ts +12 -0
  7. package/es/src/gis-map/utils/common-utils.mjs +81 -43
  8. package/es/src/gis-map/utils/holo-flow/trace-holo-flow.d.ts +0 -2
  9. package/es/src/gis-map/utils/holo-flow/trace-holo-flow.mjs +42 -118
  10. package/es/src/gis-map/utils/holo-flow/trace-renderer-external.d.ts +4 -0
  11. package/es/src/gis-map/utils/holo-flow/trace-renderer-external.mjs +200 -108
  12. package/es/src/gis-map/utils/holo-flow/trace-renderer-layer.d.ts +3 -0
  13. package/es/src/gis-map/utils/holo-flow/trace-renderer-layer.mjs +42 -16
  14. package/es/src/gis-map/utils/open-drive-renderer/draw-bezier.d.ts +17 -0
  15. package/es/src/gis-map/utils/open-drive-renderer/draw-bezier.mjs +49 -0
  16. package/es/src/gis-map/utils/open-drive-renderer/index.d.ts +31 -3
  17. package/es/src/gis-map/utils/open-drive-renderer/index.mjs +274 -44
  18. package/es/src/gis-map/utils/open-drive-renderer/junction.d.ts +50 -0
  19. package/es/src/gis-map/utils/open-drive-renderer/junction.mjs +151 -0
  20. package/es/src/gis-map/utils/open-drive-renderer/lane-section.d.ts +48 -0
  21. package/es/src/gis-map/utils/open-drive-renderer/lane-section.mjs +82 -0
  22. package/es/src/gis-map/utils/open-drive-renderer/lane-utils.d.ts +29 -0
  23. package/es/src/gis-map/utils/open-drive-renderer/lane-utils.mjs +265 -0
  24. package/es/src/gis-map/utils/open-drive-renderer/lane.d.ts +70 -0
  25. package/es/src/gis-map/utils/open-drive-renderer/lane.mjs +93 -0
  26. package/es/src/gis-map/utils/open-drive-renderer/road.d.ts +60 -0
  27. package/es/src/gis-map/utils/open-drive-renderer/road.mjs +113 -0
  28. package/es/src/gis-map/utils/open-drive-renderer/wasm-loader.d.ts +88 -0
  29. package/es/src/gis-map/utils/open-drive-renderer/wasm-loader.mjs +366 -0
  30. package/es/src/types/index.d.ts +50 -0
  31. package/lib/src/gis-map/gis-map.vue.d.ts +5 -3
  32. package/lib/src/gis-map/gis-map.vue.js +1 -1
  33. package/lib/src/gis-map/index.d.ts +4 -2
  34. package/lib/src/gis-map/stores/appData.d.ts +3 -0
  35. package/lib/src/gis-map/stores/appData.js +1 -1
  36. package/lib/src/gis-map/utils/common-utils.d.ts +12 -0
  37. package/lib/src/gis-map/utils/common-utils.js +1 -1
  38. package/lib/src/gis-map/utils/holo-flow/trace-holo-flow.d.ts +0 -2
  39. package/lib/src/gis-map/utils/holo-flow/trace-holo-flow.js +2 -2
  40. package/lib/src/gis-map/utils/holo-flow/trace-renderer-external.d.ts +4 -0
  41. package/lib/src/gis-map/utils/holo-flow/trace-renderer-external.js +1 -1
  42. package/lib/src/gis-map/utils/holo-flow/trace-renderer-layer.d.ts +3 -0
  43. package/lib/src/gis-map/utils/holo-flow/trace-renderer-layer.js +1 -1
  44. package/lib/src/gis-map/utils/open-drive-renderer/draw-bezier.d.ts +17 -0
  45. package/lib/src/gis-map/utils/open-drive-renderer/draw-bezier.js +1 -0
  46. package/lib/src/gis-map/utils/open-drive-renderer/index.d.ts +31 -3
  47. package/lib/src/gis-map/utils/open-drive-renderer/index.js +1 -1
  48. package/lib/src/gis-map/utils/open-drive-renderer/junction.d.ts +50 -0
  49. package/lib/src/gis-map/utils/open-drive-renderer/junction.js +1 -0
  50. package/lib/src/gis-map/utils/open-drive-renderer/lane-section.d.ts +48 -0
  51. package/lib/src/gis-map/utils/open-drive-renderer/lane-section.js +1 -0
  52. package/lib/src/gis-map/utils/open-drive-renderer/lane-utils.d.ts +29 -0
  53. package/lib/src/gis-map/utils/open-drive-renderer/lane-utils.js +1 -0
  54. package/lib/src/gis-map/utils/open-drive-renderer/lane.d.ts +70 -0
  55. package/lib/src/gis-map/utils/open-drive-renderer/lane.js +1 -0
  56. package/lib/src/gis-map/utils/open-drive-renderer/road.d.ts +60 -0
  57. package/lib/src/gis-map/utils/open-drive-renderer/road.js +1 -0
  58. package/lib/src/gis-map/utils/open-drive-renderer/wasm-loader.d.ts +88 -0
  59. package/lib/src/gis-map/utils/open-drive-renderer/wasm-loader.js +1 -0
  60. package/lib/src/types/index.d.ts +50 -0
  61. package/package.json +4 -1
@@ -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,14 +3,40 @@ 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
- console.log("init");
14
40
  }
15
41
  addVehicles(i) {
16
42
  return new Promise((e) => {
@@ -19,27 +45,27 @@ class f {
19
45
  return;
20
46
  }
21
47
  const t = i.map((s) => {
22
- const { vehicleId: o, heading: a, localTimestamp: h } = s, r = Number(s.x), n = Number(s.y);
48
+ const { vehicleId: o, heading: a, localTimestamp: h } = s, r = Number(s.x), l = Number(s.y);
23
49
  this.historyPositionMap.set(o, [
24
- { pos: [r, n, 0], heading: a, time: h }
50
+ { pos: [r, l, 0], heading: a, time: h }
25
51
  ]);
26
- const l = new c({
52
+ const n = new c({
27
53
  geometry: {
28
54
  type: "point",
29
55
  x: r,
30
- y: n
56
+ y: l
31
57
  },
32
58
  attributes: {
33
59
  ...s
34
60
  },
35
61
  symbol: this.createCIMSymbol(s)
36
62
  });
37
- return l.visible = !1, this.vehicleObjectMap.set(o, {
38
- graphic: l,
63
+ return n.visible = !1, this.vehicleObjectMap.set(o, {
64
+ graphic: n,
39
65
  data: s,
40
66
  waitForDelete: !1,
41
67
  isMoving: !1
42
- }), l;
68
+ }), n;
43
69
  });
44
70
  this.vehicleLayer.addMany(t), e();
45
71
  });
@@ -52,11 +78,11 @@ class f {
52
78
  }
53
79
  const t = [];
54
80
  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(
81
+ const { vehicleId: o, heading: a, localTimestamp: h } = s, r = Number(s.x), l = Number(s.y), n = this.vehicleObjectMap.get(o);
82
+ n ? (n.data = s, this.historyPositionMap.get(
57
83
  o
58
84
  ).push({
59
- pos: [r, n, 0],
85
+ pos: [r, l, 0],
60
86
  heading: a,
61
87
  time: h
62
88
  })) : t.push(s);
@@ -123,12 +149,12 @@ class f {
123
149
  y: e[0].pos[1]
124
150
  };
125
151
  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;
152
+ 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
153
  t.graphic.geometry = {
128
154
  type: "point",
129
155
  x: h,
130
156
  y: r
131
- }, t.data.heading = n, t.graphic.symbol = this.createCIMSymbol(t.data);
157
+ }, t.data.heading = l, t.graphic.symbol = this.createCIMSymbol(t.data);
132
158
  }
133
159
  }
134
160
  /**
@@ -0,0 +1,17 @@
1
+ export default class DrawBezier {
2
+ private static sampleCount;
3
+ static drawBezierBetweenLane(incoming: number[][], outgoing: number[][]): number[][];
4
+ /**
5
+ * 生成控制点
6
+ * 进口道的延长线和出口道的反向延长线的交点
7
+ */
8
+ private static getControlPoint;
9
+ /**
10
+ * @desc 二阶贝塞尔
11
+ * @param {number} t 当前百分比
12
+ * @param {Array} p1 起点坐标
13
+ * @param {Array} p2 终点坐标
14
+ * @param {Array} cp 控制点
15
+ */
16
+ private static twoBezier;
17
+ }
@@ -0,0 +1,49 @@
1
+ import * as m from "@turf/helpers";
2
+ import f from "@turf/line-intersect";
3
+ import p from "../common-utils.mjs";
4
+ class P {
5
+ static drawBezierBetweenLane(t, i) {
6
+ const n = this.getControlPoint(t, i);
7
+ if (n.length === 3) {
8
+ const s = n[0], r = n[1], c = n[2], o = [];
9
+ for (let e = 0; e <= this.sampleCount; e++)
10
+ o.push(this.twoBezier(e / this.sampleCount, s, r, c));
11
+ return o;
12
+ } else
13
+ return n;
14
+ }
15
+ /**
16
+ * 生成控制点
17
+ * 进口道的延长线和出口道的反向延长线的交点
18
+ */
19
+ static getControlPoint(t, i) {
20
+ const n = t[0], s = t[1], r = p.getExtensionLine(
21
+ n,
22
+ s,
23
+ 100
24
+ ), c = m.lineString([n, r]), o = i[0], e = i[1], l = p.getExtensionLine(
25
+ e,
26
+ o,
27
+ 100
28
+ ), u = m.lineString([l, e]), g = f(c, u);
29
+ if (g.features.length === 0)
30
+ return [s, o];
31
+ const a = g.features[0].geometry.coordinates;
32
+ return [s, o, a];
33
+ }
34
+ /**
35
+ * @desc 二阶贝塞尔
36
+ * @param {number} t 当前百分比
37
+ * @param {Array} p1 起点坐标
38
+ * @param {Array} p2 终点坐标
39
+ * @param {Array} cp 控制点
40
+ */
41
+ static twoBezier(t, i, n, s) {
42
+ const [r, c] = i, [o, e] = s, [l, u] = n, g = (1 - t) * (1 - t) * r + 2 * t * (1 - t) * o + t * t * l, a = (1 - t) * (1 - t) * c + 2 * t * (1 - t) * e + t * t * u;
43
+ return [g, a];
44
+ }
45
+ }
46
+ P.sampleCount = 50;
47
+ export {
48
+ P as default
49
+ };
@@ -1,9 +1,37 @@
1
1
  import View from '@arcgis/core/views/View';
2
+ import { IFindSumoParams, IResult, IShowOpenDriveFromFileParams } from '../../../types';
2
3
  export default class OpenDriveRenderer {
4
+ private static instance;
5
+ static getInstance(view: View): OpenDriveRenderer;
3
6
  private readonly view;
4
7
  private laneLayer;
8
+ private roadNameLayer;
9
+ private junctionLayer;
10
+ private highlightLayer;
11
+ private allLaneGraphics;
12
+ private allRefLineGraphics;
13
+ private wasmLoader;
5
14
  constructor(view: View);
6
- showOpenDrive(server: string, projectName: string): Promise<void>;
7
- private showRoad;
8
- hideOpenDrive(): Promise<void>;
15
+ showOpenDriveFromFile(params: IShowOpenDriveFromFileParams): Promise<IResult>;
16
+ /**
17
+ * 从服务器载入OpenDrive文件解析结果并显示
18
+ * @param server
19
+ * @param projectName
20
+ */
21
+ showOpenDriveFromServer(server: string, projectName: string): Promise<IResult>;
22
+ private showAllLanes;
23
+ private showJunction;
24
+ clearOpenDrive(): Promise<void>;
25
+ /**
26
+ * 用sumo的id定位车道、基本段、路段
27
+ * @param params
28
+ * @returns
29
+ */
30
+ findSumo(params: IFindSumoParams): Promise<IResult>;
31
+ /**
32
+ * 用sumo的id定位车道、基本段、路段
33
+ * @param params
34
+ * @returns
35
+ */
36
+ private findLane;
9
37
  }
@@ -1,10 +1,14 @@
1
- import h from "@arcgis/core/Graphic";
2
- import m from "@arcgis/core/layers/FeatureLayer";
3
- import w from "axios";
4
- import f from "pako";
1
+ import p from "@arcgis/core/Graphic";
2
+ import { Polyline as j, Polygon as b } from "@arcgis/core/geometry";
3
+ import * as N from "@arcgis/core/geometry/geometryEngineAsync.js";
4
+ import L from "@arcgis/core/layers/FeatureLayer";
5
+ import v from "@arcgis/core/layers/GraphicsLayer";
6
+ import O from "axios";
7
+ import G from "pako";
8
+ import R from "./wasm-loader.mjs";
5
9
  class I {
6
10
  constructor(e) {
7
- this.view = e, this.laneLayer = new m({
11
+ this.wasmLoader = R.getInstance(), this.view = e, this.laneLayer = new L({
8
12
  id: "OpenDriveLane",
9
13
  fields: [
10
14
  {
@@ -93,7 +97,7 @@ class I {
93
97
  symbol: {
94
98
  type: "simple-fill",
95
99
  // color: '#2F4F4F',
96
- color: [47, 79, 79, 0.5],
100
+ color: [47, 79, 79, 0.8],
97
101
  style: "solid",
98
102
  outline: {
99
103
  color: "white",
@@ -207,64 +211,290 @@ class I {
207
211
  }
208
212
  ]
209
213
  }
210
- }), this.view.map.add(this.laneLayer);
214
+ }), this.roadNameLayer = new L({
215
+ id: "OpenDriveRoadName",
216
+ fields: [
217
+ {
218
+ name: "ObjectID",
219
+ alias: "ObjectID",
220
+ type: "oid"
221
+ },
222
+ {
223
+ name: "roadId",
224
+ alias: "道路号",
225
+ type: "string"
226
+ },
227
+ {
228
+ name: "roadName",
229
+ alias: "道路名称",
230
+ type: "string"
231
+ }
232
+ ],
233
+ objectIdField: "ObjectID",
234
+ geometryType: "polyline",
235
+ spatialReference: { wkid: 4326 },
236
+ source: [],
237
+ renderer: {
238
+ type: "simple",
239
+ symbol: {
240
+ type: "simple-line",
241
+ style: "solid",
242
+ color: [0, 0, 0, 0],
243
+ width: 1
244
+ }
245
+ },
246
+ labelingInfo: [
247
+ {
248
+ symbol: {
249
+ type: "text",
250
+ color: "black",
251
+ haloColor: "white",
252
+ haloSize: 1,
253
+ font: {
254
+ size: 12,
255
+ family: "sans-serif"
256
+ }
257
+ },
258
+ labelPlacement: "center-along",
259
+ labelExpressionInfo: {
260
+ expression: "$feature.roadName"
261
+ }
262
+ }
263
+ ]
264
+ }), this.junctionLayer = new v({ id: "OpenDriveJunction" }), this.highlightLayer = new v({ id: "OpenDriveHighlight" }), this.view.map.addMany([
265
+ this.laneLayer,
266
+ this.junctionLayer,
267
+ this.highlightLayer,
268
+ this.roadNameLayer
269
+ ]);
270
+ }
271
+ static getInstance(e) {
272
+ return this.instance || (this.instance = new I(e)), this.instance;
211
273
  }
212
- async showOpenDrive(e, i) {
213
- const t = `http://${e}/api/openDrive/analyzeXodr`, o = await w.get(t, {
274
+ async showOpenDriveFromFile(e) {
275
+ var l, d, a;
276
+ const t = await this.wasmLoader.load(e.file);
277
+ if (t.status !== 0)
278
+ return t;
279
+ console.time("渲染用时");
280
+ const { roads: i, junctions: s } = t.result;
281
+ return await this.showAllLanes(
282
+ i,
283
+ ((l = e.options) == null ? void 0 : l.showJunctionLane) || !1,
284
+ ((d = e.options) == null ? void 0 : d.showRoadName) || !0
285
+ ), (a = e.options) != null && a.showJunctionPolygon && this.showJunction(s), console.timeEnd("渲染用时"), { status: 0, message: "ok" };
286
+ }
287
+ /**
288
+ * 从服务器载入OpenDrive文件解析结果并显示
289
+ * @param server
290
+ * @param projectName
291
+ */
292
+ async showOpenDriveFromServer(e, t) {
293
+ const i = `http://${e}/api/openDrive/analyzeXodr`, s = await O.get(i, {
214
294
  headers: {
215
- projectName: i
295
+ projectName: t
216
296
  },
217
297
  params: {
218
298
  analyze: !1,
219
299
  compressed: !0
220
300
  }
221
301
  });
222
- if (o.status !== 200)
223
- throw new Error(`OpenDriveRenderer: ${o.statusText}`);
224
- let l = o.data.result.json;
302
+ if (s.status !== 200)
303
+ throw new Error(`OpenDriveRenderer: ${s.statusText}`);
304
+ let l = s.data.result.json;
225
305
  l.startsWith(window.location.protocol) || (l = `${window.location.protocol}//${e}${l}`);
226
- const r = await (await fetch(l)).arrayBuffer(), n = f.inflate(r, { to: "string" }), a = JSON.parse(n);
227
- this.showRoad(a);
306
+ const a = await (await fetch(l)).arrayBuffer(), c = G.inflate(a, { to: "string" }), h = JSON.parse(c);
307
+ return await this.showAllLanes(h, !1, !1), { status: 0, message: "ok" };
228
308
  }
229
- async showRoad(e) {
230
- const i = await this.laneLayer.queryFeatures();
231
- i.features.length > 0 && this.laneLayer.applyEdits({
232
- deleteFeatures: i.features
233
- });
234
- for (const t of e) {
235
- const o = t.id, l = [];
236
- for (const s of t.laneSections) {
237
- const r = s.id;
238
- for (const n of s.lanePaths) {
239
- const { id: a, type: y, innerPath: d, outerPath: c } = n, p = d.concat(c.reverse());
240
- p.push(d[0]);
241
- const u = new h({
242
- geometry: {
243
- type: "polygon",
244
- rings: [p]
245
- },
246
- attributes: {
247
- id: a,
248
- roadId: o,
249
- roadName: t.name,
250
- sectionId: r,
251
- laneId: a,
252
- type: y
309
+ async showAllLanes(e, t, i) {
310
+ const s = await this.laneLayer.queryFeatures();
311
+ return s.features.length > 0 && this.laneLayer.applyEdits({
312
+ deleteFeatures: s.features
313
+ }), this.roadNameLayer.visible = i, new Promise((l) => {
314
+ let d = 0;
315
+ this.allLaneGraphics = [], this.allRefLineGraphics = [];
316
+ for (const c of e) {
317
+ if (!t && c.junction !== "-1")
318
+ continue;
319
+ const { id: h, refLine: y } = c;
320
+ let u = c.name;
321
+ u.includes("(") && (u = u.slice(0, u.indexOf("(")));
322
+ const f = new p({
323
+ geometry: new j({
324
+ paths: [y]
325
+ }),
326
+ attributes: {
327
+ ObjectID: d++,
328
+ roadId: h,
329
+ roadName: u
330
+ }
331
+ });
332
+ this.allRefLineGraphics.push(f);
333
+ for (const o of c.laneSections) {
334
+ const r = Number(o.id);
335
+ for (const n of o.lanePaths) {
336
+ const m = Number(n.id);
337
+ if (m === 0)
338
+ continue;
339
+ const D = n.type, w = n.innerPath.concat(n.outerPath.reverse());
340
+ if (w.length <= 3) {
341
+ console.warn(`lane ${m} has less than 3 points`);
342
+ continue;
253
343
  }
254
- });
255
- l.push(u);
344
+ w.push(n.innerPath[0]);
345
+ const g = new b({
346
+ rings: [w]
347
+ });
348
+ if (g) {
349
+ const F = new p({
350
+ geometry: g,
351
+ attributes: {
352
+ ObjectID: d++,
353
+ id: `${h}+${r}+${m}`,
354
+ roadId: h,
355
+ roadName: c.name,
356
+ sectionId: r,
357
+ laneId: m,
358
+ type: D
359
+ }
360
+ });
361
+ this.allLaneGraphics.push(F);
362
+ }
363
+ }
256
364
  }
257
365
  }
258
- await this.laneLayer.applyEdits({
259
- addFeatures: l
366
+ const a = setInterval(() => {
367
+ if (this.allLaneGraphics.length > 0 || this.allRefLineGraphics.length > 0) {
368
+ if (this.allLaneGraphics.length > 0) {
369
+ const c = this.allLaneGraphics.splice(0, 100);
370
+ this.laneLayer.applyEdits({
371
+ addFeatures: c
372
+ });
373
+ }
374
+ if (this.allRefLineGraphics.length > 0) {
375
+ const c = this.allRefLineGraphics.splice(0, 10);
376
+ this.roadNameLayer.applyEdits({
377
+ addFeatures: c
378
+ });
379
+ }
380
+ } else
381
+ clearInterval(a), l();
382
+ }, 10);
383
+ });
384
+ }
385
+ async showJunction(e) {
386
+ for (const t of e) {
387
+ const i = new b({
388
+ rings: [t.outline]
389
+ }), s = new p({
390
+ geometry: i,
391
+ attributes: {
392
+ id: t.id,
393
+ name: t.name
394
+ },
395
+ symbol: {
396
+ type: "simple-fill",
397
+ color: [47, 79, 79, 0.8],
398
+ style: "solid",
399
+ outline: {
400
+ color: "white",
401
+ width: 1
402
+ }
403
+ }
260
404
  });
405
+ this.junctionLayer.add(s);
261
406
  }
262
407
  }
263
- async hideOpenDrive() {
408
+ async clearOpenDrive() {
264
409
  const e = await this.laneLayer.queryFeatures();
265
410
  e.features.length > 0 && this.laneLayer.applyEdits({
266
411
  deleteFeatures: e.features
412
+ }), this.wasmLoader.clear();
413
+ }
414
+ /**
415
+ * 用sumo的id定位车道、基本段、路段
416
+ * @param params
417
+ * @returns
418
+ */
419
+ async findSumo(e) {
420
+ const { id: t } = e, i = t.split("+");
421
+ if (i.length > 2)
422
+ return { status: -1, message: "id格式错误" };
423
+ const s = i.length === 2 ? Number(i[1]) : void 0, l = i[0].split("#");
424
+ if (l.length > 2)
425
+ return { status: -1, message: "id格式错误" };
426
+ const d = l[0], a = l.length === 2 ? Number(l[1]) : void 0;
427
+ return await this.findLane({ roadsectId: d, segmentId: a, laneId: s });
428
+ }
429
+ /**
430
+ * 用sumo的id定位车道、基本段、路段
431
+ * @param params
432
+ * @returns
433
+ */
434
+ async findLane(e) {
435
+ let { roadsectId: t, segmentId: i, laneId: s } = e;
436
+ t.startsWith("-") && (t = t.slice(1)), console.log(t, i, s);
437
+ const l = this.laneLayer.createQuery();
438
+ l.returnGeometry = !0, l.outFields = ["*"], l.where = `roadId = '${t}'`;
439
+ const d = await this.laneLayer.queryFeatures(l);
440
+ if (d.features.length === 0)
441
+ return { status: -1, message: "未找到。请检查路段编号" };
442
+ let a = d.features;
443
+ if (i !== void 0) {
444
+ const o = [];
445
+ if (a.forEach((r) => {
446
+ const n = Number(r.attributes.sectionId);
447
+ o.indexOf(n) === -1 && o.push(n);
448
+ }), o.sort((r, n) => r - n), i > o.length - 1)
449
+ return { status: -1, message: "未找到。请检查基本段编号" };
450
+ i = o[i], a = a.filter(
451
+ (r) => Number(r.attributes.sectionId) === i
452
+ );
453
+ }
454
+ if (s !== void 0) {
455
+ const o = [];
456
+ if (a.forEach((r) => {
457
+ const n = Number(r.attributes.laneId);
458
+ o.indexOf(n) === -1 && o.push(n);
459
+ }), o.sort((r, n) => r - n), s > o.length - 1)
460
+ return { status: -1, message: "未找到。请检查车道编号" };
461
+ s = o[s], a = a.filter(
462
+ (r) => Number(r.attributes.laneId) === s
463
+ );
464
+ }
465
+ const c = a.map(
466
+ (o) => o.geometry
467
+ ), h = await N.union(c);
468
+ this.highlightLayer.removeAll(), this.highlightLayer.add(
469
+ new p({
470
+ geometry: h,
471
+ symbol: {
472
+ type: "simple-fill",
473
+ style: "none",
474
+ outline: {
475
+ color: "red",
476
+ width: 2
477
+ }
478
+ }
479
+ })
480
+ );
481
+ const y = new p({
482
+ geometry: h,
483
+ symbol: {
484
+ type: "simple-fill",
485
+ color: [255, 0, 0, 0.5],
486
+ style: "solid",
487
+ outline: {
488
+ width: 0
489
+ }
490
+ }
267
491
  });
492
+ this.highlightLayer.add(y);
493
+ let u = 0;
494
+ const f = setInterval(() => {
495
+ u % 2 === 0 ? y.visible = !0 : y.visible = !1, u++, u > 10 && (this.highlightLayer.removeAll(), clearInterval(f));
496
+ }, 500);
497
+ return this.view.type === "2d" ? await this.view.goTo(h, { duration: 1e3 }) : await this.view.goTo(h, { duration: 1e3 }), { status: 0, message: "ok" };
268
498
  }
269
499
  }
270
500
  export {
@@ -0,0 +1,50 @@
1
+ import { ILaneInfo } from '../../../types';
2
+ interface ILink {
3
+ incoming: ILaneInfo;
4
+ connecting: ILaneInfo;
5
+ outgoing: ILaneInfo;
6
+ }
7
+ export default class Junction {
8
+ id: string;
9
+ name: string;
10
+ /** 路口内的行车通道,包含进口道->转接道->出口道三个车道 */
11
+ laneLinks: Array<ILink>;
12
+ /** 进口车道按roadId归类, */
13
+ private incomingLanes;
14
+ private outline;
15
+ private wasmLoader;
16
+ private roadList;
17
+ constructor(odrJunction: any);
18
+ /**
19
+ * 在路口中,找到进口道的后继转接车道
20
+ * @param {string} roadId 进口道道路id
21
+ * @param {number} laneId 进口道车道id
22
+ * @returns {ILaneInfo[]}
23
+ */
24
+ getSuccessorForIncoming(roadId: string, laneId: number): ILaneInfo[];
25
+ /**
26
+ * 在路口中,找到出口道的前驱转接车道
27
+ * @param {string} roadId 出口道道路id
28
+ * @param {number} laneId 出口道车道id
29
+ * @returns {ILaneInfo[]}
30
+ */
31
+ getPredecessorForOutgoing(roadId: string, laneId: number): ILaneInfo[];
32
+ /**
33
+ * 获取路口轮廓线
34
+ * 要等所有路口对象生成之后才能调用,所以不放在初始化中
35
+ * @returns
36
+ */
37
+ getJunctionOutline(): number[][];
38
+ /**
39
+ * 获取此路口各个进口道的停止线
40
+ */
41
+ getRoadStopLine(): {
42
+ roadId: string;
43
+ line: number[][];
44
+ }[];
45
+ /**
46
+ * 获取此路口的所有进口车道
47
+ */
48
+ getAllIncomingLanes(): ILaneInfo[];
49
+ }
50
+ export {};