gisviewer-vue3-arcgis 1.0.115 → 1.0.117

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 (53) hide show
  1. package/es/src/gis-map/gis-map.vue.d.ts +6 -3
  2. package/es/src/gis-map/gis-map.vue.mjs +100 -95
  3. package/es/src/gis-map/index.d.ts +5 -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-renderer-external.mjs +3 -3
  9. package/es/src/gis-map/utils/holo-flow/trace-renderer-layer.mjs +0 -1
  10. package/es/src/gis-map/utils/open-drive-renderer/draw-bezier.d.ts +17 -0
  11. package/es/src/gis-map/utils/open-drive-renderer/draw-bezier.mjs +49 -0
  12. package/es/src/gis-map/utils/open-drive-renderer/index.d.ts +32 -3
  13. package/es/src/gis-map/utils/open-drive-renderer/index.mjs +279 -45
  14. package/es/src/gis-map/utils/open-drive-renderer/junction.d.ts +50 -0
  15. package/es/src/gis-map/utils/open-drive-renderer/junction.mjs +151 -0
  16. package/es/src/gis-map/utils/open-drive-renderer/lane-section.d.ts +48 -0
  17. package/es/src/gis-map/utils/open-drive-renderer/lane-section.mjs +82 -0
  18. package/es/src/gis-map/utils/open-drive-renderer/lane-utils.d.ts +29 -0
  19. package/es/src/gis-map/utils/open-drive-renderer/lane-utils.mjs +265 -0
  20. package/es/src/gis-map/utils/open-drive-renderer/lane.d.ts +77 -0
  21. package/es/src/gis-map/utils/open-drive-renderer/lane.mjs +110 -0
  22. package/es/src/gis-map/utils/open-drive-renderer/road.d.ts +60 -0
  23. package/es/src/gis-map/utils/open-drive-renderer/road.mjs +113 -0
  24. package/es/src/gis-map/utils/open-drive-renderer/wasm-loader.d.ts +88 -0
  25. package/es/src/gis-map/utils/open-drive-renderer/wasm-loader.mjs +367 -0
  26. package/es/src/types/index.d.ts +54 -0
  27. package/lib/src/gis-map/gis-map.vue.d.ts +6 -3
  28. package/lib/src/gis-map/gis-map.vue.js +1 -1
  29. package/lib/src/gis-map/index.d.ts +5 -2
  30. package/lib/src/gis-map/stores/appData.d.ts +3 -0
  31. package/lib/src/gis-map/stores/appData.js +1 -1
  32. package/lib/src/gis-map/utils/common-utils.d.ts +12 -0
  33. package/lib/src/gis-map/utils/common-utils.js +1 -1
  34. package/lib/src/gis-map/utils/holo-flow/trace-renderer-external.js +1 -1
  35. package/lib/src/gis-map/utils/holo-flow/trace-renderer-layer.js +1 -1
  36. package/lib/src/gis-map/utils/open-drive-renderer/draw-bezier.d.ts +17 -0
  37. package/lib/src/gis-map/utils/open-drive-renderer/draw-bezier.js +1 -0
  38. package/lib/src/gis-map/utils/open-drive-renderer/index.d.ts +32 -3
  39. package/lib/src/gis-map/utils/open-drive-renderer/index.js +1 -1
  40. package/lib/src/gis-map/utils/open-drive-renderer/junction.d.ts +50 -0
  41. package/lib/src/gis-map/utils/open-drive-renderer/junction.js +1 -0
  42. package/lib/src/gis-map/utils/open-drive-renderer/lane-section.d.ts +48 -0
  43. package/lib/src/gis-map/utils/open-drive-renderer/lane-section.js +1 -0
  44. package/lib/src/gis-map/utils/open-drive-renderer/lane-utils.d.ts +29 -0
  45. package/lib/src/gis-map/utils/open-drive-renderer/lane-utils.js +1 -0
  46. package/lib/src/gis-map/utils/open-drive-renderer/lane.d.ts +77 -0
  47. package/lib/src/gis-map/utils/open-drive-renderer/lane.js +1 -0
  48. package/lib/src/gis-map/utils/open-drive-renderer/road.d.ts +60 -0
  49. package/lib/src/gis-map/utils/open-drive-renderer/road.js +1 -0
  50. package/lib/src/gis-map/utils/open-drive-renderer/wasm-loader.d.ts +88 -0
  51. package/lib/src/gis-map/utils/open-drive-renderer/wasm-loader.js +1 -0
  52. package/lib/src/types/index.d.ts +54 -0
  53. package/package.json +4 -1
