gisviewer-vue3-arcgis 1.0.264 → 1.0.265

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.
@@ -310,13 +310,13 @@ class O {
310
310
  return this.instance || (this.instance = new O(e)), this.instance;
311
311
  }
312
312
  async makeMd5FromFile(e) {
313
- var t;
313
+ var i;
314
314
  try {
315
315
  const s = await (await fetch(e)).text();
316
- let r = (t = new J({
316
+ let r = (i = new J({
317
317
  ignoreAttributes: !1,
318
318
  allowBooleanAttributes: !0
319
- }).parse(s).OpenDRIVE.userData) == null ? void 0 : t.border;
319
+ }).parse(s).OpenDRIVE.userData) == null ? void 0 : i.border;
320
320
  return r ? r = JSON.parse(r) : r = [], { status: 0, message: "ok", result: { md5: E(s), border: r } };
321
321
  } catch (o) {
322
322
  return { status: -1, message: o.message };
@@ -335,8 +335,8 @@ class O {
335
335
  u > this.junctionScale && p <= this.junctionScale ? this.updateAllJunctionSymbol("marker") : u <= this.junctionScale && p > this.junctionScale && this.updateAllJunctionSymbol("picture");
336
336
  }
337
337
  );
338
- let t = e.file.split("/").pop() || "";
339
- t = t.split(".").slice(0, -1).join("."), this.openDriveServer = e.server;
338
+ let i = e.file.split("/").pop() || "";
339
+ i = i.split(".").slice(0, -1).join("."), this.openDriveServer = e.server;
340
340
  const o = `http://${this.openDriveServer}/api/openDrive/uploadXodr`;
341
341
  let s;
342
342
  try {
@@ -346,7 +346,7 @@ class O {
346
346
  {
347
347
  params: {
348
348
  url: e.file,
349
- projectName: t
349
+ projectName: i
350
350
  }
351
351
  }
352
352
  );
@@ -356,11 +356,11 @@ class O {
356
356
  if (s.status !== 200)
357
357
  return { status: -1, message: s.statusText };
358
358
  console.time("渲染用时");
359
- const i = s.data.result.geoSetting;
359
+ const t = s.data.result.geoSetting;
360
360
  A.setGeoData(
361
- i.geoReference,
362
- i.offsetX,
363
- i.offsetY
361
+ t.geoReference,
362
+ t.offsetX,
363
+ t.offsetY
364
364
  );
365
365
  let l = s.data.result.json;
366
366
  l.startsWith(window.location.protocol) || (l = `${window.location.protocol}//${e.server}${l}`);
@@ -394,10 +394,10 @@ class O {
394
394
  * @param server
395
395
  * @param projectName
396
396
  */
397
- async showOpenDriveFromServer(e, t) {
397
+ async showOpenDriveFromServer(e, i) {
398
398
  const o = `http://${e}/api/openDrive/analyzeXodr`, s = await w.get(o, {
399
399
  headers: {
400
- projectName: t
400
+ projectName: i
401
401
  },
402
402
  params: {
403
403
  analyze: !1,
@@ -406,11 +406,11 @@ class O {
406
406
  });
407
407
  if (s.status !== 200)
408
408
  throw new Error(`OpenDriveRenderer: ${s.statusText}`);
409
- let i = s.data.result.json;
410
- i.startsWith(window.location.protocol) || (i = `${window.location.protocol}//${e}${i}`);
411
- const l = await fetch(i);
409
+ let t = s.data.result.json;
410
+ t.startsWith(window.location.protocol) || (t = `${window.location.protocol}//${e}${t}`);
411
+ const l = await fetch(t);
412
412
  let r;
413
- if (i.endsWith("bin")) {
413
+ if (t.endsWith("bin")) {
414
414
  const a = await l.arrayBuffer(), c = M.inflate(a, { to: "string" });
415
415
  r = JSON.parse(c);
416
416
  } else
@@ -424,17 +424,17 @@ class O {
424
424
  * @param showRoadName 是否显示道路名称
425
425
  * @returns
426
426
  */
427
- async showAllLanes(e, t, o) {
427
+ async showAllLanes(e, i, o) {
428
428
  const s = await this.laneLayer.queryFeatures();
429
429
  return s.features.length > 0 && this.laneLayer.applyEdits({
430
430
  deleteFeatures: s.features
431
- }), this.roadNameLayer.visible = o, new Promise((i) => {
431
+ }), this.roadNameLayer.visible = o, new Promise((t) => {
432
432
  var c;
433
433
  let l = 0;
434
434
  this.allLaneGraphics = [], this.allRefLineGraphics = [];
435
435
  const r = [];
436
436
  for (const n of e) {
437
- if (!t && n.junction !== "-1")
437
+ if (!i && n.junction !== "-1")
438
438
  continue;
439
439
  const { id: d, refLine: y } = n;
440
440
  let h = n.name;
@@ -510,7 +510,7 @@ class O {
510
510
  });
511
511
  }
512
512
  } else
513
- clearInterval(a), i();
513
+ clearInterval(a), t();
514
514
  }, 10);
515
515
  });
516
516
  }
@@ -520,21 +520,21 @@ class O {
520
520
  * @returns
521
521
  */
522
522
  showJunction(e) {
523
- const t = [];
523
+ const i = [];
524
524
  let o;
525
525
  this.xodrBorder.length > 0 && (o = new S({
526
526
  rings: [this.xodrBorder]
527
527
  }));
528
528
  for (const s of e)
529
529
  if (s && (this.junctionNames.set(s.id, s.name), s.nodeType = s.type, s.crossId)) {
530
- const i = new F({
530
+ const t = new F({
531
531
  x: s.coordinates[0],
532
532
  y: s.coordinates[1]
533
533
  });
534
534
  let l = !0;
535
- if (o && (l = L.contains(o, i)), l) {
535
+ if (o && (l = L.contains(o, t)), l) {
536
536
  const r = new I({
537
- geometry: i,
537
+ geometry: t,
538
538
  attributes: {
539
539
  ...s,
540
540
  selected: !1,
@@ -542,18 +542,18 @@ class O {
542
542
  },
543
543
  symbol: this.getCrossGraphicSymbol(s, "marker")
544
544
  });
545
- t.push(r);
545
+ i.push(r);
546
546
  }
547
547
  }
548
- this.junctionLayer.addMany(t);
548
+ this.junctionLayer.addMany(i);
549
549
  }
550
550
  /**
551
551
  * 监听鼠标移动事件,高亮显示鼠标所在路段和路口
552
552
  */
553
553
  monitorMouseMove() {
554
- const e = j.debounce(async (t) => {
554
+ const e = j.debounce(async (i) => {
555
555
  var l;
556
- const s = (l = (await this.view.hitTest(t, {
556
+ const s = (l = (await this.view.hitTest(i, {
557
557
  include: [this.laneLayer, this.junctionLayer]
558
558
  })).results) == null ? void 0 : l.filter(
559
559
  (r) => r.type === "graphic"
@@ -562,8 +562,8 @@ class O {
562
562
  this.currentSectionCode !== "" && (this.currentSectionCode = "", this.highlightLayer.removeAll()), this.currentJunctionId !== "" && (this.currentJunctionId = ""), this.view.closePopup();
563
563
  return;
564
564
  }
565
- const i = s[0];
566
- if (this.hitGraphic = i.graphic, i.layer.id === "OpenDriveLane") {
565
+ const t = s[0];
566
+ if (this.hitGraphic = t.graphic, t.layer.id === "OpenDriveLane") {
567
567
  const r = `${this.hitGraphic.getAttribute(
568
568
  "roadId"
569
569
  )}+${this.hitGraphic.getAttribute("sectionId")}`, a = this.hitGraphic.getAttribute("roadsectBaseIds");
@@ -594,7 +594,8 @@ class O {
594
594
  fromNodeName: u,
595
595
  toNodeName: p,
596
596
  laneCount: n.length,
597
- roadsectBaseIds: this.hitGraphic.getAttribute("roadsectBaseIds")
597
+ roadsectBaseIds: this.hitGraphic.getAttribute("roadsectBaseIds"),
598
+ roadId: this.hitGraphic.getAttribute("roadId")
598
599
  },
599
600
  popupTemplate: {
600
601
  title: this.hitGraphic.getAttribute("roadName"),
@@ -620,15 +621,15 @@ class O {
620
621
  }
621
622
  });
622
623
  this.highlightLayer.removeAll(), this.highlightLayer.add(g);
623
- } else if (i.layer.id === "OpenDriveJunction") {
624
+ } else if (t.layer.id === "OpenDriveJunction") {
624
625
  const r = this.hitGraphic.getAttribute("id");
625
626
  if (r === this.currentJunctionId)
626
627
  return;
627
628
  this.currentJunctionId = r;
628
629
  }
629
630
  });
630
- this.mouseMoveHandler = this.view.on("pointer-move", async (t) => {
631
- e(t).catch(() => {
631
+ this.mouseMoveHandler = this.view.on("pointer-move", async (i) => {
632
+ e(i).catch(() => {
632
633
  });
633
634
  });
634
635
  }
@@ -636,20 +637,18 @@ class O {
636
637
  * 监听鼠标点击事件,获取高亮要素的拓扑信息
637
638
  */
638
639
  monitorMouseClick() {
639
- const e = j.debounce(async (t) => {
640
+ const e = j.debounce(async (i) => {
640
641
  var a;
641
- const s = (a = (await this.view.hitTest(t, {
642
+ const s = (a = (await this.view.hitTest(i, {
642
643
  include: [this.highlightLayer, this.junctionLayer, this.sectionLayer]
643
644
  })).results) == null ? void 0 : a.filter(
644
645
  (c) => c.type === "graphic"
645
646
  );
646
647
  if (s.length === 0)
647
648
  return;
648
- const i = s[0].graphic;
649
- console.log(i.attributes);
650
- const l = i.getAttribute("type"), r = i.getAttribute("id");
649
+ const t = s[0].graphic, l = t.getAttribute("type"), r = t.getAttribute("id");
651
650
  if (l === "OpenDriveJunction")
652
- if (i.getAttribute("selected") === !1) {
651
+ if (t.getAttribute("selected") === !1) {
653
652
  const c = `http://${this.openDriveServer}/api/sumo/getSumoJunction`, n = await w.get(c, {
654
653
  params: {
655
654
  id: r,
@@ -660,24 +659,24 @@ class O {
660
659
  type: "OpenDriveJunction",
661
660
  id: r,
662
661
  details: n.data.result
663
- }), i.setAttribute("selected", !0), i.symbol = {
662
+ }), t.setAttribute("selected", !0), t.symbol = {
664
663
  type: "picture-marker",
665
664
  url: "/GisViewerAssets/Images/point_red.png",
666
665
  width: "20px",
667
666
  height: "20px"
668
- }, this.increasePictureMarkerSize(i, 50));
667
+ }, this.increasePictureMarkerSize(t, 50));
669
668
  } else
670
669
  this.openDriveClickCallback && this.openDriveClickCallback({
671
670
  type: "OpenDriveJunction",
672
671
  id: r,
673
672
  details: void 0
674
- }), i.setAttribute("selected", !1), i.symbol = this.getCrossGraphicSymbol(
675
- i.attributes,
673
+ }), t.setAttribute("selected", !1), t.symbol = this.getCrossGraphicSymbol(
674
+ t.attributes,
676
675
  this.view.scale < this.junctionScale ? "picture" : "marker"
677
676
  );
678
677
  else
679
- l === "OpenDriveSection" && (i.layer.id === "OpenDriveHighlight" ? (this.highlightLayer.removeAll(), this.sectionLayer.removeAll(), this.selectedSectionIds = [], this.sectionLayer.add(i), i.setAttribute("selected", !0), this.selectedSectionIds.push(r), this.splitLaneLayer.graphics.filter(
680
- (n) => n.getAttribute("roadsectBaseIds") === i.getAttribute("roadsectBaseIds")
678
+ l === "OpenDriveSection" && (t.layer.id === "OpenDriveHighlight" ? (this.highlightLayer.removeAll(), this.sectionLayer.removeAll(), this.selectedSectionIds = [], this.sectionLayer.add(t), t.setAttribute("selected", !0), this.selectedSectionIds.push(r), this.splitLaneLayer.graphics.filter(
679
+ (n) => n.getAttribute("roadsectBaseIds") === t.getAttribute("roadsectBaseIds")
681
680
  ).forEach(
682
681
  (n) => n.symbol = {
683
682
  type: "simple-fill",
@@ -689,10 +688,13 @@ class O {
689
688
  }
690
689
  ), this.openDriveClickCallback && this.openDriveClickCallback({
691
690
  type: "OpenDriveSection",
692
- id: i.getAttribute("roadsectBaseIds"),
693
- details: void 0
691
+ id: t.getAttribute("id"),
692
+ details: {
693
+ roadsectId: t.getAttribute("roadId"),
694
+ roadsectBaseIds: t.getAttribute("roadsectBaseIds")
695
+ }
694
696
  })) : (this.splitLaneLayer.graphics.filter(
695
- (n) => n.getAttribute("roadsectBaseIds") === i.getAttribute("roadsectBaseIds")
697
+ (n) => n.getAttribute("roadsectBaseIds") === t.getAttribute("roadsectBaseIds")
696
698
  ).forEach(
697
699
  (n) => n.symbol = {
698
700
  type: "simple-fill",
@@ -702,14 +704,17 @@ class O {
702
704
  width: 1
703
705
  }
704
706
  }
705
- ), this.sectionLayer.remove(i), this.selectedSectionIds = [], this.openDriveClickCallback && this.openDriveClickCallback({
707
+ ), this.sectionLayer.remove(t), this.selectedSectionIds = [], this.openDriveClickCallback && this.openDriveClickCallback({
706
708
  type: "CloseOpenDriveSection",
707
- id: i.getAttribute("roadsectBaseIds"),
708
- details: void 0
709
+ id: t.getAttribute("roadsectBaseIds"),
710
+ details: {
711
+ roadsectId: t.getAttribute("roadId"),
712
+ roadsectBaseIds: t.getAttribute("roadsectBaseIds")
713
+ }
709
714
  })));
710
715
  });
711
- this.mouseClickHandler = this.view.on("immediate-click", async (t) => {
712
- e(t).catch(() => {
716
+ this.mouseClickHandler = this.view.on("immediate-click", async (i) => {
717
+ e(i).catch(() => {
713
718
  });
714
719
  });
715
720
  }
@@ -718,14 +723,14 @@ class O {
718
723
  * @param graphic
719
724
  * @param targetSize
720
725
  */
721
- increasePictureMarkerSize(e, t) {
726
+ increasePictureMarkerSize(e, i) {
722
727
  const o = setInterval(() => {
723
- const s = e.symbol, i = s.width;
724
- i < t ? e.symbol = {
728
+ const s = e.symbol, t = s.width;
729
+ t < i ? e.symbol = {
725
730
  type: "picture-marker",
726
731
  url: s.url,
727
- width: i + 1,
728
- height: i + 1
732
+ width: t + 1,
733
+ height: t + 1
729
734
  } : clearInterval(o);
730
735
  }, 20);
731
736
  }
@@ -734,21 +739,21 @@ class O {
734
739
  * @param graphic
735
740
  * @param targetSize
736
741
  */
737
- decreasePictureMarkerSize(e, t) {
742
+ decreasePictureMarkerSize(e, i) {
738
743
  const o = setInterval(() => {
739
- const s = e.symbol, i = s.width;
740
- i > t ? e.symbol = {
744
+ const s = e.symbol, t = s.width;
745
+ t > i ? e.symbol = {
741
746
  type: "picture-marker",
742
747
  url: s.url,
743
- width: i - 1,
744
- height: i - 1
748
+ width: t - 1,
749
+ height: t - 1
745
750
  } : clearInterval(o);
746
751
  }, 20);
747
752
  }
748
753
  async getSumoInfo(e) {
749
754
  switch (e.type) {
750
755
  case "junction": {
751
- const t = `http://${this.openDriveServer}/api/sumo/getSumoJunction`, o = await w.get(t, {
756
+ const i = `http://${this.openDriveServer}/api/sumo/getSumoJunction`, o = await w.get(i, {
752
757
  params: {
753
758
  id: e.id,
754
759
  projectName: this.projectName
@@ -757,16 +762,16 @@ class O {
757
762
  return o.status === 200 ? o.data : { status: -1, message: `路口信息查询失败: ${e.id}` };
758
763
  }
759
764
  case "edge": {
760
- const t = e.id.split("#");
761
- let o = t[0];
765
+ const i = e.id.split("#");
766
+ let o = i[0];
762
767
  o.startsWith("-") && (o = o.slice(1));
763
768
  let s = 0;
764
- t.length === 2 && (s = Number(t[1]));
765
- const i = this.allLaneGraphics.find(
769
+ i.length === 2 && (s = Number(i[1]));
770
+ const t = this.allLaneGraphics.find(
766
771
  (l) => l.getAttribute("roadId") === o && l.getAttribute("sectionIndex") === s
767
772
  );
768
- if (i) {
769
- const l = `${o}+${i.getAttribute(
773
+ if (t) {
774
+ const l = `${o}+${t.getAttribute(
770
775
  "sectionId"
771
776
  )}`, r = `http://${this.openDriveServer}/api/sumo/getSumoEdge`, a = await w.get(r, {
772
777
  params: {
@@ -789,13 +794,13 @@ class O {
789
794
  * 清除OpenDrive内容
790
795
  */
791
796
  async clearOpenDrive() {
792
- var t, o, s;
797
+ var i, o, s;
793
798
  let e = await this.laneLayer.queryFeatures();
794
799
  e.features.length > 0 && await this.laneLayer.applyEdits({
795
800
  deleteFeatures: e.features
796
801
  }), e = await this.roadNameLayer.queryFeatures(), e.features.length > 0 && await this.roadNameLayer.applyEdits({
797
802
  deleteFeatures: e.features
798
- }), 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, (o = this.mouseClickHandler) == null || o.remove(), this.mouseClickHandler = void 0, (s = this.scaleWatch) == null || s.remove(), this.scaleWatch = void 0;
803
+ }), this.highlightLayer.removeAll(), this.junctionLayer.removeAll(), this.sectionLayer.removeAll(), this.flashLayer.removeAll(), this.borderLayer.removeAll(), (i = this.mouseMoveHandler) == null || i.remove(), this.mouseMoveHandler = void 0, (o = this.mouseClickHandler) == null || o.remove(), this.mouseClickHandler = void 0, (s = this.scaleWatch) == null || s.remove(), this.scaleWatch = void 0;
799
804
  }
800
805
  /**
801
806
  * 用sumo的id定位车道、基本段、路段
@@ -803,14 +808,14 @@ class O {
803
808
  * @returns
804
809
  */
805
810
  async findSumo(e) {
806
- const { type: t, id: o } = e, s = e.flash === void 0 ? !0 : e.flash;
807
- if (t === "junction")
811
+ const { type: i, id: o } = e, s = e.flash === void 0 ? !0 : e.flash;
812
+ if (i === "junction")
808
813
  return await this.findJunction(o, s);
809
- if (t === "edge") {
810
- const i = o.split("_");
811
- if (i.length > 2)
814
+ if (i === "edge") {
815
+ const t = o.split("_");
816
+ if (t.length > 2)
812
817
  return { status: -1, message: "id格式错误" };
813
- const l = i.length === 2 ? Number(i[1]) : void 0, r = i[0].split("#");
818
+ const l = t.length === 2 ? Number(t[1]) : void 0, r = t[0].split("#");
814
819
  if (r.length > 2)
815
820
  return { status: -1, message: "id格式错误" };
816
821
  const a = r[0], c = r.length === 2 ? Number(r[1]) : void 0;
@@ -818,13 +823,13 @@ class O {
818
823
  } else
819
824
  return { status: -1, message: "未知类型" };
820
825
  }
821
- async findJunction(e, t) {
826
+ async findJunction(e, i) {
822
827
  const o = this.junctionLayer.graphics.find(
823
828
  (s) => s.attributes.id === e
824
829
  );
825
830
  if (!o)
826
831
  return { status: -1, message: "未找到。请检查路口编号" };
827
- if (t) {
832
+ if (i) {
828
833
  const s = new I({
829
834
  geometry: o.geometry,
830
835
  symbol: {
@@ -848,36 +853,36 @@ class O {
848
853
  * @returns
849
854
  */
850
855
  async findLane(e) {
851
- let { roadsectId: t, segmentId: o, laneId: s } = e;
852
- t.startsWith("-") && (t = t.slice(1));
853
- let i = this.allLaneGraphics.filter(
854
- (a) => a.attributes.roadId === t
856
+ let { roadsectId: i, segmentId: o, laneId: s } = e;
857
+ i.startsWith("-") && (i = i.slice(1));
858
+ let t = this.allLaneGraphics.filter(
859
+ (a) => a.attributes.roadId === i
855
860
  );
856
- if (i.length === 0)
861
+ if (t.length === 0)
857
862
  return { status: -1, message: "未找到。请检查路段编号" };
858
863
  if (o !== void 0) {
859
864
  const a = [];
860
- if (i.forEach((c) => {
865
+ if (t.forEach((c) => {
861
866
  const n = Number(c.attributes.sectionId);
862
867
  a.indexOf(n) === -1 && a.push(n);
863
868
  }), a.sort((c, n) => c - n), o > a.length - 1)
864
869
  return { status: -1, message: "未找到。请检查基本段编号" };
865
- o = a[o], i = i.filter(
870
+ o = a[o], t = t.filter(
866
871
  (c) => Number(c.attributes.sectionId) === o
867
872
  );
868
873
  }
869
874
  if (s !== void 0) {
870
875
  const a = [];
871
- if (i.forEach((c) => {
876
+ if (t.forEach((c) => {
872
877
  const n = Number(c.attributes.laneId);
873
878
  a.indexOf(n) === -1 && a.push(n);
874
879
  }), a.sort((c, n) => c - n), s > a.length - 1)
875
880
  return { status: -1, message: "未找到。请检查车道编号" };
876
- s = a[s], i = i.filter(
881
+ s = a[s], t = t.filter(
877
882
  (c) => Number(c.attributes.laneId) === s
878
883
  );
879
884
  }
880
- const l = i.map(
885
+ const l = t.map(
881
886
  (a) => a.geometry
882
887
  ), r = L.union(l);
883
888
  if (e.flash) {
@@ -902,9 +907,9 @@ class O {
902
907
  */
903
908
  flashGraphic(e) {
904
909
  this.flashLayer.removeAll(), this.flashLayer.add(e);
905
- let t = 0, o = !0;
910
+ let i = 0, o = !0;
906
911
  const s = setInterval(() => {
907
- o ? (this.flashLayer.opacity -= 0.02, this.flashLayer.opacity <= 0.1 && (o = !1, t++)) : (this.flashLayer.opacity += 0.02, this.flashLayer.opacity >= 1 && (o = !0)), t >= 5 && (this.flashLayer.removeAll(), this.flashLayer.opacity = 1, clearInterval(s));
912
+ o ? (this.flashLayer.opacity -= 0.02, this.flashLayer.opacity <= 0.1 && (o = !1, i++)) : (this.flashLayer.opacity += 0.02, this.flashLayer.opacity >= 1 && (o = !0)), i >= 5 && (this.flashLayer.removeAll(), this.flashLayer.opacity = 1, clearInterval(s));
908
913
  }, 10);
909
914
  }
910
915
  /**
@@ -913,19 +918,19 @@ class O {
913
918
  * @returns
914
919
  */
915
920
  unselectSumo(e) {
916
- if (e ? e.type === "junction" && this.junctionLayer.graphics.forEach((t) => {
917
- (!e || !e.id || e.id === "" || e.id === t.getAttribute("id")) && t.getAttribute("selected") && (t.setAttribute("selected", !1), t.symbol = this.getCrossGraphicSymbol(
918
- t.attributes,
921
+ if (e ? e.type === "junction" && this.junctionLayer.graphics.forEach((i) => {
922
+ (!e || !e.id || e.id === "" || e.id === i.getAttribute("id")) && i.getAttribute("selected") && (i.setAttribute("selected", !1), i.symbol = this.getCrossGraphicSymbol(
923
+ i.attributes,
919
924
  this.view.scale < this.junctionScale ? "picture" : "marker"
920
925
  ));
921
926
  }) : (this.highlightLayer.removeAll(), this.sectionLayer.removeAll(), this.selectedSectionIds = [], this.splitLaneLayer.removeAll()), !e || e.type === "edge") {
922
- let t;
923
- !e || !e.id || e.id === "" ? t = this.sectionLayer.graphics.toArray() : t = this.sectionLayer.graphics.filter((o) => o.getAttribute("edgeId") === e.id).toArray(), t.length > 0 && (t.forEach((o) => {
927
+ let i;
928
+ !e || !e.id || e.id === "" ? i = this.sectionLayer.graphics.toArray() : i = this.sectionLayer.graphics.filter((o) => o.getAttribute("edgeId") === e.id).toArray(), i.length > 0 && (i.forEach((o) => {
924
929
  const s = o.getAttribute("id");
925
930
  this.selectedSectionIds = this.selectedSectionIds.filter(
926
- (i) => i !== s
931
+ (t) => t !== s
927
932
  );
928
- }), this.sectionLayer.removeMany(t));
933
+ }), this.sectionLayer.removeMany(i));
929
934
  }
930
935
  return { status: 0, message: "ok" };
931
936
  }
@@ -937,24 +942,24 @@ class O {
937
942
  async selectSumo(e) {
938
943
  switch (e.type) {
939
944
  case "junction":
940
- return this.junctionLayer.graphics.forEach((t) => {
941
- if (e.id === t.getAttribute("id"))
942
- return t.setAttribute("selected", !0), t.symbol.url = "/GisViewerAssets/Images/point_red.png", this.increasePictureMarkerSize(t, 50), { status: 0, message: "ok" };
945
+ return this.junctionLayer.graphics.forEach((i) => {
946
+ if (e.id === i.getAttribute("id"))
947
+ return i.setAttribute("selected", !0), i.symbol.url = "/GisViewerAssets/Images/point_red.png", this.increasePictureMarkerSize(i, 50), { status: 0, message: "ok" };
943
948
  }), { status: -1, message: "未找到路口" };
944
949
  case "edge": {
945
- const t = e.id.split("#");
946
- let o = String(t[0]);
950
+ const i = e.id.split("#");
951
+ let o = String(i[0]);
947
952
  o.startsWith("-") && (o = o.slice(1));
948
953
  let s = 0;
949
- t.length === 2 && (s = Number(t[1]));
950
- let i = [];
951
- if (t.length === 1 ? i = this.allLaneGraphics.filter(
954
+ i.length === 2 && (s = Number(i[1]));
955
+ let t = [];
956
+ if (i.length === 1 ? t = this.allLaneGraphics.filter(
952
957
  (l) => l.getAttribute("roadId") === o
953
- ) : t.length === 2 && (i = this.allLaneGraphics.filter(
958
+ ) : i.length === 2 && (t = this.allLaneGraphics.filter(
954
959
  (l) => l.getAttribute("roadId") === o && l.getAttribute("sectionIndex") === s
955
- )), i.length > 0) {
960
+ )), t.length > 0) {
956
961
  const l = /* @__PURE__ */ new Map();
957
- return i.forEach((r) => {
962
+ return t.forEach((r) => {
958
963
  const a = r.getAttribute("roadId") + "+" + r.getAttribute("sectionId");
959
964
  this.selectedSectionIds.includes(a) || this.selectedSectionIds.push(a);
960
965
  let c = l.get(a);
@@ -988,12 +993,12 @@ class O {
988
993
  }
989
994
  }
990
995
  async geometrySearch(e) {
991
- const t = new S({
996
+ const i = new S({
992
997
  rings: [e]
993
998
  }), o = await this.laneLayer.queryFeatures({
994
- geometry: t,
999
+ geometry: i,
995
1000
  outFields: ["*"]
996
- }), s = [], i = [];
1001
+ }), s = [], t = [];
997
1002
  for (const a of o.features) {
998
1003
  const c = a.getAttribute("roadId"), n = a.getAttribute("sectionIndex"), d = `${c}#${n}`;
999
1004
  if (s.indexOf(d) === -1) {
@@ -1007,12 +1012,12 @@ class O {
1007
1012
  projectName: this.projectName
1008
1013
  }
1009
1014
  });
1010
- h.status === 200 && h.data.status === 0 && i.push(h.data.result);
1015
+ h.status === 200 && h.data.status === 0 && t.push(h.data.result);
1011
1016
  }
1012
1017
  }
1013
1018
  const l = this.junctionLayer.graphics.filter((a) => {
1014
1019
  const c = a.geometry;
1015
- return L.contains(t, c);
1020
+ return L.contains(i, c);
1016
1021
  }), r = [];
1017
1022
  for (const a of l) {
1018
1023
  const c = a.getAttribute("id");
@@ -1033,7 +1038,7 @@ class O {
1033
1038
  message: "ok",
1034
1039
  result: {
1035
1040
  junctions: r,
1036
- edges: i
1041
+ edges: t
1037
1042
  }
1038
1043
  };
1039
1044
  }
@@ -1046,8 +1051,8 @@ class O {
1046
1051
  const o = e.id.split("_");
1047
1052
  if (o.length !== 2)
1048
1053
  return { status: -1, message: "车道编号格式错误" };
1049
- const s = Number(o[1]), i = o[0].split("#"), l = i.length === 2 ? Number(i[1]) : 0;
1050
- let r = i[0];
1054
+ const s = Number(o[1]), t = o[0].split("#"), l = t.length === 2 ? Number(t[1]) : 0;
1055
+ let r = t[0];
1051
1056
  r.startsWith("-") && (r = r.slice(1));
1052
1057
  const a = this.allLaneGraphics.filter((b) => b.getAttribute("roadId") === r && b.getAttribute("sectionIndex") === l);
1053
1058
  if (a.length === 0)
@@ -1099,27 +1104,27 @@ class O {
1099
1104
  * @param params
1100
1105
  */
1101
1106
  blockLane(e) {
1102
- const t = this.allLaneGraphics.filter((s) => {
1107
+ const i = this.allLaneGraphics.filter((s) => {
1103
1108
  var l;
1104
- let i = String(s.getAttribute("laneId"));
1105
- return i.startsWith("-") && (i = i.slice(1)), s.getAttribute("roadId") === e.roadsectId && ((l = s.getAttribute("roadsectBaseIds")) == null ? void 0 : l.includes(e.roadsectBaseId)) && i === String(e.laneId);
1106
- }), o = t.map((s) => {
1107
- const i = s.clone();
1109
+ let t = String(s.getAttribute("laneId"));
1110
+ return t.startsWith("-") && (t = t.slice(1)), s.getAttribute("roadId") === e.roadsectId && ((l = s.getAttribute("roadsectBaseIds")) == null ? void 0 : l.includes(e.roadsectBaseId)) && t === String(e.laneId);
1111
+ }), o = i.map((s) => {
1112
+ const t = s.clone();
1108
1113
  return console.log(
1109
- t[0].getAttribute("roadsectBaseIds"),
1114
+ i[0].getAttribute("roadsectBaseIds"),
1110
1115
  this.selectedSectionIds,
1111
1116
  this.selectedSectionIds.includes(
1112
- t[0].getAttribute("roadsectBaseIds")
1117
+ i[0].getAttribute("roadsectBaseIds")
1113
1118
  )
1114
- ), i.symbol = {
1119
+ ), t.symbol = {
1115
1120
  type: "simple-fill",
1116
1121
  color: this.selectedSectionIds.includes(
1117
- t[0].getAttribute("roadsectBaseIds")
1122
+ i[0].getAttribute("roadsectBaseIds")
1118
1123
  ) ? [255, 69, 0, 0.8] : [255, 0, 0, 0.8],
1119
1124
  outline: {
1120
1125
  color: "red"
1121
1126
  }
1122
- }, i;
1127
+ }, t;
1123
1128
  });
1124
1129
  this.splitLaneLayer.addMany(o), A.viewGoto(this.view, o);
1125
1130
  }
@@ -1131,14 +1136,14 @@ class O {
1131
1136
  this.allLaneGraphics.forEach((o) => {
1132
1137
  o.getAttribute("roadsectBaseIds") || console.log(o.attributes);
1133
1138
  });
1134
- const t = this.allLaneGraphics.filter((o) => {
1139
+ const i = this.allLaneGraphics.filter((o) => {
1135
1140
  var s;
1136
1141
  return (s = o.getAttribute("roadsectBaseIds")) == null ? void 0 : s.includes(e.id);
1137
1142
  });
1138
- if (t.length > 0) {
1143
+ if (i.length > 0) {
1139
1144
  const o = L.union(
1140
- t.map((r) => r.geometry)
1141
- ), s = t[0].getAttribute("roadsectBaseIds"), i = new I({
1145
+ i.map((r) => r.geometry)
1146
+ ), s = i[0].getAttribute("roadsectBaseIds"), t = new I({
1142
1147
  geometry: o,
1143
1148
  symbol: {
1144
1149
  type: "simple-fill",
@@ -1154,7 +1159,7 @@ class O {
1154
1159
  roadsectBaseIds: s
1155
1160
  }
1156
1161
  });
1157
- this.sectionLayer.removeAll(), this.sectionLayer.add(i), A.viewGoto(this.view, [i]), this.selectedSectionIds = [s];
1162
+ this.sectionLayer.removeAll(), this.sectionLayer.add(t), A.viewGoto(this.view, [t]), this.selectedSectionIds = [s];
1158
1163
  const l = this.splitLaneLayer.graphics.filter(
1159
1164
  (r) => {
1160
1165
  var a;
@@ -1179,13 +1184,13 @@ class O {
1179
1184
  * @param symbolStyle
1180
1185
  */
1181
1186
  updateAllJunctionSymbol(e) {
1182
- const t = this.junctionLayer.graphics.clone();
1183
- this.junctionLayer.removeAll(), t.forEach((o) => {
1187
+ const i = this.junctionLayer.graphics.clone();
1188
+ this.junctionLayer.removeAll(), i.forEach((o) => {
1184
1189
  o.getAttribute("selected") || (o.symbol = this.getCrossGraphicSymbol(
1185
1190
  o.attributes,
1186
1191
  e
1187
1192
  ));
1188
- }), this.junctionLayer.addMany(t.toArray());
1193
+ }), this.junctionLayer.addMany(i.toArray());
1189
1194
  }
1190
1195
  /**
1191
1196
  * 生成路口点符号。在不同比例尺下,使用不同的符号
@@ -1193,16 +1198,16 @@ class O {
1193
1198
  * @param symbolType
1194
1199
  * @returns
1195
1200
  */
1196
- getCrossGraphicSymbol(e, t) {
1201
+ getCrossGraphicSymbol(e, i) {
1197
1202
  const o = e.crossId !== "" && e.crossId !== void 0 && e.crossId !== null;
1198
- if (t === "marker")
1203
+ if (i === "marker")
1199
1204
  return {
1200
1205
  type: "picture-marker",
1201
1206
  url: `/GisViewerAssets/Images/cross/${o ? "gis_xhj_blue" : "gis_lkcz_xz"}.png`,
1202
1207
  width: "32px",
1203
1208
  height: "32px"
1204
1209
  };
1205
- if (t === "picture")
1210
+ if (i === "picture")
1206
1211
  return o ? {
1207
1212
  type: "cim",
1208
1213
  data: {
@@ -1 +1 @@
1
- "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const I=require("@arcgis/core/Graphic"),J=require("@arcgis/core/core/promiseUtils"),E=require("@arcgis/core/core/reactiveUtils.js"),A=require("@arcgis/core/geometry"),q=require("@arcgis/core/geometry/geometryEngine"),x=require("@arcgis/core/layers/FeatureLayer"),v=require("@arcgis/core/layers/GraphicsLayer"),T=require("@turf/helpers"),O=require("@turf/line-slice-along"),w=require("axios"),_=require("fast-xml-parser"),R=require("md5"),M=require("pako"),z=require("vue"),H=require("../../stores/index.js"),k=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 s=Object.getOwnPropertyDescriptor(S,t);Object.defineProperty(e,t,s.get?s:{enumerable:!0,get:()=>S[t]})}}return e.default=S,Object.freeze(e)}const P=N(J),U=N(E),L=N(q),B=N(T);class C{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"},{name:"roadsectBaseIds",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 v({id:"OpenDriveJunction"}),this.sectionLayer=new v({id:"OpenDriveSection"}),this.highlightLayer=new v({id:"OpenDriveHighlight"}),this.flashLayer=new v({id:"OpenDriveFlash"}),this.drawLayer=new v({id:"Draw"}),this.splitLaneLayer=new v({id:"SplitLane"}),this.borderLayer=new v({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 o=await(await fetch(e)).text();let r=(t=new _.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:R(o),border:r}}}catch(s){return{status:-1,message:s.message}}}async showOpenDriveFromFile(e){var d,m,u;this.openDriveClickCallback=e.selectedCallback,this.scaleWatch=U.watch(()=>this.view.scale,(h,p)=>{h>this.junctionScale&&p<=this.junctionScale?this.updateAllJunctionSymbol("marker"):h<=this.junctionScale&&p>this.junctionScale&&this.updateAllJunctionSymbol("picture")});let t=e.file.split("/").pop()||"";t=t.split(".").slice(0,-1).join("."),this.openDriveServer=e.server;const s=`http://${this.openDriveServer}/api/openDrive/uploadXodr`;let o;try{o=await w.post(s,{},{params:{url:e.file,projectName:t}})}catch(h){return{status:-1,message:h.message}}if(o.status!==200)return{status:-1,message:o.statusText};console.time("渲染用时");const i=o.data.result.geoSetting;k.default.setGeoData(i.geoReference,i.offsetX,i.offsetY);let l=o.data.result.json;l.startsWith(window.location.protocol)||(l=`${window.location.protocol}//${e.server}${l}`);const r=await fetch(l);let a;if(l.endsWith("bin")){const h=await r.arrayBuffer(),p=M.inflate(h,{to:"string"});a=JSON.parse(p)}else a=await r.json();if(await this.showAllLanes(a,((d=e.options)==null?void 0:d.showJunctionLane)||!1,((m=e.options)==null?void 0:m.showRoadName)||!0),((u=e.options)==null?void 0:u.showJunctionPoint)!==!1){const h=o.data.result.junctions;this.showJunction(h)}e.options&&e.options.centerMap!==!1&&await this.view.goTo(this.allLaneGraphics),this.mouseMoveHandler||this.monitorMouseMove(),this.mouseClickHandler||this.monitorMouseClick();const n=H.default.useAppDataStore;return z.watch(()=>n.isSketching,()=>{var h,p;n.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())}),console.timeEnd("渲染用时"),{status:0,message:"ok"}}async showOpenDriveFromServer(e,t){const s=`http://${e}/api/openDrive/analyzeXodr`,o=await w.get(s,{headers:{projectName:t},params:{analyze:!1,compressed:!0}});if(o.status!==200)throw new Error(`OpenDriveRenderer: ${o.statusText}`);let i=o.data.result.json;i.startsWith(window.location.protocol)||(i=`${window.location.protocol}//${e}${i}`);const l=await fetch(i);let r;if(i.endsWith("bin")){const a=await l.arrayBuffer(),c=M.inflate(a,{to:"string"});r=JSON.parse(c)}else r=await l.json();return await this.showAllLanes(r,!1,!1),{status:0,message:"ok"}}async showAllLanes(e,t,s){const o=await this.laneLayer.queryFeatures();return o.features.length>0&&this.laneLayer.applyEdits({deleteFeatures:o.features}),this.roadNameLayer.visible=s,new Promise(i=>{var c;let l=0;this.allLaneGraphics=[],this.allRefLineGraphics=[];const r=[];for(const n of e){if(!t&&n.junction!=="-1")continue;const{id:d,refLine:m}=n;let u=n.name;u.includes("(")&&(u=u.slice(0,u.indexOf("("))),u=u.replace(/(.)/g,"$1 ");const h=new I({geometry:{type:"polyline",paths:[m]},attributes:{ObjectID:l++,roadId:d,roadName:u}});this.allRefLineGraphics.push(h),n.laneSections.sort((p,g)=>Number(p.id)-Number(g.id));for(let p=0;p<n.laneSections.length;p++){const g=n.laneSections[p],y=Number(g.id);for(const f of g.lanePaths){const b=Number(f.id);if(b===0)continue;const $=f.type,F=[...f.outerPath],j=f.innerPath.concat(F.reverse());if(j.length<=3){console.warn(`lane ${b} has less than 3 points`);continue}j.push(f.innerPath[0]);const D=new A.Polygon({rings:[j]});if(D){const G=new I({geometry:D,attributes:{ObjectID:l++,id:`${d}+${y}+${b}`,fromNode:n.fromNode,toNode:n.toNode,roadId:String(d),roadName:n.name,sectionId:String(y),sectionIndex:p,laneId:b,type:$,sumoId:"",leftLine:f.innerPath,rightLine:f.outerPath,roadsectBaseIds:(c=g.roadsectBaseIds)==null?void 0:c.toString()}});this.allLaneGraphics.push(G),r.push(G)}}}}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),i()},10)})}showJunction(e){const t=[];let s;this.xodrBorder.length>0&&(s=new A.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 i=new A.Point({x:o.coordinates[0],y:o.coordinates[1]});let l=!0;if(s&&(l=L.contains(s,i)),l){const r=new I({geometry:i,attributes:{...o,selected:!1,type:"OpenDriveJunction"},symbol:this.getCrossGraphicSymbol(o,"marker")});t.push(r)}}this.junctionLayer.addMany(t)}monitorMouseMove(){const e=P.debounce(async t=>{var l;const o=(l=(await this.view.hitTest(t,{include:[this.laneLayer,this.junctionLayer]})).results)==null?void 0:l.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 i=o[0];if(this.hitGraphic=i.graphic,i.layer.id==="OpenDriveLane"){const r=`${this.hitGraphic.getAttribute("roadId")}+${this.hitGraphic.getAttribute("sectionId")}`,a=this.hitGraphic.getAttribute("roadsectBaseIds");if(this.currentSectionCode===r||this.selectedSectionIds.includes(a)||this.sectionLayer.graphics.findIndex(y=>y.getAttribute("id")===r)>=0)return;this.currentSectionCode=r;const n=this.allLaneGraphics.filter(y=>`${y.attributes.roadId}+${y.attributes.sectionId}`===r),d=L.union(n.map(y=>y.geometry)),m=this.hitGraphic.getAttribute("fromNode"),u=this.hitGraphic.getAttribute("toNode"),h=this.junctionNames.get(m)||m,p=this.junctionNames.get(u)||u,g=new I({geometry:d,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:h,toNodeName:p,laneCount:n.length,roadsectBaseIds:this.hitGraphic.getAttribute("roadsectBaseIds")},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(g)}else if(i.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=P.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(c=>c.type==="graphic");if(o.length===0)return;const i=o[0].graphic;console.log(i.attributes);const l=i.getAttribute("type"),r=i.getAttribute("id");if(l==="OpenDriveJunction")if(i.getAttribute("selected")===!1){const c=`http://${this.openDriveServer}/api/sumo/getSumoJunction`,n=await w.get(c,{params:{id:r,projectName:this.projectName}});n.status===200&&n.data.status===0&&(this.openDriveClickCallback&&this.openDriveClickCallback({type:"OpenDriveJunction",id:r,details:n.data.result}),i.setAttribute("selected",!0),i.symbol={type:"picture-marker",url:"/GisViewerAssets/Images/point_red.png",width:"20px",height:"20px"},this.increasePictureMarkerSize(i,50))}else this.openDriveClickCallback&&this.openDriveClickCallback({type:"OpenDriveJunction",id:r,details:void 0}),i.setAttribute("selected",!1),i.symbol=this.getCrossGraphicSymbol(i.attributes,this.view.scale<this.junctionScale?"picture":"marker");else l==="OpenDriveSection"&&(i.layer.id==="OpenDriveHighlight"?(this.highlightLayer.removeAll(),this.sectionLayer.removeAll(),this.selectedSectionIds=[],this.sectionLayer.add(i),i.setAttribute("selected",!0),this.selectedSectionIds.push(r),this.splitLaneLayer.graphics.filter(n=>n.getAttribute("roadsectBaseIds")===i.getAttribute("roadsectBaseIds")).forEach(n=>n.symbol={type:"simple-fill",color:[255,69,0],outline:{color:"red",width:2}}),this.openDriveClickCallback&&this.openDriveClickCallback({type:"OpenDriveSection",id:i.getAttribute("roadsectBaseIds"),details:void 0})):(this.splitLaneLayer.graphics.filter(n=>n.getAttribute("roadsectBaseIds")===i.getAttribute("roadsectBaseIds")).forEach(n=>n.symbol={type:"simple-fill",color:[255,0,0,.8],outline:{color:"red",width:1}}),this.sectionLayer.remove(i),this.selectedSectionIds=[],this.openDriveClickCallback&&this.openDriveClickCallback({type:"CloseOpenDriveSection",id:i.getAttribute("roadsectBaseIds"),details:void 0})))});this.mouseClickHandler=this.view.on("immediate-click",async t=>{e(t).catch(()=>{})})}increasePictureMarkerSize(e,t){const s=setInterval(()=>{const o=e.symbol,i=o.width;i<t?e.symbol={type:"picture-marker",url:o.url,width:i+1,height:i+1}:clearInterval(s)},20)}decreasePictureMarkerSize(e,t){const s=setInterval(()=>{const o=e.symbol,i=o.width;i>t?e.symbol={type:"picture-marker",url:o.url,width:i-1,height:i-1}:clearInterval(s)},20)}async getSumoInfo(e){switch(e.type){case"junction":{const t=`http://${this.openDriveServer}/api/sumo/getSumoJunction`,s=await w.get(t,{params:{id:e.id,projectName:this.projectName}});return s.status===200?s.data:{status:-1,message:`路口信息查询失败: ${e.id}`}}case"edge":{const t=e.id.split("#");let s=t[0];s.startsWith("-")&&(s=s.slice(1));let o=0;t.length===2&&(o=Number(t[1]));const i=this.allLaneGraphics.find(l=>l.getAttribute("roadId")===s&&l.getAttribute("sectionIndex")===o);if(i){const l=`${s}+${i.getAttribute("sectionId")}`,r=`http://${this.openDriveServer}/api/sumo/getSumoEdge`,a=await w.get(r,{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:"未知类型"}}}setOpendriveVisibility(e){this.laneLayer.visible=e}async clearOpenDrive(){var t,s,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,(s=this.mouseClickHandler)==null||s.remove(),this.mouseClickHandler=void 0,(o=this.scaleWatch)==null||o.remove(),this.scaleWatch=void 0}async findSumo(e){const{type:t,id:s}=e,o=e.flash===void 0?!0:e.flash;if(t==="junction")return await this.findJunction(s,o);if(t==="edge"){const i=s.split("_");if(i.length>2)return{status:-1,message:"id格式错误"};const l=i.length===2?Number(i[1]):void 0,r=i[0].split("#");if(r.length>2)return{status:-1,message:"id格式错误"};const a=r[0],c=r.length===2?Number(r[1]):void 0;return await this.findLane({roadsectId:a,segmentId:c,laneId:l,flash:o})}else return{status:-1,message:"未知类型"}}async findJunction(e,t){const s=this.junctionLayer.graphics.find(o=>o.attributes.id===e);if(!s)return{status:-1,message:"未找到。请检查路口编号"};if(t){const o=new I({geometry:s.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(s.geometry,{duration:1e3}),{status:0,message:"ok"}}async findLane(e){let{roadsectId:t,segmentId:s,laneId:o}=e;t.startsWith("-")&&(t=t.slice(1));let i=this.allLaneGraphics.filter(a=>a.attributes.roadId===t);if(i.length===0)return{status:-1,message:"未找到。请检查路段编号"};if(s!==void 0){const a=[];if(i.forEach(c=>{const n=Number(c.attributes.sectionId);a.indexOf(n)===-1&&a.push(n)}),a.sort((c,n)=>c-n),s>a.length-1)return{status:-1,message:"未找到。请检查基本段编号"};s=a[s],i=i.filter(c=>Number(c.attributes.sectionId)===s)}if(o!==void 0){const a=[];if(i.forEach(c=>{const n=Number(c.attributes.laneId);a.indexOf(n)===-1&&a.push(n)}),a.sort((c,n)=>c-n),o>a.length-1)return{status:-1,message:"未找到。请检查车道编号"};o=a[o],i=i.filter(c=>Number(c.attributes.laneId)===o)}const l=i.map(a=>a.geometry),r=L.union(l);if(e.flash){const a=new I({geometry:r,symbol:{type:"simple-fill",color:[0,255,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,s=!0;const o=setInterval(()=>{s?(this.flashLayer.opacity-=.02,this.flashLayer.opacity<=.1&&(s=!1,t++)):(this.flashLayer.opacity+=.02,this.flashLayer.opacity>=1&&(s=!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"))}):(this.highlightLayer.removeAll(),this.sectionLayer.removeAll(),this.selectedSectionIds=[],this.splitLaneLayer.removeAll()),!e||e.type==="edge"){let t;!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=>{const o=s.getAttribute("id");this.selectedSectionIds=this.selectedSectionIds.filter(i=>i!==o)}),this.sectionLayer.removeMany(t))}return{status:0,message:"ok"}}async 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 s=String(t[0]);s.startsWith("-")&&(s=s.slice(1));let o=0;t.length===2&&(o=Number(t[1]));let i=[];if(t.length===1?i=this.allLaneGraphics.filter(l=>l.getAttribute("roadId")===s):t.length===2&&(i=this.allLaneGraphics.filter(l=>l.getAttribute("roadId")===s&&l.getAttribute("sectionIndex")===o)),i.length>0){const l=new Map;return i.forEach(r=>{const a=r.getAttribute("roadId")+"+"+r.getAttribute("sectionId");this.selectedSectionIds.includes(a)||this.selectedSectionIds.push(a);let c=l.get(a);c?c.push(r.geometry):(c=[r.geometry],l.set(a,c))}),l.forEach(async(r,a)=>{const c=L.union(r),n=new I({geometry:c,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(n),await this.view.goTo(n)}),{status:0,message:"ok"}}else return{status:-1,message:"未找到路段"}}default:return{status:-1,message:"未知类型"}}}async geometrySearch(e){const t=new A.Polygon({rings:[e]}),s=await this.laneLayer.queryFeatures({geometry:t,outFields:["*"]}),o=[],i=[];for(const a of s.features){const c=a.getAttribute("roadId"),n=a.getAttribute("sectionIndex"),d=`${c}#${n}`;if(o.indexOf(d)===-1){o.push(d),this.selectSumo({type:"edge",id:d});const m=`http://${this.openDriveServer}/api/sumo/getSumoEdge`,u=await w.get(m,{params:{id:`${c}+${a.getAttribute("sectionId")}`,projectName:this.projectName}});u.status===200&&u.data.status===0&&i.push(u.data.result)}}const l=this.junctionLayer.graphics.filter(a=>{const c=a.geometry;return L.contains(t,c)}),r=[];for(const a of l){const c=a.getAttribute("id");this.selectSumo({type:"junction",id:c});const n=`http://${this.openDriveServer}/api/sumo/getSumoJunction`,d=await w.get(n,{params:{id:c,projectName:this.projectName}});d.status===200&&d.data.status===0&&r.push(d.data.result)}return{status:0,message:"ok",result:{junctions:r,edges:i}}}async splitLane(e){const s=e.id.split("_");if(s.length!==2)return{status:-1,message:"车道编号格式错误"};const o=Number(s[1]),i=s[0].split("#"),l=i.length===2?Number(i[1]):0;let r=i[0];r.startsWith("-")&&(r=r.slice(1));const a=this.allLaneGraphics.filter(b=>b.getAttribute("roadId")===r&&b.getAttribute("sectionIndex")===l);if(a.length===0)return{status:-1,message:"未找到路段"};const c=a.length-o,n=a.find(b=>Math.abs(b.getAttribute("laneId"))===c);if(!n)return{status:-1,message:"未找到车道"};const d=e.start||0,m=e.end||100,u=B.lineString(n.getAttribute("leftLine")),h=O.lineSliceAlong(u,d,m,{units:"meters"}),p=B.lineString(n.getAttribute("rightLine")),g=O.lineSliceAlong(p,d,m,{units:"meters"}),y=h.geometry.coordinates.concat(g.geometry.coordinates.reverse());y.push(y[y.length-1]);const f=new I({geometry:new A.Polygon({rings:[y]}),attributes:{ObjectID:n.getAttribute("ObjectID"),id:n.getAttribute("id"),fromNode:n.getAttribute("fromNode"),toNode:n.getAttribute("toNode"),roadId:n.getAttribute("roadId"),roadName:n.getAttribute("roadName"),sectionId:n.getAttribute("sectionId"),sectionIndex:n.getAttribute("sectionIndex"),laneId:n.getAttribute("laneId"),type:n.getAttribute("type"),sumoId:n.getAttribute("sumoId"),leftLine:h.geometry.coordinates,rightLine:g.geometry.coordinates},symbol:{type:"simple-fill",color:[255,0,0,.8],outline:{color:"red"}}});return this.splitLaneLayer.add(f),k.default.viewGoto(this.view,[f]),{status:0,message:"ok",result:{coordinates:y}}}blockLane(e){const t=this.allLaneGraphics.filter(o=>{var l;let i=String(o.getAttribute("laneId"));return i.startsWith("-")&&(i=i.slice(1)),o.getAttribute("roadId")===e.roadsectId&&((l=o.getAttribute("roadsectBaseIds"))==null?void 0:l.includes(e.roadsectBaseId))&&i===String(e.laneId)}),s=t.map(o=>{const i=o.clone();return console.log(t[0].getAttribute("roadsectBaseIds"),this.selectedSectionIds,this.selectedSectionIds.includes(t[0].getAttribute("roadsectBaseIds"))),i.symbol={type:"simple-fill",color:this.selectedSectionIds.includes(t[0].getAttribute("roadsectBaseIds"))?[255,69,0,.8]:[255,0,0,.8],outline:{color:"red"}},i});this.splitLaneLayer.addMany(s),k.default.viewGoto(this.view,s)}clearSplitLane(){this.splitLaneLayer.removeAll()}selectComputable(e){if(e.type==="roadsectBase"){this.allLaneGraphics.forEach(s=>{s.getAttribute("roadsectBaseIds")||console.log(s.attributes)});const t=this.allLaneGraphics.filter(s=>{var o;return(o=s.getAttribute("roadsectBaseIds"))==null?void 0:o.includes(e.id)});if(t.length>0){const s=L.union(t.map(r=>r.geometry)),o=t[0].getAttribute("roadsectBaseIds"),i=new I({geometry:s,symbol:{type:"simple-fill",color:[0,255,255,.5],style:"solid",outline:{color:[0,255,255],width:1}},attributes:{type:"OpenDriveSection",roadsectBaseIds:o}});this.sectionLayer.removeAll(),this.sectionLayer.add(i),k.default.viewGoto(this.view,[i]),this.selectedSectionIds=[o];const l=this.splitLaneLayer.graphics.filter(r=>{var a;return(a=r.getAttribute("roadsectBaseIds"))==null?void 0:a.includes(e.id)});l.length>0&&l.forEach(r=>r.symbol={type:"simple-fill",color:[255,69,0],outline:{color:"red",width:2}})}}}updateAllJunctionSymbol(e){const t=this.junctionLayer.graphics.clone();this.junctionLayer.removeAll(),t.forEach(s=>{s.getAttribute("selected")||(s.symbol=this.getCrossGraphicSymbol(s.attributes,e))}),this.junctionLayer.addMany(t.toArray())}getCrossGraphicSymbol(e,t){const s=e.crossId!==""&&e.crossId!==void 0&&e.crossId!==null;if(t==="marker")return{type:"picture-marker",url:`/GisViewerAssets/Images/cross/${s?"gis_xhj_blue":"gis_lkcz_xz"}.png`,width:"32px",height:"32px"};if(t==="picture")return s?{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:s?25:15,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:32,rotateClockwise:!0,textureFilter:"Picture",url:"/GisViewerAssets/Images/cross/gis_xhj_blue.png"}]}}}:{type:"picture-marker",url:"/GisViewerAssets/Images/cross/gis_lkcz_xz.png",width:"32px",height:"32px"}}}exports.default=C;
1
+ "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const I=require("@arcgis/core/Graphic"),J=require("@arcgis/core/core/promiseUtils"),E=require("@arcgis/core/core/reactiveUtils.js"),A=require("@arcgis/core/geometry"),q=require("@arcgis/core/geometry/geometryEngine"),x=require("@arcgis/core/layers/FeatureLayer"),v=require("@arcgis/core/layers/GraphicsLayer"),T=require("@turf/helpers"),O=require("@turf/line-slice-along"),w=require("axios"),_=require("fast-xml-parser"),R=require("md5"),M=require("pako"),z=require("vue"),H=require("../../stores/index.js"),k=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 s=Object.getOwnPropertyDescriptor(S,t);Object.defineProperty(e,t,s.get?s:{enumerable:!0,get:()=>S[t]})}}return e.default=S,Object.freeze(e)}const P=N(J),U=N(E),L=N(q),B=N(T);class C{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"},{name:"roadsectBaseIds",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 v({id:"OpenDriveJunction"}),this.sectionLayer=new v({id:"OpenDriveSection"}),this.highlightLayer=new v({id:"OpenDriveHighlight"}),this.flashLayer=new v({id:"OpenDriveFlash"}),this.drawLayer=new v({id:"Draw"}),this.splitLaneLayer=new v({id:"SplitLane"}),this.borderLayer=new v({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 o=await(await fetch(e)).text();let r=(t=new _.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:R(o),border:r}}}catch(s){return{status:-1,message:s.message}}}async showOpenDriveFromFile(e){var d,m,u;this.openDriveClickCallback=e.selectedCallback,this.scaleWatch=U.watch(()=>this.view.scale,(h,p)=>{h>this.junctionScale&&p<=this.junctionScale?this.updateAllJunctionSymbol("marker"):h<=this.junctionScale&&p>this.junctionScale&&this.updateAllJunctionSymbol("picture")});let t=e.file.split("/").pop()||"";t=t.split(".").slice(0,-1).join("."),this.openDriveServer=e.server;const s=`http://${this.openDriveServer}/api/openDrive/uploadXodr`;let o;try{o=await w.post(s,{},{params:{url:e.file,projectName:t}})}catch(h){return{status:-1,message:h.message}}if(o.status!==200)return{status:-1,message:o.statusText};console.time("渲染用时");const i=o.data.result.geoSetting;k.default.setGeoData(i.geoReference,i.offsetX,i.offsetY);let l=o.data.result.json;l.startsWith(window.location.protocol)||(l=`${window.location.protocol}//${e.server}${l}`);const r=await fetch(l);let a;if(l.endsWith("bin")){const h=await r.arrayBuffer(),p=M.inflate(h,{to:"string"});a=JSON.parse(p)}else a=await r.json();if(await this.showAllLanes(a,((d=e.options)==null?void 0:d.showJunctionLane)||!1,((m=e.options)==null?void 0:m.showRoadName)||!0),((u=e.options)==null?void 0:u.showJunctionPoint)!==!1){const h=o.data.result.junctions;this.showJunction(h)}e.options&&e.options.centerMap!==!1&&await this.view.goTo(this.allLaneGraphics),this.mouseMoveHandler||this.monitorMouseMove(),this.mouseClickHandler||this.monitorMouseClick();const n=H.default.useAppDataStore;return z.watch(()=>n.isSketching,()=>{var h,p;n.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())}),console.timeEnd("渲染用时"),{status:0,message:"ok"}}async showOpenDriveFromServer(e,t){const s=`http://${e}/api/openDrive/analyzeXodr`,o=await w.get(s,{headers:{projectName:t},params:{analyze:!1,compressed:!0}});if(o.status!==200)throw new Error(`OpenDriveRenderer: ${o.statusText}`);let i=o.data.result.json;i.startsWith(window.location.protocol)||(i=`${window.location.protocol}//${e}${i}`);const l=await fetch(i);let r;if(i.endsWith("bin")){const a=await l.arrayBuffer(),c=M.inflate(a,{to:"string"});r=JSON.parse(c)}else r=await l.json();return await this.showAllLanes(r,!1,!1),{status:0,message:"ok"}}async showAllLanes(e,t,s){const o=await this.laneLayer.queryFeatures();return o.features.length>0&&this.laneLayer.applyEdits({deleteFeatures:o.features}),this.roadNameLayer.visible=s,new Promise(i=>{var c;let l=0;this.allLaneGraphics=[],this.allRefLineGraphics=[];const r=[];for(const n of e){if(!t&&n.junction!=="-1")continue;const{id:d,refLine:m}=n;let u=n.name;u.includes("(")&&(u=u.slice(0,u.indexOf("("))),u=u.replace(/(.)/g,"$1 ");const h=new I({geometry:{type:"polyline",paths:[m]},attributes:{ObjectID:l++,roadId:d,roadName:u}});this.allRefLineGraphics.push(h),n.laneSections.sort((p,g)=>Number(p.id)-Number(g.id));for(let p=0;p<n.laneSections.length;p++){const g=n.laneSections[p],y=Number(g.id);for(const f of g.lanePaths){const b=Number(f.id);if(b===0)continue;const $=f.type,F=[...f.outerPath],j=f.innerPath.concat(F.reverse());if(j.length<=3){console.warn(`lane ${b} has less than 3 points`);continue}j.push(f.innerPath[0]);const D=new A.Polygon({rings:[j]});if(D){const G=new I({geometry:D,attributes:{ObjectID:l++,id:`${d}+${y}+${b}`,fromNode:n.fromNode,toNode:n.toNode,roadId:String(d),roadName:n.name,sectionId:String(y),sectionIndex:p,laneId:b,type:$,sumoId:"",leftLine:f.innerPath,rightLine:f.outerPath,roadsectBaseIds:(c=g.roadsectBaseIds)==null?void 0:c.toString()}});this.allLaneGraphics.push(G),r.push(G)}}}}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),i()},10)})}showJunction(e){const t=[];let s;this.xodrBorder.length>0&&(s=new A.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 i=new A.Point({x:o.coordinates[0],y:o.coordinates[1]});let l=!0;if(s&&(l=L.contains(s,i)),l){const r=new I({geometry:i,attributes:{...o,selected:!1,type:"OpenDriveJunction"},symbol:this.getCrossGraphicSymbol(o,"marker")});t.push(r)}}this.junctionLayer.addMany(t)}monitorMouseMove(){const e=P.debounce(async t=>{var l;const o=(l=(await this.view.hitTest(t,{include:[this.laneLayer,this.junctionLayer]})).results)==null?void 0:l.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 i=o[0];if(this.hitGraphic=i.graphic,i.layer.id==="OpenDriveLane"){const r=`${this.hitGraphic.getAttribute("roadId")}+${this.hitGraphic.getAttribute("sectionId")}`,a=this.hitGraphic.getAttribute("roadsectBaseIds");if(this.currentSectionCode===r||this.selectedSectionIds.includes(a)||this.sectionLayer.graphics.findIndex(y=>y.getAttribute("id")===r)>=0)return;this.currentSectionCode=r;const n=this.allLaneGraphics.filter(y=>`${y.attributes.roadId}+${y.attributes.sectionId}`===r),d=L.union(n.map(y=>y.geometry)),m=this.hitGraphic.getAttribute("fromNode"),u=this.hitGraphic.getAttribute("toNode"),h=this.junctionNames.get(m)||m,p=this.junctionNames.get(u)||u,g=new I({geometry:d,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:h,toNodeName:p,laneCount:n.length,roadsectBaseIds:this.hitGraphic.getAttribute("roadsectBaseIds"),roadId:this.hitGraphic.getAttribute("roadId")},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(g)}else if(i.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=P.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(c=>c.type==="graphic");if(o.length===0)return;const i=o[0].graphic,l=i.getAttribute("type"),r=i.getAttribute("id");if(l==="OpenDriveJunction")if(i.getAttribute("selected")===!1){const c=`http://${this.openDriveServer}/api/sumo/getSumoJunction`,n=await w.get(c,{params:{id:r,projectName:this.projectName}});n.status===200&&n.data.status===0&&(this.openDriveClickCallback&&this.openDriveClickCallback({type:"OpenDriveJunction",id:r,details:n.data.result}),i.setAttribute("selected",!0),i.symbol={type:"picture-marker",url:"/GisViewerAssets/Images/point_red.png",width:"20px",height:"20px"},this.increasePictureMarkerSize(i,50))}else this.openDriveClickCallback&&this.openDriveClickCallback({type:"OpenDriveJunction",id:r,details:void 0}),i.setAttribute("selected",!1),i.symbol=this.getCrossGraphicSymbol(i.attributes,this.view.scale<this.junctionScale?"picture":"marker");else l==="OpenDriveSection"&&(i.layer.id==="OpenDriveHighlight"?(this.highlightLayer.removeAll(),this.sectionLayer.removeAll(),this.selectedSectionIds=[],this.sectionLayer.add(i),i.setAttribute("selected",!0),this.selectedSectionIds.push(r),this.splitLaneLayer.graphics.filter(n=>n.getAttribute("roadsectBaseIds")===i.getAttribute("roadsectBaseIds")).forEach(n=>n.symbol={type:"simple-fill",color:[255,69,0],outline:{color:"red",width:2}}),this.openDriveClickCallback&&this.openDriveClickCallback({type:"OpenDriveSection",id:i.getAttribute("id"),details:{roadsectId:i.getAttribute("roadId"),roadsectBaseIds:i.getAttribute("roadsectBaseIds")}})):(this.splitLaneLayer.graphics.filter(n=>n.getAttribute("roadsectBaseIds")===i.getAttribute("roadsectBaseIds")).forEach(n=>n.symbol={type:"simple-fill",color:[255,0,0,.8],outline:{color:"red",width:1}}),this.sectionLayer.remove(i),this.selectedSectionIds=[],this.openDriveClickCallback&&this.openDriveClickCallback({type:"CloseOpenDriveSection",id:i.getAttribute("roadsectBaseIds"),details:{roadsectId:i.getAttribute("roadId"),roadsectBaseIds:i.getAttribute("roadsectBaseIds")}})))});this.mouseClickHandler=this.view.on("immediate-click",async t=>{e(t).catch(()=>{})})}increasePictureMarkerSize(e,t){const s=setInterval(()=>{const o=e.symbol,i=o.width;i<t?e.symbol={type:"picture-marker",url:o.url,width:i+1,height:i+1}:clearInterval(s)},20)}decreasePictureMarkerSize(e,t){const s=setInterval(()=>{const o=e.symbol,i=o.width;i>t?e.symbol={type:"picture-marker",url:o.url,width:i-1,height:i-1}:clearInterval(s)},20)}async getSumoInfo(e){switch(e.type){case"junction":{const t=`http://${this.openDriveServer}/api/sumo/getSumoJunction`,s=await w.get(t,{params:{id:e.id,projectName:this.projectName}});return s.status===200?s.data:{status:-1,message:`路口信息查询失败: ${e.id}`}}case"edge":{const t=e.id.split("#");let s=t[0];s.startsWith("-")&&(s=s.slice(1));let o=0;t.length===2&&(o=Number(t[1]));const i=this.allLaneGraphics.find(l=>l.getAttribute("roadId")===s&&l.getAttribute("sectionIndex")===o);if(i){const l=`${s}+${i.getAttribute("sectionId")}`,r=`http://${this.openDriveServer}/api/sumo/getSumoEdge`,a=await w.get(r,{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:"未知类型"}}}setOpendriveVisibility(e){this.laneLayer.visible=e}async clearOpenDrive(){var t,s,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,(s=this.mouseClickHandler)==null||s.remove(),this.mouseClickHandler=void 0,(o=this.scaleWatch)==null||o.remove(),this.scaleWatch=void 0}async findSumo(e){const{type:t,id:s}=e,o=e.flash===void 0?!0:e.flash;if(t==="junction")return await this.findJunction(s,o);if(t==="edge"){const i=s.split("_");if(i.length>2)return{status:-1,message:"id格式错误"};const l=i.length===2?Number(i[1]):void 0,r=i[0].split("#");if(r.length>2)return{status:-1,message:"id格式错误"};const a=r[0],c=r.length===2?Number(r[1]):void 0;return await this.findLane({roadsectId:a,segmentId:c,laneId:l,flash:o})}else return{status:-1,message:"未知类型"}}async findJunction(e,t){const s=this.junctionLayer.graphics.find(o=>o.attributes.id===e);if(!s)return{status:-1,message:"未找到。请检查路口编号"};if(t){const o=new I({geometry:s.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(s.geometry,{duration:1e3}),{status:0,message:"ok"}}async findLane(e){let{roadsectId:t,segmentId:s,laneId:o}=e;t.startsWith("-")&&(t=t.slice(1));let i=this.allLaneGraphics.filter(a=>a.attributes.roadId===t);if(i.length===0)return{status:-1,message:"未找到。请检查路段编号"};if(s!==void 0){const a=[];if(i.forEach(c=>{const n=Number(c.attributes.sectionId);a.indexOf(n)===-1&&a.push(n)}),a.sort((c,n)=>c-n),s>a.length-1)return{status:-1,message:"未找到。请检查基本段编号"};s=a[s],i=i.filter(c=>Number(c.attributes.sectionId)===s)}if(o!==void 0){const a=[];if(i.forEach(c=>{const n=Number(c.attributes.laneId);a.indexOf(n)===-1&&a.push(n)}),a.sort((c,n)=>c-n),o>a.length-1)return{status:-1,message:"未找到。请检查车道编号"};o=a[o],i=i.filter(c=>Number(c.attributes.laneId)===o)}const l=i.map(a=>a.geometry),r=L.union(l);if(e.flash){const a=new I({geometry:r,symbol:{type:"simple-fill",color:[0,255,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,s=!0;const o=setInterval(()=>{s?(this.flashLayer.opacity-=.02,this.flashLayer.opacity<=.1&&(s=!1,t++)):(this.flashLayer.opacity+=.02,this.flashLayer.opacity>=1&&(s=!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"))}):(this.highlightLayer.removeAll(),this.sectionLayer.removeAll(),this.selectedSectionIds=[],this.splitLaneLayer.removeAll()),!e||e.type==="edge"){let t;!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=>{const o=s.getAttribute("id");this.selectedSectionIds=this.selectedSectionIds.filter(i=>i!==o)}),this.sectionLayer.removeMany(t))}return{status:0,message:"ok"}}async 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 s=String(t[0]);s.startsWith("-")&&(s=s.slice(1));let o=0;t.length===2&&(o=Number(t[1]));let i=[];if(t.length===1?i=this.allLaneGraphics.filter(l=>l.getAttribute("roadId")===s):t.length===2&&(i=this.allLaneGraphics.filter(l=>l.getAttribute("roadId")===s&&l.getAttribute("sectionIndex")===o)),i.length>0){const l=new Map;return i.forEach(r=>{const a=r.getAttribute("roadId")+"+"+r.getAttribute("sectionId");this.selectedSectionIds.includes(a)||this.selectedSectionIds.push(a);let c=l.get(a);c?c.push(r.geometry):(c=[r.geometry],l.set(a,c))}),l.forEach(async(r,a)=>{const c=L.union(r),n=new I({geometry:c,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(n),await this.view.goTo(n)}),{status:0,message:"ok"}}else return{status:-1,message:"未找到路段"}}default:return{status:-1,message:"未知类型"}}}async geometrySearch(e){const t=new A.Polygon({rings:[e]}),s=await this.laneLayer.queryFeatures({geometry:t,outFields:["*"]}),o=[],i=[];for(const a of s.features){const c=a.getAttribute("roadId"),n=a.getAttribute("sectionIndex"),d=`${c}#${n}`;if(o.indexOf(d)===-1){o.push(d),this.selectSumo({type:"edge",id:d});const m=`http://${this.openDriveServer}/api/sumo/getSumoEdge`,u=await w.get(m,{params:{id:`${c}+${a.getAttribute("sectionId")}`,projectName:this.projectName}});u.status===200&&u.data.status===0&&i.push(u.data.result)}}const l=this.junctionLayer.graphics.filter(a=>{const c=a.geometry;return L.contains(t,c)}),r=[];for(const a of l){const c=a.getAttribute("id");this.selectSumo({type:"junction",id:c});const n=`http://${this.openDriveServer}/api/sumo/getSumoJunction`,d=await w.get(n,{params:{id:c,projectName:this.projectName}});d.status===200&&d.data.status===0&&r.push(d.data.result)}return{status:0,message:"ok",result:{junctions:r,edges:i}}}async splitLane(e){const s=e.id.split("_");if(s.length!==2)return{status:-1,message:"车道编号格式错误"};const o=Number(s[1]),i=s[0].split("#"),l=i.length===2?Number(i[1]):0;let r=i[0];r.startsWith("-")&&(r=r.slice(1));const a=this.allLaneGraphics.filter(b=>b.getAttribute("roadId")===r&&b.getAttribute("sectionIndex")===l);if(a.length===0)return{status:-1,message:"未找到路段"};const c=a.length-o,n=a.find(b=>Math.abs(b.getAttribute("laneId"))===c);if(!n)return{status:-1,message:"未找到车道"};const d=e.start||0,m=e.end||100,u=B.lineString(n.getAttribute("leftLine")),h=O.lineSliceAlong(u,d,m,{units:"meters"}),p=B.lineString(n.getAttribute("rightLine")),g=O.lineSliceAlong(p,d,m,{units:"meters"}),y=h.geometry.coordinates.concat(g.geometry.coordinates.reverse());y.push(y[y.length-1]);const f=new I({geometry:new A.Polygon({rings:[y]}),attributes:{ObjectID:n.getAttribute("ObjectID"),id:n.getAttribute("id"),fromNode:n.getAttribute("fromNode"),toNode:n.getAttribute("toNode"),roadId:n.getAttribute("roadId"),roadName:n.getAttribute("roadName"),sectionId:n.getAttribute("sectionId"),sectionIndex:n.getAttribute("sectionIndex"),laneId:n.getAttribute("laneId"),type:n.getAttribute("type"),sumoId:n.getAttribute("sumoId"),leftLine:h.geometry.coordinates,rightLine:g.geometry.coordinates},symbol:{type:"simple-fill",color:[255,0,0,.8],outline:{color:"red"}}});return this.splitLaneLayer.add(f),k.default.viewGoto(this.view,[f]),{status:0,message:"ok",result:{coordinates:y}}}blockLane(e){const t=this.allLaneGraphics.filter(o=>{var l;let i=String(o.getAttribute("laneId"));return i.startsWith("-")&&(i=i.slice(1)),o.getAttribute("roadId")===e.roadsectId&&((l=o.getAttribute("roadsectBaseIds"))==null?void 0:l.includes(e.roadsectBaseId))&&i===String(e.laneId)}),s=t.map(o=>{const i=o.clone();return console.log(t[0].getAttribute("roadsectBaseIds"),this.selectedSectionIds,this.selectedSectionIds.includes(t[0].getAttribute("roadsectBaseIds"))),i.symbol={type:"simple-fill",color:this.selectedSectionIds.includes(t[0].getAttribute("roadsectBaseIds"))?[255,69,0,.8]:[255,0,0,.8],outline:{color:"red"}},i});this.splitLaneLayer.addMany(s),k.default.viewGoto(this.view,s)}clearSplitLane(){this.splitLaneLayer.removeAll()}selectComputable(e){if(e.type==="roadsectBase"){this.allLaneGraphics.forEach(s=>{s.getAttribute("roadsectBaseIds")||console.log(s.attributes)});const t=this.allLaneGraphics.filter(s=>{var o;return(o=s.getAttribute("roadsectBaseIds"))==null?void 0:o.includes(e.id)});if(t.length>0){const s=L.union(t.map(r=>r.geometry)),o=t[0].getAttribute("roadsectBaseIds"),i=new I({geometry:s,symbol:{type:"simple-fill",color:[0,255,255,.5],style:"solid",outline:{color:[0,255,255],width:1}},attributes:{type:"OpenDriveSection",roadsectBaseIds:o}});this.sectionLayer.removeAll(),this.sectionLayer.add(i),k.default.viewGoto(this.view,[i]),this.selectedSectionIds=[o];const l=this.splitLaneLayer.graphics.filter(r=>{var a;return(a=r.getAttribute("roadsectBaseIds"))==null?void 0:a.includes(e.id)});l.length>0&&l.forEach(r=>r.symbol={type:"simple-fill",color:[255,69,0],outline:{color:"red",width:2}})}}}updateAllJunctionSymbol(e){const t=this.junctionLayer.graphics.clone();this.junctionLayer.removeAll(),t.forEach(s=>{s.getAttribute("selected")||(s.symbol=this.getCrossGraphicSymbol(s.attributes,e))}),this.junctionLayer.addMany(t.toArray())}getCrossGraphicSymbol(e,t){const s=e.crossId!==""&&e.crossId!==void 0&&e.crossId!==null;if(t==="marker")return{type:"picture-marker",url:`/GisViewerAssets/Images/cross/${s?"gis_xhj_blue":"gis_lkcz_xz"}.png`,width:"32px",height:"32px"};if(t==="picture")return s?{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:s?25:15,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:32,rotateClockwise:!0,textureFilter:"Picture",url:"/GisViewerAssets/Images/cross/gis_xhj_blue.png"}]}}}:{type:"picture-marker",url:"/GisViewerAssets/Images/cross/gis_lkcz_xz.png",width:"32px",height:"32px"}}}exports.default=C;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "gisviewer-vue3-arcgis",
3
- "version": "1.0.264",
3
+ "version": "1.0.265",
4
4
  "main": "lib/index.js",
5
5
  "module": "es/index.mjs",
6
6
  "files": [