gisviewer-vue3-arcgis 1.0.148 → 1.0.150
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.
- package/es/src/gis-map/utils/open-drive-renderer/index.mjs +92 -89
- package/es/src/gis-map/utils/signal-control-area-controller/index.mjs +7 -7
- package/lib/src/gis-map/utils/open-drive-renderer/index.js +1 -1
- package/lib/src/gis-map/utils/signal-control-area-controller/index.js +1 -1
- package/package.json +1 -1
|
@@ -346,20 +346,20 @@ class F {
|
|
|
346
346
|
);
|
|
347
347
|
let c = o.data.result.json;
|
|
348
348
|
c.startsWith(window.location.protocol) || (c = `${window.location.protocol}//${e.server}${c}`);
|
|
349
|
-
const
|
|
349
|
+
const a = await (await fetch(c)).arrayBuffer(), r = O.inflate(a, { to: "string" }), n = JSON.parse(r);
|
|
350
350
|
await this.showAllLanes(
|
|
351
351
|
n,
|
|
352
352
|
((g = e.options) == null ? void 0 : g.showJunctionLane) || !1,
|
|
353
353
|
((p = e.options) == null ? void 0 : p.showRoadName) || !0
|
|
354
354
|
);
|
|
355
|
-
const
|
|
356
|
-
this.showJunction(
|
|
357
|
-
const
|
|
355
|
+
const d = o.data.result.junctions;
|
|
356
|
+
this.showJunction(d), e.options && e.options.centerMap !== !1 && await this.view.goTo(this.allLaneGraphics), this.mouseMoveHandler || this.monitorMouseMove(), this.mouseClickHandler || this.monitorMouseClick();
|
|
357
|
+
const h = J.useAppDataStore;
|
|
358
358
|
return x(
|
|
359
|
-
() =>
|
|
359
|
+
() => h.isSketching,
|
|
360
360
|
() => {
|
|
361
361
|
var m, u;
|
|
362
|
-
|
|
362
|
+
h.isSketching ? ((m = this.mouseMoveHandler) == null || m.remove(), this.mouseMoveHandler = void 0, (u = this.mouseClickHandler) == null || u.remove(), this.mouseClickHandler = void 0) : (this.monitorMouseMove(), this.monitorMouseClick());
|
|
363
363
|
}
|
|
364
364
|
), console.timeEnd("渲染用时"), { status: 0, message: "ok" };
|
|
365
365
|
}
|
|
@@ -382,7 +382,7 @@ class F {
|
|
|
382
382
|
throw new Error(`OpenDriveRenderer: ${o.statusText}`);
|
|
383
383
|
let s = o.data.result.json;
|
|
384
384
|
s.startsWith(window.location.protocol) || (s = `${window.location.protocol}//${e}${s}`);
|
|
385
|
-
const
|
|
385
|
+
const l = await (await fetch(s)).arrayBuffer(), a = O.inflate(l, { to: "string" }), r = JSON.parse(a);
|
|
386
386
|
return await this.showAllLanes(r, !1, !1), { status: 0, message: "ok" };
|
|
387
387
|
}
|
|
388
388
|
/**
|
|
@@ -399,23 +399,23 @@ class F {
|
|
|
399
399
|
}), this.roadNameLayer.visible = i, new Promise((s) => {
|
|
400
400
|
let c = 0;
|
|
401
401
|
this.allLaneGraphics = [], this.allRefLineGraphics = [];
|
|
402
|
-
const
|
|
402
|
+
const l = [];
|
|
403
403
|
console.log(e.length);
|
|
404
404
|
for (const r of e) {
|
|
405
405
|
if (!t && r.junction !== "-1")
|
|
406
406
|
continue;
|
|
407
|
-
const { id: n, refLine:
|
|
408
|
-
let
|
|
409
|
-
|
|
407
|
+
const { id: n, refLine: d } = r;
|
|
408
|
+
let h = r.name;
|
|
409
|
+
h.includes("(") && (h = h.slice(0, h.indexOf("("))), h = h.replace(/(.)/g, "$1 ");
|
|
410
410
|
const g = new y({
|
|
411
411
|
geometry: {
|
|
412
412
|
type: "polyline",
|
|
413
|
-
paths: [
|
|
413
|
+
paths: [d]
|
|
414
414
|
},
|
|
415
415
|
attributes: {
|
|
416
416
|
ObjectID: c++,
|
|
417
417
|
roadId: n,
|
|
418
|
-
roadName:
|
|
418
|
+
roadName: h
|
|
419
419
|
}
|
|
420
420
|
});
|
|
421
421
|
this.allRefLineGraphics.push(g), r.laneSections.sort((p, m) => Number(p.id) - Number(m.id));
|
|
@@ -456,15 +456,15 @@ class F {
|
|
|
456
456
|
rightLine: f.outerPath
|
|
457
457
|
}
|
|
458
458
|
});
|
|
459
|
-
this.allLaneGraphics.push(D),
|
|
459
|
+
this.allLaneGraphics.push(D), l.push(D);
|
|
460
460
|
}
|
|
461
461
|
}
|
|
462
462
|
}
|
|
463
463
|
}
|
|
464
|
-
const
|
|
465
|
-
if (
|
|
466
|
-
if (
|
|
467
|
-
const r =
|
|
464
|
+
const a = setInterval(() => {
|
|
465
|
+
if (l.length > 0 || this.allRefLineGraphics.length > 0) {
|
|
466
|
+
if (l.length > 0) {
|
|
467
|
+
const r = l.splice(0, 100);
|
|
468
468
|
this.laneLayer.applyEdits({
|
|
469
469
|
addFeatures: r
|
|
470
470
|
});
|
|
@@ -476,7 +476,7 @@ class F {
|
|
|
476
476
|
});
|
|
477
477
|
}
|
|
478
478
|
} else
|
|
479
|
-
clearInterval(
|
|
479
|
+
clearInterval(a), s();
|
|
480
480
|
}, 10);
|
|
481
481
|
});
|
|
482
482
|
}
|
|
@@ -540,7 +540,7 @@ class F {
|
|
|
540
540
|
const o = (c = (await this.view.hitTest(t, {
|
|
541
541
|
include: [this.laneLayer, this.junctionLayer]
|
|
542
542
|
})).results) == null ? void 0 : c.filter(
|
|
543
|
-
(
|
|
543
|
+
(l) => l.type === "graphic"
|
|
544
544
|
);
|
|
545
545
|
if (o.length === 0) {
|
|
546
546
|
this.currentSectionCode !== "" && (this.currentSectionCode = "", this.highlightGraphic = void 0, this.highlightLayer.removeAll()), this.currentJunctionId !== "" && (this.currentJunctionId = "", this.view.closePopup());
|
|
@@ -548,19 +548,19 @@ class F {
|
|
|
548
548
|
}
|
|
549
549
|
const s = o[0];
|
|
550
550
|
if (this.hitGraphic = s.graphic, s.layer.id === "OpenDriveLane") {
|
|
551
|
-
const
|
|
551
|
+
const l = `${this.hitGraphic.getAttribute(
|
|
552
552
|
"roadId"
|
|
553
553
|
)}+${this.hitGraphic.getAttribute("sectionId")}`;
|
|
554
|
-
if (
|
|
555
|
-
(u) => u.getAttribute("id") ===
|
|
554
|
+
if (l === this.currentSectionCode || this.sectionLayer.graphics.findIndex(
|
|
555
|
+
(u) => u.getAttribute("id") === l
|
|
556
556
|
) >= 0)
|
|
557
557
|
return;
|
|
558
|
-
this.currentSectionCode =
|
|
558
|
+
this.currentSectionCode = l;
|
|
559
559
|
const r = this.allLaneGraphics.filter(
|
|
560
|
-
(u) => `${u.attributes.roadId}+${u.attributes.sectionId}` ===
|
|
560
|
+
(u) => `${u.attributes.roadId}+${u.attributes.sectionId}` === l
|
|
561
561
|
), n = L.union(
|
|
562
562
|
r.map((u) => u.geometry)
|
|
563
|
-
),
|
|
563
|
+
), d = this.hitGraphic.getAttribute("fromNode"), h = this.hitGraphic.getAttribute("toNode"), g = this.junctionNames.get(d) || d, p = this.junctionNames.get(h) || h;
|
|
564
564
|
this.highlightGraphic = new y({
|
|
565
565
|
geometry: n,
|
|
566
566
|
symbol: {
|
|
@@ -574,7 +574,7 @@ class F {
|
|
|
574
574
|
},
|
|
575
575
|
attributes: {
|
|
576
576
|
type: "OpenDriveSection",
|
|
577
|
-
id:
|
|
577
|
+
id: l,
|
|
578
578
|
selected: !1,
|
|
579
579
|
fromNodeName: g,
|
|
580
580
|
toNodeName: p,
|
|
@@ -609,10 +609,10 @@ class F {
|
|
|
609
609
|
location: m
|
|
610
610
|
});
|
|
611
611
|
} else if (s.layer.id === "OpenDriveJunction") {
|
|
612
|
-
const
|
|
613
|
-
if (
|
|
612
|
+
const l = this.hitGraphic.getAttribute("id");
|
|
613
|
+
if (l === this.currentJunctionId)
|
|
614
614
|
return;
|
|
615
|
-
this.currentJunctionId =
|
|
615
|
+
this.currentJunctionId = l, this.view.openPopup({
|
|
616
616
|
features: [this.hitGraphic],
|
|
617
617
|
location: this.hitGraphic.geometry
|
|
618
618
|
});
|
|
@@ -628,32 +628,32 @@ class F {
|
|
|
628
628
|
*/
|
|
629
629
|
monitorMouseClick() {
|
|
630
630
|
const e = j.debounce(async (t) => {
|
|
631
|
-
var
|
|
632
|
-
const o = (
|
|
631
|
+
var a;
|
|
632
|
+
const o = (a = (await this.view.hitTest(t, {
|
|
633
633
|
include: [this.highlightLayer, this.junctionLayer, this.sectionLayer]
|
|
634
|
-
})).results) == null ? void 0 :
|
|
634
|
+
})).results) == null ? void 0 : a.filter(
|
|
635
635
|
(r) => r.type === "graphic"
|
|
636
636
|
);
|
|
637
637
|
if (o.length === 0)
|
|
638
638
|
return;
|
|
639
|
-
const s = o[0].graphic, c = s.getAttribute("type"),
|
|
639
|
+
const s = o[0].graphic, c = s.getAttribute("type"), l = s.getAttribute("id");
|
|
640
640
|
if (c === "OpenDriveJunction")
|
|
641
641
|
if (s.getAttribute("selected") === !1) {
|
|
642
642
|
const r = `http://${this.openDriveServer}/api/sumo/getSumoJunction`, n = await b.get(r, {
|
|
643
643
|
params: {
|
|
644
|
-
id:
|
|
644
|
+
id: l,
|
|
645
645
|
projectName: this.projectName
|
|
646
646
|
}
|
|
647
647
|
});
|
|
648
648
|
n.status === 200 && n.data.status === 0 && (this.openDriveClickCallback && this.openDriveClickCallback({
|
|
649
649
|
type: "OpenDriveJunction",
|
|
650
|
-
id:
|
|
650
|
+
id: l,
|
|
651
651
|
details: n.data.result
|
|
652
652
|
}), s.setAttribute("selected", !0), s.symbol.url = "/GisViewerAssets/Images/point_red.png", this.increasePictureMarkerSize(s, 50));
|
|
653
653
|
} else {
|
|
654
654
|
this.openDriveClickCallback && this.openDriveClickCallback({
|
|
655
655
|
type: "OpenDriveJunction",
|
|
656
|
-
id:
|
|
656
|
+
id: l,
|
|
657
657
|
details: void 0
|
|
658
658
|
}), s.setAttribute("selected", !1);
|
|
659
659
|
const r = s.getAttribute("crossId");
|
|
@@ -663,22 +663,25 @@ class F {
|
|
|
663
663
|
if (s.getAttribute("selected"))
|
|
664
664
|
this.sectionLayer.remove(s), this.openDriveClickCallback && this.openDriveClickCallback({
|
|
665
665
|
type: "OpenDriveSection",
|
|
666
|
-
id:
|
|
666
|
+
id: s.getAttribute("edgeId"),
|
|
667
667
|
details: void 0
|
|
668
668
|
});
|
|
669
669
|
else {
|
|
670
670
|
this.highlightLayer.remove(s), this.sectionLayer.add(s), s.setAttribute("selected", !0);
|
|
671
671
|
const r = `http://${this.openDriveServer}/api/sumo/getSumoEdge`, n = await b.get(r, {
|
|
672
672
|
params: {
|
|
673
|
-
id:
|
|
673
|
+
id: l,
|
|
674
674
|
projectName: this.projectName
|
|
675
675
|
}
|
|
676
676
|
});
|
|
677
|
-
n.status === 200 && n.data.status === 0 && this.openDriveClickCallback
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
677
|
+
if (n.status === 200 && n.data.status === 0 && this.openDriveClickCallback) {
|
|
678
|
+
const d = n.data.result.obj_id;
|
|
679
|
+
s.setAttribute("edgeId", d), this.openDriveClickCallback({
|
|
680
|
+
type: "OpenDriveSection",
|
|
681
|
+
id: d,
|
|
682
|
+
details: n.data.result
|
|
683
|
+
});
|
|
684
|
+
}
|
|
682
685
|
}
|
|
683
686
|
});
|
|
684
687
|
this.mouseClickHandler = this.view.on("immediate-click", async (t) => {
|
|
@@ -741,13 +744,13 @@ class F {
|
|
|
741
744
|
if (s) {
|
|
742
745
|
const c = `${i}+${s.getAttribute(
|
|
743
746
|
"sectionId"
|
|
744
|
-
)}`,
|
|
747
|
+
)}`, l = `http://${this.openDriveServer}/api/sumo/getSumoEdge`, a = await b.get(l, {
|
|
745
748
|
params: {
|
|
746
749
|
id: c,
|
|
747
750
|
projectName: this.projectName
|
|
748
751
|
}
|
|
749
752
|
});
|
|
750
|
-
return
|
|
753
|
+
return a.status === 200 ? a.data : { status: -1, message: `路段信息查询失败: ${c}` };
|
|
751
754
|
} else
|
|
752
755
|
return { status: -1, message: "未知类型" };
|
|
753
756
|
}
|
|
@@ -780,11 +783,11 @@ class F {
|
|
|
780
783
|
const s = i.split("_");
|
|
781
784
|
if (s.length > 2)
|
|
782
785
|
return { status: -1, message: "id格式错误" };
|
|
783
|
-
const c = s.length === 2 ? Number(s[1]) : void 0,
|
|
784
|
-
if (
|
|
786
|
+
const c = s.length === 2 ? Number(s[1]) : void 0, l = s[0].split("#");
|
|
787
|
+
if (l.length > 2)
|
|
785
788
|
return { status: -1, message: "id格式错误" };
|
|
786
|
-
const
|
|
787
|
-
return await this.findLane({ roadsectId:
|
|
789
|
+
const a = l[0], r = l.length === 2 ? Number(l[1]) : void 0;
|
|
790
|
+
return await this.findLane({ roadsectId: a, segmentId: r, laneId: c, flash: o });
|
|
788
791
|
} else
|
|
789
792
|
return { status: -1, message: "未知类型" };
|
|
790
793
|
}
|
|
@@ -821,38 +824,38 @@ class F {
|
|
|
821
824
|
let { roadsectId: t, segmentId: i, laneId: o } = e;
|
|
822
825
|
t.startsWith("-") && (t = t.slice(1));
|
|
823
826
|
let s = this.allLaneGraphics.filter(
|
|
824
|
-
(
|
|
827
|
+
(a) => a.attributes.roadId === t
|
|
825
828
|
);
|
|
826
829
|
if (s.length === 0)
|
|
827
830
|
return { status: -1, message: "未找到。请检查路段编号" };
|
|
828
831
|
if (i !== void 0) {
|
|
829
|
-
const
|
|
832
|
+
const a = [];
|
|
830
833
|
if (s.forEach((r) => {
|
|
831
834
|
const n = Number(r.attributes.sectionId);
|
|
832
|
-
|
|
833
|
-
}),
|
|
835
|
+
a.indexOf(n) === -1 && a.push(n);
|
|
836
|
+
}), a.sort((r, n) => r - n), i > a.length - 1)
|
|
834
837
|
return { status: -1, message: "未找到。请检查基本段编号" };
|
|
835
|
-
i =
|
|
838
|
+
i = a[i], s = s.filter(
|
|
836
839
|
(r) => Number(r.attributes.sectionId) === i
|
|
837
840
|
);
|
|
838
841
|
}
|
|
839
842
|
if (o !== void 0) {
|
|
840
|
-
const
|
|
843
|
+
const a = [];
|
|
841
844
|
if (s.forEach((r) => {
|
|
842
845
|
const n = Number(r.attributes.laneId);
|
|
843
|
-
|
|
844
|
-
}),
|
|
846
|
+
a.indexOf(n) === -1 && a.push(n);
|
|
847
|
+
}), a.sort((r, n) => r - n), o > a.length - 1)
|
|
845
848
|
return { status: -1, message: "未找到。请检查车道编号" };
|
|
846
|
-
o =
|
|
849
|
+
o = a[o], s = s.filter(
|
|
847
850
|
(r) => Number(r.attributes.laneId) === o
|
|
848
851
|
);
|
|
849
852
|
}
|
|
850
853
|
const c = s.map(
|
|
851
|
-
(
|
|
852
|
-
),
|
|
854
|
+
(a) => a.geometry
|
|
855
|
+
), l = L.union(c);
|
|
853
856
|
if (e.flash) {
|
|
854
|
-
const
|
|
855
|
-
geometry:
|
|
857
|
+
const a = new y({
|
|
858
|
+
geometry: l,
|
|
856
859
|
symbol: {
|
|
857
860
|
type: "simple-fill",
|
|
858
861
|
color: [255, 0, 0, 0.5],
|
|
@@ -863,9 +866,9 @@ class F {
|
|
|
863
866
|
}
|
|
864
867
|
}
|
|
865
868
|
});
|
|
866
|
-
this.flashGraphic(
|
|
869
|
+
this.flashGraphic(a);
|
|
867
870
|
}
|
|
868
|
-
return await this.view.goTo(
|
|
871
|
+
return await this.view.goTo(l, { duration: 1e3 }), { status: 0, message: "ok" };
|
|
869
872
|
}
|
|
870
873
|
/**
|
|
871
874
|
* graphic渐隐渐显闪烁
|
|
@@ -926,8 +929,8 @@ class F {
|
|
|
926
929
|
(c) => c.getAttribute("roadId") === i && c.getAttribute("sectionId") === o
|
|
927
930
|
)), s.length > 0) {
|
|
928
931
|
const c = L.union(
|
|
929
|
-
s.map((
|
|
930
|
-
),
|
|
932
|
+
s.map((a) => a.geometry)
|
|
933
|
+
), l = new y({
|
|
931
934
|
geometry: c,
|
|
932
935
|
symbol: {
|
|
933
936
|
type: "simple-fill",
|
|
@@ -944,7 +947,7 @@ class F {
|
|
|
944
947
|
selected: !0
|
|
945
948
|
}
|
|
946
949
|
});
|
|
947
|
-
return this.sectionLayer.add(
|
|
950
|
+
return this.sectionLayer.add(l), { status: 0, message: "ok" };
|
|
948
951
|
} else
|
|
949
952
|
return { status: -1, message: "未找到路段" };
|
|
950
953
|
}
|
|
@@ -959,14 +962,14 @@ class F {
|
|
|
959
962
|
geometry: t,
|
|
960
963
|
outFields: ["*"]
|
|
961
964
|
}), o = [], s = [];
|
|
962
|
-
for (const
|
|
963
|
-
const r =
|
|
964
|
-
if (o.indexOf(
|
|
965
|
-
o.push(
|
|
965
|
+
for (const a of i.features) {
|
|
966
|
+
const r = a.getAttribute("roadId"), n = a.getAttribute("sectionId"), d = `${r}#${n}`;
|
|
967
|
+
if (o.indexOf(d) === -1) {
|
|
968
|
+
o.push(d), this.selectSumo({
|
|
966
969
|
type: "edge",
|
|
967
|
-
id:
|
|
970
|
+
id: d
|
|
968
971
|
});
|
|
969
|
-
const
|
|
972
|
+
const h = `http://${this.openDriveServer}/api/sumo/getSumoEdge`, g = await b.get(h, {
|
|
970
973
|
params: {
|
|
971
974
|
id: `${r}+${n}`,
|
|
972
975
|
projectName: this.projectName
|
|
@@ -975,29 +978,29 @@ class F {
|
|
|
975
978
|
g.status === 200 && g.data.status === 0 && s.push(g.data.result);
|
|
976
979
|
}
|
|
977
980
|
}
|
|
978
|
-
const c = this.junctionLayer.graphics.filter((
|
|
979
|
-
const r =
|
|
981
|
+
const c = this.junctionLayer.graphics.filter((a) => {
|
|
982
|
+
const r = a.geometry;
|
|
980
983
|
return L.contains(t, r);
|
|
981
|
-
}),
|
|
982
|
-
for (const
|
|
983
|
-
const r =
|
|
984
|
+
}), l = [];
|
|
985
|
+
for (const a of c) {
|
|
986
|
+
const r = a.getAttribute("id");
|
|
984
987
|
this.selectSumo({
|
|
985
988
|
type: "junction",
|
|
986
989
|
id: r
|
|
987
990
|
});
|
|
988
|
-
const n = `http://${this.openDriveServer}/api/sumo/getSumoJunction`,
|
|
991
|
+
const n = `http://${this.openDriveServer}/api/sumo/getSumoJunction`, d = await b.get(n, {
|
|
989
992
|
params: {
|
|
990
993
|
id: r,
|
|
991
994
|
projectName: this.projectName
|
|
992
995
|
}
|
|
993
996
|
});
|
|
994
|
-
|
|
997
|
+
d.status === 200 && d.data.status === 0 && l.push(d.data.result);
|
|
995
998
|
}
|
|
996
999
|
return {
|
|
997
1000
|
status: 0,
|
|
998
1001
|
message: "ok",
|
|
999
1002
|
result: {
|
|
1000
|
-
junctions:
|
|
1003
|
+
junctions: l,
|
|
1001
1004
|
edges: s
|
|
1002
1005
|
}
|
|
1003
1006
|
};
|
|
@@ -1007,19 +1010,19 @@ class F {
|
|
|
1007
1010
|
if (i.length !== 2)
|
|
1008
1011
|
return { status: -1, message: "车道编号格式错误" };
|
|
1009
1012
|
const o = Number(i[1]), s = i[0].split("#"), c = s.length === 2 ? Number(s[1]) : 0;
|
|
1010
|
-
let
|
|
1011
|
-
|
|
1012
|
-
const
|
|
1013
|
-
if (
|
|
1013
|
+
let l = s[0];
|
|
1014
|
+
l.startsWith("-") && (l = l.slice(1));
|
|
1015
|
+
const a = this.allLaneGraphics.filter((v) => v.getAttribute("roadId") === l && v.getAttribute("sectionIndex") === c);
|
|
1016
|
+
if (a.length === 0)
|
|
1014
1017
|
return { status: -1, message: "未找到路段" };
|
|
1015
|
-
const r =
|
|
1018
|
+
const r = a.length - o, n = a.find(
|
|
1016
1019
|
(v) => Math.abs(v.getAttribute("laneId")) === r
|
|
1017
1020
|
);
|
|
1018
1021
|
if (!n)
|
|
1019
1022
|
return { status: -1, message: "未找到车道" };
|
|
1020
|
-
const
|
|
1023
|
+
const d = e.start || 0, h = e.end || 100, g = G.lineString(n.getAttribute("leftLine")), p = C(g, d, h, {
|
|
1021
1024
|
units: "meters"
|
|
1022
|
-
}), m = G.lineString(n.getAttribute("rightLine")), u = C(m,
|
|
1025
|
+
}), m = G.lineString(n.getAttribute("rightLine")), u = C(m, d, h, {
|
|
1023
1026
|
units: "meters"
|
|
1024
1027
|
}), f = p.geometry.coordinates.concat(
|
|
1025
1028
|
u.geometry.coordinates.reverse()
|
|
@@ -75,7 +75,7 @@ class x {
|
|
|
75
75
|
return t ? (t.attributes.type === "cross" ? await this.view.goTo({
|
|
76
76
|
target: t.geometry,
|
|
77
77
|
scale: 1500
|
|
78
|
-
}) : await this.view.goTo(t.geometry),
|
|
78
|
+
}) : await this.view.goTo(t.geometry), { status: 0, message: "ok" }) : { status: 1, message: "未找到" };
|
|
79
79
|
}
|
|
80
80
|
showPopup(e) {
|
|
81
81
|
const t = e.geometry.type === "point" ? e.geometry : e.geometry.centroid;
|
|
@@ -91,13 +91,13 @@ class x {
|
|
|
91
91
|
).toArray().map((i) => i.clone()), s = this.crossLayer.graphics.filter(
|
|
92
92
|
(i) => i.getAttribute("id") === e.id || i.getAttribute("districtId") === e.id || i.getAttribute("subDistrictId") === e.id
|
|
93
93
|
).toArray().map((i) => i.clone());
|
|
94
|
-
return t.length > 0 && this.highlightLayer.addMany(t), r.length > 0 &&
|
|
94
|
+
return t.length > 0 && this.highlightLayer.addMany(t), r.length > 0 && this.highlightLayer.addMany(r), s.length > 0 && this.highlightLayer.addMany(s), this.highlightLayer.graphics.length === 0 ? { status: 1, message: "未找到" } : (t.length > 0 ? await this.view.goTo(t) : r.length > 0 ? await this.view.goTo(r) : s.length > 1 ? await this.view.goTo(s) : await this.view.goTo({
|
|
95
95
|
target: s[0].geometry,
|
|
96
96
|
scale: 1500
|
|
97
|
-
}),
|
|
97
|
+
}), { status: 0, message: "ok" });
|
|
98
98
|
}
|
|
99
99
|
resetHighlight() {
|
|
100
|
-
return this.highlightLayer.removeAll(), this.districtControllerLayer.visible = !0, this.subDistrictControllerLayer.visible = !0, this.crossLayer.visible = !0, { status: 0, message: "ok" };
|
|
100
|
+
return this.highlightLayer.removeAll(), this.view.closePopup(), this.districtControllerLayer.visible = !0, this.subDistrictControllerLayer.visible = !0, this.crossLayer.visible = !0, { status: 0, message: "ok" };
|
|
101
101
|
}
|
|
102
102
|
/**
|
|
103
103
|
* 在区控\子区\路口图层中查找对应的graphic
|
|
@@ -126,7 +126,7 @@ class x {
|
|
|
126
126
|
i = h.lineString(r);
|
|
127
127
|
else if (r.length > 2) {
|
|
128
128
|
const n = h.featureCollection(
|
|
129
|
-
r.map((
|
|
129
|
+
r.map((p) => h.point(p))
|
|
130
130
|
);
|
|
131
131
|
t ? i = m(n) : (i = b(n, { maxEdge: 400, units: "meters" }), i || (i = m(n)));
|
|
132
132
|
}
|
|
@@ -166,7 +166,7 @@ class x {
|
|
|
166
166
|
label: "路口数量"
|
|
167
167
|
}
|
|
168
168
|
];
|
|
169
|
-
const
|
|
169
|
+
const u = {
|
|
170
170
|
type: "signalControlArea",
|
|
171
171
|
id: e.id,
|
|
172
172
|
name: e.name,
|
|
@@ -188,7 +188,7 @@ class x {
|
|
|
188
188
|
style: t ? "solid" : "long-dash"
|
|
189
189
|
}
|
|
190
190
|
},
|
|
191
|
-
attributes:
|
|
191
|
+
attributes: u,
|
|
192
192
|
popupTemplate: {
|
|
193
193
|
title: `${t ? "区控" : "子区"} ${e.name}`,
|
|
194
194
|
content: [
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const y=require("@arcgis/core/Graphic"),x=require("@arcgis/core/core/promiseUtils"),A=require("@arcgis/core/geometry"),J=require("@arcgis/core/geometry/geometryEngine"),C=require("@arcgis/core/layers/FeatureLayer"),I=require("@arcgis/core/layers/GraphicsLayer"),q=require("@turf/helpers"),O=require("@turf/line-slice-along"),b=require("axios"),T=require("md5"),F=require("pako"),E=require("vue"),R=require("../../stores/index.js"),_=require("../common-utils.js");function j(L){const e=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(L){for(const t in L)if(t!=="default"){const i=Object.getOwnPropertyDescriptor(L,t);Object.defineProperty(e,t,i.get?i:{enumerable:!0,get:()=>L[t]})}}return e.default=L,Object.freeze(e)}const M=j(x),S=j(J),$=j(q);class D{constructor(e){this.junctionNames=new Map,this.projectName="",this.openDriveServer="",this.currentSectionCode="",this.currentJunctionId="",this.view=e,this.view.popup.visibleElements={collapseButton:!1,actionBar:!1},this.laneLayer=new C({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"},{name:"fromNode",alias:"起点路口",type:"string"},{name:"toNode",alias:"终点路口",type:"string"}],objectIdField:"ObjectID",geometryType:"polygon",spatialReference:{wkid:4326},source:[],outFields:["*"],renderer:{type:"unique-value",field:"type",defaultSymbol:{type:"simple-fill",color:[100,100,100],style:"solid",outline:{color:"white",width:1}},uniqueValueInfos:[{value:"shoulder",label:"路肩",symbol:{type:"simple-fill",color:"#008000",style:"solid",outline:{color:"white",width:1}}},{value:"border",label:"路沿",symbol:{type:"simple-fill",color:"#DCDCDC",style:"solid",outline:{color:"white",width:1}}},{value:"driving",label:"机动车道",symbol:{type:"simple-fill",color:[47,79,79,.8],style:"solid",outline:{color:"white",width:1}}},{value:"none",label:"无",symbol:{type:"simple-fill",color:[111,120,135],style:"none",outline:{color:"white",width:1}}},{value:"restricted",label:"禁行区",symbol:{type:"simple-fill",color:"yellow",style:"solid",outline:{color:"yellow",width:2}}},{value:"parking",label:"停车区",symbol:{type:"simple-fill",color:[115,115,115],style:"solid",outline:{color:"white",width:1}}},{value:"median",label:"中央隔离带",symbol:{type:"simple-fill",color:"#008000",style:"solid",outline:{color:"white",width:1}}},{value:"biking",label:"非机动车道",symbol:{type:"simple-fill",color:"#D3D3D3",style:"solid",outline:{color:"white",width:1}}},{value:"sidewalk",label:"人行道",symbol:{type:"simple-fill",color:"#C0C0C0",style:"solid",outline:{color:"white",width:1}}},{value:"junction",label:"路口区域",symbol:{type:"simple-fill",color:"#2F4F4F",style:"solid",outline:{color:"white",width:1}}},{value:"selected",label:"选中车道",symbol:{type:"simple-fill",color:[141,168,211],style:"solid",outline:{color:"white",width:1}}}]}}),this.roadNameLayer=new C({id:"OpenDriveRoadName",fields:[{name:"ObjectID",alias:"ObjectID",type:"oid"},{name:"roadId",alias:"道路号",type:"string"},{name:"roadName",alias:"道路名称",type:"string"}],objectIdField:"ObjectID",geometryType:"polyline",spatialReference:{wkid:4326},source:[],renderer:{type:"simple",symbol:{type:"simple-line",style:"solid",color:[0,0,0,0],width:1}},labelingInfo:[{symbol:{type:"text",color:"black",haloColor:"white",haloSize:1,font:{size:12,family:"sans-serif"}},labelPlacement:this.view.type==="2d"?"center-along":void 0,labelExpressionInfo:{expression:"$feature.roadName"}}]}),this.junctionLayer=new I({id:"OpenDriveJunction"}),this.sectionLayer=new I({id:"OpenDriveSection"}),this.highlightLayer=new I({id:"OpenDriveHighlight"}),this.flashLayer=new I({id:"OpenDriveFlash"}),this.drawLayer=new I({id:"Draw"}),this.splitLaneLayer=new I({id:"SplitLane"}),this.view.map.addMany([this.laneLayer,this.junctionLayer,this.sectionLayer,this.roadNameLayer,this.highlightLayer,this.flashLayer,this.drawLayer,this.splitLaneLayer])}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:T(i)}}catch(t){return{status:-1,message:t.message}}}async showOpenDriveFromFile(e){var g,p;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 b.post(i,{},{params:{url:e.file,projectName:this.projectName}})}catch(m){return{status:-1,message:m.message}}if(o.status!==200)return{status:-1,message:o.statusText};console.time("渲染用时");const s=o.data.result.geoSetting;_.default.setGeoData(s.geoReference,s.offsetX,s.offsetY);let c=o.data.result.json;c.startsWith(window.location.protocol)||(c=`${window.location.protocol}//${e.server}${c}`);const l=await(await fetch(c)).arrayBuffer(),n=F.inflate(l,{to:"string"}),r=JSON.parse(n);await this.showAllLanes(r,((g=e.options)==null?void 0:g.showJunctionLane)||!1,((p=e.options)==null?void 0:p.showRoadName)||!0);const d=o.data.result.junctions;this.showJunction(d),e.options&&e.options.centerMap!==!1&&await this.view.goTo(this.allLaneGraphics),this.mouseMoveHandler||this.monitorMouseMove(),this.mouseClickHandler||this.monitorMouseClick();const u=R.default.useAppDataStore;return E.watch(()=>u.isSketching,()=>{var m,h;u.isSketching?((m=this.mouseMoveHandler)==null||m.remove(),this.mouseMoveHandler=void 0,(h=this.mouseClickHandler)==null||h.remove(),this.mouseClickHandler=void 0):(this.monitorMouseMove(),this.monitorMouseClick())}),console.timeEnd("渲染用时"),{status:0,message:"ok"}}async showOpenDriveFromServer(e,t){const i=`http://${e}/api/openDrive/analyzeXodr`,o=await b.get(i,{headers:{projectName:t},params:{analyze:!1,compressed:!0}});if(o.status!==200)throw new Error(`OpenDriveRenderer: ${o.statusText}`);let s=o.data.result.json;s.startsWith(window.location.protocol)||(s=`${window.location.protocol}//${e}${s}`);const a=await(await fetch(s)).arrayBuffer(),l=F.inflate(a,{to:"string"}),n=JSON.parse(l);return await this.showAllLanes(n,!1,!1),{status:0,message:"ok"}}async showAllLanes(e,t,i){const o=await this.laneLayer.queryFeatures();return o.features.length>0&&this.laneLayer.applyEdits({deleteFeatures:o.features}),this.roadNameLayer.visible=i,new Promise(s=>{let c=0;this.allLaneGraphics=[],this.allRefLineGraphics=[];const a=[];console.log(e.length);for(const n of e){if(!t&&n.junction!=="-1")continue;const{id:r,refLine:d}=n;let u=n.name;u.includes("(")&&(u=u.slice(0,u.indexOf("("))),u=u.replace(/(.)/g,"$1 ");const g=new y({geometry:{type:"polyline",paths:[d]},attributes:{ObjectID:c++,roadId:r,roadName:u}});this.allRefLineGraphics.push(g),n.laneSections.sort((p,m)=>Number(p.id)-Number(m.id));for(let p=0;p<n.laneSections.length;p++){const m=n.laneSections[p],h=Number(m.id);for(const f of m.lanePaths){const w=Number(f.id);if(w===0)continue;const v=f.type,P=[...f.outerPath],N=f.innerPath.concat(P.reverse());if(N.length<=3){console.warn(`lane ${w} has less than 3 points`);continue}N.push(f.innerPath[0]);const k=new A.Polygon({rings:[N]});if(k){const G=new y({geometry:k,attributes:{ObjectID:c++,id:`${r}+${h}+${w}`,fromNode:n.fromNode,toNode:n.toNode,roadId:String(r),roadName:n.name,sectionId:String(h),sectionIndex:p,laneId:w,type:v,sumoId:"",leftLine:f.innerPath,rightLine:f.outerPath}});this.allLaneGraphics.push(G),a.push(G)}}}}const l=setInterval(()=>{if(a.length>0||this.allRefLineGraphics.length>0){if(a.length>0){const n=a.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(l),s()},10)})}showJunction(e){const t=[];for(const i of e){if(!i)continue;this.junctionNames.set(i.id,i.name),i.nodeType=i.type;const o=new y({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},popupTemplate:{title:i.name,content:[{type:"fields",fieldInfos:[{fieldName:"id",label:"路口编号"},{fieldName:"crossId",label:"信号机编号"}]}]}});t.push(o)}this.junctionLayer.addMany(t)}monitorMouseMove(){const e=M.debounce(async t=>{var c;const o=(c=(await this.view.hitTest(t,{include:[this.laneLayer,this.junctionLayer]})).results)==null?void 0:c.filter(a=>a.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 a=`${this.hitGraphic.getAttribute("roadId")}+${this.hitGraphic.getAttribute("sectionId")}`;if(a===this.currentSectionCode||this.sectionLayer.graphics.findIndex(h=>h.getAttribute("id")===a)>=0)return;this.currentSectionCode=a;const n=this.allLaneGraphics.filter(h=>`${h.attributes.roadId}+${h.attributes.sectionId}`===a),r=S.union(n.map(h=>h.geometry)),d=this.hitGraphic.getAttribute("fromNode"),u=this.hitGraphic.getAttribute("toNode"),g=this.junctionNames.get(d)||d,p=this.junctionNames.get(u)||u;this.highlightGraphic=new y({geometry:r,symbol:{type:"simple-fill",color:[0,255,255,.5],style:"solid",outline:{color:[0,255,255],width:1}},attributes:{type:"OpenDriveSection",id:a,selected:!1,fromNodeName:g,toNodeName:p,laneCount:n.length},popupTemplate:{title:this.hitGraphic.getAttribute("roadName"),content:[{type:"fields",fieldInfos:[{fieldName:"fromNodeName",label:"起点路口"},{fieldName:"toNodeName",label:"终点路口"},{fieldName:"laneCount",label:"车道数量"}]}]}}),this.highlightLayer.removeAll(),this.highlightLayer.add(this.highlightGraphic);const m=this.view.toMap(t);this.view.openPopup({features:[this.highlightGraphic],location:m})}else if(s.layer.id==="OpenDriveJunction"){const a=this.hitGraphic.getAttribute("id");if(a===this.currentJunctionId)return;this.currentJunctionId=a,this.view.openPopup({features:[this.hitGraphic],location:this.hitGraphic.geometry})}});this.mouseMoveHandler=this.view.on("pointer-move",async t=>{e(t).catch(()=>{})})}monitorMouseClick(){const e=M.debounce(async t=>{var l;const o=(l=(await this.view.hitTest(t,{include:[this.highlightLayer,this.junctionLayer,this.sectionLayer]})).results)==null?void 0:l.filter(n=>n.type==="graphic");if(o.length===0)return;const s=o[0].graphic,c=s.getAttribute("type"),a=s.getAttribute("id");if(c==="OpenDriveJunction")if(s.getAttribute("selected")===!1){const n=`http://${this.openDriveServer}/api/sumo/getSumoJunction`,r=await b.get(n,{params:{id:a,projectName:this.projectName}});r.status===200&&r.data.status===0&&(this.openDriveClickCallback&&this.openDriveClickCallback({type:"OpenDriveJunction",id:a,details:r.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:a,details:void 0}),s.setAttribute("selected",!1);const n=s.getAttribute("crossId");s.symbol.url=n?"/GisViewerAssets/Images/point_green.png":"/GisViewerAssets/Images/point_yellow.png",this.decreasePictureMarkerSize(s,30)}else if(c==="OpenDriveSection")if(s.getAttribute("selected"))this.sectionLayer.remove(s),this.openDriveClickCallback&&this.openDriveClickCallback({type:"OpenDriveSection",id:a,details:void 0});else{this.highlightLayer.remove(s),this.sectionLayer.add(s),s.setAttribute("selected",!0);const n=`http://${this.openDriveServer}/api/sumo/getSumoEdge`,r=await b.get(n,{params:{id:a,projectName:this.projectName}});r.status===200&&r.data.status===0&&this.openDriveClickCallback&&(s.setAttribute("edgeId",r.data.result.obj_id),this.openDriveClickCallback({type:"OpenDriveSection",id:a,details:r.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 b.get(t,{params:{id:e.id,projectName:this.projectName}});return i.status===200?i.data:{status:-1,message:`路口信息查询失败: ${e.id}`}}case"edge":{const t=e.id.split("#");let i=t[0];i.startsWith("-")&&(i=i.slice(1));let o=0;t.length===2&&(o=Number(t[1]));const s=this.allLaneGraphics.find(c=>c.getAttribute("roadId")===i&&c.getAttribute("sectionIndex")===o);if(s){const c=`${i}+${s.getAttribute("sectionId")}`,a=`http://${this.openDriveServer}/api/sumo/getSumoEdge`,l=await b.get(a,{params:{id:c,projectName:this.projectName}});return l.status===200?l.data:{status:-1,message:`路段信息查询失败: ${c}`}}else return{status:-1,message:"未知类型"}}default:return{status:-1,message:"未知类型"}}}async clearOpenDrive(){var t,i;let e=await this.laneLayer.queryFeatures();e.features.length>0&&await this.laneLayer.applyEdits({deleteFeatures:e.features}),e=await this.roadNameLayer.queryFeatures(),e.features.length>0&&await this.roadNameLayer.applyEdits({deleteFeatures:e.features}),this.highlightLayer.removeAll(),this.junctionLayer.removeAll(),this.sectionLayer.removeAll(),this.flashLayer.removeAll(),(t=this.mouseMoveHandler)==null||t.remove(),this.mouseMoveHandler=void 0,(i=this.mouseClickHandler)==null||i.remove(),this.mouseClickHandler=void 0}async findSumo(e){const{type:t,id:i}=e,o=e.flash===void 0?!0:e.flash;if(t==="junction")return await this.findJunction(i,o);if(t==="edge"){const s=i.split("_");if(s.length>2)return{status:-1,message:"id格式错误"};const c=s.length===2?Number(s[1]):void 0,a=s[0].split("#");if(a.length>2)return{status:-1,message:"id格式错误"};const l=a[0],n=a.length===2?Number(a[1]):void 0;return await this.findLane({roadsectId:l,segmentId:n,laneId:c,flash:o})}else return{status:-1,message:"未知类型"}}async findJunction(e,t){const i=this.junctionLayer.graphics.find(o=>o.attributes.id===e);if(!i)return{status:-1,message:"未找到。请检查路口编号"};if(t){const o=new y({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(l=>l.attributes.roadId===t);if(s.length===0)return{status:-1,message:"未找到。请检查路段编号"};if(i!==void 0){const l=[];if(s.forEach(n=>{const r=Number(n.attributes.sectionId);l.indexOf(r)===-1&&l.push(r)}),l.sort((n,r)=>n-r),i>l.length-1)return{status:-1,message:"未找到。请检查基本段编号"};i=l[i],s=s.filter(n=>Number(n.attributes.sectionId)===i)}if(o!==void 0){const l=[];if(s.forEach(n=>{const r=Number(n.attributes.laneId);l.indexOf(r)===-1&&l.push(r)}),l.sort((n,r)=>n-r),o>l.length-1)return{status:-1,message:"未找到。请检查车道编号"};o=l[o],s=s.filter(n=>Number(n.attributes.laneId)===o)}const c=s.map(l=>l.geometry),a=S.union(c);if(e.flash){const l=new y({geometry:a,symbol:{type:"simple-fill",color:[255,0,0,.5],style:"solid",outline:{color:"red",width:0}}});this.flashGraphic(l)}return await this.view.goTo(a,{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=String(t[0]);i.startsWith("-")&&(i=i.slice(1));let o="0";t.length===2&&(o=String(t[1]));let s=[];if(t.length===1?s=this.allLaneGraphics.filter(c=>c.getAttribute("roadId")===i):t.length===2&&(s=this.allLaneGraphics.filter(c=>c.getAttribute("roadId")===i&&c.getAttribute("sectionId")===o)),s.length>0){const c=S.union(s.map(l=>l.geometry)),a=new y({geometry:c,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(a),{status:0,message:"ok"}}else return{status:-1,message:"未找到路段"}}default:return{status:-1,message:"未知类型"}}}async geometrySearch(e){const t=new A.Polygon({rings:[e]}),i=await this.laneLayer.queryFeatures({geometry:t,outFields:["*"]}),o=[],s=[];for(const l of i.features){const n=l.getAttribute("roadId"),r=l.getAttribute("sectionId"),d=`${n}#${r}`;if(o.indexOf(d)===-1){o.push(d),this.selectSumo({type:"edge",id:d});const u=`http://${this.openDriveServer}/api/sumo/getSumoEdge`,g=await b.get(u,{params:{id:`${n}+${r}`,projectName:this.projectName}});g.status===200&&g.data.status===0&&s.push(g.data.result)}}const c=this.junctionLayer.graphics.filter(l=>{const n=l.geometry;return S.contains(t,n)}),a=[];for(const l of c){const n=l.getAttribute("id");this.selectSumo({type:"junction",id:n});const r=`http://${this.openDriveServer}/api/sumo/getSumoJunction`,d=await b.get(r,{params:{id:n,projectName:this.projectName}});d.status===200&&d.data.status===0&&a.push(d.data.result)}return{status:0,message:"ok",result:{junctions:a,edges:s}}}async splitLane(e){const i=e.id.split("_");if(i.length!==2)return{status:-1,message:"车道编号格式错误"};const o=Number(i[1]),s=i[0].split("#"),c=s.length===2?Number(s[1]):0;let a=s[0];a.startsWith("-")&&(a=a.slice(1));const l=this.allLaneGraphics.filter(v=>v.getAttribute("roadId")===a&&v.getAttribute("sectionIndex")===c);if(l.length===0)return{status:-1,message:"未找到路段"};const n=l.length-o,r=l.find(v=>Math.abs(v.getAttribute("laneId"))===n);if(!r)return{status:-1,message:"未找到车道"};const d=e.start||0,u=e.end||100,g=$.lineString(r.getAttribute("leftLine")),p=O.lineSliceAlong(g,d,u,{units:"meters"}),m=$.lineString(r.getAttribute("rightLine")),h=O.lineSliceAlong(m,d,u,{units:"meters"}),f=p.geometry.coordinates.concat(h.geometry.coordinates.reverse());f.push(f[f.length-1]);const w=new y({geometry:new A.Polygon({rings:[f]}),attributes:{ObjectID:r.getAttribute("ObjectID"),id:r.getAttribute("id"),fromNode:r.getAttribute("fromNode"),toNode:r.getAttribute("toNode"),roadId:r.getAttribute("roadId"),roadName:r.getAttribute("roadName"),sectionId:r.getAttribute("sectionId"),sectionIndex:r.getAttribute("sectionIndex"),laneId:r.getAttribute("laneId"),type:r.getAttribute("type"),sumoId:r.getAttribute("sumoId"),leftLine:p.geometry.coordinates,rightLine:h.geometry.coordinates},symbol:{type:"simple-fill",color:[255,0,0,.8],outline:{color:"red"}}});return this.splitLaneLayer.add(w),this.view.goTo(w),{status:0,message:"ok",result:e}}clearSplitLane(){this.splitLaneLayer.removeAll()}}exports.default=D;
|
|
1
|
+
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const y=require("@arcgis/core/Graphic"),x=require("@arcgis/core/core/promiseUtils"),A=require("@arcgis/core/geometry"),J=require("@arcgis/core/geometry/geometryEngine"),C=require("@arcgis/core/layers/FeatureLayer"),I=require("@arcgis/core/layers/GraphicsLayer"),q=require("@turf/helpers"),O=require("@turf/line-slice-along"),b=require("axios"),T=require("md5"),F=require("pako"),E=require("vue"),R=require("../../stores/index.js"),_=require("../common-utils.js");function j(L){const e=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(L){for(const t in L)if(t!=="default"){const i=Object.getOwnPropertyDescriptor(L,t);Object.defineProperty(e,t,i.get?i:{enumerable:!0,get:()=>L[t]})}}return e.default=L,Object.freeze(e)}const M=j(x),S=j(J),$=j(q);class D{constructor(e){this.junctionNames=new Map,this.projectName="",this.openDriveServer="",this.currentSectionCode="",this.currentJunctionId="",this.view=e,this.view.popup.visibleElements={collapseButton:!1,actionBar:!1},this.laneLayer=new C({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"},{name:"fromNode",alias:"起点路口",type:"string"},{name:"toNode",alias:"终点路口",type:"string"}],objectIdField:"ObjectID",geometryType:"polygon",spatialReference:{wkid:4326},source:[],outFields:["*"],renderer:{type:"unique-value",field:"type",defaultSymbol:{type:"simple-fill",color:[100,100,100],style:"solid",outline:{color:"white",width:1}},uniqueValueInfos:[{value:"shoulder",label:"路肩",symbol:{type:"simple-fill",color:"#008000",style:"solid",outline:{color:"white",width:1}}},{value:"border",label:"路沿",symbol:{type:"simple-fill",color:"#DCDCDC",style:"solid",outline:{color:"white",width:1}}},{value:"driving",label:"机动车道",symbol:{type:"simple-fill",color:[47,79,79,.8],style:"solid",outline:{color:"white",width:1}}},{value:"none",label:"无",symbol:{type:"simple-fill",color:[111,120,135],style:"none",outline:{color:"white",width:1}}},{value:"restricted",label:"禁行区",symbol:{type:"simple-fill",color:"yellow",style:"solid",outline:{color:"yellow",width:2}}},{value:"parking",label:"停车区",symbol:{type:"simple-fill",color:[115,115,115],style:"solid",outline:{color:"white",width:1}}},{value:"median",label:"中央隔离带",symbol:{type:"simple-fill",color:"#008000",style:"solid",outline:{color:"white",width:1}}},{value:"biking",label:"非机动车道",symbol:{type:"simple-fill",color:"#D3D3D3",style:"solid",outline:{color:"white",width:1}}},{value:"sidewalk",label:"人行道",symbol:{type:"simple-fill",color:"#C0C0C0",style:"solid",outline:{color:"white",width:1}}},{value:"junction",label:"路口区域",symbol:{type:"simple-fill",color:"#2F4F4F",style:"solid",outline:{color:"white",width:1}}},{value:"selected",label:"选中车道",symbol:{type:"simple-fill",color:[141,168,211],style:"solid",outline:{color:"white",width:1}}}]}}),this.roadNameLayer=new C({id:"OpenDriveRoadName",fields:[{name:"ObjectID",alias:"ObjectID",type:"oid"},{name:"roadId",alias:"道路号",type:"string"},{name:"roadName",alias:"道路名称",type:"string"}],objectIdField:"ObjectID",geometryType:"polyline",spatialReference:{wkid:4326},source:[],renderer:{type:"simple",symbol:{type:"simple-line",style:"solid",color:[0,0,0,0],width:1}},labelingInfo:[{symbol:{type:"text",color:"black",haloColor:"white",haloSize:1,font:{size:12,family:"sans-serif"}},labelPlacement:this.view.type==="2d"?"center-along":void 0,labelExpressionInfo:{expression:"$feature.roadName"}}]}),this.junctionLayer=new I({id:"OpenDriveJunction"}),this.sectionLayer=new I({id:"OpenDriveSection"}),this.highlightLayer=new I({id:"OpenDriveHighlight"}),this.flashLayer=new I({id:"OpenDriveFlash"}),this.drawLayer=new I({id:"Draw"}),this.splitLaneLayer=new I({id:"SplitLane"}),this.view.map.addMany([this.laneLayer,this.junctionLayer,this.sectionLayer,this.roadNameLayer,this.highlightLayer,this.flashLayer,this.drawLayer,this.splitLaneLayer])}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:T(i)}}catch(t){return{status:-1,message:t.message}}}async showOpenDriveFromFile(e){var m,p;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 b.post(i,{},{params:{url:e.file,projectName:this.projectName}})}catch(g){return{status:-1,message:g.message}}if(o.status!==200)return{status:-1,message:o.statusText};console.time("渲染用时");const s=o.data.result.geoSetting;_.default.setGeoData(s.geoReference,s.offsetX,s.offsetY);let c=o.data.result.json;c.startsWith(window.location.protocol)||(c=`${window.location.protocol}//${e.server}${c}`);const a=await(await fetch(c)).arrayBuffer(),n=F.inflate(a,{to:"string"}),r=JSON.parse(n);await this.showAllLanes(r,((m=e.options)==null?void 0:m.showJunctionLane)||!1,((p=e.options)==null?void 0:p.showRoadName)||!0);const u=o.data.result.junctions;this.showJunction(u),e.options&&e.options.centerMap!==!1&&await this.view.goTo(this.allLaneGraphics),this.mouseMoveHandler||this.monitorMouseMove(),this.mouseClickHandler||this.monitorMouseClick();const d=R.default.useAppDataStore;return E.watch(()=>d.isSketching,()=>{var g,h;d.isSketching?((g=this.mouseMoveHandler)==null||g.remove(),this.mouseMoveHandler=void 0,(h=this.mouseClickHandler)==null||h.remove(),this.mouseClickHandler=void 0):(this.monitorMouseMove(),this.monitorMouseClick())}),console.timeEnd("渲染用时"),{status:0,message:"ok"}}async showOpenDriveFromServer(e,t){const i=`http://${e}/api/openDrive/analyzeXodr`,o=await b.get(i,{headers:{projectName:t},params:{analyze:!1,compressed:!0}});if(o.status!==200)throw new Error(`OpenDriveRenderer: ${o.statusText}`);let s=o.data.result.json;s.startsWith(window.location.protocol)||(s=`${window.location.protocol}//${e}${s}`);const l=await(await fetch(s)).arrayBuffer(),a=F.inflate(l,{to:"string"}),n=JSON.parse(a);return await this.showAllLanes(n,!1,!1),{status:0,message:"ok"}}async showAllLanes(e,t,i){const o=await this.laneLayer.queryFeatures();return o.features.length>0&&this.laneLayer.applyEdits({deleteFeatures:o.features}),this.roadNameLayer.visible=i,new Promise(s=>{let c=0;this.allLaneGraphics=[],this.allRefLineGraphics=[];const l=[];console.log(e.length);for(const n of e){if(!t&&n.junction!=="-1")continue;const{id:r,refLine:u}=n;let d=n.name;d.includes("(")&&(d=d.slice(0,d.indexOf("("))),d=d.replace(/(.)/g,"$1 ");const m=new y({geometry:{type:"polyline",paths:[u]},attributes:{ObjectID:c++,roadId:r,roadName:d}});this.allRefLineGraphics.push(m),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],h=Number(g.id);for(const f of g.lanePaths){const w=Number(f.id);if(w===0)continue;const v=f.type,P=[...f.outerPath],N=f.innerPath.concat(P.reverse());if(N.length<=3){console.warn(`lane ${w} has less than 3 points`);continue}N.push(f.innerPath[0]);const k=new A.Polygon({rings:[N]});if(k){const G=new y({geometry:k,attributes:{ObjectID:c++,id:`${r}+${h}+${w}`,fromNode:n.fromNode,toNode:n.toNode,roadId:String(r),roadName:n.name,sectionId:String(h),sectionIndex:p,laneId:w,type:v,sumoId:"",leftLine:f.innerPath,rightLine:f.outerPath}});this.allLaneGraphics.push(G),l.push(G)}}}}const a=setInterval(()=>{if(l.length>0||this.allRefLineGraphics.length>0){if(l.length>0){const n=l.splice(0,100);this.laneLayer.applyEdits({addFeatures:n})}if(this.allRefLineGraphics.length>0){const n=this.allRefLineGraphics.splice(0,10);this.roadNameLayer.applyEdits({addFeatures:n})}}else clearInterval(a),s()},10)})}showJunction(e){const t=[];for(const i of e){if(!i)continue;this.junctionNames.set(i.id,i.name),i.nodeType=i.type;const o=new y({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},popupTemplate:{title:i.name,content:[{type:"fields",fieldInfos:[{fieldName:"id",label:"路口编号"},{fieldName:"crossId",label:"信号机编号"}]}]}});t.push(o)}this.junctionLayer.addMany(t)}monitorMouseMove(){const e=M.debounce(async t=>{var c;const o=(c=(await this.view.hitTest(t,{include:[this.laneLayer,this.junctionLayer]})).results)==null?void 0:c.filter(l=>l.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 l=`${this.hitGraphic.getAttribute("roadId")}+${this.hitGraphic.getAttribute("sectionId")}`;if(l===this.currentSectionCode||this.sectionLayer.graphics.findIndex(h=>h.getAttribute("id")===l)>=0)return;this.currentSectionCode=l;const n=this.allLaneGraphics.filter(h=>`${h.attributes.roadId}+${h.attributes.sectionId}`===l),r=S.union(n.map(h=>h.geometry)),u=this.hitGraphic.getAttribute("fromNode"),d=this.hitGraphic.getAttribute("toNode"),m=this.junctionNames.get(u)||u,p=this.junctionNames.get(d)||d;this.highlightGraphic=new y({geometry:r,symbol:{type:"simple-fill",color:[0,255,255,.5],style:"solid",outline:{color:[0,255,255],width:1}},attributes:{type:"OpenDriveSection",id:l,selected:!1,fromNodeName:m,toNodeName:p,laneCount:n.length},popupTemplate:{title:this.hitGraphic.getAttribute("roadName"),content:[{type:"fields",fieldInfos:[{fieldName:"fromNodeName",label:"起点路口"},{fieldName:"toNodeName",label:"终点路口"},{fieldName:"laneCount",label:"车道数量"}]}]}}),this.highlightLayer.removeAll(),this.highlightLayer.add(this.highlightGraphic);const g=this.view.toMap(t);this.view.openPopup({features:[this.highlightGraphic],location:g})}else if(s.layer.id==="OpenDriveJunction"){const l=this.hitGraphic.getAttribute("id");if(l===this.currentJunctionId)return;this.currentJunctionId=l,this.view.openPopup({features:[this.hitGraphic],location:this.hitGraphic.geometry})}});this.mouseMoveHandler=this.view.on("pointer-move",async t=>{e(t).catch(()=>{})})}monitorMouseClick(){const e=M.debounce(async t=>{var a;const o=(a=(await this.view.hitTest(t,{include:[this.highlightLayer,this.junctionLayer,this.sectionLayer]})).results)==null?void 0:a.filter(n=>n.type==="graphic");if(o.length===0)return;const s=o[0].graphic,c=s.getAttribute("type"),l=s.getAttribute("id");if(c==="OpenDriveJunction")if(s.getAttribute("selected")===!1){const n=`http://${this.openDriveServer}/api/sumo/getSumoJunction`,r=await b.get(n,{params:{id:l,projectName:this.projectName}});r.status===200&&r.data.status===0&&(this.openDriveClickCallback&&this.openDriveClickCallback({type:"OpenDriveJunction",id:l,details:r.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:l,details:void 0}),s.setAttribute("selected",!1);const n=s.getAttribute("crossId");s.symbol.url=n?"/GisViewerAssets/Images/point_green.png":"/GisViewerAssets/Images/point_yellow.png",this.decreasePictureMarkerSize(s,30)}else if(c==="OpenDriveSection")if(s.getAttribute("selected"))this.sectionLayer.remove(s),this.openDriveClickCallback&&this.openDriveClickCallback({type:"OpenDriveSection",id:s.getAttribute("edgeId"),details:void 0});else{this.highlightLayer.remove(s),this.sectionLayer.add(s),s.setAttribute("selected",!0);const n=`http://${this.openDriveServer}/api/sumo/getSumoEdge`,r=await b.get(n,{params:{id:l,projectName:this.projectName}});if(r.status===200&&r.data.status===0&&this.openDriveClickCallback){const u=r.data.result.obj_id;s.setAttribute("edgeId",u),this.openDriveClickCallback({type:"OpenDriveSection",id:u,details:r.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 b.get(t,{params:{id:e.id,projectName:this.projectName}});return i.status===200?i.data:{status:-1,message:`路口信息查询失败: ${e.id}`}}case"edge":{const t=e.id.split("#");let i=t[0];i.startsWith("-")&&(i=i.slice(1));let o=0;t.length===2&&(o=Number(t[1]));const s=this.allLaneGraphics.find(c=>c.getAttribute("roadId")===i&&c.getAttribute("sectionIndex")===o);if(s){const c=`${i}+${s.getAttribute("sectionId")}`,l=`http://${this.openDriveServer}/api/sumo/getSumoEdge`,a=await b.get(l,{params:{id:c,projectName:this.projectName}});return a.status===200?a.data:{status:-1,message:`路段信息查询失败: ${c}`}}else return{status:-1,message:"未知类型"}}default:return{status:-1,message:"未知类型"}}}async clearOpenDrive(){var t,i;let e=await this.laneLayer.queryFeatures();e.features.length>0&&await this.laneLayer.applyEdits({deleteFeatures:e.features}),e=await this.roadNameLayer.queryFeatures(),e.features.length>0&&await this.roadNameLayer.applyEdits({deleteFeatures:e.features}),this.highlightLayer.removeAll(),this.junctionLayer.removeAll(),this.sectionLayer.removeAll(),this.flashLayer.removeAll(),(t=this.mouseMoveHandler)==null||t.remove(),this.mouseMoveHandler=void 0,(i=this.mouseClickHandler)==null||i.remove(),this.mouseClickHandler=void 0}async findSumo(e){const{type:t,id:i}=e,o=e.flash===void 0?!0:e.flash;if(t==="junction")return await this.findJunction(i,o);if(t==="edge"){const s=i.split("_");if(s.length>2)return{status:-1,message:"id格式错误"};const c=s.length===2?Number(s[1]):void 0,l=s[0].split("#");if(l.length>2)return{status:-1,message:"id格式错误"};const a=l[0],n=l.length===2?Number(l[1]):void 0;return await this.findLane({roadsectId:a,segmentId:n,laneId:c,flash:o})}else return{status:-1,message:"未知类型"}}async findJunction(e,t){const i=this.junctionLayer.graphics.find(o=>o.attributes.id===e);if(!i)return{status:-1,message:"未找到。请检查路口编号"};if(t){const o=new y({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(n=>{const r=Number(n.attributes.sectionId);a.indexOf(r)===-1&&a.push(r)}),a.sort((n,r)=>n-r),i>a.length-1)return{status:-1,message:"未找到。请检查基本段编号"};i=a[i],s=s.filter(n=>Number(n.attributes.sectionId)===i)}if(o!==void 0){const a=[];if(s.forEach(n=>{const r=Number(n.attributes.laneId);a.indexOf(r)===-1&&a.push(r)}),a.sort((n,r)=>n-r),o>a.length-1)return{status:-1,message:"未找到。请检查车道编号"};o=a[o],s=s.filter(n=>Number(n.attributes.laneId)===o)}const c=s.map(a=>a.geometry),l=S.union(c);if(e.flash){const a=new y({geometry:l,symbol:{type:"simple-fill",color:[255,0,0,.5],style:"solid",outline:{color:"red",width:0}}});this.flashGraphic(a)}return await this.view.goTo(l,{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=String(t[0]);i.startsWith("-")&&(i=i.slice(1));let o="0";t.length===2&&(o=String(t[1]));let s=[];if(t.length===1?s=this.allLaneGraphics.filter(c=>c.getAttribute("roadId")===i):t.length===2&&(s=this.allLaneGraphics.filter(c=>c.getAttribute("roadId")===i&&c.getAttribute("sectionId")===o)),s.length>0){const c=S.union(s.map(a=>a.geometry)),l=new y({geometry:c,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(l),{status:0,message:"ok"}}else return{status:-1,message:"未找到路段"}}default:return{status:-1,message:"未知类型"}}}async geometrySearch(e){const t=new A.Polygon({rings:[e]}),i=await this.laneLayer.queryFeatures({geometry:t,outFields:["*"]}),o=[],s=[];for(const a of i.features){const n=a.getAttribute("roadId"),r=a.getAttribute("sectionId"),u=`${n}#${r}`;if(o.indexOf(u)===-1){o.push(u),this.selectSumo({type:"edge",id:u});const d=`http://${this.openDriveServer}/api/sumo/getSumoEdge`,m=await b.get(d,{params:{id:`${n}+${r}`,projectName:this.projectName}});m.status===200&&m.data.status===0&&s.push(m.data.result)}}const c=this.junctionLayer.graphics.filter(a=>{const n=a.geometry;return S.contains(t,n)}),l=[];for(const a of c){const n=a.getAttribute("id");this.selectSumo({type:"junction",id:n});const r=`http://${this.openDriveServer}/api/sumo/getSumoJunction`,u=await b.get(r,{params:{id:n,projectName:this.projectName}});u.status===200&&u.data.status===0&&l.push(u.data.result)}return{status:0,message:"ok",result:{junctions:l,edges:s}}}async splitLane(e){const i=e.id.split("_");if(i.length!==2)return{status:-1,message:"车道编号格式错误"};const o=Number(i[1]),s=i[0].split("#"),c=s.length===2?Number(s[1]):0;let l=s[0];l.startsWith("-")&&(l=l.slice(1));const a=this.allLaneGraphics.filter(v=>v.getAttribute("roadId")===l&&v.getAttribute("sectionIndex")===c);if(a.length===0)return{status:-1,message:"未找到路段"};const n=a.length-o,r=a.find(v=>Math.abs(v.getAttribute("laneId"))===n);if(!r)return{status:-1,message:"未找到车道"};const u=e.start||0,d=e.end||100,m=$.lineString(r.getAttribute("leftLine")),p=O.lineSliceAlong(m,u,d,{units:"meters"}),g=$.lineString(r.getAttribute("rightLine")),h=O.lineSliceAlong(g,u,d,{units:"meters"}),f=p.geometry.coordinates.concat(h.geometry.coordinates.reverse());f.push(f[f.length-1]);const w=new y({geometry:new A.Polygon({rings:[f]}),attributes:{ObjectID:r.getAttribute("ObjectID"),id:r.getAttribute("id"),fromNode:r.getAttribute("fromNode"),toNode:r.getAttribute("toNode"),roadId:r.getAttribute("roadId"),roadName:r.getAttribute("roadName"),sectionId:r.getAttribute("sectionId"),sectionIndex:r.getAttribute("sectionIndex"),laneId:r.getAttribute("laneId"),type:r.getAttribute("type"),sumoId:r.getAttribute("sumoId"),leftLine:p.geometry.coordinates,rightLine:h.geometry.coordinates},symbol:{type:"simple-fill",color:[255,0,0,.8],outline:{color:"red"}}});return this.splitLaneLayer.add(w),this.view.goTo(w),{status:0,message:"ok",result:e}}clearSplitLane(){this.splitLaneLayer.removeAll()}}exports.default=D;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const b=require("@arcgis/core/core/reactiveUtils.js"),y=require("@arcgis/core/Graphic"),l=require("@arcgis/core/layers/GraphicsLayer"),f=require("@turf/buffer"),L=require("@turf/concave"),m=require("@turf/convex"),v=require("@turf/helpers"),C=require("./district-controller.js");function
|
|
1
|
+
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const b=require("@arcgis/core/core/reactiveUtils.js"),y=require("@arcgis/core/Graphic"),l=require("@arcgis/core/layers/GraphicsLayer"),f=require("@turf/buffer"),L=require("@turf/concave"),m=require("@turf/convex"),v=require("@turf/helpers"),C=require("./district-controller.js");function g(a){const e=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(a){for(const t in a)if(t!=="default"){const r=Object.getOwnPropertyDescriptor(a,t);Object.defineProperty(e,t,r.get?r:{enumerable:!0,get:()=>a[t]})}}return e.default=a,Object.freeze(e)}const w=g(b),c=g(v);class A{constructor(e){this.crossScale=3e3,this.view=e,this.view.popup.visibleElements={closeButton:!0,collapseButton:!1,actionBar:!0},this.districtControllerLayer=new l({id:"districtControllerLayer",maxScale:144447,minScale:1155582}),this.subDistrictControllerLayer=new l({id:"subDistrictControllerLayer",maxScale:0,minScale:144447}),this.crossLayer=new l({id:"crossLayer",maxScale:0,minScale:36112}),this.highlightLayer=new l({id:"highlightLayer"}),this.view.map.addMany([this.districtControllerLayer,this.subDistrictControllerLayer,this.crossLayer,this.highlightLayer])}showSignalControlArea(e){this.districtControllerLayer.removeAll(),this.subDistrictControllerLayer.removeAll(),this.crossLayer.removeAll(),this.highlightLayer.removeAll(),this.districtControllerLayer.visible=!0,this.subDistrictControllerLayer.visible=!0;for(const t of e){const r=new C.default(t);this.drawArea(r,!0)}return this.watchHandle=w.watch(()=>this.view.scale,(t,r)=>{t>this.crossScale&&r<=this.crossScale?(this.crossLayer.graphics.forEach(s=>{s.symbol=this.getCrossGraphicSymbol(s.attributes,"marker")}),this.highlightLayer.graphics.forEach(s=>{s.getAttribute("type")==="cross"&&(s.symbol=this.getCrossGraphicSymbol(s.attributes,"marker"))})):t<=this.crossScale&&r>this.crossScale&&(this.crossLayer.graphics.forEach(s=>{s.symbol=this.getCrossGraphicSymbol(s.attributes,"picture")}),this.highlightLayer.graphics.forEach(s=>{s.getAttribute("type")==="cross"&&(s.symbol=this.getCrossGraphicSymbol(s.attributes,"picture"))}))}),{status:0,message:"ok"}}clearSignalControlArea(){var e;return this.districtControllerLayer.removeAll(),this.subDistrictControllerLayer.removeAll(),this.crossLayer.removeAll(),this.highlightLayer.removeAll(),(e=this.watchHandle)==null||e.remove(),this.view.closePopup(),{status:0,message:"ok"}}async locateSignalControlArea(e){const t=this.findAreaGraphic(e.id);return t?(t.attributes.type==="cross"?await this.view.goTo({target:t.geometry,scale:1500}):await this.view.goTo(t.geometry),{status:0,message:"ok"}):{status:1,message:"未找到"}}showPopup(e){const t=e.geometry.type==="point"?e.geometry:e.geometry.centroid;this.view.openPopup({features:[e],location:t})}async highlightSignalControlArea(e){this.highlightLayer.removeAll(),this.districtControllerLayer.visible=!1,this.subDistrictControllerLayer.visible=!1,this.crossLayer.visible=!1;const t=this.districtControllerLayer.graphics.filter(i=>i.getAttribute("id")===e.id).toArray().map(i=>i.clone()),r=this.subDistrictControllerLayer.graphics.filter(i=>i.getAttribute("id")===e.id||i.getAttribute("parentId")===e.id).toArray().map(i=>i.clone()),s=this.crossLayer.graphics.filter(i=>i.getAttribute("id")===e.id||i.getAttribute("districtId")===e.id||i.getAttribute("subDistrictId")===e.id).toArray().map(i=>i.clone());return t.length>0&&this.highlightLayer.addMany(t),r.length>0&&this.highlightLayer.addMany(r),s.length>0&&this.highlightLayer.addMany(s),this.highlightLayer.graphics.length===0?{status:1,message:"未找到"}:(t.length>0?await this.view.goTo(t):r.length>0?await this.view.goTo(r):s.length>1?await this.view.goTo(s):await this.view.goTo({target:s[0].geometry,scale:1500}),{status:0,message:"ok"})}resetHighlight(){return this.highlightLayer.removeAll(),this.view.closePopup(),this.districtControllerLayer.visible=!0,this.subDistrictControllerLayer.visible=!0,this.crossLayer.visible=!0,{status:0,message:"ok"}}findAreaGraphic(e){let t=this.districtControllerLayer.graphics.find(r=>r.attributes.id===e);return t||(t=this.subDistrictControllerLayer.graphics.find(r=>r.attributes.id===e)),t||(t=this.crossLayer.graphics.find(r=>r.attributes.id===e)),t}drawArea(e,t){const r=e.getAllCrossCoordinates();if(r.length>=2){let i=null;if(r.length===2)i=c.lineString(r);else if(r.length>2){const h=c.featureCollection(r.map(d=>c.point(d)));t?i=m(h):(i=L(h,{maxEdge:400,units:"meters"}),i||(i=m(h)))}if(!i){console.log("生成区控面失败",e);return}const o=f(i.geometry,t?200:30,{units:"meters"});let n;t?n=[{fieldName:"id",label:"区控编号"},{fieldName:"crossCount",label:"路口数量"},{fieldName:"subDistrictCount",label:"子区数量"}]:n=[{fieldName:"parentName",label:"所属区控"},{fieldName:"crossCount",label:"路口数量"}];const p={type:"signalControlArea",id:e.id,name:e.name,parentId:e.parentId,parentName:e.parentName,crossCount:e.crossCount,subDistrictCount:e.subDistrictCount},u=new y({geometry:{type:"polygon",rings:o.geometry.coordinates},symbol:{type:"simple-fill",color:[...e.areaColor,t?.6:.8],outline:{color:e.areaColor,width:2,style:t?"solid":"long-dash"}},attributes:p,popupTemplate:{title:`${t?"区控":"子区"} ${e.name}`,content:[{type:"fields",fieldInfos:n}]}});t?this.districtControllerLayer.add(u):this.subDistrictControllerLayer.add(u)}for(const i of e.subDistricts)this.drawArea(i,!1);const s=e.crosses.map(i=>{const o={type:"cross",id:i.id,name:i.name,color:e.areaColor,signalId:i.signalId,districtId:t?e.id:e.parentId,districtName:t?e.name:e.parentName,subDistrictId:t?"":e.id,subDistrictName:t?"":e.name,isKey:i.isKey};return new y({geometry:{type:"point",x:i.longitude,y:i.latitude},symbol:this.getCrossGraphicSymbol(o,"marker"),attributes:o,popupTemplate:{title:i.name,content:[{type:"fields",fieldInfos:[{fieldName:"districtName",label:"区控名称"},{fieldName:"subDistrictName",label:"子区名称"},{fieldName:"id",label:"路口编号"},{fieldName:"signalId",label:"信号机编号"}]}]}})});this.crossLayer.addMany(s)}getCrossGraphicSymbol(e,t){const{isKey:r,color:s}=e;if(t==="marker")return r?{type:"picture-marker",url:"/GisViewerAssets/Images/icon_star.png",width:"30px",height:"30px"}:{type:"simple-marker",style:"circle",color:s,size:8,outline:{color:"white",width:1}};if(t==="picture")return{type:"cim",data:{type:"CIMSymbolReference",primitiveOverrides:[{type:"CIMPrimitiveOverride",primitiveName:"textGraphic",propertyName:"TextString",valueExpressionInfo:{type:"CIMExpressionInfo",title:"Custom",expression:'Replace($feature.name, "与", "/") + " " + $feature.signalId',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:r?30:22,haloSize:1,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:r?45:30,rotateClockwise:!0,textureFilter:"Picture",url:`/GisViewerAssets/Images/xhj_${r?4:1}.png`}]}}}}}exports.default=A;
|