@@ -1,9 +1,38 @@
1
1
  import View from '@arcgis/core/views/View';
2
+ import { IFindSumoParams, IResult, IShowOpenDriveFromFileParams, ISplitOpenDriveLaneParams } 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;
37
+ splitLane(params: ISplitOpenDriveLaneParams): Promise<IResult>;
9
38
  }
@@ -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 m from "@arcgis/core/Graphic";
2
+ import { Polygon as b } from "@arcgis/core/geometry";
3
+ import * as O from "@arcgis/core/geometry/geometryEngineAsync.js";
4
+ import L from "@arcgis/core/layers/FeatureLayer";
5
+ import v from "@arcgis/core/layers/GraphicsLayer";
6
+ import j from "axios";
7
+ import N from "pako";
8
+ import G from "./wasm-loader.mjs";
5
9
  class I {
6
10
  constructor(e) {
7
- this.view = e, this.laneLayer = new m({
11
+ this.wasmLoader = G.getInstance(), this.view = e, this.laneLayer = new L({
8
12
  id: "OpenDriveLane",
9
13
  fields: [
10
14
  {
@@ -41,6 +45,11 @@ class I {
41
45
  name: "type",
42
46
  alias: "类型",
43
47
  type: "string"
48
+ },
49
+ {
50
+ name: "sumoId",
51
+ alias: "sumo编号",
52
+ type: "string"
44
53
  }
45
54
  ],
46
55
  objectIdField: "ObjectID",
@@ -93,7 +102,7 @@ class I {
93
102
  symbol: {
94
103
  type: "simple-fill",
95
104
  // color: '#2F4F4F',
96
- color: [47, 79, 79, 0.5],
105
+ color: [47, 79, 79, 0.8],
97
106
  style: "solid",
98
107
  outline: {
99
108
  color: "white",
@@ -207,10 +216,86 @@ class I {
207
216
  }
208
217
  ]
209
218
  }
210
- }), this.view.map.add(this.laneLayer);
219
+ }), this.roadNameLayer = new L({
220
+ id: "OpenDriveRoadName",
221
+ fields: [
222
+ {
223
+ name: "ObjectID",
224
+ alias: "ObjectID",
225
+ type: "oid"
226
+ },
227
+ {
228
+ name: "roadId",
229
+ alias: "道路号",
230
+ type: "string"
231
+ },
232
+ {
233
+ name: "roadName",
234
+ alias: "道路名称",
235
+ type: "string"
236
+ }
237
+ ],
238
+ objectIdField: "ObjectID",
239
+ geometryType: "polyline",
240
+ spatialReference: { wkid: 4326 },
241
+ source: [],
242
+ renderer: {
243
+ type: "simple",
244
+ symbol: {
245
+ type: "simple-line",
246
+ style: "solid",
247
+ color: [0, 0, 0, 0],
248
+ width: 1
249
+ }
250
+ },
251
+ labelingInfo: [
252
+ {
253
+ symbol: {
254
+ type: "text",
255
+ color: "black",
256
+ haloColor: "white",
257
+ haloSize: 1,
258
+ font: {
259
+ size: 12,
260
+ family: "sans-serif"
261
+ }
262
+ },
263
+ labelPlacement: this.view.type === "2d" ? "center-along" : void 0,
264
+ labelExpressionInfo: {
265
+ expression: "$feature.roadName"
266
+ }
267
+ }
268
+ ]
269
+ }), this.junctionLayer = new v({ id: "OpenDriveJunction" }), this.highlightLayer = new v({ id: "OpenDriveHighlight" }), this.view.map.addMany([
270
+ this.laneLayer,
271
+ this.junctionLayer,
272
+ this.highlightLayer,
273
+ this.roadNameLayer
274
+ ]);
211
275
  }
212
- async showOpenDrive(e, i) {
213
- const t = `http://${e}/api/openDrive/analyzeXodr`, o = await w.get(t, {
276
+ static getInstance(e) {
277
+ return this.instance || (this.instance = new I(e)), this.instance;
278
+ }
279
+ async showOpenDriveFromFile(e) {
280
+ var o, c, s;
281
+ const i = await this.wasmLoader.load(e.file);
282
+ if (i.status !== 0)
283
+ return i;
284
+ console.time("渲染用时");
285
+ const { roads: n, junctions: a } = i.result;
286
+ return await this.showAllLanes(
287
+ n,
288
+ ((o = e.options) == null ? void 0 : o.showJunctionLane) || !1,
289
+ ((c = e.options) == null ? void 0 : c.showRoadName) || !0
290
+ ), (s = e.options) != null && s.showJunctionPolygon && this.showJunction(a), console.timeEnd("渲染用时"), { status: 0, message: "ok" };
291
+ }
292
+ /**
293
+ * 从服务器载入OpenDrive文件解析结果并显示
294
+ * @param server
295
+ * @param projectName
296
+ */
297
+ async showOpenDriveFromServer(e, i) {
298
+ const n = `http://${e}/api/openDrive/analyzeXodr`, a = await j.get(n, {
214
299
  headers: {
215
300
  projectName: i
216
301
  },
@@ -219,52 +304,201 @@ class I {
219
304
  compressed: !0
220
305
  }
221
306
  });
222
- if (o.status !== 200)
223
- throw new Error(`OpenDriveRenderer: ${o.statusText}`);
224
- let l = o.data.result.json;
225
- 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);
307
+ if (a.status !== 200)
308
+ throw new Error(`OpenDriveRenderer: ${a.statusText}`);
309
+ let o = a.data.result.json;
310
+ o.startsWith(window.location.protocol) || (o = `${window.location.protocol}//${e}${o}`);
311
+ const s = await (await fetch(o)).arrayBuffer(), r = N.inflate(s, { to: "string" }), d = JSON.parse(r);
312
+ return await this.showAllLanes(d, !1, !1), { status: 0, message: "ok" };
228
313
  }
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
314
+ async showAllLanes(e, i, n) {
315
+ const a = await this.laneLayer.queryFeatures();
316
+ return a.features.length > 0 && this.laneLayer.applyEdits({
317
+ deleteFeatures: a.features
318
+ }), this.roadNameLayer.visible = n, new Promise((o) => {
319
+ let c = 0;
320
+ this.allLaneGraphics = [], this.allRefLineGraphics = [];
321
+ for (const r of e) {
322
+ if (!i && r.junction !== "-1")
323
+ continue;
324
+ const { id: d, refLine: l } = r;
325
+ let t = r.name;
326
+ t.includes("(") && (t = t.slice(0, t.indexOf("("))), t = t.replace(/(.)/g, "$1 ");
327
+ const h = new m({
328
+ geometry: {
329
+ type: "polyline",
330
+ paths: [l]
331
+ },
332
+ attributes: {
333
+ ObjectID: c++,
334
+ roadId: d,
335
+ roadName: t
336
+ }
337
+ });
338
+ this.allRefLineGraphics.push(h);
339
+ for (const y of r.laneSections) {
340
+ const g = Number(y.id);
341
+ for (const u of y.lanePaths) {
342
+ const p = Number(u.id);
343
+ if (p === 0)
344
+ continue;
345
+ const D = u.type, f = u.innerPath.concat(
346
+ u.outerPath.reverse()
347
+ );
348
+ if (f.length <= 3) {
349
+ console.warn(`lane ${p} has less than 3 points`);
350
+ continue;
351
+ }
352
+ f.push(u.innerPath[0]);
353
+ const w = new b({
354
+ rings: [f]
355
+ });
356
+ if (w) {
357
+ const F = new m({
358
+ geometry: w,
359
+ attributes: {
360
+ ObjectID: c++,
361
+ id: `${d}+${g}+${p}`,
362
+ roadId: d,
363
+ roadName: r.name,
364
+ sectionId: g,
365
+ laneId: p,
366
+ type: D,
367
+ sumoId: ""
368
+ }
369
+ });
370
+ this.allLaneGraphics.push(F);
253
371
  }
254
- });
255
- l.push(u);
372
+ }
256
373
  }
257
374
  }
258
- await this.laneLayer.applyEdits({
259
- addFeatures: l
375
+ const s = setInterval(() => {
376
+ if (this.allLaneGraphics.length > 0 || this.allRefLineGraphics.length > 0) {
377
+ if (this.allLaneGraphics.length > 0) {
378
+ const r = this.allLaneGraphics.splice(0, 100);
379
+ this.laneLayer.applyEdits({
380
+ addFeatures: r
381
+ });
382
+ }
383
+ if (this.allRefLineGraphics.length > 0) {
384
+ const r = this.allRefLineGraphics.splice(0, 10);
385
+ this.roadNameLayer.applyEdits({
386
+ addFeatures: r
387
+ });
388
+ }
389
+ } else
390
+ clearInterval(s), o();
391
+ }, 10);
392
+ });
393
+ }
394
+ async showJunction(e) {
395
+ for (const i of e) {
396
+ const n = new b({
397
+ rings: [i.outline]
398
+ }), a = new m({
399
+ geometry: n,
400
+ attributes: {
401
+ id: i.id,
402
+ name: i.name
403
+ },
404
+ symbol: {
405
+ type: "simple-fill",
406
+ color: [47, 79, 79, 0.8],
407
+ style: "solid",
408
+ outline: {
409
+ color: "white",
410
+ width: 1
411
+ }
412
+ }
260
413
  });
414
+ this.junctionLayer.add(a);
261
415
  }
262
416
  }
263
- async hideOpenDrive() {
417
+ async clearOpenDrive() {
264
418
  const e = await this.laneLayer.queryFeatures();
265
419
  e.features.length > 0 && this.laneLayer.applyEdits({
266
420
  deleteFeatures: e.features
267
- });
421
+ }), this.wasmLoader.clear();
422
+ }
423
+ /**
424
+ * 用sumo的id定位车道、基本段、路段
425
+ * @param params
426
+ * @returns
427
+ */
428
+ async findSumo(e) {
429
+ const { id: i } = e, n = e.flash === void 0 ? !0 : e.flash, a = i.split("+");
430
+ if (a.length > 2)
431
+ return { status: -1, message: "id格式错误" };
432
+ const o = a.length === 2 ? Number(a[1]) : void 0, c = a[0].split("#");
433
+ if (c.length > 2)
434
+ return { status: -1, message: "id格式错误" };
435
+ let s = c[0];
436
+ s.startsWith("-") && (s = s.slice(1));
437
+ const r = c.length === 2 ? Number(c[1]) : void 0;
438
+ return await this.findLane({ roadsectId: s, segmentId: r, laneId: o, flash: n });
439
+ }
440
+ /**
441
+ * 用sumo的id定位车道、基本段、路段
442
+ * @param params
443
+ * @returns
444
+ */
445
+ async findLane(e) {
446
+ let { segmentId: i, laneId: n } = e;
447
+ const { roadsectId: a } = e, o = this.laneLayer.createQuery();
448
+ o.returnGeometry = !0, o.outFields = ["*"], o.where = `roadId = '${a}'`;
449
+ const c = await this.laneLayer.queryFeatures(o);
450
+ if (c.features.length === 0)
451
+ return { status: -1, message: "未找到。请检查路段编号" };
452
+ let s = c.features;
453
+ if (i !== void 0) {
454
+ const l = [];
455
+ if (s.forEach((t) => {
456
+ const h = Number(t.attributes.sectionId);
457
+ l.indexOf(h) === -1 && l.push(h);
458
+ }), l.sort((t, h) => t - h), i > l.length - 1)
459
+ return { status: -1, message: "未找到。请检查基本段编号" };
460
+ i = l[i], s = s.filter(
461
+ (t) => Number(t.attributes.sectionId) === i
462
+ );
463
+ }
464
+ if (n !== void 0) {
465
+ const l = [];
466
+ if (s.forEach((t) => {
467
+ const h = Number(t.attributes.laneId);
468
+ l.indexOf(h) === -1 && l.push(h);
469
+ }), l.sort((t, h) => t - h), n > l.length - 1)
470
+ return { status: -1, message: "未找到。请检查车道编号" };
471
+ n = l[n], s = s.filter(
472
+ (t) => Number(t.attributes.laneId) === n
473
+ );
474
+ }
475
+ const r = s.map(
476
+ (l) => l.geometry
477
+ ), d = await O.union(r);
478
+ if (e.flash) {
479
+ this.highlightLayer.removeAll();
480
+ const l = new m({
481
+ geometry: d,
482
+ symbol: {
483
+ type: "simple-fill",
484
+ color: [255, 0, 0, 0.5],
485
+ style: "solid",
486
+ outline: {
487
+ color: "red",
488
+ width: 2
489
+ }
490
+ }
491
+ });
492
+ this.highlightLayer.add(l);
493
+ let t = 0, h = !0;
494
+ const y = setInterval(() => {
495
+ h ? (this.highlightLayer.opacity -= 0.02, this.highlightLayer.opacity <= 0.1 && (h = !1, t++)) : (this.highlightLayer.opacity += 0.02, this.highlightLayer.opacity >= 1 && (h = !0)), t > 5 && (this.highlightLayer.removeAll(), this.highlightLayer.opacity = 1, clearInterval(y));
496
+ }, 20);
497
+ }
498
+ return this.view.type === "2d" ? await this.view.goTo(d, { duration: 1e3 }) : await this.view.goTo(d, { duration: 1e3 }), { status: 0, message: "ok" };
499
+ }
500
+ async splitLane(e) {
501
+ return { status: 0, message: "ok", result: e };
268
502
  }
269
503
  }
270
504
  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 {};
@@ -0,0 +1,151 @@
1
+ import f from "../common-utils.mjs";
2
+ import E from "./draw-bezier.mjs";
3
+ import p from "./wasm-loader.mjs";
4
+ class R {
5
+ constructor(t) {
6
+ this.laneLinks = [], this.incomingLanes = /* @__PURE__ */ new Map(), this.wasmLoader = p.getInstance(), this.id = t.id, this.name = t.name, this.roadList = p.getInstance().roadList;
7
+ const i = f.getStdVecEntries(
8
+ t.odr_connections
9
+ );
10
+ for (const o of i) {
11
+ const n = o.connecting_road, e = this.roadList.get(n);
12
+ if (!e) {
13
+ console.log(`转接道路不存在: ${n}`), console.log(`junction: ${this.id}, connection: ${o.id}`);
14
+ continue;
15
+ }
16
+ if (!e.predecessor.elementId) {
17
+ console.log(`转接道路不存在predecessor: ${n}`), console.log(`junction: ${this.id}, connection: ${o.id}`);
18
+ continue;
19
+ }
20
+ if (!e.successor.elementId) {
21
+ console.log(`转接道路不存在successor: ${n}`), console.log(`junction: ${this.id}, connection: ${o.id}`);
22
+ continue;
23
+ }
24
+ const { elementId: s, contactPoint: c } = e.predecessor, g = this.roadList.get(s);
25
+ if (!g) {
26
+ console.log(`进口道路不存在: ${s}`), console.log(`junction: ${this.id}, connection: ${o.id}`);
27
+ continue;
28
+ }
29
+ const { elementId: a, contactPoint: h } = e.successor, r = this.roadList.get(a);
30
+ if (!r) {
31
+ console.log(`出口道路不存在: ${a}`), console.log(`junction: ${this.id}, connection: ${o.id}`);
32
+ continue;
33
+ }
34
+ const L = f.getStdVecEntries(o.odr_lane_links);
35
+ for (const l of L) {
36
+ const I = c === "start" ? 0 : g.getLastLaneSection().s0, m = l.from;
37
+ if (m === 0) {
38
+ console.log("进口车道id为0"), console.log(`junction: ${this.id}, connection: ${o.id}`);
39
+ continue;
40
+ }
41
+ const $ = 0, u = l.to;
42
+ if (u === 0) {
43
+ console.log("转接车道id为0"), console.log(`junction: ${this.id}, connection: ${o.id}`);
44
+ continue;
45
+ }
46
+ const d = e.getFirstLaneSection().getLane(u);
47
+ if (!d || (d == null ? void 0 : d.successor) === 0) {
48
+ console.log(
49
+ `转接车道不存在successor: ${n}_0_${u}`
50
+ ), console.log(`junction: ${this.id}, connection: ${o.id}`);
51
+ continue;
52
+ }
53
+ const S = h === "start" ? 0 : r.getLastLaneSection().s0, v = d.successor;
54
+ this.laneLinks.push({
55
+ incoming: {
56
+ roadId: s,
57
+ sectionId: I,
58
+ laneId: m
59
+ },
60
+ connecting: {
61
+ roadId: n,
62
+ sectionId: $,
63
+ laneId: u
64
+ },
65
+ outgoing: {
66
+ roadId: a,
67
+ sectionId: S,
68
+ laneId: v
69
+ }
70
+ });
71
+ }
72
+ }
73
+ this.laneLinks.forEach((o) => {
74
+ const n = o.incoming, { roadId: e, laneId: s } = n, c = this.incomingLanes.get(e);
75
+ c ? c.find((g) => g.laneId === s) || c.push(n) : this.incomingLanes.set(e, [n]);
76
+ });
77
+ for (const o of this.incomingLanes.values())
78
+ o.sort(
79
+ (n, e) => +(Math.abs(n.laneId) > Math.abs(e.laneId)) || +(n.laneId === e.laneId) - 1
80
+ );
81
+ }
82
+ /**
83
+ * 在路口中,找到进口道的后继转接车道
84
+ * @param {string} roadId 进口道道路id
85
+ * @param {number} laneId 进口道车道id
86
+ * @returns {ILaneInfo[]}
87
+ */
88
+ getSuccessorForIncoming(t, i) {
89
+ const o = [];
90
+ return this.laneLinks.forEach((n) => {
91
+ n.incoming.roadId === t && n.incoming.laneId === i && o.push(n.connecting);
92
+ }), o;
93
+ }
94
+ /**
95
+ * 在路口中,找到出口道的前驱转接车道
96
+ * @param {string} roadId 出口道道路id
97
+ * @param {number} laneId 出口道车道id
98
+ * @returns {ILaneInfo[]}
99
+ */
100
+ getPredecessorForOutgoing(t, i) {
101
+ const o = [];
102
+ return this.laneLinks.forEach((n) => {
103
+ n.outgoing.roadId === t && n.outgoing.laneId === i && o.push(n.connecting);
104
+ }), o;
105
+ }
106
+ /**
107
+ * 获取路口轮廓线
108
+ * 要等所有路口对象生成之后才能调用,所以不放在初始化中
109
+ * @returns
110
+ */
111
+ getJunctionOutline() {
112
+ if (this.outline)
113
+ return this.outline;
114
+ const t = [], i = [];
115
+ this.incomingLanes.forEach((o) => {
116
+ const n = this.wasmLoader.getLane(o[0]);
117
+ n && i.push(n);
118
+ }), i.sort((o, n) => {
119
+ const e = o.drivingAngle < 0 ? o.drivingAngle + 360 : o.drivingAngle, s = n.drivingAngle < 0 ? n.drivingAngle + 360 : n.drivingAngle;
120
+ return e - s;
121
+ }), i.push(i[0]);
122
+ for (let o = 0; o < i.length - 1; o++) {
123
+ const n = i[o], e = i[o + 1], s = n.laneSection.allLaneIds, c = n.id > 0 ? s[0] : s[s.length - 1], g = n.laneSection.getLane(c), a = e.laneSection.allLaneIds, h = e.id > 0 ? a[a.length - 1] : a[0], r = e.laneSection.getLane(h), L = g.getLaneEndPoints("outer").reverse(), l = r.getLaneEndPoints("outer").reverse(), I = E.drawBezierBetweenLane(L, l);
124
+ t.push(...I);
125
+ }
126
+ return t.push(t[0]), this.outline = t, t;
127
+ }
128
+ /**
129
+ * 获取此路口各个进口道的停止线
130
+ */
131
+ getRoadStopLine() {
132
+ const t = [];
133
+ for (const i of this.incomingLanes) {
134
+ const o = i[0], n = i[1], e = this.wasmLoader.getLane(n[0]);
135
+ if (!e || e.isDirEqual === void 0)
136
+ continue;
137
+ const s = e.isDirEqual ? e.laneSection.borders.top : e.laneSection.borders.bottom;
138
+ t.push({ roadId: o, line: s });
139
+ }
140
+ return t;
141
+ }
142
+ /**
143
+ * 获取此路口的所有进口车道
144
+ */
145
+ getAllIncomingLanes() {
146
+ return [...this.incomingLanes.values()].flat();
147
+ }
148
+ }
149
+ export {
150
+ R as default
151
+ };
@@ -0,0 +1,48 @@
1
+ import { ISampledLaneSection } from '../../../types';
2
+ import Lane from './lane';
3
+ import Road from './road';
4
+ export default class LaneSection {
5
+ /** 路段id:
6
+ * 在道路参考线上,路段起始点与道路起始点的距离
7
+ */
8
+ s0: number;
9
+ road: Road;
10
+ /** 路段上下左右的边框 */
11
+ borders: {
12
+ left: number[][];
13
+ right: number[][];
14
+ top: number[][];
15
+ bottom: number[][];
16
+ };
17
+ /** 上下左右边框围成的多边形 */
18
+ polygon: number[][];
19
+ /** 路段内的车道 */
20
+ private idToLane;
21
+ constructor(odrLanesection: any, road: Road);
22
+ /**
23
+ * 获取一个车道
24
+ * @param id
25
+ * @returns
26
+ */
27
+ getLane(id: number): Lane | undefined;
28
+ /**
29
+ * 获取所有车道
30
+ * @returns
31
+ */
32
+ get allLanes(): Lane[];
33
+ get laneNumber(): number;
34
+ /**
35
+ * 获取所有车道id,id升序排列
36
+ * @returns
37
+ */
38
+ get allLaneIds(): number[];
39
+ /**
40
+ * 路段采样后的数据
41
+ */
42
+ get sampledLaneSection(): ISampledLaneSection;
43
+ /**
44
+ * 计算路段上下左右边框
45
+ * @returns
46
+ */
47
+ private getBorderLine;
48
+ }