gisviewer-vue3-arcgis 1.0.163 → 1.0.165

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.
@@ -18,6 +18,8 @@ export default class OpenDriveRenderer {
18
18
  private mouseClickHandler;
19
19
  private junctionNames;
20
20
  private readonly junctionScale;
21
+ private scaleWatch;
22
+ private xodrBorder;
21
23
  constructor(view: __esri.MapView | __esri.SceneView);
22
24
  private projectName;
23
25
  private openDriveServer;
@@ -111,6 +113,11 @@ export default class OpenDriveRenderer {
111
113
  geometrySearch(coordinate: number[][]): Promise<IResult>;
112
114
  splitLane(params: ISplitOpenDriveLaneParams): Promise<IResult>;
113
115
  clearSplitLane(): void;
116
+ /**
117
+ * 更新所有路口的symbol
118
+ * @param symbolStyle
119
+ */
120
+ private updateAllJunctionSymbol;
114
121
  /**
115
122
  * 生成路口点符号。在不同比例尺下,使用不同的符号
116
123
  * @param attributes
@@ -1,22 +1,22 @@
1
1
  import g from "@arcgis/core/Graphic";
2
2
  import * as C from "@arcgis/core/core/promiseUtils";
3
3
  import * as $ from "@arcgis/core/core/reactiveUtils.js";
4
- import { Polygon as N } from "@arcgis/core/geometry";
5
- import * as L from "@arcgis/core/geometry/geometryEngine";
4
+ import { Polygon as L, Point as F } from "@arcgis/core/geometry";
5
+ import * as S from "@arcgis/core/geometry/geometryEngine";
6
6
  import k from "@arcgis/core/layers/FeatureLayer";
7
- import I from "@arcgis/core/layers/GraphicsLayer";
7
+ import w from "@arcgis/core/layers/GraphicsLayer";
8
8
  import * as D from "@turf/helpers";
9
- import { lineSliceAlong as G } from "@turf/line-slice-along";
9
+ import { lineSliceAlong as x } from "@turf/line-slice-along";
10
10
  import b from "axios";
11
- import { XMLParser as F } from "fast-xml-parser";
12
- import P from "md5";
13
- import x from "pako";
11
+ import { XMLParser as P } from "fast-xml-parser";
12
+ import J from "md5";
13
+ import G from "pako";
14
14
  import { watch as E } from "vue";
15
15
  import R from "../../stores/index.mjs";
16
- import J from "../common-utils.mjs";
17
- class M {
16
+ import T from "../common-utils.mjs";
17
+ class O {
18
18
  constructor(e) {
19
- this.junctionNames = /* @__PURE__ */ new Map(), this.junctionScale = 5e3, this.projectName = "", this.openDriveServer = "", this.currentSectionCode = "", this.selectedSectionIds = [], this.currentJunctionId = "", this.view = e, this.laneLayer = new k({
19
+ this.junctionNames = /* @__PURE__ */ new Map(), this.junctionScale = 5e3, this.xodrBorder = [], this.projectName = "", this.openDriveServer = "", this.currentSectionCode = "", this.selectedSectionIds = [], this.currentJunctionId = "", this.view = e, this.laneLayer = new k({
20
20
  id: "OpenDriveLane",
21
21
  fields: [
22
22
  {
@@ -289,7 +289,7 @@ class M {
289
289
  }
290
290
  }
291
291
  ]
292
- }), this.junctionLayer = new I({ id: "OpenDriveJunction" }), this.sectionLayer = new I({ id: "OpenDriveSection" }), this.highlightLayer = new I({ id: "OpenDriveHighlight" }), this.flashLayer = new I({ id: "OpenDriveFlash" }), this.drawLayer = new I({ id: "Draw" }), this.splitLaneLayer = new I({ id: "SplitLane" }), this.borderLayer = new I({ id: "OpenDriveBorder" }), this.view.map.addMany([
292
+ }), this.junctionLayer = new w({ id: "OpenDriveJunction" }), this.sectionLayer = new w({ id: "OpenDriveSection" }), this.highlightLayer = new w({ id: "OpenDriveHighlight" }), this.flashLayer = new w({ id: "OpenDriveFlash" }), this.drawLayer = new w({ id: "Draw" }), this.splitLaneLayer = new w({ id: "SplitLane" }), this.borderLayer = new w({ id: "OpenDriveBorder" }), this.view.map.addMany([
293
293
  this.laneLayer,
294
294
  this.sectionLayer,
295
295
  this.roadNameLayer,
@@ -302,18 +302,19 @@ class M {
302
302
  ]);
303
303
  }
304
304
  static getInstance(e) {
305
- return this.instance || (this.instance = new M(e)), this.instance;
305
+ return this.instance || (this.instance = new O(e)), this.instance;
306
306
  }
307
307
  async makeMd5FromFile(e) {
308
308
  var t;
309
309
  try {
310
- const r = await (await fetch(e)).text(), n = (t = new F({
310
+ const o = await (await fetch(e)).text();
311
+ let r = (t = new P({
311
312
  ignoreAttributes: !1,
312
313
  allowBooleanAttributes: !0
313
- }).parse(r).OpenDRIVE.userData) == null ? void 0 : t.border;
314
- return { status: 0, message: "ok", result: { md5: P(r), border: n } };
315
- } catch (i) {
316
- return { status: -1, message: i.message };
314
+ }).parse(o).OpenDRIVE.userData) == null ? void 0 : t.border;
315
+ return r ? r = JSON.parse(r) : r = [], { status: 0, message: "ok", result: { md5: J(o), border: r } };
316
+ } catch (s) {
317
+ return { status: -1, message: s.message };
317
318
  }
318
319
  }
319
320
  /**
@@ -322,32 +323,39 @@ class M {
322
323
  * @returns
323
324
  */
324
325
  async showOpenDriveFromFile(e) {
325
- var f, y;
326
- this.openDriveClickCallback = e.selectedCallback, $.watch(
326
+ var y, m;
327
+ this.openDriveClickCallback = e.selectedCallback, this.scaleWatch = $.watch(
327
328
  () => this.view.scale,
328
- (p, h) => {
329
- p > this.junctionScale && h <= this.junctionScale ? (console.log(p, h), this.junctionLayer.graphics.forEach((m) => {
330
- m.symbol = this.getCrossGraphicSymbol(
331
- m.attributes,
332
- "marker"
333
- );
334
- })) : p <= this.junctionScale && h > this.junctionScale && (console.log(p, h), this.junctionLayer.graphics.forEach((m) => {
335
- m.symbol = this.getCrossGraphicSymbol(
336
- m.attributes,
337
- "picture"
338
- );
339
- }));
329
+ (h, p) => {
330
+ h > this.junctionScale && p <= this.junctionScale ? this.updateAllJunctionSymbol("marker") : h <= this.junctionScale && p > this.junctionScale && this.updateAllJunctionSymbol("picture");
340
331
  }
341
332
  ), console.time("md5用时");
342
333
  const t = await this.makeMd5FromFile(e.file);
343
334
  if (t.status !== 0)
344
335
  return t;
345
- this.projectName = t.result.md5, console.timeEnd("md5用时"), console.log(t.result.border), this.openDriveServer = e.server;
346
- const i = `http://${this.openDriveServer}/api/openDrive/uploadXodr`;
347
- let r;
336
+ if (this.projectName = t.result.md5, console.timeEnd("md5用时"), this.xodrBorder = t.result.border, this.xodrBorder.length > 0) {
337
+ const h = new g({
338
+ geometry: new L({
339
+ rings: [this.xodrBorder]
340
+ }),
341
+ symbol: {
342
+ type: "simple-fill",
343
+ style: "none",
344
+ outline: {
345
+ style: "dash",
346
+ color: "black",
347
+ width: 2
348
+ }
349
+ }
350
+ });
351
+ console.log(h.toJSON()), this.borderLayer.add(h);
352
+ }
353
+ this.openDriveServer = e.server;
354
+ const s = `http://${this.openDriveServer}/api/openDrive/uploadXodr`;
355
+ let o;
348
356
  try {
349
- r = await b.post(
350
- i,
357
+ o = await b.post(
358
+ s,
351
359
  {},
352
360
  {
353
361
  params: {
@@ -356,34 +364,34 @@ class M {
356
364
  }
357
365
  }
358
366
  );
359
- } catch (p) {
360
- return { status: -1, message: p.message };
367
+ } catch (h) {
368
+ return { status: -1, message: h.message };
361
369
  }
362
- if (r.status !== 200)
363
- return { status: -1, message: r.statusText };
370
+ if (o.status !== 200)
371
+ return { status: -1, message: o.statusText };
364
372
  console.time("渲染用时");
365
- const s = r.data.result.geoSetting;
366
- J.setGeoData(
367
- s.geoReference,
368
- s.offsetX,
369
- s.offsetY
373
+ const i = o.data.result.geoSetting;
374
+ T.setGeoData(
375
+ i.geoReference,
376
+ i.offsetX,
377
+ i.offsetY
370
378
  );
371
- let c = r.data.result.json;
379
+ let c = o.data.result.json;
372
380
  c.startsWith(window.location.protocol) || (c = `${window.location.protocol}//${e.server}${c}`);
373
- const a = await (await fetch(c)).arrayBuffer(), o = x.inflate(a, { to: "string" }), l = JSON.parse(o);
381
+ const a = await (await fetch(c)).arrayBuffer(), n = G.inflate(a, { to: "string" }), l = JSON.parse(n);
374
382
  await this.showAllLanes(
375
383
  l,
376
- ((f = e.options) == null ? void 0 : f.showJunctionLane) || !1,
377
- ((y = e.options) == null ? void 0 : y.showRoadName) || !0
384
+ ((y = e.options) == null ? void 0 : y.showJunctionLane) || !1,
385
+ ((m = e.options) == null ? void 0 : m.showRoadName) || !0
378
386
  );
379
- const d = r.data.result.junctions;
387
+ const d = o.data.result.junctions;
380
388
  this.showJunction(d), e.options && e.options.centerMap !== !1 && await this.view.goTo(this.allLaneGraphics), this.mouseMoveHandler || this.monitorMouseMove(), this.mouseClickHandler || this.monitorMouseClick();
381
389
  const u = R.useAppDataStore;
382
390
  return E(
383
391
  () => u.isSketching,
384
392
  () => {
385
- var p, h;
386
- u.isSketching ? ((p = this.mouseMoveHandler) == null || p.remove(), this.mouseMoveHandler = void 0, (h = this.mouseClickHandler) == null || h.remove(), this.mouseClickHandler = void 0) : (this.monitorMouseMove(), this.monitorMouseClick());
393
+ var h, p;
394
+ u.isSketching ? ((h = this.mouseMoveHandler) == null || h.remove(), this.mouseMoveHandler = void 0, (p = this.mouseClickHandler) == null || p.remove(), this.mouseClickHandler = void 0) : (this.monitorMouseMove(), this.monitorMouseClick());
387
395
  }
388
396
  ), console.timeEnd("渲染用时"), { status: 0, message: "ok" };
389
397
  }
@@ -393,7 +401,7 @@ class M {
393
401
  * @param projectName
394
402
  */
395
403
  async showOpenDriveFromServer(e, t) {
396
- const i = `http://${e}/api/openDrive/analyzeXodr`, r = await b.get(i, {
404
+ const s = `http://${e}/api/openDrive/analyzeXodr`, o = await b.get(s, {
397
405
  headers: {
398
406
  projectName: t
399
407
  },
@@ -402,12 +410,12 @@ class M {
402
410
  compressed: !0
403
411
  }
404
412
  });
405
- if (r.status !== 200)
406
- throw new Error(`OpenDriveRenderer: ${r.statusText}`);
407
- let s = r.data.result.json;
408
- s.startsWith(window.location.protocol) || (s = `${window.location.protocol}//${e}${s}`);
409
- const n = await (await fetch(s)).arrayBuffer(), a = x.inflate(n, { to: "string" }), o = JSON.parse(a);
410
- return await this.showAllLanes(o, !1, !1), { status: 0, message: "ok" };
413
+ if (o.status !== 200)
414
+ throw new Error(`OpenDriveRenderer: ${o.statusText}`);
415
+ let i = o.data.result.json;
416
+ i.startsWith(window.location.protocol) || (i = `${window.location.protocol}//${e}${i}`);
417
+ const r = await (await fetch(i)).arrayBuffer(), a = G.inflate(r, { to: "string" }), n = JSON.parse(a);
418
+ return await this.showAllLanes(n, !1, !1), { status: 0, message: "ok" };
411
419
  }
412
420
  /**
413
421
  * 显示所有车道
@@ -416,21 +424,21 @@ class M {
416
424
  * @param showRoadName 是否显示道路名称
417
425
  * @returns
418
426
  */
419
- async showAllLanes(e, t, i) {
420
- const r = await this.laneLayer.queryFeatures();
421
- return r.features.length > 0 && this.laneLayer.applyEdits({
422
- deleteFeatures: r.features
423
- }), this.roadNameLayer.visible = i, new Promise((s) => {
427
+ async showAllLanes(e, t, s) {
428
+ const o = await this.laneLayer.queryFeatures();
429
+ return o.features.length > 0 && this.laneLayer.applyEdits({
430
+ deleteFeatures: o.features
431
+ }), this.roadNameLayer.visible = s, new Promise((i) => {
424
432
  let c = 0;
425
433
  this.allLaneGraphics = [], this.allRefLineGraphics = [];
426
- const n = [];
427
- for (const o of e) {
428
- if (!t && o.junction !== "-1")
434
+ const r = [];
435
+ for (const n of e) {
436
+ if (!t && n.junction !== "-1")
429
437
  continue;
430
- const { id: l, refLine: d } = o;
431
- let u = o.name;
438
+ const { id: l, refLine: d } = n;
439
+ let u = n.name;
432
440
  u.includes("(") && (u = u.slice(0, u.indexOf("("))), u = u.replace(/(.)/g, "$1 ");
433
- const f = new g({
441
+ const y = new g({
434
442
  geometry: {
435
443
  type: "polyline",
436
444
  paths: [d]
@@ -441,65 +449,65 @@ class M {
441
449
  roadName: u
442
450
  }
443
451
  });
444
- this.allRefLineGraphics.push(f), o.laneSections.sort((y, p) => Number(y.id) - Number(p.id));
445
- for (let y = 0; y < o.laneSections.length; y++) {
446
- const p = o.laneSections[y], h = Number(p.id);
447
- for (const m of p.lanePaths) {
448
- const v = Number(m.id);
452
+ this.allRefLineGraphics.push(y), n.laneSections.sort((m, h) => Number(m.id) - Number(h.id));
453
+ for (let m = 0; m < n.laneSections.length; m++) {
454
+ const h = n.laneSections[m], p = Number(h.id);
455
+ for (const f of h.lanePaths) {
456
+ const v = Number(f.id);
449
457
  if (v === 0)
450
458
  continue;
451
- const w = m.type, O = [...m.outerPath], S = m.innerPath.concat(
452
- O.reverse()
459
+ const I = f.type, M = [...f.outerPath], N = f.innerPath.concat(
460
+ M.reverse()
453
461
  );
454
- if (S.length <= 3) {
462
+ if (N.length <= 3) {
455
463
  console.warn(`lane ${v} has less than 3 points`);
456
464
  continue;
457
465
  }
458
- S.push(m.innerPath[0]);
459
- const A = new N({
460
- rings: [S]
466
+ N.push(f.innerPath[0]);
467
+ const A = new L({
468
+ rings: [N]
461
469
  });
462
470
  if (A) {
463
471
  const j = new g({
464
472
  geometry: A,
465
473
  attributes: {
466
474
  ObjectID: c++,
467
- id: `${l}+${h}+${v}`,
468
- fromNode: o.fromNode,
469
- toNode: o.toNode,
475
+ id: `${l}+${p}+${v}`,
476
+ fromNode: n.fromNode,
477
+ toNode: n.toNode,
470
478
  roadId: String(l),
471
- roadName: o.name,
472
- sectionId: String(h),
473
- sectionIndex: y,
479
+ roadName: n.name,
480
+ sectionId: String(p),
481
+ sectionIndex: m,
474
482
  laneId: v,
475
- type: w,
483
+ type: I,
476
484
  sumoId: "",
477
485
  // 记录左右边线的起始点,用于按长度高亮车道的一部分
478
- leftLine: m.innerPath,
479
- rightLine: m.outerPath
486
+ leftLine: f.innerPath,
487
+ rightLine: f.outerPath
480
488
  }
481
489
  });
482
- this.allLaneGraphics.push(j), n.push(j);
490
+ this.allLaneGraphics.push(j), r.push(j);
483
491
  }
484
492
  }
485
493
  }
486
494
  }
487
495
  const a = setInterval(() => {
488
- if (n.length > 0 || this.allRefLineGraphics.length > 0) {
489
- if (n.length > 0) {
490
- const o = n.splice(0, 100);
496
+ if (r.length > 0 || this.allRefLineGraphics.length > 0) {
497
+ if (r.length > 0) {
498
+ const n = r.splice(0, 100);
491
499
  this.laneLayer.applyEdits({
492
- addFeatures: o
500
+ addFeatures: n
493
501
  });
494
502
  }
495
503
  if (this.allRefLineGraphics.length > 0) {
496
- const o = this.allRefLineGraphics.splice(0, 10);
504
+ const n = this.allRefLineGraphics.splice(0, 10);
497
505
  this.roadNameLayer.applyEdits({
498
- addFeatures: o
506
+ addFeatures: n
499
507
  });
500
508
  }
501
509
  } else
502
- clearInterval(a), s();
510
+ clearInterval(a), i();
503
511
  }, 10);
504
512
  });
505
513
  }
@@ -510,52 +518,30 @@ class M {
510
518
  */
511
519
  showJunction(e) {
512
520
  const t = [];
513
- for (const i of e) {
514
- if (!i)
515
- continue;
516
- this.junctionNames.set(i.id, i.name), i.nodeType = i.type;
517
- const r = new g({
518
- geometry: {
519
- type: "point",
520
- x: i.coordinates[0],
521
- y: i.coordinates[1]
522
- },
523
- attributes: {
524
- ...i,
525
- selected: !1,
526
- type: "OpenDriveJunction"
527
- },
528
- symbol: this.getCrossGraphicSymbol(i, "marker")
529
- // symbol: {
530
- // type: 'picture-marker',
531
- // url: junctionTableData.crossId
532
- // ? '/GisViewerAssets/Images/xhj_1.png'
533
- // : '/GisViewerAssets/Images/xhj_2.png',
534
- // width: '18px',
535
- // height: '28px',
536
- // yoffset: '9px'
537
- // } as any,
538
- // popupTemplate: {
539
- // title: junctionTableData.name,
540
- // content: [
541
- // {
542
- // type: 'fields',
543
- // fieldInfos: [
544
- // {
545
- // fieldName: 'id',
546
- // label: '路口编号'
547
- // },
548
- // {
549
- // fieldName: 'crossId',
550
- // label: '信号机编号'
551
- // }
552
- // ]
553
- // }
554
- // ]
555
- // }
556
- });
557
- t.push(r);
558
- }
521
+ let s;
522
+ this.xodrBorder.length > 0 && (s = new L({
523
+ rings: [this.xodrBorder]
524
+ }));
525
+ for (const o of e)
526
+ if (o && (this.junctionNames.set(o.id, o.name), o.nodeType = o.type, o.crossId)) {
527
+ const i = new F({
528
+ x: o.coordinates[0],
529
+ y: o.coordinates[1]
530
+ });
531
+ let c = !0;
532
+ if (s && (c = S.contains(s, i)), c) {
533
+ const r = new g({
534
+ geometry: i,
535
+ attributes: {
536
+ ...o,
537
+ selected: !1,
538
+ type: "OpenDriveJunction"
539
+ },
540
+ symbol: this.getCrossGraphicSymbol(o, "marker")
541
+ });
542
+ t.push(r);
543
+ }
544
+ }
559
545
  this.junctionLayer.addMany(t);
560
546
  }
561
547
  /**
@@ -564,30 +550,30 @@ class M {
564
550
  monitorMouseMove() {
565
551
  const e = C.debounce(async (t) => {
566
552
  var c;
567
- const r = (c = (await this.view.hitTest(t, {
553
+ const o = (c = (await this.view.hitTest(t, {
568
554
  include: [this.laneLayer, this.junctionLayer]
569
555
  })).results) == null ? void 0 : c.filter(
570
- (n) => n.type === "graphic"
556
+ (r) => r.type === "graphic"
571
557
  );
572
- if (r.length === 0) {
558
+ if (o.length === 0) {
573
559
  this.currentSectionCode !== "" && (this.currentSectionCode = "", this.highlightLayer.removeAll()), this.currentJunctionId !== "" && (this.currentJunctionId = ""), this.view.closePopup();
574
560
  return;
575
561
  }
576
- const s = r[0];
577
- if (this.hitGraphic = s.graphic, s.layer.id === "OpenDriveLane") {
578
- const n = `${this.hitGraphic.getAttribute(
562
+ const i = o[0];
563
+ if (this.hitGraphic = i.graphic, i.layer.id === "OpenDriveLane") {
564
+ const r = `${this.hitGraphic.getAttribute(
579
565
  "roadId"
580
566
  )}+${this.hitGraphic.getAttribute("sectionId")}`;
581
- if (this.currentSectionCode === n || this.selectedSectionIds.includes(n) || this.sectionLayer.graphics.findIndex(
582
- (h) => h.getAttribute("id") === n
567
+ if (this.currentSectionCode === r || this.selectedSectionIds.includes(r) || this.sectionLayer.graphics.findIndex(
568
+ (p) => p.getAttribute("id") === r
583
569
  ) >= 0)
584
570
  return;
585
- this.currentSectionCode = n;
586
- const o = this.allLaneGraphics.filter(
587
- (h) => `${h.attributes.roadId}+${h.attributes.sectionId}` === n
588
- ), l = L.union(
589
- o.map((h) => h.geometry)
590
- ), d = this.hitGraphic.getAttribute("fromNode"), u = this.hitGraphic.getAttribute("toNode"), f = this.junctionNames.get(d) || d, y = this.junctionNames.get(u) || u, p = new g({
571
+ this.currentSectionCode = r;
572
+ const n = this.allLaneGraphics.filter(
573
+ (p) => `${p.attributes.roadId}+${p.attributes.sectionId}` === r
574
+ ), l = S.union(
575
+ n.map((p) => p.geometry)
576
+ ), d = this.hitGraphic.getAttribute("fromNode"), u = this.hitGraphic.getAttribute("toNode"), y = this.junctionNames.get(d) || d, m = this.junctionNames.get(u) || u, h = new g({
591
577
  geometry: l,
592
578
  symbol: {
593
579
  type: "simple-fill",
@@ -600,11 +586,11 @@ class M {
600
586
  },
601
587
  attributes: {
602
588
  type: "OpenDriveSection",
603
- id: n,
589
+ id: r,
604
590
  selected: !1,
605
- fromNodeName: f,
606
- toNodeName: y,
607
- laneCount: o.length
591
+ fromNodeName: y,
592
+ toNodeName: m,
593
+ laneCount: n.length
608
594
  },
609
595
  popupTemplate: {
610
596
  title: this.hitGraphic.getAttribute("roadName"),
@@ -629,12 +615,12 @@ class M {
629
615
  ]
630
616
  }
631
617
  });
632
- this.highlightLayer.removeAll(), this.highlightLayer.add(p);
633
- } else if (s.layer.id === "OpenDriveJunction") {
634
- const n = this.hitGraphic.getAttribute("id");
635
- if (n === this.currentJunctionId)
618
+ this.highlightLayer.removeAll(), this.highlightLayer.add(h);
619
+ } else if (i.layer.id === "OpenDriveJunction") {
620
+ const r = this.hitGraphic.getAttribute("id");
621
+ if (r === this.currentJunctionId)
636
622
  return;
637
- this.currentJunctionId = n;
623
+ this.currentJunctionId = r;
638
624
  }
639
625
  });
640
626
  this.mouseMoveHandler = this.view.on("pointer-move", async (t) => {
@@ -648,64 +634,64 @@ class M {
648
634
  monitorMouseClick() {
649
635
  const e = C.debounce(async (t) => {
650
636
  var a;
651
- const r = (a = (await this.view.hitTest(t, {
637
+ const o = (a = (await this.view.hitTest(t, {
652
638
  include: [this.highlightLayer, this.junctionLayer, this.sectionLayer]
653
639
  })).results) == null ? void 0 : a.filter(
654
- (o) => o.type === "graphic"
640
+ (n) => n.type === "graphic"
655
641
  );
656
- if (r.length === 0)
642
+ if (o.length === 0)
657
643
  return;
658
- const s = r[0].graphic, c = s.getAttribute("type"), n = s.getAttribute("id");
644
+ const i = o[0].graphic, c = i.getAttribute("type"), r = i.getAttribute("id");
659
645
  if (c === "OpenDriveJunction")
660
- if (s.getAttribute("selected") === !1) {
661
- const o = `http://${this.openDriveServer}/api/sumo/getSumoJunction`, l = await b.get(o, {
646
+ if (i.getAttribute("selected") === !1) {
647
+ const n = `http://${this.openDriveServer}/api/sumo/getSumoJunction`, l = await b.get(n, {
662
648
  params: {
663
- id: n,
649
+ id: r,
664
650
  projectName: this.projectName
665
651
  }
666
652
  });
667
653
  l.status === 200 && l.data.status === 0 && (this.openDriveClickCallback && this.openDriveClickCallback({
668
654
  type: "OpenDriveJunction",
669
- id: n,
655
+ id: r,
670
656
  details: l.data.result
671
- }), s.setAttribute("selected", !0), s.symbol = {
657
+ }), i.setAttribute("selected", !0), i.symbol = {
672
658
  type: "picture-marker",
673
659
  url: "/GisViewerAssets/Images/point_red.png",
674
660
  width: "20px",
675
661
  height: "20px"
676
- }, this.increasePictureMarkerSize(s, 50));
662
+ }, this.increasePictureMarkerSize(i, 50));
677
663
  } else
678
664
  this.openDriveClickCallback && this.openDriveClickCallback({
679
665
  type: "OpenDriveJunction",
680
- id: n,
666
+ id: r,
681
667
  details: void 0
682
- }), s.setAttribute("selected", !1), s.symbol = this.getCrossGraphicSymbol(
683
- s.attributes,
668
+ }), i.setAttribute("selected", !1), i.symbol = this.getCrossGraphicSymbol(
669
+ i.attributes,
684
670
  this.view.scale < this.junctionScale ? "picture" : "marker"
685
671
  );
686
672
  else if (c === "OpenDriveSection")
687
- if (s.layer.id === "OpenDriveHighlight") {
688
- this.highlightLayer.remove(s), this.sectionLayer.add(s), s.setAttribute("selected", !0), this.selectedSectionIds.push(n);
689
- const o = `http://${this.openDriveServer}/api/sumo/getSumoEdge`, l = await b.get(o, {
673
+ if (i.layer.id === "OpenDriveHighlight") {
674
+ this.highlightLayer.remove(i), this.sectionLayer.add(i), i.setAttribute("selected", !0), this.selectedSectionIds.push(r);
675
+ const n = `http://${this.openDriveServer}/api/sumo/getSumoEdge`, l = await b.get(n, {
690
676
  params: {
691
- id: n,
677
+ id: r,
692
678
  projectName: this.projectName
693
679
  }
694
680
  });
695
681
  if (l.status === 200 && l.data.status === 0 && this.openDriveClickCallback) {
696
682
  const d = l.data.result.obj_id;
697
- s.setAttribute("edgeId", d), this.openDriveClickCallback({
683
+ i.setAttribute("edgeId", d), this.openDriveClickCallback({
698
684
  type: "OpenDriveSection",
699
685
  id: d,
700
686
  details: l.data.result
701
687
  });
702
688
  }
703
689
  } else
704
- this.sectionLayer.remove(s), this.selectedSectionIds = this.selectedSectionIds.filter(
705
- (o) => o !== n
690
+ this.sectionLayer.remove(i), this.selectedSectionIds = this.selectedSectionIds.filter(
691
+ (n) => n !== r
706
692
  ), this.openDriveClickCallback && this.openDriveClickCallback({
707
693
  type: "OpenDriveSection",
708
- id: s.getAttribute("edgeId"),
694
+ id: i.getAttribute("edgeId"),
709
695
  details: void 0
710
696
  });
711
697
  });
@@ -720,14 +706,14 @@ class M {
720
706
  * @param targetSize
721
707
  */
722
708
  increasePictureMarkerSize(e, t) {
723
- const i = setInterval(() => {
724
- const r = e.symbol, s = r.width;
725
- s < t ? e.symbol = {
709
+ const s = setInterval(() => {
710
+ const o = e.symbol, i = o.width;
711
+ i < t ? e.symbol = {
726
712
  type: "picture-marker",
727
- url: r.url,
728
- width: s + 1,
729
- height: s + 1
730
- } : clearInterval(i);
713
+ url: o.url,
714
+ width: i + 1,
715
+ height: i + 1
716
+ } : clearInterval(s);
731
717
  }, 20);
732
718
  }
733
719
  /**
@@ -736,40 +722,40 @@ class M {
736
722
  * @param targetSize
737
723
  */
738
724
  decreasePictureMarkerSize(e, t) {
739
- const i = setInterval(() => {
740
- const r = e.symbol, s = r.width;
741
- s > t ? e.symbol = {
725
+ const s = setInterval(() => {
726
+ const o = e.symbol, i = o.width;
727
+ i > t ? e.symbol = {
742
728
  type: "picture-marker",
743
- url: r.url,
744
- width: s - 1,
745
- height: s - 1
746
- } : clearInterval(i);
729
+ url: o.url,
730
+ width: i - 1,
731
+ height: i - 1
732
+ } : clearInterval(s);
747
733
  }, 20);
748
734
  }
749
735
  async getSumoInfo(e) {
750
736
  switch (e.type) {
751
737
  case "junction": {
752
- const t = `http://${this.openDriveServer}/api/sumo/getSumoJunction`, i = await b.get(t, {
738
+ const t = `http://${this.openDriveServer}/api/sumo/getSumoJunction`, s = await b.get(t, {
753
739
  params: {
754
740
  id: e.id,
755
741
  projectName: this.projectName
756
742
  }
757
743
  });
758
- return i.status === 200 ? i.data : { status: -1, message: `路口信息查询失败: ${e.id}` };
744
+ return s.status === 200 ? s.data : { status: -1, message: `路口信息查询失败: ${e.id}` };
759
745
  }
760
746
  case "edge": {
761
747
  const t = e.id.split("#");
762
- let i = t[0];
763
- i.startsWith("-") && (i = i.slice(1));
764
- let r = 0;
765
- t.length === 2 && (r = Number(t[1]));
766
- const s = this.allLaneGraphics.find(
767
- (c) => c.getAttribute("roadId") === i && c.getAttribute("sectionIndex") === r
748
+ let s = t[0];
749
+ s.startsWith("-") && (s = s.slice(1));
750
+ let o = 0;
751
+ t.length === 2 && (o = Number(t[1]));
752
+ const i = this.allLaneGraphics.find(
753
+ (c) => c.getAttribute("roadId") === s && c.getAttribute("sectionIndex") === o
768
754
  );
769
- if (s) {
770
- const c = `${i}+${s.getAttribute(
755
+ if (i) {
756
+ const c = `${s}+${i.getAttribute(
771
757
  "sectionId"
772
- )}`, n = `http://${this.openDriveServer}/api/sumo/getSumoEdge`, a = await b.get(n, {
758
+ )}`, r = `http://${this.openDriveServer}/api/sumo/getSumoEdge`, a = await b.get(r, {
773
759
  params: {
774
760
  id: c,
775
761
  projectName: this.projectName
@@ -787,13 +773,13 @@ class M {
787
773
  * 清除OpenDrive内容
788
774
  */
789
775
  async clearOpenDrive() {
790
- var t, i;
776
+ var t, s, o;
791
777
  let e = await this.laneLayer.queryFeatures();
792
778
  e.features.length > 0 && await this.laneLayer.applyEdits({
793
779
  deleteFeatures: e.features
794
780
  }), e = await this.roadNameLayer.queryFeatures(), e.features.length > 0 && await this.roadNameLayer.applyEdits({
795
781
  deleteFeatures: e.features
796
- }), this.highlightLayer.removeAll(), this.junctionLayer.removeAll(), this.sectionLayer.removeAll(), this.flashLayer.removeAll(), (t = this.mouseMoveHandler) == null || t.remove(), this.mouseMoveHandler = void 0, (i = this.mouseClickHandler) == null || i.remove(), this.mouseClickHandler = void 0;
782
+ }), this.highlightLayer.removeAll(), this.junctionLayer.removeAll(), this.sectionLayer.removeAll(), this.flashLayer.removeAll(), this.borderLayer.removeAll(), (t = this.mouseMoveHandler) == null || t.remove(), this.mouseMoveHandler = void 0, (s = this.mouseClickHandler) == null || s.remove(), this.mouseClickHandler = void 0, (o = this.scaleWatch) == null || o.remove(), this.scaleWatch = void 0;
797
783
  }
798
784
  /**
799
785
  * 用sumo的id定位车道、基本段、路段
@@ -801,30 +787,30 @@ class M {
801
787
  * @returns
802
788
  */
803
789
  async findSumo(e) {
804
- const { type: t, id: i } = e, r = e.flash === void 0 ? !0 : e.flash;
790
+ const { type: t, id: s } = e, o = e.flash === void 0 ? !0 : e.flash;
805
791
  if (t === "junction")
806
- return await this.findJunction(i, r);
792
+ return await this.findJunction(s, o);
807
793
  if (t === "edge") {
808
- const s = i.split("_");
809
- if (s.length > 2)
794
+ const i = s.split("_");
795
+ if (i.length > 2)
810
796
  return { status: -1, message: "id格式错误" };
811
- const c = s.length === 2 ? Number(s[1]) : void 0, n = s[0].split("#");
812
- if (n.length > 2)
797
+ const c = i.length === 2 ? Number(i[1]) : void 0, r = i[0].split("#");
798
+ if (r.length > 2)
813
799
  return { status: -1, message: "id格式错误" };
814
- const a = n[0], o = n.length === 2 ? Number(n[1]) : void 0;
815
- return await this.findLane({ roadsectId: a, segmentId: o, laneId: c, flash: r });
800
+ const a = r[0], n = r.length === 2 ? Number(r[1]) : void 0;
801
+ return await this.findLane({ roadsectId: a, segmentId: n, laneId: c, flash: o });
816
802
  } else
817
803
  return { status: -1, message: "未知类型" };
818
804
  }
819
805
  async findJunction(e, t) {
820
- const i = this.junctionLayer.graphics.find(
821
- (r) => r.attributes.id === e
806
+ const s = this.junctionLayer.graphics.find(
807
+ (o) => o.attributes.id === e
822
808
  );
823
- if (!i)
809
+ if (!s)
824
810
  return { status: -1, message: "未找到。请检查路口编号" };
825
811
  if (t) {
826
- const r = new g({
827
- geometry: i.geometry,
812
+ const o = new g({
813
+ geometry: s.geometry,
828
814
  symbol: {
829
815
  type: "simple-marker",
830
816
  style: "circle",
@@ -836,9 +822,9 @@ class M {
836
822
  }
837
823
  }
838
824
  });
839
- this.flashGraphic(r);
825
+ this.flashGraphic(o);
840
826
  }
841
- return await this.view.goTo(i.geometry, { duration: 1e3 }), { status: 0, message: "ok" };
827
+ return await this.view.goTo(s.geometry, { duration: 1e3 }), { status: 0, message: "ok" };
842
828
  }
843
829
  /**
844
830
  * 用sumo的id定位车道、基本段、路段
@@ -846,41 +832,41 @@ class M {
846
832
  * @returns
847
833
  */
848
834
  async findLane(e) {
849
- let { roadsectId: t, segmentId: i, laneId: r } = e;
835
+ let { roadsectId: t, segmentId: s, laneId: o } = e;
850
836
  t.startsWith("-") && (t = t.slice(1));
851
- let s = this.allLaneGraphics.filter(
837
+ let i = this.allLaneGraphics.filter(
852
838
  (a) => a.attributes.roadId === t
853
839
  );
854
- if (s.length === 0)
840
+ if (i.length === 0)
855
841
  return { status: -1, message: "未找到。请检查路段编号" };
856
- if (i !== void 0) {
842
+ if (s !== void 0) {
857
843
  const a = [];
858
- if (s.forEach((o) => {
859
- const l = Number(o.attributes.sectionId);
844
+ if (i.forEach((n) => {
845
+ const l = Number(n.attributes.sectionId);
860
846
  a.indexOf(l) === -1 && a.push(l);
861
- }), a.sort((o, l) => o - l), i > a.length - 1)
847
+ }), a.sort((n, l) => n - l), s > a.length - 1)
862
848
  return { status: -1, message: "未找到。请检查基本段编号" };
863
- i = a[i], s = s.filter(
864
- (o) => Number(o.attributes.sectionId) === i
849
+ s = a[s], i = i.filter(
850
+ (n) => Number(n.attributes.sectionId) === s
865
851
  );
866
852
  }
867
- if (r !== void 0) {
853
+ if (o !== void 0) {
868
854
  const a = [];
869
- if (s.forEach((o) => {
870
- const l = Number(o.attributes.laneId);
855
+ if (i.forEach((n) => {
856
+ const l = Number(n.attributes.laneId);
871
857
  a.indexOf(l) === -1 && a.push(l);
872
- }), a.sort((o, l) => o - l), r > a.length - 1)
858
+ }), a.sort((n, l) => n - l), o > a.length - 1)
873
859
  return { status: -1, message: "未找到。请检查车道编号" };
874
- r = a[r], s = s.filter(
875
- (o) => Number(o.attributes.laneId) === r
860
+ o = a[o], i = i.filter(
861
+ (n) => Number(n.attributes.laneId) === o
876
862
  );
877
863
  }
878
- const c = s.map(
864
+ const c = i.map(
879
865
  (a) => a.geometry
880
- ), n = L.union(c);
866
+ ), r = S.union(c);
881
867
  if (e.flash) {
882
868
  const a = new g({
883
- geometry: n,
869
+ geometry: r,
884
870
  symbol: {
885
871
  type: "simple-fill",
886
872
  color: [0, 0, 255, 0.6],
@@ -892,7 +878,7 @@ class M {
892
878
  });
893
879
  this.flashGraphic(a);
894
880
  }
895
- return await this.view.goTo(n, { duration: 1e3 }), { status: 0, message: "ok" };
881
+ return await this.view.goTo(r, { duration: 1e3 }), { status: 0, message: "ok" };
896
882
  }
897
883
  /**
898
884
  * graphic渐隐渐显闪烁
@@ -900,9 +886,9 @@ class M {
900
886
  */
901
887
  flashGraphic(e) {
902
888
  this.flashLayer.removeAll(), this.flashLayer.add(e);
903
- let t = 0, i = !0;
904
- const r = setInterval(() => {
905
- i ? (this.flashLayer.opacity -= 0.02, this.flashLayer.opacity <= 0.1 && (i = !1, t++)) : (this.flashLayer.opacity += 0.02, this.flashLayer.opacity >= 1 && (i = !0)), t >= 5 && (this.flashLayer.removeAll(), this.flashLayer.opacity = 1, clearInterval(r));
889
+ let t = 0, s = !0;
890
+ const o = setInterval(() => {
891
+ s ? (this.flashLayer.opacity -= 0.02, this.flashLayer.opacity <= 0.1 && (s = !1, t++)) : (this.flashLayer.opacity += 0.02, this.flashLayer.opacity >= 1 && (s = !0)), t >= 5 && (this.flashLayer.removeAll(), this.flashLayer.opacity = 1, clearInterval(o));
906
892
  }, 10);
907
893
  }
908
894
  /**
@@ -918,10 +904,10 @@ class M {
918
904
  ));
919
905
  }), !e || e.type === "edge") {
920
906
  let t;
921
- !e || !e.id || e.id === "" ? t = this.sectionLayer.graphics.toArray() : t = this.sectionLayer.graphics.filter((i) => i.getAttribute("edgeId") === e.id).toArray(), t.length > 0 && (t.forEach((i) => {
922
- const r = i.getAttribute("id");
907
+ !e || !e.id || e.id === "" ? t = this.sectionLayer.graphics.toArray() : t = this.sectionLayer.graphics.filter((s) => s.getAttribute("edgeId") === e.id).toArray(), t.length > 0 && (t.forEach((s) => {
908
+ const o = s.getAttribute("id");
923
909
  this.selectedSectionIds = this.selectedSectionIds.filter(
924
- (s) => s !== r
910
+ (i) => i !== o
925
911
  );
926
912
  }), this.sectionLayer.removeMany(t));
927
913
  }
@@ -941,25 +927,25 @@ class M {
941
927
  }), { status: -1, message: "未找到路口" };
942
928
  case "edge": {
943
929
  const t = e.id.split("#");
944
- let i = String(t[0]);
945
- i.startsWith("-") && (i = i.slice(1));
946
- let r = 0;
947
- t.length === 2 && (r = Number(t[1]));
948
- let s = [];
949
- if (t.length === 1 ? s = this.allLaneGraphics.filter(
950
- (c) => c.getAttribute("roadId") === i
951
- ) : t.length === 2 && (s = this.allLaneGraphics.filter(
952
- (c) => c.getAttribute("roadId") === i && c.getAttribute("sectionIndex") === r
953
- )), s.length > 0) {
930
+ let s = String(t[0]);
931
+ s.startsWith("-") && (s = s.slice(1));
932
+ let o = 0;
933
+ t.length === 2 && (o = Number(t[1]));
934
+ let i = [];
935
+ if (t.length === 1 ? i = this.allLaneGraphics.filter(
936
+ (c) => c.getAttribute("roadId") === s
937
+ ) : t.length === 2 && (i = this.allLaneGraphics.filter(
938
+ (c) => c.getAttribute("roadId") === s && c.getAttribute("sectionIndex") === o
939
+ )), i.length > 0) {
954
940
  const c = /* @__PURE__ */ new Map();
955
- return s.forEach((n) => {
956
- const a = n.getAttribute("roadId") + "+" + n.getAttribute("sectionId");
941
+ return i.forEach((r) => {
942
+ const a = r.getAttribute("roadId") + "+" + r.getAttribute("sectionId");
957
943
  this.selectedSectionIds.includes(a) || this.selectedSectionIds.push(a);
958
- let o = c.get(a);
959
- o ? o.push(n.geometry) : (o = [n.geometry], c.set(a, o));
960
- }), c.forEach((n, a) => {
961
- const o = L.union(n), l = new g({
962
- geometry: o,
944
+ let n = c.get(a);
945
+ n ? n.push(r.geometry) : (n = [r.geometry], c.set(a, n));
946
+ }), c.forEach((r, a) => {
947
+ const n = S.union(r), l = new g({
948
+ geometry: n,
963
949
  symbol: {
964
950
  type: "simple-fill",
965
951
  color: [0, 255, 255, 0.5],
@@ -986,81 +972,81 @@ class M {
986
972
  }
987
973
  }
988
974
  async geometrySearch(e) {
989
- const t = new N({
975
+ const t = new L({
990
976
  rings: [e]
991
- }), i = await this.laneLayer.queryFeatures({
977
+ }), s = await this.laneLayer.queryFeatures({
992
978
  geometry: t,
993
979
  outFields: ["*"]
994
- }), r = [], s = [];
995
- for (const a of i.features) {
996
- const o = a.getAttribute("roadId"), l = a.getAttribute("sectionIndex"), d = `${o}#${l}`;
997
- if (r.indexOf(d) === -1) {
998
- r.push(d), this.selectSumo({
980
+ }), o = [], i = [];
981
+ for (const a of s.features) {
982
+ const n = a.getAttribute("roadId"), l = a.getAttribute("sectionIndex"), d = `${n}#${l}`;
983
+ if (o.indexOf(d) === -1) {
984
+ o.push(d), this.selectSumo({
999
985
  type: "edge",
1000
986
  id: d
1001
987
  });
1002
- const u = `http://${this.openDriveServer}/api/sumo/getSumoEdge`, f = await b.get(u, {
988
+ const u = `http://${this.openDriveServer}/api/sumo/getSumoEdge`, y = await b.get(u, {
1003
989
  params: {
1004
- id: `${o}+${a.getAttribute("sectionId")}`,
990
+ id: `${n}+${a.getAttribute("sectionId")}`,
1005
991
  projectName: this.projectName
1006
992
  }
1007
993
  });
1008
- f.status === 200 && f.data.status === 0 && s.push(f.data.result);
994
+ y.status === 200 && y.data.status === 0 && i.push(y.data.result);
1009
995
  }
1010
996
  }
1011
997
  const c = this.junctionLayer.graphics.filter((a) => {
1012
- const o = a.geometry;
1013
- return L.contains(t, o);
1014
- }), n = [];
998
+ const n = a.geometry;
999
+ return S.contains(t, n);
1000
+ }), r = [];
1015
1001
  for (const a of c) {
1016
- const o = a.getAttribute("id");
1002
+ const n = a.getAttribute("id");
1017
1003
  this.selectSumo({
1018
1004
  type: "junction",
1019
- id: o
1005
+ id: n
1020
1006
  });
1021
1007
  const l = `http://${this.openDriveServer}/api/sumo/getSumoJunction`, d = await b.get(l, {
1022
1008
  params: {
1023
- id: o,
1009
+ id: n,
1024
1010
  projectName: this.projectName
1025
1011
  }
1026
1012
  });
1027
- d.status === 200 && d.data.status === 0 && n.push(d.data.result);
1013
+ d.status === 200 && d.data.status === 0 && r.push(d.data.result);
1028
1014
  }
1029
1015
  return {
1030
1016
  status: 0,
1031
1017
  message: "ok",
1032
1018
  result: {
1033
- junctions: n,
1034
- edges: s
1019
+ junctions: r,
1020
+ edges: i
1035
1021
  }
1036
1022
  };
1037
1023
  }
1038
1024
  async splitLane(e) {
1039
- const i = e.id.split("_");
1040
- if (i.length !== 2)
1025
+ const s = e.id.split("_");
1026
+ if (s.length !== 2)
1041
1027
  return { status: -1, message: "车道编号格式错误" };
1042
- const r = Number(i[1]), s = i[0].split("#"), c = s.length === 2 ? Number(s[1]) : 0;
1043
- let n = s[0];
1044
- n.startsWith("-") && (n = n.slice(1));
1045
- const a = this.allLaneGraphics.filter((w) => w.getAttribute("roadId") === n && w.getAttribute("sectionIndex") === c);
1028
+ const o = Number(s[1]), i = s[0].split("#"), c = i.length === 2 ? Number(i[1]) : 0;
1029
+ let r = i[0];
1030
+ r.startsWith("-") && (r = r.slice(1));
1031
+ const a = this.allLaneGraphics.filter((I) => I.getAttribute("roadId") === r && I.getAttribute("sectionIndex") === c);
1046
1032
  if (a.length === 0)
1047
1033
  return { status: -1, message: "未找到路段" };
1048
- const o = a.length - r, l = a.find(
1049
- (w) => Math.abs(w.getAttribute("laneId")) === o
1034
+ const n = a.length - o, l = a.find(
1035
+ (I) => Math.abs(I.getAttribute("laneId")) === n
1050
1036
  );
1051
1037
  if (!l)
1052
1038
  return { status: -1, message: "未找到车道" };
1053
- const d = e.start || 0, u = e.end || 100, f = D.lineString(l.getAttribute("leftLine")), y = G(f, d, u, {
1039
+ const d = e.start || 0, u = e.end || 100, y = D.lineString(l.getAttribute("leftLine")), m = x(y, d, u, {
1054
1040
  units: "meters"
1055
- }), p = D.lineString(l.getAttribute("rightLine")), h = G(p, d, u, {
1041
+ }), h = D.lineString(l.getAttribute("rightLine")), p = x(h, d, u, {
1056
1042
  units: "meters"
1057
- }), m = y.geometry.coordinates.concat(
1058
- h.geometry.coordinates.reverse()
1043
+ }), f = m.geometry.coordinates.concat(
1044
+ p.geometry.coordinates.reverse()
1059
1045
  );
1060
- m.push(m[m.length - 1]);
1046
+ f.push(f[f.length - 1]);
1061
1047
  const v = new g({
1062
- geometry: new N({
1063
- rings: [m]
1048
+ geometry: new L({
1049
+ rings: [f]
1064
1050
  }),
1065
1051
  attributes: {
1066
1052
  ObjectID: l.getAttribute("ObjectID"),
@@ -1074,8 +1060,8 @@ class M {
1074
1060
  laneId: l.getAttribute("laneId"),
1075
1061
  type: l.getAttribute("type"),
1076
1062
  sumoId: l.getAttribute("sumoId"),
1077
- leftLine: y.geometry.coordinates,
1078
- rightLine: h.geometry.coordinates
1063
+ leftLine: m.geometry.coordinates,
1064
+ rightLine: p.geometry.coordinates
1079
1065
  },
1080
1066
  symbol: {
1081
1067
  type: "simple-fill",
@@ -1090,6 +1076,19 @@ class M {
1090
1076
  clearSplitLane() {
1091
1077
  this.splitLaneLayer.removeAll();
1092
1078
  }
1079
+ /**
1080
+ * 更新所有路口的symbol
1081
+ * @param symbolStyle
1082
+ */
1083
+ updateAllJunctionSymbol(e) {
1084
+ const t = this.junctionLayer.graphics.clone();
1085
+ this.junctionLayer.removeAll(), t.forEach((s) => {
1086
+ s.symbol = this.getCrossGraphicSymbol(
1087
+ s.attributes,
1088
+ e
1089
+ );
1090
+ }), this.junctionLayer.addMany(t.toArray());
1091
+ }
1093
1092
  /**
1094
1093
  * 生成路口点符号。在不同比例尺下,使用不同的符号
1095
1094
  * @param attributes
@@ -1097,17 +1096,17 @@ class M {
1097
1096
  * @returns
1098
1097
  */
1099
1098
  getCrossGraphicSymbol(e, t) {
1100
- const i = e.crossId !== "" && e.crossId !== void 0 && e.crossId !== null;
1099
+ const s = e.crossId !== "" && e.crossId !== void 0 && e.crossId !== null;
1101
1100
  if (t === "marker")
1102
1101
  return {
1103
1102
  type: "picture-marker",
1104
- url: `/GisViewerAssets/Images/xhj_${i ? 4 : 2}.png`,
1103
+ url: `/GisViewerAssets/Images/xhj_${s ? 1 : 2}.png`,
1105
1104
  width: "18px",
1106
1105
  height: "28px",
1107
1106
  yOffset: "12px"
1108
1107
  };
1109
1108
  if (t === "picture")
1110
- return i ? {
1109
+ return s ? {
1111
1110
  type: "cim",
1112
1111
  data: {
1113
1112
  type: "CIMSymbolReference",
@@ -1145,7 +1144,7 @@ class M {
1145
1144
  height: 12,
1146
1145
  horizontalAlignment: "Center",
1147
1146
  offsetX: 0,
1148
- offsetY: i ? 50 : 40,
1147
+ offsetY: s ? 50 : 40,
1149
1148
  haloSize: 2,
1150
1149
  haloSymbol: {
1151
1150
  type: "CIMPolygonSymbol",
@@ -1187,8 +1186,8 @@ class M {
1187
1186
  size: 45,
1188
1187
  rotateClockwise: !0,
1189
1188
  textureFilter: "Picture",
1190
- url: "/GisViewerAssets/Images/xhj_4.png",
1191
- offsetY: i ? 22 : 15
1189
+ url: "/GisViewerAssets/Images/xhj_1.png",
1190
+ offsetY: s ? 22 : 15
1192
1191
  }
1193
1192
  ]
1194
1193
  }
@@ -1203,5 +1202,5 @@ class M {
1203
1202
  }
1204
1203
  }
1205
1204
  export {
1206
- M as default
1205
+ O as default
1207
1206
  };
@@ -18,6 +18,8 @@ export default class OpenDriveRenderer {
18
18
  private mouseClickHandler;
19
19
  private junctionNames;
20
20
  private readonly junctionScale;
21
+ private scaleWatch;
22
+ private xodrBorder;
21
23
  constructor(view: __esri.MapView | __esri.SceneView);
22
24
  private projectName;
23
25
  private openDriveServer;
@@ -111,6 +113,11 @@ export default class OpenDriveRenderer {
111
113
  geometrySearch(coordinate: number[][]): Promise<IResult>;
112
114
  splitLane(params: ISplitOpenDriveLaneParams): Promise<IResult>;
113
115
  clearSplitLane(): void;
116
+ /**
117
+ * 更新所有路口的symbol
118
+ * @param symbolStyle
119
+ */
120
+ private updateAllJunctionSymbol;
114
121
  /**
115
122
  * 生成路口点符号。在不同比例尺下,使用不同的符号
116
123
  * @param attributes
@@ -1 +1 @@
1
- "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const f=require("@arcgis/core/Graphic"),F=require("@arcgis/core/core/promiseUtils"),E=require("@arcgis/core/core/reactiveUtils.js"),A=require("@arcgis/core/geometry"),q=require("@arcgis/core/geometry/geometryEngine"),G=require("@arcgis/core/layers/FeatureLayer"),I=require("@arcgis/core/layers/GraphicsLayer"),R=require("@turf/helpers"),x=require("@turf/line-slice-along"),b=require("axios"),J=require("fast-xml-parser"),T=require("md5"),O=require("pako"),H=require("vue"),_=require("../../stores/index.js"),z=require("../common-utils.js");function N(L){const e=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(L){for(const t in L)if(t!=="default"){const i=Object.getOwnPropertyDescriptor(L,t);Object.defineProperty(e,t,i.get?i:{enumerable:!0,get:()=>L[t]})}}return e.default=L,Object.freeze(e)}const M=N(F),U=N(E),S=N(q),P=N(R);class C{constructor(e){this.junctionNames=new Map,this.junctionScale=5e3,this.projectName="",this.openDriveServer="",this.currentSectionCode="",this.selectedSectionIds=[],this.currentJunctionId="",this.view=e,this.laneLayer=new G({id:"OpenDriveLane",fields:[{name:"ObjectID",alias:"ObjectID",type:"oid"},{name:"id",alias:"编号",type:"string"},{name:"roadId",alias:"道路号",type:"string"},{name:"roadName",alias:"道路名称",type:"string"},{name:"sectionId",alias:"路段号",type:"string"},{name:"sectionIndex",alias:"路段序号",type:"string"},{name:"laneId",alias:"车道号",type:"string"},{name:"type",alias:"类型",type:"string"},{name:"sumoId",alias:"sumo编号",type:"string"},{name:"fromNode",alias:"起点路口",type:"string"},{name:"toNode",alias:"终点路口",type:"string"}],objectIdField:"ObjectID",geometryType:"polygon",spatialReference:{wkid:4326},source:[],outFields:["*"],renderer:{type:"unique-value",field:"type",defaultSymbol:{type:"simple-fill",color:[100,100,100],style:"solid",outline:{color:"white",width:1}},uniqueValueInfos:[{value:"shoulder",label:"路肩",symbol:{type:"simple-fill",color:"#008000",style:"solid",outline:{color:"white",width:1}}},{value:"border",label:"路沿",symbol:{type:"simple-fill",color:"#DCDCDC",style:"solid",outline:{color:"white",width:1}}},{value:"driving",label:"机动车道",symbol:{type:"simple-fill",color:[47,79,79,.8],style:"solid",outline:{color:"white",width:1}}},{value:"none",label:"无",symbol:{type:"simple-fill",color:[111,120,135],style:"none",outline:{color:"white",width:1}}},{value:"restricted",label:"禁行区",symbol:{type:"simple-fill",color:"yellow",style:"solid",outline:{color:"yellow",width:2}}},{value:"parking",label:"停车区",symbol:{type:"simple-fill",color:[115,115,115],style:"solid",outline:{color:"white",width:1}}},{value:"median",label:"中央隔离带",symbol:{type:"simple-fill",color:"#008000",style:"solid",outline:{color:"white",width:1}}},{value:"biking",label:"非机动车道",symbol:{type:"simple-fill",color:"#D3D3D3",style:"solid",outline:{color:"white",width:1}}},{value:"sidewalk",label:"人行道",symbol:{type:"simple-fill",color:"#C0C0C0",style:"solid",outline:{color:"white",width:1}}},{value:"junction",label:"路口区域",symbol:{type:"simple-fill",color:"#2F4F4F",style:"solid",outline:{color:"white",width:1}}},{value:"selected",label:"选中车道",symbol:{type:"simple-fill",color:[141,168,211],style:"solid",outline:{color:"white",width:1}}}]}}),this.roadNameLayer=new G({id:"OpenDriveRoadName",fields:[{name:"ObjectID",alias:"ObjectID",type:"oid"},{name:"roadId",alias:"道路号",type:"string"},{name:"roadName",alias:"道路名称",type:"string"}],objectIdField:"ObjectID",geometryType:"polyline",spatialReference:{wkid:4326},source:[],renderer:{type:"simple",symbol:{type:"simple-line",style:"solid",color:[0,0,0,0],width:1}},labelingInfo:[{symbol:{type:"text",color:"black",haloColor:"white",haloSize:1,font:{size:12,family:"sans-serif"}},labelPlacement:this.view.type==="2d"?"center-along":void 0,labelExpressionInfo:{expression:"$feature.roadName"}}]}),this.junctionLayer=new I({id:"OpenDriveJunction"}),this.sectionLayer=new I({id:"OpenDriveSection"}),this.highlightLayer=new I({id:"OpenDriveHighlight"}),this.flashLayer=new I({id:"OpenDriveFlash"}),this.drawLayer=new I({id:"Draw"}),this.splitLaneLayer=new I({id:"SplitLane"}),this.borderLayer=new I({id:"OpenDriveBorder"}),this.view.map.addMany([this.laneLayer,this.sectionLayer,this.roadNameLayer,this.junctionLayer,this.highlightLayer,this.flashLayer,this.drawLayer,this.splitLaneLayer,this.borderLayer])}static getInstance(e){return this.instance||(this.instance=new C(e)),this.instance}async makeMd5FromFile(e){var t;try{const r=await(await fetch(e)).text(),n=(t=new J.XMLParser({ignoreAttributes:!1,allowBooleanAttributes:!0}).parse(r).OpenDRIVE.userData)==null?void 0:t.border;return{status:0,message:"ok",result:{md5:T(r),border:n}}}catch(i){return{status:-1,message:i.message}}}async showOpenDriveFromFile(e){var g,y;this.openDriveClickCallback=e.selectedCallback,U.watch(()=>this.view.scale,(p,d)=>{p>this.junctionScale&&d<=this.junctionScale?(console.log(p,d),this.junctionLayer.graphics.forEach(m=>{m.symbol=this.getCrossGraphicSymbol(m.attributes,"marker")})):p<=this.junctionScale&&d>this.junctionScale&&(console.log(p,d),this.junctionLayer.graphics.forEach(m=>{m.symbol=this.getCrossGraphicSymbol(m.attributes,"picture")}))}),console.time("md5用时");const t=await this.makeMd5FromFile(e.file);if(t.status!==0)return t;this.projectName=t.result.md5,console.timeEnd("md5用时"),console.log(t.result.border),this.openDriveServer=e.server;const i=`http://${this.openDriveServer}/api/openDrive/uploadXodr`;let r;try{r=await b.post(i,{},{params:{url:e.file,projectName:this.projectName}})}catch(p){return{status:-1,message:p.message}}if(r.status!==200)return{status:-1,message:r.statusText};console.time("渲染用时");const s=r.data.result.geoSetting;z.default.setGeoData(s.geoReference,s.offsetX,s.offsetY);let c=r.data.result.json;c.startsWith(window.location.protocol)||(c=`${window.location.protocol}//${e.server}${c}`);const a=await(await fetch(c)).arrayBuffer(),o=O.inflate(a,{to:"string"}),l=JSON.parse(o);await this.showAllLanes(l,((g=e.options)==null?void 0:g.showJunctionLane)||!1,((y=e.options)==null?void 0:y.showRoadName)||!0);const u=r.data.result.junctions;this.showJunction(u),e.options&&e.options.centerMap!==!1&&await this.view.goTo(this.allLaneGraphics),this.mouseMoveHandler||this.monitorMouseMove(),this.mouseClickHandler||this.monitorMouseClick();const h=_.default.useAppDataStore;return H.watch(()=>h.isSketching,()=>{var p,d;h.isSketching?((p=this.mouseMoveHandler)==null||p.remove(),this.mouseMoveHandler=void 0,(d=this.mouseClickHandler)==null||d.remove(),this.mouseClickHandler=void 0):(this.monitorMouseMove(),this.monitorMouseClick())}),console.timeEnd("渲染用时"),{status:0,message:"ok"}}async showOpenDriveFromServer(e,t){const i=`http://${e}/api/openDrive/analyzeXodr`,r=await b.get(i,{headers:{projectName:t},params:{analyze:!1,compressed:!0}});if(r.status!==200)throw new Error(`OpenDriveRenderer: ${r.statusText}`);let s=r.data.result.json;s.startsWith(window.location.protocol)||(s=`${window.location.protocol}//${e}${s}`);const n=await(await fetch(s)).arrayBuffer(),a=O.inflate(n,{to:"string"}),o=JSON.parse(a);return await this.showAllLanes(o,!1,!1),{status:0,message:"ok"}}async showAllLanes(e,t,i){const r=await this.laneLayer.queryFeatures();return r.features.length>0&&this.laneLayer.applyEdits({deleteFeatures:r.features}),this.roadNameLayer.visible=i,new Promise(s=>{let c=0;this.allLaneGraphics=[],this.allRefLineGraphics=[];const n=[];for(const o of e){if(!t&&o.junction!=="-1")continue;const{id:l,refLine:u}=o;let h=o.name;h.includes("(")&&(h=h.slice(0,h.indexOf("("))),h=h.replace(/(.)/g,"$1 ");const g=new f({geometry:{type:"polyline",paths:[u]},attributes:{ObjectID:c++,roadId:l,roadName:h}});this.allRefLineGraphics.push(g),o.laneSections.sort((y,p)=>Number(y.id)-Number(p.id));for(let y=0;y<o.laneSections.length;y++){const p=o.laneSections[y],d=Number(p.id);for(const m of p.lanePaths){const v=Number(m.id);if(v===0)continue;const w=m.type,$=[...m.outerPath],j=m.innerPath.concat($.reverse());if(j.length<=3){console.warn(`lane ${v} has less than 3 points`);continue}j.push(m.innerPath[0]);const D=new A.Polygon({rings:[j]});if(D){const k=new f({geometry:D,attributes:{ObjectID:c++,id:`${l}+${d}+${v}`,fromNode:o.fromNode,toNode:o.toNode,roadId:String(l),roadName:o.name,sectionId:String(d),sectionIndex:y,laneId:v,type:w,sumoId:"",leftLine:m.innerPath,rightLine:m.outerPath}});this.allLaneGraphics.push(k),n.push(k)}}}}const a=setInterval(()=>{if(n.length>0||this.allRefLineGraphics.length>0){if(n.length>0){const o=n.splice(0,100);this.laneLayer.applyEdits({addFeatures:o})}if(this.allRefLineGraphics.length>0){const o=this.allRefLineGraphics.splice(0,10);this.roadNameLayer.applyEdits({addFeatures:o})}}else clearInterval(a),s()},10)})}showJunction(e){const t=[];for(const i of e){if(!i)continue;this.junctionNames.set(i.id,i.name),i.nodeType=i.type;const r=new f({geometry:{type:"point",x:i.coordinates[0],y:i.coordinates[1]},attributes:{...i,selected:!1,type:"OpenDriveJunction"},symbol:this.getCrossGraphicSymbol(i,"marker")});t.push(r)}this.junctionLayer.addMany(t)}monitorMouseMove(){const e=M.debounce(async t=>{var c;const r=(c=(await this.view.hitTest(t,{include:[this.laneLayer,this.junctionLayer]})).results)==null?void 0:c.filter(n=>n.type==="graphic");if(r.length===0){this.currentSectionCode!==""&&(this.currentSectionCode="",this.highlightLayer.removeAll()),this.currentJunctionId!==""&&(this.currentJunctionId=""),this.view.closePopup();return}const s=r[0];if(this.hitGraphic=s.graphic,s.layer.id==="OpenDriveLane"){const n=`${this.hitGraphic.getAttribute("roadId")}+${this.hitGraphic.getAttribute("sectionId")}`;if(this.currentSectionCode===n||this.selectedSectionIds.includes(n)||this.sectionLayer.graphics.findIndex(d=>d.getAttribute("id")===n)>=0)return;this.currentSectionCode=n;const o=this.allLaneGraphics.filter(d=>`${d.attributes.roadId}+${d.attributes.sectionId}`===n),l=S.union(o.map(d=>d.geometry)),u=this.hitGraphic.getAttribute("fromNode"),h=this.hitGraphic.getAttribute("toNode"),g=this.junctionNames.get(u)||u,y=this.junctionNames.get(h)||h,p=new f({geometry:l,symbol:{type:"simple-fill",color:[0,255,255,.5],style:"solid",outline:{color:[0,255,255],width:1}},attributes:{type:"OpenDriveSection",id:n,selected:!1,fromNodeName:g,toNodeName:y,laneCount:o.length},popupTemplate:{title:this.hitGraphic.getAttribute("roadName"),content:[{type:"fields",fieldInfos:[{fieldName:"fromNodeName",label:"起点路口"},{fieldName:"toNodeName",label:"终点路口"},{fieldName:"laneCount",label:"车道数量"}]}]}});this.highlightLayer.removeAll(),this.highlightLayer.add(p)}else if(s.layer.id==="OpenDriveJunction"){const n=this.hitGraphic.getAttribute("id");if(n===this.currentJunctionId)return;this.currentJunctionId=n}});this.mouseMoveHandler=this.view.on("pointer-move",async t=>{e(t).catch(()=>{})})}monitorMouseClick(){const e=M.debounce(async t=>{var a;const r=(a=(await this.view.hitTest(t,{include:[this.highlightLayer,this.junctionLayer,this.sectionLayer]})).results)==null?void 0:a.filter(o=>o.type==="graphic");if(r.length===0)return;const s=r[0].graphic,c=s.getAttribute("type"),n=s.getAttribute("id");if(c==="OpenDriveJunction")if(s.getAttribute("selected")===!1){const o=`http://${this.openDriveServer}/api/sumo/getSumoJunction`,l=await b.get(o,{params:{id:n,projectName:this.projectName}});l.status===200&&l.data.status===0&&(this.openDriveClickCallback&&this.openDriveClickCallback({type:"OpenDriveJunction",id:n,details:l.data.result}),s.setAttribute("selected",!0),s.symbol={type:"picture-marker",url:"/GisViewerAssets/Images/point_red.png",width:"20px",height:"20px"},this.increasePictureMarkerSize(s,50))}else this.openDriveClickCallback&&this.openDriveClickCallback({type:"OpenDriveJunction",id:n,details:void 0}),s.setAttribute("selected",!1),s.symbol=this.getCrossGraphicSymbol(s.attributes,this.view.scale<this.junctionScale?"picture":"marker");else if(c==="OpenDriveSection")if(s.layer.id==="OpenDriveHighlight"){this.highlightLayer.remove(s),this.sectionLayer.add(s),s.setAttribute("selected",!0),this.selectedSectionIds.push(n);const o=`http://${this.openDriveServer}/api/sumo/getSumoEdge`,l=await b.get(o,{params:{id:n,projectName:this.projectName}});if(l.status===200&&l.data.status===0&&this.openDriveClickCallback){const u=l.data.result.obj_id;s.setAttribute("edgeId",u),this.openDriveClickCallback({type:"OpenDriveSection",id:u,details:l.data.result})}}else this.sectionLayer.remove(s),this.selectedSectionIds=this.selectedSectionIds.filter(o=>o!==n),this.openDriveClickCallback&&this.openDriveClickCallback({type:"OpenDriveSection",id:s.getAttribute("edgeId"),details:void 0})});this.mouseClickHandler=this.view.on("immediate-click",async t=>{e(t).catch(()=>{})})}increasePictureMarkerSize(e,t){const i=setInterval(()=>{const r=e.symbol,s=r.width;s<t?e.symbol={type:"picture-marker",url:r.url,width:s+1,height:s+1}:clearInterval(i)},20)}decreasePictureMarkerSize(e,t){const i=setInterval(()=>{const r=e.symbol,s=r.width;s>t?e.symbol={type:"picture-marker",url:r.url,width:s-1,height:s-1}:clearInterval(i)},20)}async getSumoInfo(e){switch(e.type){case"junction":{const t=`http://${this.openDriveServer}/api/sumo/getSumoJunction`,i=await b.get(t,{params:{id:e.id,projectName:this.projectName}});return i.status===200?i.data:{status:-1,message:`路口信息查询失败: ${e.id}`}}case"edge":{const t=e.id.split("#");let i=t[0];i.startsWith("-")&&(i=i.slice(1));let r=0;t.length===2&&(r=Number(t[1]));const s=this.allLaneGraphics.find(c=>c.getAttribute("roadId")===i&&c.getAttribute("sectionIndex")===r);if(s){const c=`${i}+${s.getAttribute("sectionId")}`,n=`http://${this.openDriveServer}/api/sumo/getSumoEdge`,a=await b.get(n,{params:{id:c,projectName:this.projectName}});return a.status===200?a.data:{status:-1,message:`路段信息查询失败: ${c}`}}else return{status:-1,message:"未知类型"}}default:return{status:-1,message:"未知类型"}}}async clearOpenDrive(){var t,i;let e=await this.laneLayer.queryFeatures();e.features.length>0&&await this.laneLayer.applyEdits({deleteFeatures:e.features}),e=await this.roadNameLayer.queryFeatures(),e.features.length>0&&await this.roadNameLayer.applyEdits({deleteFeatures:e.features}),this.highlightLayer.removeAll(),this.junctionLayer.removeAll(),this.sectionLayer.removeAll(),this.flashLayer.removeAll(),(t=this.mouseMoveHandler)==null||t.remove(),this.mouseMoveHandler=void 0,(i=this.mouseClickHandler)==null||i.remove(),this.mouseClickHandler=void 0}async findSumo(e){const{type:t,id:i}=e,r=e.flash===void 0?!0:e.flash;if(t==="junction")return await this.findJunction(i,r);if(t==="edge"){const s=i.split("_");if(s.length>2)return{status:-1,message:"id格式错误"};const c=s.length===2?Number(s[1]):void 0,n=s[0].split("#");if(n.length>2)return{status:-1,message:"id格式错误"};const a=n[0],o=n.length===2?Number(n[1]):void 0;return await this.findLane({roadsectId:a,segmentId:o,laneId:c,flash:r})}else return{status:-1,message:"未知类型"}}async findJunction(e,t){const i=this.junctionLayer.graphics.find(r=>r.attributes.id===e);if(!i)return{status:-1,message:"未找到。请检查路口编号"};if(t){const r=new f({geometry:i.geometry,symbol:{type:"simple-marker",style:"circle",size:30,color:[0,255,255,.8],outline:{color:[0,255,255],width:1}}});this.flashGraphic(r)}return await this.view.goTo(i.geometry,{duration:1e3}),{status:0,message:"ok"}}async findLane(e){let{roadsectId:t,segmentId:i,laneId:r}=e;t.startsWith("-")&&(t=t.slice(1));let s=this.allLaneGraphics.filter(a=>a.attributes.roadId===t);if(s.length===0)return{status:-1,message:"未找到。请检查路段编号"};if(i!==void 0){const a=[];if(s.forEach(o=>{const l=Number(o.attributes.sectionId);a.indexOf(l)===-1&&a.push(l)}),a.sort((o,l)=>o-l),i>a.length-1)return{status:-1,message:"未找到。请检查基本段编号"};i=a[i],s=s.filter(o=>Number(o.attributes.sectionId)===i)}if(r!==void 0){const a=[];if(s.forEach(o=>{const l=Number(o.attributes.laneId);a.indexOf(l)===-1&&a.push(l)}),a.sort((o,l)=>o-l),r>a.length-1)return{status:-1,message:"未找到。请检查车道编号"};r=a[r],s=s.filter(o=>Number(o.attributes.laneId)===r)}const c=s.map(a=>a.geometry),n=S.union(c);if(e.flash){const a=new f({geometry:n,symbol:{type:"simple-fill",color:[0,0,255,.6],style:"solid",outline:{width:0}}});this.flashGraphic(a)}return await this.view.goTo(n,{duration:1e3}),{status:0,message:"ok"}}flashGraphic(e){this.flashLayer.removeAll(),this.flashLayer.add(e);let t=0,i=!0;const r=setInterval(()=>{i?(this.flashLayer.opacity-=.02,this.flashLayer.opacity<=.1&&(i=!1,t++)):(this.flashLayer.opacity+=.02,this.flashLayer.opacity>=1&&(i=!0)),t>=5&&(this.flashLayer.removeAll(),this.flashLayer.opacity=1,clearInterval(r))},10)}unselectSumo(e){if((!e||e.type==="junction")&&this.junctionLayer.graphics.forEach(t=>{(!e||!e.id||e.id===""||e.id===t.getAttribute("id"))&&t.getAttribute("selected")&&(t.setAttribute("selected",!1),t.symbol=this.getCrossGraphicSymbol(t.attributes,this.view.scale<this.junctionScale?"picture":"marker"))}),!e||e.type==="edge"){let t;!e||!e.id||e.id===""?t=this.sectionLayer.graphics.toArray():t=this.sectionLayer.graphics.filter(i=>i.getAttribute("edgeId")===e.id).toArray(),t.length>0&&(t.forEach(i=>{const r=i.getAttribute("id");this.selectedSectionIds=this.selectedSectionIds.filter(s=>s!==r)}),this.sectionLayer.removeMany(t))}return{status:0,message:"ok"}}selectSumo(e){switch(e.type){case"junction":return this.junctionLayer.graphics.forEach(t=>{if(e.id===t.getAttribute("id"))return t.setAttribute("selected",!0),t.symbol.url="/GisViewerAssets/Images/point_red.png",this.increasePictureMarkerSize(t,50),{status:0,message:"ok"}}),{status:-1,message:"未找到路口"};case"edge":{const t=e.id.split("#");let i=String(t[0]);i.startsWith("-")&&(i=i.slice(1));let r=0;t.length===2&&(r=Number(t[1]));let s=[];if(t.length===1?s=this.allLaneGraphics.filter(c=>c.getAttribute("roadId")===i):t.length===2&&(s=this.allLaneGraphics.filter(c=>c.getAttribute("roadId")===i&&c.getAttribute("sectionIndex")===r)),s.length>0){const c=new Map;return s.forEach(n=>{const a=n.getAttribute("roadId")+"+"+n.getAttribute("sectionId");this.selectedSectionIds.includes(a)||this.selectedSectionIds.push(a);let o=c.get(a);o?o.push(n.geometry):(o=[n.geometry],c.set(a,o))}),c.forEach((n,a)=>{const o=S.union(n),l=new f({geometry:o,symbol:{type:"simple-fill",color:[0,255,255,.5],style:"solid",outline:{color:[0,255,255],width:1}},attributes:{type:"OpenDriveSection",id:a,edgeId:e.id,selected:!0}});this.sectionLayer.add(l)}),{status:0,message:"ok"}}else return{status:-1,message:"未找到路段"}}default:return{status:-1,message:"未知类型"}}}async geometrySearch(e){const t=new A.Polygon({rings:[e]}),i=await this.laneLayer.queryFeatures({geometry:t,outFields:["*"]}),r=[],s=[];for(const a of i.features){const o=a.getAttribute("roadId"),l=a.getAttribute("sectionIndex"),u=`${o}#${l}`;if(r.indexOf(u)===-1){r.push(u),this.selectSumo({type:"edge",id:u});const h=`http://${this.openDriveServer}/api/sumo/getSumoEdge`,g=await b.get(h,{params:{id:`${o}+${a.getAttribute("sectionId")}`,projectName:this.projectName}});g.status===200&&g.data.status===0&&s.push(g.data.result)}}const c=this.junctionLayer.graphics.filter(a=>{const o=a.geometry;return S.contains(t,o)}),n=[];for(const a of c){const o=a.getAttribute("id");this.selectSumo({type:"junction",id:o});const l=`http://${this.openDriveServer}/api/sumo/getSumoJunction`,u=await b.get(l,{params:{id:o,projectName:this.projectName}});u.status===200&&u.data.status===0&&n.push(u.data.result)}return{status:0,message:"ok",result:{junctions:n,edges:s}}}async splitLane(e){const i=e.id.split("_");if(i.length!==2)return{status:-1,message:"车道编号格式错误"};const r=Number(i[1]),s=i[0].split("#"),c=s.length===2?Number(s[1]):0;let n=s[0];n.startsWith("-")&&(n=n.slice(1));const a=this.allLaneGraphics.filter(w=>w.getAttribute("roadId")===n&&w.getAttribute("sectionIndex")===c);if(a.length===0)return{status:-1,message:"未找到路段"};const o=a.length-r,l=a.find(w=>Math.abs(w.getAttribute("laneId"))===o);if(!l)return{status:-1,message:"未找到车道"};const u=e.start||0,h=e.end||100,g=P.lineString(l.getAttribute("leftLine")),y=x.lineSliceAlong(g,u,h,{units:"meters"}),p=P.lineString(l.getAttribute("rightLine")),d=x.lineSliceAlong(p,u,h,{units:"meters"}),m=y.geometry.coordinates.concat(d.geometry.coordinates.reverse());m.push(m[m.length-1]);const v=new f({geometry:new A.Polygon({rings:[m]}),attributes:{ObjectID:l.getAttribute("ObjectID"),id:l.getAttribute("id"),fromNode:l.getAttribute("fromNode"),toNode:l.getAttribute("toNode"),roadId:l.getAttribute("roadId"),roadName:l.getAttribute("roadName"),sectionId:l.getAttribute("sectionId"),sectionIndex:l.getAttribute("sectionIndex"),laneId:l.getAttribute("laneId"),type:l.getAttribute("type"),sumoId:l.getAttribute("sumoId"),leftLine:y.geometry.coordinates,rightLine:d.geometry.coordinates},symbol:{type:"simple-fill",color:[255,0,0,.8],outline:{color:"red"}}});return this.splitLaneLayer.add(v),this.view.goTo(v),{status:0,message:"ok",result:e}}clearSplitLane(){this.splitLaneLayer.removeAll()}getCrossGraphicSymbol(e,t){const i=e.crossId!==""&&e.crossId!==void 0&&e.crossId!==null;if(t==="marker")return{type:"picture-marker",url:`/GisViewerAssets/Images/xhj_${i?4:2}.png`,width:"18px",height:"28px",yOffset:"12px"};if(t==="picture")return i?{type:"cim",data:{type:"CIMSymbolReference",primitiveOverrides:[{type:"CIMPrimitiveOverride",primitiveName:"textGraphic",propertyName:"TextString",valueExpressionInfo:{type:"CIMExpressionInfo",title:"Custom",expression:'Replace($feature.name, "与", "/") + " " + $feature.crossId',returnType:"Default"}}],symbol:{type:"CIMPointSymbol",symbolLayers:[{type:"CIMVectorMarker",size:32,colorLocked:!0,anchorPointUnits:"Relative",frame:{xmin:-16,ymin:-16,xmax:16,ymax:16},markerGraphics:[{type:"CIMMarkerGraphic",primitiveName:"textGraphic",geometry:{x:0,y:0},symbol:{type:"CIMTextSymbol",height:12,horizontalAlignment:"Center",offsetX:0,offsetY:i?50:40,haloSize:2,haloSymbol:{type:"CIMPolygonSymbol",symbolLayers:[{type:"CIMSolidFill",enable:!0,color:[255,255,255,255]}]},symbol:{type:"CIMPolygonSymbol",symbolLayers:[{type:"CIMSolidFill",enable:!0,color:[0,0,0,255]}]},verticalAlignment:"Center"},textString:""}],scaleSymbolsProportionally:!0,respectFrame:!0},{type:"CIMPictureMarker",enable:!0,anchorPoint:{x:0,y:0},anchorPointUnits:"Relative",size:45,rotateClockwise:!0,textureFilter:"Picture",url:"/GisViewerAssets/Images/xhj_4.png",offsetY:i?22:15}]}}}:{type:"picture-marker",url:"/GisViewerAssets/Images/xhj_2.png",width:"27px",height:"42px",yOffset:"22px"}}}exports.default=C;
1
+ "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const f=require("@arcgis/core/Graphic"),F=require("@arcgis/core/core/promiseUtils"),J=require("@arcgis/core/core/reactiveUtils.js"),L=require("@arcgis/core/geometry"),E=require("@arcgis/core/geometry/geometryEngine"),x=require("@arcgis/core/layers/FeatureLayer"),w=require("@arcgis/core/layers/GraphicsLayer"),q=require("@turf/helpers"),G=require("@turf/line-slice-along"),b=require("axios"),R=require("fast-xml-parser"),T=require("md5"),O=require("pako"),H=require("vue"),_=require("../../stores/index.js"),z=require("../common-utils.js");function N(S){const e=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(S){for(const t in S)if(t!=="default"){const i=Object.getOwnPropertyDescriptor(S,t);Object.defineProperty(e,t,i.get?i:{enumerable:!0,get:()=>S[t]})}}return e.default=S,Object.freeze(e)}const M=N(F),U=N(J),A=N(E),P=N(q);class k{constructor(e){this.junctionNames=new Map,this.junctionScale=5e3,this.xodrBorder=[],this.projectName="",this.openDriveServer="",this.currentSectionCode="",this.selectedSectionIds=[],this.currentJunctionId="",this.view=e,this.laneLayer=new x({id:"OpenDriveLane",fields:[{name:"ObjectID",alias:"ObjectID",type:"oid"},{name:"id",alias:"编号",type:"string"},{name:"roadId",alias:"道路号",type:"string"},{name:"roadName",alias:"道路名称",type:"string"},{name:"sectionId",alias:"路段号",type:"string"},{name:"sectionIndex",alias:"路段序号",type:"string"},{name:"laneId",alias:"车道号",type:"string"},{name:"type",alias:"类型",type:"string"},{name:"sumoId",alias:"sumo编号",type:"string"},{name:"fromNode",alias:"起点路口",type:"string"},{name:"toNode",alias:"终点路口",type:"string"}],objectIdField:"ObjectID",geometryType:"polygon",spatialReference:{wkid:4326},source:[],outFields:["*"],renderer:{type:"unique-value",field:"type",defaultSymbol:{type:"simple-fill",color:[100,100,100],style:"solid",outline:{color:"white",width:1}},uniqueValueInfos:[{value:"shoulder",label:"路肩",symbol:{type:"simple-fill",color:"#008000",style:"solid",outline:{color:"white",width:1}}},{value:"border",label:"路沿",symbol:{type:"simple-fill",color:"#DCDCDC",style:"solid",outline:{color:"white",width:1}}},{value:"driving",label:"机动车道",symbol:{type:"simple-fill",color:[47,79,79,.8],style:"solid",outline:{color:"white",width:1}}},{value:"none",label:"无",symbol:{type:"simple-fill",color:[111,120,135],style:"none",outline:{color:"white",width:1}}},{value:"restricted",label:"禁行区",symbol:{type:"simple-fill",color:"yellow",style:"solid",outline:{color:"yellow",width:2}}},{value:"parking",label:"停车区",symbol:{type:"simple-fill",color:[115,115,115],style:"solid",outline:{color:"white",width:1}}},{value:"median",label:"中央隔离带",symbol:{type:"simple-fill",color:"#008000",style:"solid",outline:{color:"white",width:1}}},{value:"biking",label:"非机动车道",symbol:{type:"simple-fill",color:"#D3D3D3",style:"solid",outline:{color:"white",width:1}}},{value:"sidewalk",label:"人行道",symbol:{type:"simple-fill",color:"#C0C0C0",style:"solid",outline:{color:"white",width:1}}},{value:"junction",label:"路口区域",symbol:{type:"simple-fill",color:"#2F4F4F",style:"solid",outline:{color:"white",width:1}}},{value:"selected",label:"选中车道",symbol:{type:"simple-fill",color:[141,168,211],style:"solid",outline:{color:"white",width:1}}}]}}),this.roadNameLayer=new x({id:"OpenDriveRoadName",fields:[{name:"ObjectID",alias:"ObjectID",type:"oid"},{name:"roadId",alias:"道路号",type:"string"},{name:"roadName",alias:"道路名称",type:"string"}],objectIdField:"ObjectID",geometryType:"polyline",spatialReference:{wkid:4326},source:[],renderer:{type:"simple",symbol:{type:"simple-line",style:"solid",color:[0,0,0,0],width:1}},labelingInfo:[{symbol:{type:"text",color:"black",haloColor:"white",haloSize:1,font:{size:12,family:"sans-serif"}},labelPlacement:this.view.type==="2d"?"center-along":void 0,labelExpressionInfo:{expression:"$feature.roadName"}}]}),this.junctionLayer=new w({id:"OpenDriveJunction"}),this.sectionLayer=new w({id:"OpenDriveSection"}),this.highlightLayer=new w({id:"OpenDriveHighlight"}),this.flashLayer=new w({id:"OpenDriveFlash"}),this.drawLayer=new w({id:"Draw"}),this.splitLaneLayer=new w({id:"SplitLane"}),this.borderLayer=new w({id:"OpenDriveBorder"}),this.view.map.addMany([this.laneLayer,this.sectionLayer,this.roadNameLayer,this.junctionLayer,this.highlightLayer,this.flashLayer,this.drawLayer,this.splitLaneLayer,this.borderLayer])}static getInstance(e){return this.instance||(this.instance=new k(e)),this.instance}async makeMd5FromFile(e){var t;try{const o=await(await fetch(e)).text();let r=(t=new R.XMLParser({ignoreAttributes:!1,allowBooleanAttributes:!0}).parse(o).OpenDRIVE.userData)==null?void 0:t.border;return r?r=JSON.parse(r):r=[],{status:0,message:"ok",result:{md5:T(o),border:r}}}catch(i){return{status:-1,message:i.message}}}async showOpenDriveFromFile(e){var y,m;this.openDriveClickCallback=e.selectedCallback,this.scaleWatch=U.watch(()=>this.view.scale,(u,p)=>{u>this.junctionScale&&p<=this.junctionScale?this.updateAllJunctionSymbol("marker"):u<=this.junctionScale&&p>this.junctionScale&&this.updateAllJunctionSymbol("picture")}),console.time("md5用时");const t=await this.makeMd5FromFile(e.file);if(t.status!==0)return t;if(this.projectName=t.result.md5,console.timeEnd("md5用时"),this.xodrBorder=t.result.border,this.xodrBorder.length>0){const u=new f({geometry:new L.Polygon({rings:[this.xodrBorder]}),symbol:{type:"simple-fill",style:"none",outline:{style:"dash",color:"black",width:2}}});console.log(u.toJSON()),this.borderLayer.add(u)}this.openDriveServer=e.server;const i=`http://${this.openDriveServer}/api/openDrive/uploadXodr`;let o;try{o=await b.post(i,{},{params:{url:e.file,projectName:this.projectName}})}catch(u){return{status:-1,message:u.message}}if(o.status!==200)return{status:-1,message:o.statusText};console.time("渲染用时");const s=o.data.result.geoSetting;z.default.setGeoData(s.geoReference,s.offsetX,s.offsetY);let c=o.data.result.json;c.startsWith(window.location.protocol)||(c=`${window.location.protocol}//${e.server}${c}`);const a=await(await fetch(c)).arrayBuffer(),n=O.inflate(a,{to:"string"}),l=JSON.parse(n);await this.showAllLanes(l,((y=e.options)==null?void 0:y.showJunctionLane)||!1,((m=e.options)==null?void 0:m.showRoadName)||!0);const d=o.data.result.junctions;this.showJunction(d),e.options&&e.options.centerMap!==!1&&await this.view.goTo(this.allLaneGraphics),this.mouseMoveHandler||this.monitorMouseMove(),this.mouseClickHandler||this.monitorMouseClick();const h=_.default.useAppDataStore;return H.watch(()=>h.isSketching,()=>{var u,p;h.isSketching?((u=this.mouseMoveHandler)==null||u.remove(),this.mouseMoveHandler=void 0,(p=this.mouseClickHandler)==null||p.remove(),this.mouseClickHandler=void 0):(this.monitorMouseMove(),this.monitorMouseClick())}),console.timeEnd("渲染用时"),{status:0,message:"ok"}}async showOpenDriveFromServer(e,t){const i=`http://${e}/api/openDrive/analyzeXodr`,o=await b.get(i,{headers:{projectName:t},params:{analyze:!1,compressed:!0}});if(o.status!==200)throw new Error(`OpenDriveRenderer: ${o.statusText}`);let s=o.data.result.json;s.startsWith(window.location.protocol)||(s=`${window.location.protocol}//${e}${s}`);const r=await(await fetch(s)).arrayBuffer(),a=O.inflate(r,{to:"string"}),n=JSON.parse(a);return await this.showAllLanes(n,!1,!1),{status:0,message:"ok"}}async showAllLanes(e,t,i){const o=await this.laneLayer.queryFeatures();return o.features.length>0&&this.laneLayer.applyEdits({deleteFeatures:o.features}),this.roadNameLayer.visible=i,new Promise(s=>{let c=0;this.allLaneGraphics=[],this.allRefLineGraphics=[];const r=[];for(const n of e){if(!t&&n.junction!=="-1")continue;const{id:l,refLine:d}=n;let h=n.name;h.includes("(")&&(h=h.slice(0,h.indexOf("("))),h=h.replace(/(.)/g,"$1 ");const y=new f({geometry:{type:"polyline",paths:[d]},attributes:{ObjectID:c++,roadId:l,roadName:h}});this.allRefLineGraphics.push(y),n.laneSections.sort((m,u)=>Number(m.id)-Number(u.id));for(let m=0;m<n.laneSections.length;m++){const u=n.laneSections[m],p=Number(u.id);for(const g of u.lanePaths){const v=Number(g.id);if(v===0)continue;const I=g.type,$=[...g.outerPath],j=g.innerPath.concat($.reverse());if(j.length<=3){console.warn(`lane ${v} has less than 3 points`);continue}j.push(g.innerPath[0]);const C=new L.Polygon({rings:[j]});if(C){const D=new f({geometry:C,attributes:{ObjectID:c++,id:`${l}+${p}+${v}`,fromNode:n.fromNode,toNode:n.toNode,roadId:String(l),roadName:n.name,sectionId:String(p),sectionIndex:m,laneId:v,type:I,sumoId:"",leftLine:g.innerPath,rightLine:g.outerPath}});this.allLaneGraphics.push(D),r.push(D)}}}}const a=setInterval(()=>{if(r.length>0||this.allRefLineGraphics.length>0){if(r.length>0){const n=r.splice(0,100);this.laneLayer.applyEdits({addFeatures:n})}if(this.allRefLineGraphics.length>0){const n=this.allRefLineGraphics.splice(0,10);this.roadNameLayer.applyEdits({addFeatures:n})}}else clearInterval(a),s()},10)})}showJunction(e){const t=[];let i;this.xodrBorder.length>0&&(i=new L.Polygon({rings:[this.xodrBorder]}));for(const o of e)if(o&&(this.junctionNames.set(o.id,o.name),o.nodeType=o.type,o.crossId)){const s=new L.Point({x:o.coordinates[0],y:o.coordinates[1]});let c=!0;if(i&&(c=A.contains(i,s)),c){const r=new f({geometry:s,attributes:{...o,selected:!1,type:"OpenDriveJunction"},symbol:this.getCrossGraphicSymbol(o,"marker")});t.push(r)}}this.junctionLayer.addMany(t)}monitorMouseMove(){const e=M.debounce(async t=>{var c;const o=(c=(await this.view.hitTest(t,{include:[this.laneLayer,this.junctionLayer]})).results)==null?void 0:c.filter(r=>r.type==="graphic");if(o.length===0){this.currentSectionCode!==""&&(this.currentSectionCode="",this.highlightLayer.removeAll()),this.currentJunctionId!==""&&(this.currentJunctionId=""),this.view.closePopup();return}const s=o[0];if(this.hitGraphic=s.graphic,s.layer.id==="OpenDriveLane"){const r=`${this.hitGraphic.getAttribute("roadId")}+${this.hitGraphic.getAttribute("sectionId")}`;if(this.currentSectionCode===r||this.selectedSectionIds.includes(r)||this.sectionLayer.graphics.findIndex(p=>p.getAttribute("id")===r)>=0)return;this.currentSectionCode=r;const n=this.allLaneGraphics.filter(p=>`${p.attributes.roadId}+${p.attributes.sectionId}`===r),l=A.union(n.map(p=>p.geometry)),d=this.hitGraphic.getAttribute("fromNode"),h=this.hitGraphic.getAttribute("toNode"),y=this.junctionNames.get(d)||d,m=this.junctionNames.get(h)||h,u=new f({geometry:l,symbol:{type:"simple-fill",color:[0,255,255,.5],style:"solid",outline:{color:[0,255,255],width:1}},attributes:{type:"OpenDriveSection",id:r,selected:!1,fromNodeName:y,toNodeName:m,laneCount:n.length},popupTemplate:{title:this.hitGraphic.getAttribute("roadName"),content:[{type:"fields",fieldInfos:[{fieldName:"fromNodeName",label:"起点路口"},{fieldName:"toNodeName",label:"终点路口"},{fieldName:"laneCount",label:"车道数量"}]}]}});this.highlightLayer.removeAll(),this.highlightLayer.add(u)}else if(s.layer.id==="OpenDriveJunction"){const r=this.hitGraphic.getAttribute("id");if(r===this.currentJunctionId)return;this.currentJunctionId=r}});this.mouseMoveHandler=this.view.on("pointer-move",async t=>{e(t).catch(()=>{})})}monitorMouseClick(){const e=M.debounce(async t=>{var a;const o=(a=(await this.view.hitTest(t,{include:[this.highlightLayer,this.junctionLayer,this.sectionLayer]})).results)==null?void 0:a.filter(n=>n.type==="graphic");if(o.length===0)return;const s=o[0].graphic,c=s.getAttribute("type"),r=s.getAttribute("id");if(c==="OpenDriveJunction")if(s.getAttribute("selected")===!1){const n=`http://${this.openDriveServer}/api/sumo/getSumoJunction`,l=await b.get(n,{params:{id:r,projectName:this.projectName}});l.status===200&&l.data.status===0&&(this.openDriveClickCallback&&this.openDriveClickCallback({type:"OpenDriveJunction",id:r,details:l.data.result}),s.setAttribute("selected",!0),s.symbol={type:"picture-marker",url:"/GisViewerAssets/Images/point_red.png",width:"20px",height:"20px"},this.increasePictureMarkerSize(s,50))}else this.openDriveClickCallback&&this.openDriveClickCallback({type:"OpenDriveJunction",id:r,details:void 0}),s.setAttribute("selected",!1),s.symbol=this.getCrossGraphicSymbol(s.attributes,this.view.scale<this.junctionScale?"picture":"marker");else if(c==="OpenDriveSection")if(s.layer.id==="OpenDriveHighlight"){this.highlightLayer.remove(s),this.sectionLayer.add(s),s.setAttribute("selected",!0),this.selectedSectionIds.push(r);const n=`http://${this.openDriveServer}/api/sumo/getSumoEdge`,l=await b.get(n,{params:{id:r,projectName:this.projectName}});if(l.status===200&&l.data.status===0&&this.openDriveClickCallback){const d=l.data.result.obj_id;s.setAttribute("edgeId",d),this.openDriveClickCallback({type:"OpenDriveSection",id:d,details:l.data.result})}}else this.sectionLayer.remove(s),this.selectedSectionIds=this.selectedSectionIds.filter(n=>n!==r),this.openDriveClickCallback&&this.openDriveClickCallback({type:"OpenDriveSection",id:s.getAttribute("edgeId"),details:void 0})});this.mouseClickHandler=this.view.on("immediate-click",async t=>{e(t).catch(()=>{})})}increasePictureMarkerSize(e,t){const i=setInterval(()=>{const o=e.symbol,s=o.width;s<t?e.symbol={type:"picture-marker",url:o.url,width:s+1,height:s+1}:clearInterval(i)},20)}decreasePictureMarkerSize(e,t){const i=setInterval(()=>{const o=e.symbol,s=o.width;s>t?e.symbol={type:"picture-marker",url:o.url,width:s-1,height:s-1}:clearInterval(i)},20)}async getSumoInfo(e){switch(e.type){case"junction":{const t=`http://${this.openDriveServer}/api/sumo/getSumoJunction`,i=await b.get(t,{params:{id:e.id,projectName:this.projectName}});return i.status===200?i.data:{status:-1,message:`路口信息查询失败: ${e.id}`}}case"edge":{const t=e.id.split("#");let i=t[0];i.startsWith("-")&&(i=i.slice(1));let o=0;t.length===2&&(o=Number(t[1]));const s=this.allLaneGraphics.find(c=>c.getAttribute("roadId")===i&&c.getAttribute("sectionIndex")===o);if(s){const c=`${i}+${s.getAttribute("sectionId")}`,r=`http://${this.openDriveServer}/api/sumo/getSumoEdge`,a=await b.get(r,{params:{id:c,projectName:this.projectName}});return a.status===200?a.data:{status:-1,message:`路段信息查询失败: ${c}`}}else return{status:-1,message:"未知类型"}}default:return{status:-1,message:"未知类型"}}}async clearOpenDrive(){var t,i,o;let e=await this.laneLayer.queryFeatures();e.features.length>0&&await this.laneLayer.applyEdits({deleteFeatures:e.features}),e=await this.roadNameLayer.queryFeatures(),e.features.length>0&&await this.roadNameLayer.applyEdits({deleteFeatures:e.features}),this.highlightLayer.removeAll(),this.junctionLayer.removeAll(),this.sectionLayer.removeAll(),this.flashLayer.removeAll(),this.borderLayer.removeAll(),(t=this.mouseMoveHandler)==null||t.remove(),this.mouseMoveHandler=void 0,(i=this.mouseClickHandler)==null||i.remove(),this.mouseClickHandler=void 0,(o=this.scaleWatch)==null||o.remove(),this.scaleWatch=void 0}async findSumo(e){const{type:t,id:i}=e,o=e.flash===void 0?!0:e.flash;if(t==="junction")return await this.findJunction(i,o);if(t==="edge"){const s=i.split("_");if(s.length>2)return{status:-1,message:"id格式错误"};const c=s.length===2?Number(s[1]):void 0,r=s[0].split("#");if(r.length>2)return{status:-1,message:"id格式错误"};const a=r[0],n=r.length===2?Number(r[1]):void 0;return await this.findLane({roadsectId:a,segmentId:n,laneId:c,flash:o})}else return{status:-1,message:"未知类型"}}async findJunction(e,t){const i=this.junctionLayer.graphics.find(o=>o.attributes.id===e);if(!i)return{status:-1,message:"未找到。请检查路口编号"};if(t){const o=new f({geometry:i.geometry,symbol:{type:"simple-marker",style:"circle",size:30,color:[0,255,255,.8],outline:{color:[0,255,255],width:1}}});this.flashGraphic(o)}return await this.view.goTo(i.geometry,{duration:1e3}),{status:0,message:"ok"}}async findLane(e){let{roadsectId:t,segmentId:i,laneId:o}=e;t.startsWith("-")&&(t=t.slice(1));let s=this.allLaneGraphics.filter(a=>a.attributes.roadId===t);if(s.length===0)return{status:-1,message:"未找到。请检查路段编号"};if(i!==void 0){const a=[];if(s.forEach(n=>{const l=Number(n.attributes.sectionId);a.indexOf(l)===-1&&a.push(l)}),a.sort((n,l)=>n-l),i>a.length-1)return{status:-1,message:"未找到。请检查基本段编号"};i=a[i],s=s.filter(n=>Number(n.attributes.sectionId)===i)}if(o!==void 0){const a=[];if(s.forEach(n=>{const l=Number(n.attributes.laneId);a.indexOf(l)===-1&&a.push(l)}),a.sort((n,l)=>n-l),o>a.length-1)return{status:-1,message:"未找到。请检查车道编号"};o=a[o],s=s.filter(n=>Number(n.attributes.laneId)===o)}const c=s.map(a=>a.geometry),r=A.union(c);if(e.flash){const a=new f({geometry:r,symbol:{type:"simple-fill",color:[0,0,255,.6],style:"solid",outline:{width:0}}});this.flashGraphic(a)}return await this.view.goTo(r,{duration:1e3}),{status:0,message:"ok"}}flashGraphic(e){this.flashLayer.removeAll(),this.flashLayer.add(e);let t=0,i=!0;const o=setInterval(()=>{i?(this.flashLayer.opacity-=.02,this.flashLayer.opacity<=.1&&(i=!1,t++)):(this.flashLayer.opacity+=.02,this.flashLayer.opacity>=1&&(i=!0)),t>=5&&(this.flashLayer.removeAll(),this.flashLayer.opacity=1,clearInterval(o))},10)}unselectSumo(e){if((!e||e.type==="junction")&&this.junctionLayer.graphics.forEach(t=>{(!e||!e.id||e.id===""||e.id===t.getAttribute("id"))&&t.getAttribute("selected")&&(t.setAttribute("selected",!1),t.symbol=this.getCrossGraphicSymbol(t.attributes,this.view.scale<this.junctionScale?"picture":"marker"))}),!e||e.type==="edge"){let t;!e||!e.id||e.id===""?t=this.sectionLayer.graphics.toArray():t=this.sectionLayer.graphics.filter(i=>i.getAttribute("edgeId")===e.id).toArray(),t.length>0&&(t.forEach(i=>{const o=i.getAttribute("id");this.selectedSectionIds=this.selectedSectionIds.filter(s=>s!==o)}),this.sectionLayer.removeMany(t))}return{status:0,message:"ok"}}selectSumo(e){switch(e.type){case"junction":return this.junctionLayer.graphics.forEach(t=>{if(e.id===t.getAttribute("id"))return t.setAttribute("selected",!0),t.symbol.url="/GisViewerAssets/Images/point_red.png",this.increasePictureMarkerSize(t,50),{status:0,message:"ok"}}),{status:-1,message:"未找到路口"};case"edge":{const t=e.id.split("#");let i=String(t[0]);i.startsWith("-")&&(i=i.slice(1));let o=0;t.length===2&&(o=Number(t[1]));let s=[];if(t.length===1?s=this.allLaneGraphics.filter(c=>c.getAttribute("roadId")===i):t.length===2&&(s=this.allLaneGraphics.filter(c=>c.getAttribute("roadId")===i&&c.getAttribute("sectionIndex")===o)),s.length>0){const c=new Map;return s.forEach(r=>{const a=r.getAttribute("roadId")+"+"+r.getAttribute("sectionId");this.selectedSectionIds.includes(a)||this.selectedSectionIds.push(a);let n=c.get(a);n?n.push(r.geometry):(n=[r.geometry],c.set(a,n))}),c.forEach((r,a)=>{const n=A.union(r),l=new f({geometry:n,symbol:{type:"simple-fill",color:[0,255,255,.5],style:"solid",outline:{color:[0,255,255],width:1}},attributes:{type:"OpenDriveSection",id:a,edgeId:e.id,selected:!0}});this.sectionLayer.add(l)}),{status:0,message:"ok"}}else return{status:-1,message:"未找到路段"}}default:return{status:-1,message:"未知类型"}}}async geometrySearch(e){const t=new L.Polygon({rings:[e]}),i=await this.laneLayer.queryFeatures({geometry:t,outFields:["*"]}),o=[],s=[];for(const a of i.features){const n=a.getAttribute("roadId"),l=a.getAttribute("sectionIndex"),d=`${n}#${l}`;if(o.indexOf(d)===-1){o.push(d),this.selectSumo({type:"edge",id:d});const h=`http://${this.openDriveServer}/api/sumo/getSumoEdge`,y=await b.get(h,{params:{id:`${n}+${a.getAttribute("sectionId")}`,projectName:this.projectName}});y.status===200&&y.data.status===0&&s.push(y.data.result)}}const c=this.junctionLayer.graphics.filter(a=>{const n=a.geometry;return A.contains(t,n)}),r=[];for(const a of c){const n=a.getAttribute("id");this.selectSumo({type:"junction",id:n});const l=`http://${this.openDriveServer}/api/sumo/getSumoJunction`,d=await b.get(l,{params:{id:n,projectName:this.projectName}});d.status===200&&d.data.status===0&&r.push(d.data.result)}return{status:0,message:"ok",result:{junctions:r,edges:s}}}async splitLane(e){const i=e.id.split("_");if(i.length!==2)return{status:-1,message:"车道编号格式错误"};const o=Number(i[1]),s=i[0].split("#"),c=s.length===2?Number(s[1]):0;let r=s[0];r.startsWith("-")&&(r=r.slice(1));const a=this.allLaneGraphics.filter(I=>I.getAttribute("roadId")===r&&I.getAttribute("sectionIndex")===c);if(a.length===0)return{status:-1,message:"未找到路段"};const n=a.length-o,l=a.find(I=>Math.abs(I.getAttribute("laneId"))===n);if(!l)return{status:-1,message:"未找到车道"};const d=e.start||0,h=e.end||100,y=P.lineString(l.getAttribute("leftLine")),m=G.lineSliceAlong(y,d,h,{units:"meters"}),u=P.lineString(l.getAttribute("rightLine")),p=G.lineSliceAlong(u,d,h,{units:"meters"}),g=m.geometry.coordinates.concat(p.geometry.coordinates.reverse());g.push(g[g.length-1]);const v=new f({geometry:new L.Polygon({rings:[g]}),attributes:{ObjectID:l.getAttribute("ObjectID"),id:l.getAttribute("id"),fromNode:l.getAttribute("fromNode"),toNode:l.getAttribute("toNode"),roadId:l.getAttribute("roadId"),roadName:l.getAttribute("roadName"),sectionId:l.getAttribute("sectionId"),sectionIndex:l.getAttribute("sectionIndex"),laneId:l.getAttribute("laneId"),type:l.getAttribute("type"),sumoId:l.getAttribute("sumoId"),leftLine:m.geometry.coordinates,rightLine:p.geometry.coordinates},symbol:{type:"simple-fill",color:[255,0,0,.8],outline:{color:"red"}}});return this.splitLaneLayer.add(v),this.view.goTo(v),{status:0,message:"ok",result:e}}clearSplitLane(){this.splitLaneLayer.removeAll()}updateAllJunctionSymbol(e){const t=this.junctionLayer.graphics.clone();this.junctionLayer.removeAll(),t.forEach(i=>{i.symbol=this.getCrossGraphicSymbol(i.attributes,e)}),this.junctionLayer.addMany(t.toArray())}getCrossGraphicSymbol(e,t){const i=e.crossId!==""&&e.crossId!==void 0&&e.crossId!==null;if(t==="marker")return{type:"picture-marker",url:`/GisViewerAssets/Images/xhj_${i?1:2}.png`,width:"18px",height:"28px",yOffset:"12px"};if(t==="picture")return i?{type:"cim",data:{type:"CIMSymbolReference",primitiveOverrides:[{type:"CIMPrimitiveOverride",primitiveName:"textGraphic",propertyName:"TextString",valueExpressionInfo:{type:"CIMExpressionInfo",title:"Custom",expression:'Replace($feature.name, "与", "/") + " " + $feature.crossId',returnType:"Default"}}],symbol:{type:"CIMPointSymbol",symbolLayers:[{type:"CIMVectorMarker",size:32,colorLocked:!0,anchorPointUnits:"Relative",frame:{xmin:-16,ymin:-16,xmax:16,ymax:16},markerGraphics:[{type:"CIMMarkerGraphic",primitiveName:"textGraphic",geometry:{x:0,y:0},symbol:{type:"CIMTextSymbol",height:12,horizontalAlignment:"Center",offsetX:0,offsetY:i?50:40,haloSize:2,haloSymbol:{type:"CIMPolygonSymbol",symbolLayers:[{type:"CIMSolidFill",enable:!0,color:[255,255,255,255]}]},symbol:{type:"CIMPolygonSymbol",symbolLayers:[{type:"CIMSolidFill",enable:!0,color:[0,0,0,255]}]},verticalAlignment:"Center"},textString:""}],scaleSymbolsProportionally:!0,respectFrame:!0},{type:"CIMPictureMarker",enable:!0,anchorPoint:{x:0,y:0},anchorPointUnits:"Relative",size:45,rotateClockwise:!0,textureFilter:"Picture",url:"/GisViewerAssets/Images/xhj_1.png",offsetY:i?22:15}]}}}:{type:"picture-marker",url:"/GisViewerAssets/Images/xhj_2.png",width:"27px",height:"42px",yOffset:"22px"}}}exports.default=k;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "gisviewer-vue3-arcgis",
3
- "version": "1.0.163",
3
+ "version": "1.0.165",
4
4
  "main": "lib/index.js",
5
5
  "module": "es/index.mjs",
6
6
  "files": [