gisviewer-vue3-arcgis 1.0.131 → 1.0.132

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.
@@ -287,8 +287,8 @@ class C {
287
287
  }
288
288
  async makeMd5FromFile(e) {
289
289
  try {
290
- const s = await (await fetch(e)).text();
291
- return { status: 0, message: "ok", result: F(s) };
290
+ const i = await (await fetch(e)).text();
291
+ return { status: 0, message: "ok", result: F(i) };
292
292
  } catch (t) {
293
293
  return { status: -1, message: t.message };
294
294
  }
@@ -305,11 +305,11 @@ class C {
305
305
  if (t.status !== 0)
306
306
  return t;
307
307
  this.projectName = t.result, console.timeEnd("md5用时"), this.openDriveServer = e.server, await this.makeMd5FromFile(e.file);
308
- const s = `http://${this.openDriveServer}/api/openDrive/uploadXodr`;
308
+ const i = `http://${this.openDriveServer}/api/openDrive/uploadXodr`;
309
309
  let o;
310
310
  try {
311
311
  o = await m.post(
312
- s,
312
+ i,
313
313
  {},
314
314
  {
315
315
  params: {
@@ -324,15 +324,15 @@ class C {
324
324
  if (o.status !== 200)
325
325
  return { status: -1, message: o.statusText };
326
326
  console.time("渲染用时");
327
- const i = o.data.result.geoSetting;
327
+ const s = o.data.result.geoSetting;
328
328
  A.setGeoData(
329
- i.geoReference,
330
- i.offsetX,
331
- i.offsetY
329
+ s.geoReference,
330
+ s.offsetX,
331
+ s.offsetY
332
332
  );
333
333
  let l = o.data.result.json;
334
334
  l.startsWith(window.location.protocol) || (l = `${window.location.protocol}//${e.server}${l}`);
335
- const n = await (await fetch(l)).arrayBuffer(), r = S.inflate(n, { to: "string" }), c = JSON.parse(r);
335
+ const a = await (await fetch(l)).arrayBuffer(), r = S.inflate(a, { to: "string" }), c = JSON.parse(r);
336
336
  await this.showAllLanes(
337
337
  c,
338
338
  ((d = e.options) == null ? void 0 : d.showJunctionLane) || !1,
@@ -351,7 +351,7 @@ class C {
351
351
  * @param projectName
352
352
  */
353
353
  async showOpenDriveFromServer(e, t) {
354
- const s = `http://${e}/api/openDrive/analyzeXodr`, o = await m.get(s, {
354
+ const i = `http://${e}/api/openDrive/analyzeXodr`, o = await m.get(i, {
355
355
  headers: {
356
356
  projectName: t
357
357
  },
@@ -362,9 +362,9 @@ class C {
362
362
  });
363
363
  if (o.status !== 200)
364
364
  throw new Error(`OpenDriveRenderer: ${o.statusText}`);
365
- let i = o.data.result.json;
366
- i.startsWith(window.location.protocol) || (i = `${window.location.protocol}//${e}${i}`);
367
- const a = await (await fetch(i)).arrayBuffer(), n = S.inflate(a, { to: "string" }), r = JSON.parse(n);
365
+ let s = o.data.result.json;
366
+ s.startsWith(window.location.protocol) || (s = `${window.location.protocol}//${e}${s}`);
367
+ const n = await (await fetch(s)).arrayBuffer(), a = S.inflate(n, { to: "string" }), r = JSON.parse(a);
368
368
  return await this.showAllLanes(r, !1, !1), { status: 0, message: "ok" };
369
369
  }
370
370
  /**
@@ -374,14 +374,14 @@ class C {
374
374
  * @param showRoadName 是否显示道路名称
375
375
  * @returns
376
376
  */
377
- async showAllLanes(e, t, s) {
377
+ async showAllLanes(e, t, i) {
378
378
  const o = await this.laneLayer.queryFeatures();
379
379
  return o.features.length > 0 && this.laneLayer.applyEdits({
380
380
  deleteFeatures: o.features
381
- }), this.roadNameLayer.visible = s, new Promise((i) => {
381
+ }), this.roadNameLayer.visible = i, new Promise((s) => {
382
382
  let l = 0;
383
383
  this.allLaneGraphics = [], this.allRefLineGraphics = [];
384
- const a = [];
384
+ const n = [];
385
385
  for (const r of e) {
386
386
  if (!t && r.junction !== "-1")
387
387
  continue;
@@ -432,15 +432,15 @@ class C {
432
432
  sumoId: ""
433
433
  }
434
434
  });
435
- this.allLaneGraphics.push(k), a.push(k);
435
+ this.allLaneGraphics.push(k), n.push(k);
436
436
  }
437
437
  }
438
438
  }
439
439
  }
440
- const n = setInterval(() => {
441
- if (a.length > 0 || this.allRefLineGraphics.length > 0) {
442
- if (a.length > 0) {
443
- const r = a.splice(0, 100);
440
+ const a = setInterval(() => {
441
+ if (n.length > 0 || this.allRefLineGraphics.length > 0) {
442
+ if (n.length > 0) {
443
+ const r = n.splice(0, 100);
444
444
  this.laneLayer.applyEdits({
445
445
  addFeatures: r
446
446
  });
@@ -452,7 +452,7 @@ class C {
452
452
  });
453
453
  }
454
454
  } else
455
- clearInterval(n), i();
455
+ clearInterval(a), s();
456
456
  }, 10);
457
457
  });
458
458
  }
@@ -463,22 +463,24 @@ class C {
463
463
  */
464
464
  showJunction(e) {
465
465
  const t = [];
466
- for (const s of e) {
467
- s.nodeType = s.type;
466
+ for (const i of e) {
467
+ if (!i)
468
+ continue;
469
+ i.nodeType = i.type;
468
470
  const o = new p({
469
471
  geometry: {
470
472
  type: "point",
471
- x: s.coordinates[0],
472
- y: s.coordinates[1]
473
+ x: i.coordinates[0],
474
+ y: i.coordinates[1]
473
475
  },
474
476
  attributes: {
475
- ...s,
477
+ ...i,
476
478
  selected: !1,
477
479
  type: "OpenDriveJunction"
478
480
  },
479
481
  symbol: {
480
482
  type: "picture-marker",
481
- url: s.crossId ? "/GisViewerAssets/Images/point_green.png" : "/GisViewerAssets/Images/point_yellow.png",
483
+ url: i.crossId ? "/GisViewerAssets/Images/point_green.png" : "/GisViewerAssets/Images/point_yellow.png",
482
484
  width: 30,
483
485
  height: 30
484
486
  }
@@ -496,22 +498,22 @@ class C {
496
498
  const o = (l = (await this.view.hitTest(t, {
497
499
  include: [this.laneLayer, this.junctionLayer]
498
500
  })).results) == null ? void 0 : l.filter(
499
- (a) => a.type === "graphic"
501
+ (n) => n.type === "graphic"
500
502
  );
501
503
  if (o.length === 0) {
502
504
  this.currentSectionCode !== "" && (this.currentSectionCode = "", this.highlightGraphic = void 0, this.highlightLayer.removeAll()), this.currentJunctionId !== "" && (this.currentJunctionId = "", this.view.closePopup());
503
505
  return;
504
506
  }
505
- const i = o[0];
506
- if (this.hitGraphic = i.graphic, i.layer.id === "OpenDriveLane") {
507
- const a = `${this.hitGraphic.attributes.roadId}+${this.hitGraphic.attributes.sectionId}`;
508
- if (a === this.currentSectionCode || this.sectionLayer.graphics.findIndex(
509
- (h) => h.getAttribute("id") === a
507
+ const s = o[0];
508
+ if (this.hitGraphic = s.graphic, s.layer.id === "OpenDriveLane") {
509
+ const n = `${this.hitGraphic.attributes.roadId}+${this.hitGraphic.attributes.sectionId}`;
510
+ if (n === this.currentSectionCode || this.sectionLayer.graphics.findIndex(
511
+ (h) => h.getAttribute("id") === n
510
512
  ) >= 0)
511
513
  return;
512
- this.currentSectionCode = a;
514
+ this.currentSectionCode = n;
513
515
  const r = this.allLaneGraphics.filter(
514
- (h) => `${h.attributes.roadId}+${h.attributes.sectionId}` === a
516
+ (h) => `${h.attributes.roadId}+${h.attributes.sectionId}` === n
515
517
  ), c = I.union(
516
518
  r.map((h) => h.geometry)
517
519
  );
@@ -528,20 +530,20 @@ class C {
528
530
  },
529
531
  attributes: {
530
532
  type: "OpenDriveSection",
531
- id: a,
533
+ id: n,
532
534
  selected: !1
533
535
  }
534
536
  }), this.highlightLayer.removeAll(), this.highlightLayer.add(this.highlightGraphic);
535
- } else if (i.layer.id === "OpenDriveJunction") {
536
- const a = this.hitGraphic.getAttribute("id");
537
- if (a === this.currentJunctionId)
537
+ } else if (s.layer.id === "OpenDriveJunction") {
538
+ const n = this.hitGraphic.getAttribute("id");
539
+ if (n === this.currentJunctionId)
538
540
  return;
539
- this.currentJunctionId = a;
540
- const n = this.hitGraphic.getAttribute("name"), r = this.hitGraphic.getAttribute("crossId");
541
+ this.currentJunctionId = n;
542
+ const a = this.hitGraphic.getAttribute("name"), r = this.hitGraphic.getAttribute("crossId");
541
543
  this.view.popup.open({
542
- title: n,
544
+ title: a,
543
545
  content: `<table>
544
- <tr><td>路口编号</td><td>${a}</td></tr>
546
+ <tr><td>路口编号</td><td>${n}</td></tr>
545
547
  <tr><td>信号机编号</td><td>${r || "无信控"}</td></tr>
546
548
  </table>`,
547
549
  location: this.hitGraphic.geometry
@@ -558,55 +560,55 @@ class C {
558
560
  */
559
561
  monitorMouseClick() {
560
562
  const e = j.debounce(async (t) => {
561
- var n;
562
- const o = (n = (await this.view.hitTest(t, {
563
+ var a;
564
+ const o = (a = (await this.view.hitTest(t, {
563
565
  include: [this.highlightLayer, this.junctionLayer, this.sectionLayer]
564
- })).results) == null ? void 0 : n.filter(
566
+ })).results) == null ? void 0 : a.filter(
565
567
  (r) => r.type === "graphic"
566
568
  );
567
569
  if (o.length === 0)
568
570
  return;
569
- const i = o[0].graphic, l = i.getAttribute("type"), a = i.getAttribute("id");
571
+ const s = o[0].graphic, l = s.getAttribute("type"), n = s.getAttribute("id");
570
572
  if (l === "OpenDriveJunction")
571
- if (i.getAttribute("selected") === !1) {
573
+ if (s.getAttribute("selected") === !1) {
572
574
  const r = `http://${this.openDriveServer}/api/sumo/getSumoJunction`, c = await m.get(r, {
573
575
  params: {
574
- id: a,
576
+ id: n,
575
577
  projectName: this.projectName
576
578
  }
577
579
  });
578
580
  c.status === 200 && c.data.status === 0 && (this.openDriveClickCallback && this.openDriveClickCallback({
579
581
  type: "OpenDriveJunction",
580
- id: a,
582
+ id: n,
581
583
  details: c.data.result
582
- }), i.setAttribute("selected", !0), i.symbol.url = "/GisViewerAssets/Images/point_red.png", this.increasePictureMarkerSize(i, 50));
584
+ }), s.setAttribute("selected", !0), s.symbol.url = "/GisViewerAssets/Images/point_red.png", this.increasePictureMarkerSize(s, 50));
583
585
  } else {
584
586
  this.openDriveClickCallback && this.openDriveClickCallback({
585
587
  type: "OpenDriveJunction",
586
- id: a,
588
+ id: n,
587
589
  details: void 0
588
- }), i.setAttribute("selected", !1);
589
- const r = i.getAttribute("crossId");
590
- i.symbol.url = r ? "/GisViewerAssets/Images/point_green.png" : "/GisViewerAssets/Images/point_yellow.png", this.decreasePictureMarkerSize(i, 30);
590
+ }), s.setAttribute("selected", !1);
591
+ const r = s.getAttribute("crossId");
592
+ s.symbol.url = r ? "/GisViewerAssets/Images/point_green.png" : "/GisViewerAssets/Images/point_yellow.png", this.decreasePictureMarkerSize(s, 30);
591
593
  }
592
594
  else if (l === "OpenDriveSection")
593
- if (i.getAttribute("selected"))
594
- this.sectionLayer.remove(i), this.openDriveClickCallback && this.openDriveClickCallback({
595
+ if (s.getAttribute("selected"))
596
+ this.sectionLayer.remove(s), this.openDriveClickCallback && this.openDriveClickCallback({
595
597
  type: "OpenDriveSection",
596
- id: a,
598
+ id: n,
597
599
  details: void 0
598
600
  });
599
601
  else {
600
- this.highlightLayer.remove(i), this.sectionLayer.add(i), i.setAttribute("selected", !0);
602
+ this.highlightLayer.remove(s), this.sectionLayer.add(s), s.setAttribute("selected", !0);
601
603
  const r = `http://${this.openDriveServer}/api/sumo/getSumoEdge`, c = await m.get(r, {
602
604
  params: {
603
- id: a,
605
+ id: n,
604
606
  projectName: this.projectName
605
607
  }
606
608
  });
607
- c.status === 200 && c.data.status === 0 && this.openDriveClickCallback && (i.setAttribute("edgeId", c.data.result.obj_id), this.openDriveClickCallback({
609
+ c.status === 200 && c.data.status === 0 && this.openDriveClickCallback && (s.setAttribute("edgeId", c.data.result.obj_id), this.openDriveClickCallback({
608
610
  type: "OpenDriveSection",
609
- id: a,
611
+ id: n,
610
612
  details: c.data.result
611
613
  }));
612
614
  }
@@ -622,14 +624,14 @@ class C {
622
624
  * @param targetSize
623
625
  */
624
626
  increasePictureMarkerSize(e, t) {
625
- const s = setInterval(() => {
626
- const o = e.symbol, i = o.width;
627
- i < t ? e.symbol = {
627
+ const i = setInterval(() => {
628
+ const o = e.symbol, s = o.width;
629
+ s < t ? e.symbol = {
628
630
  type: "picture-marker",
629
631
  url: o.url,
630
- width: i + 1,
631
- height: i + 1
632
- } : clearInterval(s);
632
+ width: s + 1,
633
+ height: s + 1
634
+ } : clearInterval(i);
633
635
  }, 20);
634
636
  }
635
637
  /**
@@ -638,46 +640,46 @@ class C {
638
640
  * @param targetSize
639
641
  */
640
642
  decreasePictureMarkerSize(e, t) {
641
- const s = setInterval(() => {
642
- const o = e.symbol, i = o.width;
643
- i > t ? e.symbol = {
643
+ const i = setInterval(() => {
644
+ const o = e.symbol, s = o.width;
645
+ s > t ? e.symbol = {
644
646
  type: "picture-marker",
645
647
  url: o.url,
646
- width: i - 1,
647
- height: i - 1
648
- } : clearInterval(s);
648
+ width: s - 1,
649
+ height: s - 1
650
+ } : clearInterval(i);
649
651
  }, 20);
650
652
  }
651
653
  async getSumoInfo(e) {
652
654
  switch (e.type) {
653
655
  case "junction": {
654
- const t = `http://${this.openDriveServer}/api/sumo/getSumoJunction`, s = await m.get(t, {
656
+ const t = `http://${this.openDriveServer}/api/sumo/getSumoJunction`, i = await m.get(t, {
655
657
  params: {
656
658
  id: e.id,
657
659
  projectName: this.projectName
658
660
  }
659
661
  });
660
- return s.status === 200 ? s.data : { status: -1, message: `路口信息查询失败: ${e.id}` };
662
+ return i.status === 200 ? i.data : { status: -1, message: `路口信息查询失败: ${e.id}` };
661
663
  }
662
664
  case "edge": {
663
665
  const t = e.id.split("#");
664
- let s = t[0];
665
- s.startsWith("-") && (s = s.slice(1));
666
+ let i = t[0];
667
+ i.startsWith("-") && (i = i.slice(1));
666
668
  let o = 0;
667
669
  t.length === 2 && (o = Number(t[1]));
668
- const i = this.allLaneGraphics.find(
669
- (l) => l.getAttribute("roadId") === s && l.getAttribute("sectionIndex") === o
670
+ const s = this.allLaneGraphics.find(
671
+ (l) => l.getAttribute("roadId") === i && l.getAttribute("sectionIndex") === o
670
672
  );
671
- if (i) {
672
- const l = `${s}+${i.getAttribute(
673
+ if (s) {
674
+ const l = `${i}+${s.getAttribute(
673
675
  "sectionId"
674
- )}`, a = `http://${this.openDriveServer}/api/sumo/getSumoEdge`, n = await m.get(a, {
676
+ )}`, n = `http://${this.openDriveServer}/api/sumo/getSumoEdge`, a = await m.get(n, {
675
677
  params: {
676
678
  id: l,
677
679
  projectName: this.projectName
678
680
  }
679
681
  });
680
- return n.status === 200 ? n.data : { status: -1, message: `路段信息查询失败: ${l}` };
682
+ return a.status === 200 ? a.data : { status: -1, message: `路段信息查询失败: ${l}` };
681
683
  } else
682
684
  return { status: -1, message: "未知类型" };
683
685
  }
@@ -689,13 +691,13 @@ class C {
689
691
  * 清除OpenDrive内容
690
692
  */
691
693
  async clearOpenDrive() {
692
- var t, s;
694
+ var t, i;
693
695
  let e = await this.laneLayer.queryFeatures();
694
696
  e.features.length > 0 && await this.laneLayer.applyEdits({
695
697
  deleteFeatures: e.features
696
698
  }), e = await this.roadNameLayer.queryFeatures(), e.features.length > 0 && await this.roadNameLayer.applyEdits({
697
699
  deleteFeatures: e.features
698
- }), this.highlightLayer.removeAll(), this.junctionLayer.removeAll(), this.sectionLayer.removeAll(), this.flashLayer.removeAll(), (t = this.mouseMoveHandler) == null || t.remove(), this.mouseMoveHandler = void 0, (s = this.mouseClickHandler) == null || s.remove(), this.mouseClickHandler = void 0;
700
+ }), 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;
699
701
  }
700
702
  /**
701
703
  * 用sumo的id定位车道、基本段、路段
@@ -703,30 +705,30 @@ class C {
703
705
  * @returns
704
706
  */
705
707
  async findSumo(e) {
706
- const { type: t, id: s } = e, o = e.flash === void 0 ? !0 : e.flash;
708
+ const { type: t, id: i } = e, o = e.flash === void 0 ? !0 : e.flash;
707
709
  if (t === "junction")
708
- return await this.findJunction(s, o);
710
+ return await this.findJunction(i, o);
709
711
  if (t === "edge") {
710
- const i = s.split("+");
711
- if (i.length > 2)
712
+ const s = i.split("+");
713
+ if (s.length > 2)
712
714
  return { status: -1, message: "id格式错误" };
713
- const l = i.length === 2 ? Number(i[1]) : void 0, a = i[0].split("#");
714
- if (a.length > 2)
715
+ const l = s.length === 2 ? Number(s[1]) : void 0, n = s[0].split("#");
716
+ if (n.length > 2)
715
717
  return { status: -1, message: "id格式错误" };
716
- const n = a[0], r = a.length === 2 ? Number(a[1]) : void 0;
717
- return await this.findLane({ roadsectId: n, segmentId: r, laneId: l, flash: o });
718
+ const a = n[0], r = n.length === 2 ? Number(n[1]) : void 0;
719
+ return await this.findLane({ roadsectId: a, segmentId: r, laneId: l, flash: o });
718
720
  } else
719
721
  return { status: -1, message: "未知类型" };
720
722
  }
721
723
  async findJunction(e, t) {
722
- const s = this.junctionLayer.graphics.find(
724
+ const i = this.junctionLayer.graphics.find(
723
725
  (o) => o.attributes.id === e
724
726
  );
725
- if (!s)
727
+ if (!i)
726
728
  return { status: -1, message: "未找到。请检查路口编号" };
727
729
  if (t) {
728
730
  const o = new p({
729
- geometry: s.geometry,
731
+ geometry: i.geometry,
730
732
  symbol: {
731
733
  type: "simple-marker",
732
734
  style: "circle",
@@ -740,7 +742,7 @@ class C {
740
742
  });
741
743
  this.flashGraphic(o);
742
744
  }
743
- return await this.view.goTo(s.geometry, { duration: 1e3 }), { status: 0, message: "ok" };
745
+ return await this.view.goTo(i.geometry, { duration: 1e3 }), { status: 0, message: "ok" };
744
746
  }
745
747
  /**
746
748
  * 用sumo的id定位车道、基本段、路段
@@ -748,41 +750,41 @@ class C {
748
750
  * @returns
749
751
  */
750
752
  async findLane(e) {
751
- let { roadsectId: t, segmentId: s, laneId: o } = e;
753
+ let { roadsectId: t, segmentId: i, laneId: o } = e;
752
754
  t.startsWith("-") && (t = t.slice(1));
753
- let i = this.allLaneGraphics.filter(
754
- (n) => n.attributes.roadId === t
755
+ let s = this.allLaneGraphics.filter(
756
+ (a) => a.attributes.roadId === t
755
757
  );
756
- if (i.length === 0)
758
+ if (s.length === 0)
757
759
  return { status: -1, message: "未找到。请检查路段编号" };
758
- if (s !== void 0) {
759
- const n = [];
760
- if (i.forEach((r) => {
760
+ if (i !== void 0) {
761
+ const a = [];
762
+ if (s.forEach((r) => {
761
763
  const c = Number(r.attributes.sectionId);
762
- n.indexOf(c) === -1 && n.push(c);
763
- }), n.sort((r, c) => r - c), s > n.length - 1)
764
+ a.indexOf(c) === -1 && a.push(c);
765
+ }), a.sort((r, c) => r - c), i > a.length - 1)
764
766
  return { status: -1, message: "未找到。请检查基本段编号" };
765
- s = n[s], i = i.filter(
766
- (r) => Number(r.attributes.sectionId) === s
767
+ i = a[i], s = s.filter(
768
+ (r) => Number(r.attributes.sectionId) === i
767
769
  );
768
770
  }
769
771
  if (o !== void 0) {
770
- const n = [];
771
- if (i.forEach((r) => {
772
+ const a = [];
773
+ if (s.forEach((r) => {
772
774
  const c = Number(r.attributes.laneId);
773
- n.indexOf(c) === -1 && n.push(c);
774
- }), n.sort((r, c) => r - c), o > n.length - 1)
775
+ a.indexOf(c) === -1 && a.push(c);
776
+ }), a.sort((r, c) => r - c), o > a.length - 1)
775
777
  return { status: -1, message: "未找到。请检查车道编号" };
776
- o = n[o], i = i.filter(
778
+ o = a[o], s = s.filter(
777
779
  (r) => Number(r.attributes.laneId) === o
778
780
  );
779
781
  }
780
- const l = i.map(
781
- (n) => n.geometry
782
- ), a = I.union(l);
782
+ const l = s.map(
783
+ (a) => a.geometry
784
+ ), n = I.union(l);
783
785
  if (e.flash) {
784
- const n = new p({
785
- geometry: a,
786
+ const a = new p({
787
+ geometry: n,
786
788
  symbol: {
787
789
  type: "simple-fill",
788
790
  color: [255, 0, 0, 0.5],
@@ -793,9 +795,9 @@ class C {
793
795
  }
794
796
  }
795
797
  });
796
- this.flashGraphic(n);
798
+ this.flashGraphic(a);
797
799
  }
798
- return await this.view.goTo(a, { duration: 1e3 }), { status: 0, message: "ok" };
800
+ return await this.view.goTo(n, { duration: 1e3 }), { status: 0, message: "ok" };
799
801
  }
800
802
  /**
801
803
  * graphic渐隐渐显闪烁
@@ -803,9 +805,9 @@ class C {
803
805
  */
804
806
  flashGraphic(e) {
805
807
  this.flashLayer.removeAll(), this.flashLayer.add(e);
806
- let t = 0, s = !0;
808
+ let t = 0, i = !0;
807
809
  const o = setInterval(() => {
808
- 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));
810
+ 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(o));
809
811
  }, 10);
810
812
  }
811
813
  /**
@@ -817,15 +819,15 @@ class C {
817
819
  if ((!e || e.type === "junction") && this.junctionLayer.graphics.forEach((t) => {
818
820
  if ((!e || !e.id || e.id === "" || e.id === t.getAttribute("id")) && t.getAttribute("selected")) {
819
821
  t.setAttribute("selected", !1);
820
- const s = t.getAttribute("crossId");
821
- t.symbol.url = s ? "/GisViewerAssets/Images/point_green.png" : "/GisViewerAssets/Images/point_yellow.png", this.decreasePictureMarkerSize(t, 30);
822
+ const i = t.getAttribute("crossId");
823
+ t.symbol.url = i ? "/GisViewerAssets/Images/point_green.png" : "/GisViewerAssets/Images/point_yellow.png", this.decreasePictureMarkerSize(t, 30);
822
824
  }
823
825
  }), !e || e.type === "edge")
824
826
  if (!e || !e.id || e.id === "")
825
827
  this.sectionLayer.removeAll();
826
828
  else {
827
829
  const t = this.sectionLayer.graphics.find(
828
- (s) => s.getAttribute("edgeId") === e.id
830
+ (i) => i.getAttribute("edgeId") === e.id
829
831
  );
830
832
  t && this.sectionLayer.remove(t);
831
833
  }
@@ -845,17 +847,17 @@ class C {
845
847
  }), { status: -1, message: "未找到路口" };
846
848
  case "edge": {
847
849
  const t = e.id.split("#");
848
- let s = t[0];
849
- s.startsWith("-") && (s = s.slice(1));
850
+ let i = t[0];
851
+ i.startsWith("-") && (i = i.slice(1));
850
852
  let o = 0;
851
853
  t.length === 2 && (o = Number(t[1]));
852
- const i = this.allLaneGraphics.filter(
853
- (l) => l.getAttribute("roadId") === s && l.getAttribute("sectionIndex") === o
854
+ const s = this.allLaneGraphics.filter(
855
+ (l) => l.getAttribute("roadId") === i && l.getAttribute("sectionIndex") === o
854
856
  );
855
- if (i.length > 0) {
857
+ if (s.length > 0) {
856
858
  const l = I.union(
857
- i.map((n) => n.geometry)
858
- ), a = new p({
859
+ s.map((a) => a.geometry)
860
+ ), n = new p({
859
861
  geometry: l,
860
862
  symbol: {
861
863
  type: "simple-fill",
@@ -872,7 +874,7 @@ class C {
872
874
  selected: !0
873
875
  }
874
876
  });
875
- return this.sectionLayer.add(a), { status: 0, message: "ok" };
877
+ return this.sectionLayer.add(n), { status: 0, message: "ok" };
876
878
  } else
877
879
  return { status: -1, message: "未找到路段" };
878
880
  }
@@ -1,4 +1,4 @@
1
- "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const p=require("@arcgis/core/Graphic"),$=require("@arcgis/core/core/promiseUtils"),M=require("@arcgis/core/geometry"),J=require("@arcgis/core/geometry/geometryEngine"),G=require("@arcgis/core/layers/FeatureLayer"),v=require("@arcgis/core/layers/GraphicsLayer"),y=require("axios"),P=require("md5"),A=require("pako"),C=require("../common-utils.js"),x=require("./wasm-loader.js");function O(m){const e=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(m){for(const t in m)if(t!=="default"){const i=Object.getOwnPropertyDescriptor(m,t);Object.defineProperty(e,t,i.get?i:{enumerable:!0,get:()=>m[t]})}}return e.default=m,Object.freeze(e)}const N=O($),L=O(J);class D{constructor(e){this.wasmLoader=x.default.getInstance(),this.projectName="",this.openDriveServer="",this.currentSectionCode="",this.currentJunctionId="",this.view=e,this.view.popup.visibleElements={closeButton:!1,collapseButton:!1,actionBar:!1},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:"laneId",alias:"车道号",type:"string"},{name:"type",alias:"类型",type:"string"},{name:"sumoId",alias:"sumo编号",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 v({id:"OpenDriveJunction"}),this.sectionLayer=new v({id:"OpenDriveSection"}),this.highlightLayer=new v({id:"OpenDriveHighlight"}),this.flashLayer=new v({id:"OpenDriveFlash"}),this.view.map.addMany([this.laneLayer,this.junctionLayer,this.sectionLayer,this.roadNameLayer,this.highlightLayer,this.flashLayer])}static getInstance(e){return this.instance||(this.instance=new D(e)),this.instance}async makeMd5FromFile(e){try{const i=await(await fetch(e)).text();return{status:0,message:"ok",result:P(i)}}catch(t){return{status:-1,message:t.message}}}async showOpenDriveFromFile(e){var h,g;this.openDriveClickCallback=e.selectedCallback,console.time("md5用时");const t=await this.makeMd5FromFile(e.file);if(t.status!==0)return t;this.projectName=t.result,console.timeEnd("md5用时"),this.openDriveServer=e.server,await this.makeMd5FromFile(e.file);const i=`http://${this.openDriveServer}/api/openDrive/uploadXodr`;let o;try{o=await y.post(i,{},{params:{url:e.file,projectName:this.projectName}})}catch(d){return{status:-1,message:d.message}}if(o.status!==200)return{status:-1,message:o.statusText};console.time("渲染用时");const s=o.data.result.geoSetting;C.default.setGeoData(s.geoReference,s.offsetX,s.offsetY);let l=o.data.result.json;l.startsWith(window.location.protocol)||(l=`${window.location.protocol}//${e.server}${l}`);const a=await(await fetch(l)).arrayBuffer(),r=A.inflate(a,{to:"string"}),c=JSON.parse(r);await this.showAllLanes(c,((h=e.options)==null?void 0:h.showJunctionLane)||!1,((g=e.options)==null?void 0:g.showRoadName)||!0);const u=o.data.result.junctions;if(this.showJunction(u),e.options&&e.options.centerMap!==!1){const d=C.default.transformPointProjection([0,0]);await this.view.goTo(d)}return this.mouseMoveHandler||this.monitorMouseMove(),this.mouseClickHandler||this.monitorMouseClick(),console.timeEnd("渲染用时"),{status:0,message:"ok"}}async showOpenDriveFromServer(e,t){const i=`http://${e}/api/openDrive/analyzeXodr`,o=await y.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 n=await(await fetch(s)).arrayBuffer(),a=A.inflate(n,{to:"string"}),r=JSON.parse(a);return await this.showAllLanes(r,!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 l=0;this.allLaneGraphics=[],this.allRefLineGraphics=[];const n=[];for(const r of e){if(!t&&r.junction!=="-1")continue;const{id:c,refLine:u}=r;let h=r.name;h.includes("(")&&(h=h.slice(0,h.indexOf("("))),h=h.replace(/(.)/g,"$1 ");const g=new p({geometry:{type:"polyline",paths:[u]},attributes:{ObjectID:l++,roadId:c,roadName:h}});this.allRefLineGraphics.push(g),r.laneSections.sort((d,b)=>Number(d.id)-Number(b.id));for(let d=0;d<r.laneSections.length;d++){const b=r.laneSections[d],k=Number(b.id);for(const f of b.lanePaths){const w=Number(f.id);if(w===0)continue;const F=f.type,I=f.innerPath.concat(f.outerPath.reverse());if(I.length<=3){console.warn(`lane ${w} has less than 3 points`);continue}I.push(f.innerPath[0]);const j=new M.Polygon({rings:[I]});if(j){const S=new p({geometry:j,attributes:{ObjectID:l++,id:`${c}+${k}+${w}`,roadId:c,roadName:r.name,sectionId:k,sectionIndex:d,laneId:w,type:F,sumoId:""}});this.allLaneGraphics.push(S),n.push(S)}}}}const a=setInterval(()=>{if(n.length>0||this.allRefLineGraphics.length>0){if(n.length>0){const r=n.splice(0,100);this.laneLayer.applyEdits({addFeatures:r})}if(this.allRefLineGraphics.length>0){const r=this.allRefLineGraphics.splice(0,10);this.roadNameLayer.applyEdits({addFeatures:r})}}else clearInterval(a),s()},10)})}showJunction(e){const t=[];for(const i of e){i.nodeType=i.type;const o=new p({geometry:{type:"point",x:i.coordinates[0],y:i.coordinates[1]},attributes:{...i,selected:!1,type:"OpenDriveJunction"},symbol:{type:"picture-marker",url:i.crossId?"/GisViewerAssets/Images/point_green.png":"/GisViewerAssets/Images/point_yellow.png",width:30,height:30}});t.push(o)}this.junctionLayer.addMany(t)}monitorMouseMove(){const e=N.debounce(async t=>{var l;const o=(l=(await this.view.hitTest(t,{include:[this.laneLayer,this.junctionLayer]})).results)==null?void 0:l.filter(n=>n.type==="graphic");if(o.length===0){this.currentSectionCode!==""&&(this.currentSectionCode="",this.highlightGraphic=void 0,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 n=`${this.hitGraphic.attributes.roadId}+${this.hitGraphic.attributes.sectionId}`;if(n===this.currentSectionCode||this.sectionLayer.graphics.findIndex(u=>u.getAttribute("id")===n)>=0)return;this.currentSectionCode=n;const r=this.allLaneGraphics.filter(u=>`${u.attributes.roadId}+${u.attributes.sectionId}`===n),c=L.union(r.map(u=>u.geometry));this.highlightGraphic=new p({geometry:c,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}}),this.highlightLayer.removeAll(),this.highlightLayer.add(this.highlightGraphic)}else if(s.layer.id==="OpenDriveJunction"){const n=this.hitGraphic.getAttribute("id");if(n===this.currentJunctionId)return;this.currentJunctionId=n;const a=this.hitGraphic.getAttribute("name"),r=this.hitGraphic.getAttribute("crossId");this.view.popup.open({title:a,content:`<table>
1
+ "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const p=require("@arcgis/core/Graphic"),$=require("@arcgis/core/core/promiseUtils"),M=require("@arcgis/core/geometry"),J=require("@arcgis/core/geometry/geometryEngine"),G=require("@arcgis/core/layers/FeatureLayer"),v=require("@arcgis/core/layers/GraphicsLayer"),y=require("axios"),P=require("md5"),A=require("pako"),C=require("../common-utils.js"),x=require("./wasm-loader.js");function O(m){const e=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(m){for(const t in m)if(t!=="default"){const i=Object.getOwnPropertyDescriptor(m,t);Object.defineProperty(e,t,i.get?i:{enumerable:!0,get:()=>m[t]})}}return e.default=m,Object.freeze(e)}const N=O($),L=O(J);class D{constructor(e){this.wasmLoader=x.default.getInstance(),this.projectName="",this.openDriveServer="",this.currentSectionCode="",this.currentJunctionId="",this.view=e,this.view.popup.visibleElements={closeButton:!1,collapseButton:!1,actionBar:!1},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:"laneId",alias:"车道号",type:"string"},{name:"type",alias:"类型",type:"string"},{name:"sumoId",alias:"sumo编号",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 v({id:"OpenDriveJunction"}),this.sectionLayer=new v({id:"OpenDriveSection"}),this.highlightLayer=new v({id:"OpenDriveHighlight"}),this.flashLayer=new v({id:"OpenDriveFlash"}),this.view.map.addMany([this.laneLayer,this.junctionLayer,this.sectionLayer,this.roadNameLayer,this.highlightLayer,this.flashLayer])}static getInstance(e){return this.instance||(this.instance=new D(e)),this.instance}async makeMd5FromFile(e){try{const i=await(await fetch(e)).text();return{status:0,message:"ok",result:P(i)}}catch(t){return{status:-1,message:t.message}}}async showOpenDriveFromFile(e){var h,g;this.openDriveClickCallback=e.selectedCallback,console.time("md5用时");const t=await this.makeMd5FromFile(e.file);if(t.status!==0)return t;this.projectName=t.result,console.timeEnd("md5用时"),this.openDriveServer=e.server,await this.makeMd5FromFile(e.file);const i=`http://${this.openDriveServer}/api/openDrive/uploadXodr`;let o;try{o=await y.post(i,{},{params:{url:e.file,projectName:this.projectName}})}catch(d){return{status:-1,message:d.message}}if(o.status!==200)return{status:-1,message:o.statusText};console.time("渲染用时");const s=o.data.result.geoSetting;C.default.setGeoData(s.geoReference,s.offsetX,s.offsetY);let l=o.data.result.json;l.startsWith(window.location.protocol)||(l=`${window.location.protocol}//${e.server}${l}`);const a=await(await fetch(l)).arrayBuffer(),r=A.inflate(a,{to:"string"}),c=JSON.parse(r);await this.showAllLanes(c,((h=e.options)==null?void 0:h.showJunctionLane)||!1,((g=e.options)==null?void 0:g.showRoadName)||!0);const u=o.data.result.junctions;if(this.showJunction(u),e.options&&e.options.centerMap!==!1){const d=C.default.transformPointProjection([0,0]);await this.view.goTo(d)}return this.mouseMoveHandler||this.monitorMouseMove(),this.mouseClickHandler||this.monitorMouseClick(),console.timeEnd("渲染用时"),{status:0,message:"ok"}}async showOpenDriveFromServer(e,t){const i=`http://${e}/api/openDrive/analyzeXodr`,o=await y.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 n=await(await fetch(s)).arrayBuffer(),a=A.inflate(n,{to:"string"}),r=JSON.parse(a);return await this.showAllLanes(r,!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 l=0;this.allLaneGraphics=[],this.allRefLineGraphics=[];const n=[];for(const r of e){if(!t&&r.junction!=="-1")continue;const{id:c,refLine:u}=r;let h=r.name;h.includes("(")&&(h=h.slice(0,h.indexOf("("))),h=h.replace(/(.)/g,"$1 ");const g=new p({geometry:{type:"polyline",paths:[u]},attributes:{ObjectID:l++,roadId:c,roadName:h}});this.allRefLineGraphics.push(g),r.laneSections.sort((d,b)=>Number(d.id)-Number(b.id));for(let d=0;d<r.laneSections.length;d++){const b=r.laneSections[d],k=Number(b.id);for(const f of b.lanePaths){const w=Number(f.id);if(w===0)continue;const F=f.type,I=f.innerPath.concat(f.outerPath.reverse());if(I.length<=3){console.warn(`lane ${w} has less than 3 points`);continue}I.push(f.innerPath[0]);const j=new M.Polygon({rings:[I]});if(j){const S=new p({geometry:j,attributes:{ObjectID:l++,id:`${c}+${k}+${w}`,roadId:c,roadName:r.name,sectionId:k,sectionIndex:d,laneId:w,type:F,sumoId:""}});this.allLaneGraphics.push(S),n.push(S)}}}}const a=setInterval(()=>{if(n.length>0||this.allRefLineGraphics.length>0){if(n.length>0){const r=n.splice(0,100);this.laneLayer.applyEdits({addFeatures:r})}if(this.allRefLineGraphics.length>0){const r=this.allRefLineGraphics.splice(0,10);this.roadNameLayer.applyEdits({addFeatures:r})}}else clearInterval(a),s()},10)})}showJunction(e){const t=[];for(const i of e){if(!i)continue;i.nodeType=i.type;const o=new p({geometry:{type:"point",x:i.coordinates[0],y:i.coordinates[1]},attributes:{...i,selected:!1,type:"OpenDriveJunction"},symbol:{type:"picture-marker",url:i.crossId?"/GisViewerAssets/Images/point_green.png":"/GisViewerAssets/Images/point_yellow.png",width:30,height:30}});t.push(o)}this.junctionLayer.addMany(t)}monitorMouseMove(){const e=N.debounce(async t=>{var l;const o=(l=(await this.view.hitTest(t,{include:[this.laneLayer,this.junctionLayer]})).results)==null?void 0:l.filter(n=>n.type==="graphic");if(o.length===0){this.currentSectionCode!==""&&(this.currentSectionCode="",this.highlightGraphic=void 0,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 n=`${this.hitGraphic.attributes.roadId}+${this.hitGraphic.attributes.sectionId}`;if(n===this.currentSectionCode||this.sectionLayer.graphics.findIndex(u=>u.getAttribute("id")===n)>=0)return;this.currentSectionCode=n;const r=this.allLaneGraphics.filter(u=>`${u.attributes.roadId}+${u.attributes.sectionId}`===n),c=L.union(r.map(u=>u.geometry));this.highlightGraphic=new p({geometry:c,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}}),this.highlightLayer.removeAll(),this.highlightLayer.add(this.highlightGraphic)}else if(s.layer.id==="OpenDriveJunction"){const n=this.hitGraphic.getAttribute("id");if(n===this.currentJunctionId)return;this.currentJunctionId=n;const a=this.hitGraphic.getAttribute("name"),r=this.hitGraphic.getAttribute("crossId");this.view.popup.open({title:a,content:`<table>
2
2
  <tr><td>路口编号</td><td>${n}</td></tr>
3
3
  <tr><td>信号机编号</td><td>${r||"无信控"}</td></tr>
4
4
  </table>`,location:this.hitGraphic.geometry})}});this.mouseMoveHandler=this.view.on("pointer-move",async t=>{e(t).catch(()=>{})})}monitorMouseClick(){const e=N.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(r=>r.type==="graphic");if(o.length===0)return;const s=o[0].graphic,l=s.getAttribute("type"),n=s.getAttribute("id");if(l==="OpenDriveJunction")if(s.getAttribute("selected")===!1){const r=`http://${this.openDriveServer}/api/sumo/getSumoJunction`,c=await y.get(r,{params:{id:n,projectName:this.projectName}});c.status===200&&c.data.status===0&&(this.openDriveClickCallback&&this.openDriveClickCallback({type:"OpenDriveJunction",id:n,details:c.data.result}),s.setAttribute("selected",!0),s.symbol.url="/GisViewerAssets/Images/point_red.png",this.increasePictureMarkerSize(s,50))}else{this.openDriveClickCallback&&this.openDriveClickCallback({type:"OpenDriveJunction",id:n,details:void 0}),s.setAttribute("selected",!1);const r=s.getAttribute("crossId");s.symbol.url=r?"/GisViewerAssets/Images/point_green.png":"/GisViewerAssets/Images/point_yellow.png",this.decreasePictureMarkerSize(s,30)}else if(l==="OpenDriveSection")if(s.getAttribute("selected"))this.sectionLayer.remove(s),this.openDriveClickCallback&&this.openDriveClickCallback({type:"OpenDriveSection",id:n,details:void 0});else{this.highlightLayer.remove(s),this.sectionLayer.add(s),s.setAttribute("selected",!0);const r=`http://${this.openDriveServer}/api/sumo/getSumoEdge`,c=await y.get(r,{params:{id:n,projectName:this.projectName}});c.status===200&&c.data.status===0&&this.openDriveClickCallback&&(s.setAttribute("edgeId",c.data.result.obj_id),this.openDriveClickCallback({type:"OpenDriveSection",id:n,details:c.data.result}))}});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 y.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(l=>l.getAttribute("roadId")===i&&l.getAttribute("sectionIndex")===o);if(s){const l=`${i}+${s.getAttribute("sectionId")}`,n=`http://${this.openDriveServer}/api/sumo/getSumoEdge`,a=await y.get(n,{params:{id:l,projectName:this.projectName}});return a.status===200?a.data:{status:-1,message:`路段信息查询失败: ${l}`}}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,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 l=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],r=n.length===2?Number(n[1]):void 0;return await this.findLane({roadsectId:a,segmentId:r,laneId:l,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 p({geometry:i.geometry,symbol:{type:"simple-marker",style:"circle",size:30,color:[255,0,0,.6],outline:{color:"red",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(r=>{const c=Number(r.attributes.sectionId);a.indexOf(c)===-1&&a.push(c)}),a.sort((r,c)=>r-c),i>a.length-1)return{status:-1,message:"未找到。请检查基本段编号"};i=a[i],s=s.filter(r=>Number(r.attributes.sectionId)===i)}if(o!==void 0){const a=[];if(s.forEach(r=>{const c=Number(r.attributes.laneId);a.indexOf(c)===-1&&a.push(c)}),a.sort((r,c)=>r-c),o>a.length-1)return{status:-1,message:"未找到。请检查车道编号"};o=a[o],s=s.filter(r=>Number(r.attributes.laneId)===o)}const l=s.map(a=>a.geometry),n=L.union(l);if(e.flash){const a=new p({geometry:n,symbol:{type:"simple-fill",color:[255,0,0,.5],style:"solid",outline:{color:"red",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 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=>{if((!e||!e.id||e.id===""||e.id===t.getAttribute("id"))&&t.getAttribute("selected")){t.setAttribute("selected",!1);const i=t.getAttribute("crossId");t.symbol.url=i?"/GisViewerAssets/Images/point_green.png":"/GisViewerAssets/Images/point_yellow.png",this.decreasePictureMarkerSize(t,30)}}),!e||e.type==="edge")if(!e||!e.id||e.id==="")this.sectionLayer.removeAll();else{const t=this.sectionLayer.graphics.find(i=>i.getAttribute("edgeId")===e.id);t&&this.sectionLayer.remove(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=t[0];i.startsWith("-")&&(i=i.slice(1));let o=0;t.length===2&&(o=Number(t[1]));const s=this.allLaneGraphics.filter(l=>l.getAttribute("roadId")===i&&l.getAttribute("sectionIndex")===o);if(s.length>0){const l=L.union(s.map(a=>a.geometry)),n=new p({geometry:l,symbol:{type:"simple-fill",color:[0,255,255,.5],style:"solid",outline:{color:[0,255,255],width:1}},attributes:{type:"OpenDriveSection",edgeId:e.id,selected:!0}});return this.sectionLayer.add(n),{status:0,message:"ok"}}else return{status:-1,message:"未找到路段"}}default:return{status:-1,message:"未知类型"}}}async splitLane(e){return{status:0,message:"ok",result:e}}}exports.default=D;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "gisviewer-vue3-arcgis",
3
- "version": "1.0.131",
3
+ "version": "1.0.132",
4
4
  "main": "lib/index.js",
5
5
  "module": "es/index.mjs",
6
6
  "files": [