gisviewer-vue3-arcgis 1.0.115 → 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 (53) 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-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 +31 -3
  13. package/es/src/gis-map/utils/open-drive-renderer/index.mjs +274 -44
  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 +70 -0
  21. package/es/src/gis-map/utils/open-drive-renderer/lane.mjs +93 -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 +366 -0
  26. package/es/src/types/index.d.ts +48 -0
  27. package/lib/src/gis-map/gis-map.vue.d.ts +5 -3
  28. package/lib/src/gis-map/gis-map.vue.js +1 -1
  29. package/lib/src/gis-map/index.d.ts +4 -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 +31 -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 +70 -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 +48 -0
  53. package/package.json +4 -1
@@ -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 {};
@@ -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
+ }