gisviewer-vue3-arcgis 1.0.155 → 1.0.156
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/gis-map.vue.d.ts +1 -1
- package/es/src/gis-map/gis-map.vue.mjs +1 -1
- package/es/src/gis-map/index.d.ts +1 -1
- package/es/src/gis-map/utils/open-drive-renderer/index.mjs +33 -33
- package/es/src/gis-map/utils/signal-control-area-controller/index.d.ts +8 -4
- package/es/src/gis-map/utils/signal-control-area-controller/index.mjs +216 -137
- package/lib/src/gis-map/gis-map.vue.d.ts +1 -1
- package/lib/src/gis-map/gis-map.vue.js +1 -1
- package/lib/src/gis-map/index.d.ts +1 -1
- package/lib/src/gis-map/utils/open-drive-renderer/index.js +1 -1
- package/lib/src/gis-map/utils/signal-control-area-controller/index.d.ts +8 -4
- package/lib/src/gis-map/utils/signal-control-area-controller/index.js +1 -1
- package/package.json +1 -1
|
@@ -84,7 +84,7 @@ declare const _sfc_main: import("vue").DefineComponent<{
|
|
|
84
84
|
status: number;
|
|
85
85
|
message: string;
|
|
86
86
|
}>;
|
|
87
|
-
showSignalControlArea: (params: any) => import("../types").IResult
|
|
87
|
+
showSignalControlArea: (params: any) => Promise<import("../types").IResult>;
|
|
88
88
|
clearSignalControlArea: () => void;
|
|
89
89
|
locateSignalControlArea: (params: {
|
|
90
90
|
id: string;
|
|
@@ -104,7 +104,7 @@ const Ee = { class: "gis-viewer" }, Fe = { style: { position: "absolute", bottom
|
|
|
104
104
|
}, ye = async () => t ? t == null ? void 0 : t.clearSplitLane() : {
|
|
105
105
|
status: -1,
|
|
106
106
|
message: "未加载OpenDrive地图"
|
|
107
|
-
}, he = (e) => (o || (o = new je(s)), o.showSignalControlArea(e)), Se = () => {
|
|
107
|
+
}, he = async (e) => (o || (o = new je(s)), await o.showSignalControlArea(e)), Se = () => {
|
|
108
108
|
o == null || o.clearSignalControlArea();
|
|
109
109
|
}, Oe = async (e) => o ? await o.locateSignalControlArea(e) : { status: -1, message: "未加载信号控制区" }, Ce = async (e) => o ? await o.highlightSignalControlArea(e) : { status: -1, message: "未加载信号控制区" }, ke = () => o ? o.resetHighlight() : { status: -1, message: "未加载信号控制区" }, y = D, w = A;
|
|
110
110
|
return L({
|
|
@@ -73,7 +73,7 @@ export declare const GisMap: import("@easyest/utils/dist/lib/withinstall").SFCWi
|
|
|
73
73
|
status: number;
|
|
74
74
|
message: string;
|
|
75
75
|
}>;
|
|
76
|
-
showSignalControlArea: (params: any) => import("../types").IResult
|
|
76
|
+
showSignalControlArea: (params: any) => Promise<import("../types").IResult>;
|
|
77
77
|
clearSignalControlArea: () => void;
|
|
78
78
|
locateSignalControlArea: (params: {
|
|
79
79
|
id: string;
|
|
@@ -7,13 +7,13 @@ import I from "@arcgis/core/layers/GraphicsLayer";
|
|
|
7
7
|
import * as G from "@turf/helpers";
|
|
8
8
|
import { lineSliceAlong as C } from "@turf/line-slice-along";
|
|
9
9
|
import b from "axios";
|
|
10
|
-
import { XMLParser as
|
|
10
|
+
import { XMLParser as $ } from "fast-xml-parser";
|
|
11
11
|
import F from "md5";
|
|
12
12
|
import O from "pako";
|
|
13
13
|
import { watch as P } from "vue";
|
|
14
14
|
import J from "../../stores/index.mjs";
|
|
15
15
|
import E from "../common-utils.mjs";
|
|
16
|
-
class
|
|
16
|
+
class x {
|
|
17
17
|
constructor(e) {
|
|
18
18
|
this.junctionNames = /* @__PURE__ */ new Map(), this.projectName = "", this.openDriveServer = "", this.currentSectionCode = "", this.selectedSectionIds = [], this.currentJunctionId = "", this.view = e, this.laneLayer = new k({
|
|
19
19
|
id: "OpenDriveLane",
|
|
@@ -301,12 +301,12 @@ class M {
|
|
|
301
301
|
]);
|
|
302
302
|
}
|
|
303
303
|
static getInstance(e) {
|
|
304
|
-
return this.instance || (this.instance = new
|
|
304
|
+
return this.instance || (this.instance = new x(e)), this.instance;
|
|
305
305
|
}
|
|
306
306
|
async makeMd5FromFile(e) {
|
|
307
307
|
var t;
|
|
308
308
|
try {
|
|
309
|
-
const r = await (await fetch(e)).text(), n = (t = new
|
|
309
|
+
const r = await (await fetch(e)).text(), n = (t = new $({
|
|
310
310
|
ignoreAttributes: !1,
|
|
311
311
|
allowBooleanAttributes: !0
|
|
312
312
|
}).parse(r).OpenDRIVE.userData) == null ? void 0 : t.border;
|
|
@@ -321,7 +321,7 @@ class M {
|
|
|
321
321
|
* @returns
|
|
322
322
|
*/
|
|
323
323
|
async showOpenDriveFromFile(e) {
|
|
324
|
-
var
|
|
324
|
+
var f, p;
|
|
325
325
|
this.openDriveClickCallback = e.selectedCallback, console.time("md5用时");
|
|
326
326
|
const t = await this.makeMd5FromFile(e.file);
|
|
327
327
|
if (t.status !== 0)
|
|
@@ -357,7 +357,7 @@ class M {
|
|
|
357
357
|
const a = await (await fetch(c)).arrayBuffer(), o = O.inflate(a, { to: "string" }), l = JSON.parse(o);
|
|
358
358
|
await this.showAllLanes(
|
|
359
359
|
l,
|
|
360
|
-
((
|
|
360
|
+
((f = e.options) == null ? void 0 : f.showJunctionLane) || !1,
|
|
361
361
|
((p = e.options) == null ? void 0 : p.showRoadName) || !0
|
|
362
362
|
);
|
|
363
363
|
const d = r.data.result.junctions;
|
|
@@ -366,8 +366,8 @@ class M {
|
|
|
366
366
|
return P(
|
|
367
367
|
() => h.isSketching,
|
|
368
368
|
() => {
|
|
369
|
-
var m,
|
|
370
|
-
h.isSketching ? ((m = this.mouseMoveHandler) == null || m.remove(), this.mouseMoveHandler = void 0, (
|
|
369
|
+
var m, g;
|
|
370
|
+
h.isSketching ? ((m = this.mouseMoveHandler) == null || m.remove(), this.mouseMoveHandler = void 0, (g = this.mouseClickHandler) == null || g.remove(), this.mouseClickHandler = void 0) : (this.monitorMouseMove(), this.monitorMouseClick());
|
|
371
371
|
}
|
|
372
372
|
), console.timeEnd("渲染用时"), { status: 0, message: "ok" };
|
|
373
373
|
}
|
|
@@ -414,7 +414,7 @@ class M {
|
|
|
414
414
|
const { id: l, refLine: d } = o;
|
|
415
415
|
let h = o.name;
|
|
416
416
|
h.includes("(") && (h = h.slice(0, h.indexOf("("))), h = h.replace(/(.)/g, "$1 ");
|
|
417
|
-
const
|
|
417
|
+
const f = new y({
|
|
418
418
|
geometry: {
|
|
419
419
|
type: "polyline",
|
|
420
420
|
paths: [d]
|
|
@@ -425,15 +425,15 @@ class M {
|
|
|
425
425
|
roadName: h
|
|
426
426
|
}
|
|
427
427
|
});
|
|
428
|
-
this.allRefLineGraphics.push(
|
|
428
|
+
this.allRefLineGraphics.push(f), o.laneSections.sort((p, m) => Number(p.id) - Number(m.id));
|
|
429
429
|
for (let p = 0; p < o.laneSections.length; p++) {
|
|
430
|
-
const m = o.laneSections[p],
|
|
430
|
+
const m = o.laneSections[p], g = Number(m.id);
|
|
431
431
|
for (const u of m.lanePaths) {
|
|
432
432
|
const w = Number(u.id);
|
|
433
433
|
if (w === 0)
|
|
434
434
|
continue;
|
|
435
|
-
const v = u.type,
|
|
436
|
-
|
|
435
|
+
const v = u.type, M = [...u.outerPath], S = u.innerPath.concat(
|
|
436
|
+
M.reverse()
|
|
437
437
|
);
|
|
438
438
|
if (S.length <= 3) {
|
|
439
439
|
console.warn(`lane ${w} has less than 3 points`);
|
|
@@ -448,12 +448,12 @@ class M {
|
|
|
448
448
|
geometry: A,
|
|
449
449
|
attributes: {
|
|
450
450
|
ObjectID: c++,
|
|
451
|
-
id: `${l}+${
|
|
451
|
+
id: `${l}+${g}+${w}`,
|
|
452
452
|
fromNode: o.fromNode,
|
|
453
453
|
toNode: o.toNode,
|
|
454
454
|
roadId: String(l),
|
|
455
455
|
roadName: o.name,
|
|
456
|
-
sectionId: String(
|
|
456
|
+
sectionId: String(g),
|
|
457
457
|
sectionIndex: p,
|
|
458
458
|
laneId: w,
|
|
459
459
|
type: v,
|
|
@@ -511,9 +511,10 @@ class M {
|
|
|
511
511
|
},
|
|
512
512
|
symbol: {
|
|
513
513
|
type: "picture-marker",
|
|
514
|
-
url: i.crossId ? "/GisViewerAssets/Images/
|
|
515
|
-
width:
|
|
516
|
-
height:
|
|
514
|
+
url: i.crossId ? "/GisViewerAssets/Images/xhj_1.png" : "/GisViewerAssets/Images/xhj_2.png",
|
|
515
|
+
width: "18px",
|
|
516
|
+
height: "28px",
|
|
517
|
+
yoffset: "9px"
|
|
517
518
|
},
|
|
518
519
|
popupTemplate: {
|
|
519
520
|
title: i.name,
|
|
@@ -567,7 +568,7 @@ class M {
|
|
|
567
568
|
(u) => `${u.attributes.roadId}+${u.attributes.sectionId}` === n
|
|
568
569
|
), l = L.union(
|
|
569
570
|
o.map((u) => u.geometry)
|
|
570
|
-
), d = this.hitGraphic.getAttribute("fromNode"), h = this.hitGraphic.getAttribute("toNode"),
|
|
571
|
+
), d = this.hitGraphic.getAttribute("fromNode"), h = this.hitGraphic.getAttribute("toNode"), f = this.junctionNames.get(d) || d, p = this.junctionNames.get(h) || h, m = new y({
|
|
571
572
|
geometry: l,
|
|
572
573
|
symbol: {
|
|
573
574
|
type: "simple-fill",
|
|
@@ -582,7 +583,7 @@ class M {
|
|
|
582
583
|
type: "OpenDriveSection",
|
|
583
584
|
id: n,
|
|
584
585
|
selected: !1,
|
|
585
|
-
fromNodeName:
|
|
586
|
+
fromNodeName: f,
|
|
586
587
|
toNodeName: p,
|
|
587
588
|
laneCount: o.length
|
|
588
589
|
},
|
|
@@ -610,10 +611,10 @@ class M {
|
|
|
610
611
|
}
|
|
611
612
|
});
|
|
612
613
|
this.highlightLayer.removeAll(), this.highlightLayer.add(m);
|
|
613
|
-
const
|
|
614
|
+
const g = this.view.toMap(t);
|
|
614
615
|
this.view.openPopup({
|
|
615
616
|
features: [m],
|
|
616
|
-
location:
|
|
617
|
+
location: g
|
|
617
618
|
});
|
|
618
619
|
} else if (s.layer.id === "OpenDriveJunction") {
|
|
619
620
|
const n = this.hitGraphic.getAttribute("id");
|
|
@@ -812,9 +813,9 @@ class M {
|
|
|
812
813
|
type: "simple-marker",
|
|
813
814
|
style: "circle",
|
|
814
815
|
size: 30,
|
|
815
|
-
color: [
|
|
816
|
+
color: [0, 0, 255, 0.6],
|
|
816
817
|
outline: {
|
|
817
|
-
color: "
|
|
818
|
+
color: "blue",
|
|
818
819
|
width: 1
|
|
819
820
|
}
|
|
820
821
|
}
|
|
@@ -866,10 +867,9 @@ class M {
|
|
|
866
867
|
geometry: n,
|
|
867
868
|
symbol: {
|
|
868
869
|
type: "simple-fill",
|
|
869
|
-
color: [
|
|
870
|
+
color: [0, 0, 255, 0.6],
|
|
870
871
|
style: "solid",
|
|
871
872
|
outline: {
|
|
872
|
-
color: "red",
|
|
873
873
|
width: 0
|
|
874
874
|
}
|
|
875
875
|
}
|
|
@@ -984,13 +984,13 @@ class M {
|
|
|
984
984
|
type: "edge",
|
|
985
985
|
id: d
|
|
986
986
|
});
|
|
987
|
-
const h = `http://${this.openDriveServer}/api/sumo/getSumoEdge`,
|
|
987
|
+
const h = `http://${this.openDriveServer}/api/sumo/getSumoEdge`, f = await b.get(h, {
|
|
988
988
|
params: {
|
|
989
989
|
id: `${o}+${a.getAttribute("sectionId")}`,
|
|
990
990
|
projectName: this.projectName
|
|
991
991
|
}
|
|
992
992
|
});
|
|
993
|
-
|
|
993
|
+
f.status === 200 && f.data.status === 0 && s.push(f.data.result);
|
|
994
994
|
}
|
|
995
995
|
}
|
|
996
996
|
const c = this.junctionLayer.graphics.filter((a) => {
|
|
@@ -1035,12 +1035,12 @@ class M {
|
|
|
1035
1035
|
);
|
|
1036
1036
|
if (!l)
|
|
1037
1037
|
return { status: -1, message: "未找到车道" };
|
|
1038
|
-
const d = e.start || 0, h = e.end || 100,
|
|
1038
|
+
const d = e.start || 0, h = e.end || 100, f = G.lineString(l.getAttribute("leftLine")), p = C(f, d, h, {
|
|
1039
1039
|
units: "meters"
|
|
1040
|
-
}), m = G.lineString(l.getAttribute("rightLine")),
|
|
1040
|
+
}), m = G.lineString(l.getAttribute("rightLine")), g = C(m, d, h, {
|
|
1041
1041
|
units: "meters"
|
|
1042
1042
|
}), u = p.geometry.coordinates.concat(
|
|
1043
|
-
|
|
1043
|
+
g.geometry.coordinates.reverse()
|
|
1044
1044
|
);
|
|
1045
1045
|
u.push(u[u.length - 1]);
|
|
1046
1046
|
const w = new y({
|
|
@@ -1060,7 +1060,7 @@ class M {
|
|
|
1060
1060
|
type: l.getAttribute("type"),
|
|
1061
1061
|
sumoId: l.getAttribute("sumoId"),
|
|
1062
1062
|
leftLine: p.geometry.coordinates,
|
|
1063
|
-
rightLine:
|
|
1063
|
+
rightLine: g.geometry.coordinates
|
|
1064
1064
|
},
|
|
1065
1065
|
symbol: {
|
|
1066
1066
|
type: "simple-fill",
|
|
@@ -1077,5 +1077,5 @@ class M {
|
|
|
1077
1077
|
}
|
|
1078
1078
|
}
|
|
1079
1079
|
export {
|
|
1080
|
-
|
|
1080
|
+
x as default
|
|
1081
1081
|
};
|
|
@@ -5,10 +5,12 @@ export default class SignalControlAreaController {
|
|
|
5
5
|
private subDistrictControllerLayer;
|
|
6
6
|
private crossLayer;
|
|
7
7
|
private highlightLayer;
|
|
8
|
+
private districtControllers;
|
|
8
9
|
private watchHandle?;
|
|
10
|
+
private openDriveServerUrl;
|
|
9
11
|
private readonly crossScale;
|
|
10
12
|
constructor(view: __esri.MapView | __esri.SceneView);
|
|
11
|
-
showSignalControlArea(params: any): IResult
|
|
13
|
+
showSignalControlArea(params: any): Promise<IResult>;
|
|
12
14
|
clearSignalControlArea(): IResult;
|
|
13
15
|
locateSignalControlArea(params: {
|
|
14
16
|
id: string;
|
|
@@ -25,12 +27,14 @@ export default class SignalControlAreaController {
|
|
|
25
27
|
*/
|
|
26
28
|
private findAreaGraphic;
|
|
27
29
|
/**
|
|
28
|
-
*
|
|
30
|
+
* 显示区控
|
|
29
31
|
* @param districtController
|
|
30
|
-
* @param isDistrict 是否是区控
|
|
31
32
|
* @returns
|
|
32
33
|
*/
|
|
33
|
-
private
|
|
34
|
+
private showDistrict;
|
|
35
|
+
private showSubDistrictCross;
|
|
36
|
+
private loadedSubDistricts;
|
|
37
|
+
private showSubDistrictRoad;
|
|
34
38
|
/**
|
|
35
39
|
* 生成路口点符号。在不同比例尺下,使用不同的符号
|
|
36
40
|
* @param attributes
|
|
@@ -1,15 +1,20 @@
|
|
|
1
|
-
import * as
|
|
2
|
-
import
|
|
1
|
+
import * as u from "@arcgis/core/core/reactiveUtils.js";
|
|
2
|
+
import { Polyline as g } from "@arcgis/core/geometry";
|
|
3
|
+
import * as y from "@arcgis/core/geometry/geometryEngine.js";
|
|
4
|
+
import a from "@arcgis/core/Graphic";
|
|
3
5
|
import l from "@arcgis/core/layers/GraphicsLayer";
|
|
4
6
|
import f from "@turf/buffer";
|
|
5
|
-
import
|
|
6
|
-
import m from "@turf/convex";
|
|
7
|
+
import b from "@turf/concave";
|
|
7
8
|
import * as n from "@turf/helpers";
|
|
8
|
-
import
|
|
9
|
-
import
|
|
10
|
-
|
|
9
|
+
import C from "axios";
|
|
10
|
+
import S from "../../stores/index.mjs";
|
|
11
|
+
import m from "../common-utils.mjs";
|
|
12
|
+
import v from "./district-controller.mjs";
|
|
13
|
+
class k {
|
|
11
14
|
constructor(e) {
|
|
12
|
-
this.crossScale = 5e3, this.
|
|
15
|
+
this.districtControllers = [], this.crossScale = 5e3, this.loadedSubDistricts = [], this.view = e;
|
|
16
|
+
const i = S.useAppDataStore.mapConfig;
|
|
17
|
+
this.openDriveServerUrl = i.openDriveServer.url, this.districtControllerLayer = new l({
|
|
13
18
|
id: "districtControllerLayer",
|
|
14
19
|
maxScale: 144447,
|
|
15
20
|
minScale: 1155582
|
|
@@ -30,82 +35,80 @@ class M {
|
|
|
30
35
|
this.highlightLayer
|
|
31
36
|
]);
|
|
32
37
|
}
|
|
33
|
-
showSignalControlArea(e) {
|
|
34
|
-
this.districtControllerLayer.removeAll(), this.subDistrictControllerLayer.removeAll(), this.crossLayer.removeAll(), this.highlightLayer.removeAll(), this.districtControllerLayer.visible = !0, this.subDistrictControllerLayer.visible = !0;
|
|
35
|
-
for (const
|
|
36
|
-
const
|
|
37
|
-
this.
|
|
38
|
+
async showSignalControlArea(e) {
|
|
39
|
+
console.time("showSignalControlArea"), this.districtControllerLayer.removeAll(), this.subDistrictControllerLayer.removeAll(), this.crossLayer.removeAll(), this.highlightLayer.removeAll(), this.districtControllerLayer.visible = !0, this.subDistrictControllerLayer.visible = !0;
|
|
40
|
+
for (const r of e) {
|
|
41
|
+
const i = new v(r);
|
|
42
|
+
this.showDistrict(i), this.districtControllers.push(i);
|
|
38
43
|
}
|
|
39
|
-
|
|
44
|
+
this.watchHandle = u.watch(
|
|
40
45
|
() => this.view.scale,
|
|
41
|
-
(
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
46
|
+
(r, i) => {
|
|
47
|
+
r > this.crossScale && i <= this.crossScale ? (this.crossLayer.graphics.forEach((t) => {
|
|
48
|
+
t.symbol = this.getCrossGraphicSymbol(
|
|
49
|
+
t.attributes,
|
|
45
50
|
"marker"
|
|
46
51
|
);
|
|
47
|
-
}), this.highlightLayer.graphics.forEach((
|
|
48
|
-
|
|
49
|
-
|
|
52
|
+
}), this.highlightLayer.graphics.forEach((t) => {
|
|
53
|
+
t.getAttribute("type") === "cross" && (t.symbol = this.getCrossGraphicSymbol(
|
|
54
|
+
t.attributes,
|
|
50
55
|
"marker"
|
|
51
56
|
));
|
|
52
|
-
})) :
|
|
53
|
-
|
|
54
|
-
|
|
57
|
+
})) : r <= this.crossScale && i > this.crossScale && (this.crossLayer.graphics.forEach((t) => {
|
|
58
|
+
t.symbol = this.getCrossGraphicSymbol(
|
|
59
|
+
t.attributes,
|
|
55
60
|
"picture"
|
|
56
61
|
);
|
|
57
|
-
}), this.highlightLayer.graphics.forEach((
|
|
58
|
-
|
|
59
|
-
|
|
62
|
+
}), this.highlightLayer.graphics.forEach((t) => {
|
|
63
|
+
t.getAttribute("type") === "cross" && (t.symbol = this.getCrossGraphicSymbol(
|
|
64
|
+
t.attributes,
|
|
60
65
|
"picture"
|
|
61
66
|
));
|
|
62
67
|
}));
|
|
63
68
|
}
|
|
64
|
-
)
|
|
69
|
+
);
|
|
70
|
+
for (const r of this.districtControllers)
|
|
71
|
+
for (const i of r.subDistricts)
|
|
72
|
+
await this.showSubDistrictRoad(i);
|
|
73
|
+
return console.timeEnd("showSignalControlArea"), { status: 0, message: "ok" };
|
|
65
74
|
}
|
|
66
75
|
clearSignalControlArea() {
|
|
67
76
|
var e;
|
|
68
77
|
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" };
|
|
69
78
|
}
|
|
70
79
|
async locateSignalControlArea(e) {
|
|
71
|
-
const
|
|
72
|
-
return
|
|
73
|
-
target:
|
|
80
|
+
const r = this.findAreaGraphic(e.id);
|
|
81
|
+
return r ? (r[0].attributes.type === "cross" ? await this.view.goTo({
|
|
82
|
+
target: r,
|
|
74
83
|
scale: 1500
|
|
75
|
-
}) : await this.view.goTo(
|
|
84
|
+
}) : await this.view.goTo(r), { status: 0, message: "ok" }) : { status: 1, message: "未找到" };
|
|
76
85
|
}
|
|
77
86
|
showPopup(e) {
|
|
78
|
-
const
|
|
87
|
+
const r = e.geometry.type === "point" ? e.geometry : e.geometry.centroid;
|
|
79
88
|
this.view.openPopup({
|
|
80
89
|
features: [e],
|
|
81
|
-
location:
|
|
90
|
+
location: r
|
|
82
91
|
});
|
|
83
92
|
}
|
|
84
93
|
async highlightSignalControlArea(e) {
|
|
85
94
|
if (!e.id || e.id === "")
|
|
86
95
|
return { status: 1, message: "请输入id" };
|
|
87
96
|
this.highlightLayer.removeAll(), this.districtControllerLayer.visible = !1, this.subDistrictControllerLayer.visible = !1, this.crossLayer.visible = !1;
|
|
88
|
-
const
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
} else
|
|
104
|
-
s.length > 1 ? await this.view.goTo(s) : await this.view.goTo({
|
|
105
|
-
target: s[0].geometry,
|
|
106
|
-
scale: 1500
|
|
107
|
-
});
|
|
108
|
-
return { status: 0, message: "ok" };
|
|
97
|
+
for (const s of this.districtControllers)
|
|
98
|
+
for (const o of s.subDistricts)
|
|
99
|
+
(o.id === e.id || o.parentId === e.id) && await this.showSubDistrictRoad(o);
|
|
100
|
+
const r = this.districtControllerLayer.graphics.filter((s) => s.getAttribute("id") === e.id).toArray().map((s) => s.clone()), i = this.subDistrictControllerLayer.graphics.filter(
|
|
101
|
+
(s) => s.getAttribute("districtId") === e.id || s.getAttribute("subDistrictId") === e.id
|
|
102
|
+
).toArray().map((s) => s.clone()), t = this.crossLayer.graphics.filter(
|
|
103
|
+
(s) => s.getAttribute("id") === e.id || s.getAttribute("districtId") === e.id || s.getAttribute("subDistrictId") === e.id
|
|
104
|
+
).toArray().map((s) => s.clone());
|
|
105
|
+
return r.length > 0 && this.highlightLayer.addMany(r), i.length > 0 && this.highlightLayer.addMany(i), t.length > 0 && this.highlightLayer.addMany(t), this.highlightLayer.graphics.length === 0 ? { status: 1, message: "未找到" } : (r.length > 0 ? await this.view.goTo(r) : i.length > 0 ? await this.view.goTo({
|
|
106
|
+
target: i,
|
|
107
|
+
scale: this.crossScale - 500
|
|
108
|
+
}) : t.length > 1 ? await this.view.goTo(t) : await this.view.goTo({
|
|
109
|
+
target: t[0].geometry,
|
|
110
|
+
scale: 1500
|
|
111
|
+
}), { status: 0, message: "ok" });
|
|
109
112
|
}
|
|
110
113
|
resetHighlight() {
|
|
111
114
|
return this.highlightLayer.removeAll(), this.view.closePopup(), this.districtControllerLayer.visible = !0, this.subDistrictControllerLayer.visible = !0, this.crossLayer.visible = !0, { status: 0, message: "ok" };
|
|
@@ -116,42 +119,35 @@ class M {
|
|
|
116
119
|
* @returns
|
|
117
120
|
*/
|
|
118
121
|
findAreaGraphic(e) {
|
|
119
|
-
let
|
|
120
|
-
(
|
|
122
|
+
let r = this.districtControllerLayer.graphics.filter(
|
|
123
|
+
(i) => i.attributes.id === e
|
|
121
124
|
);
|
|
122
|
-
|
|
123
|
-
(
|
|
124
|
-
)),
|
|
125
|
+
if (r || (r = this.subDistrictControllerLayer.graphics.filter(
|
|
126
|
+
(i) => i.attributes.getAttribute("subDistrictId") === e
|
|
127
|
+
)), r || (r = this.crossLayer.graphics.filter((i) => i.attributes.id === e)), r.length !== 0)
|
|
128
|
+
return r.toArray();
|
|
125
129
|
}
|
|
126
130
|
/**
|
|
127
|
-
*
|
|
131
|
+
* 显示区控
|
|
128
132
|
* @param districtController
|
|
129
|
-
* @param isDistrict 是否是区控
|
|
130
133
|
* @returns
|
|
131
134
|
*/
|
|
132
|
-
|
|
135
|
+
showDistrict(e) {
|
|
133
136
|
const r = e.getAllCrossCoordinates();
|
|
134
137
|
if (r.length >= 2) {
|
|
135
|
-
let
|
|
138
|
+
let t = null;
|
|
136
139
|
if (r.length === 2)
|
|
137
|
-
|
|
140
|
+
t = n.lineString(r);
|
|
138
141
|
else if (r.length > 2) {
|
|
139
|
-
const
|
|
140
|
-
r.map((
|
|
142
|
+
const p = n.featureCollection(
|
|
143
|
+
r.map((d) => n.point(d))
|
|
141
144
|
);
|
|
142
|
-
t
|
|
145
|
+
t = b(p);
|
|
143
146
|
}
|
|
144
|
-
|
|
145
|
-
const
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
t ? 200 : 30,
|
|
149
|
-
{
|
|
150
|
-
units: "meters"
|
|
151
|
-
}
|
|
152
|
-
);
|
|
153
|
-
let a;
|
|
154
|
-
t ? a = [
|
|
147
|
+
t || (t = n.lineString(r));
|
|
148
|
+
const s = f(t.geometry, 200, {
|
|
149
|
+
units: "meters"
|
|
150
|
+
}), o = [
|
|
155
151
|
{
|
|
156
152
|
fieldName: "id",
|
|
157
153
|
label: "区控编号"
|
|
@@ -164,17 +160,7 @@ class M {
|
|
|
164
160
|
fieldName: "subDistrictCount",
|
|
165
161
|
label: "子区数量"
|
|
166
162
|
}
|
|
167
|
-
]
|
|
168
|
-
{
|
|
169
|
-
fieldName: "parentName",
|
|
170
|
-
label: "所属区控"
|
|
171
|
-
},
|
|
172
|
-
{
|
|
173
|
-
fieldName: "crossCount",
|
|
174
|
-
label: "路口数量"
|
|
175
|
-
}
|
|
176
|
-
];
|
|
177
|
-
const g = {
|
|
163
|
+
], h = {
|
|
178
164
|
type: "signalControlArea",
|
|
179
165
|
id: e.id,
|
|
180
166
|
name: e.name,
|
|
@@ -182,59 +168,60 @@ class M {
|
|
|
182
168
|
parentName: e.parentName,
|
|
183
169
|
crossCount: e.crossCount,
|
|
184
170
|
subDistrictCount: e.subDistrictCount
|
|
185
|
-
}, c = new
|
|
171
|
+
}, c = new a({
|
|
186
172
|
geometry: {
|
|
187
173
|
type: "polygon",
|
|
188
|
-
rings:
|
|
174
|
+
rings: s.geometry.coordinates
|
|
189
175
|
},
|
|
190
176
|
symbol: {
|
|
191
177
|
type: "simple-fill",
|
|
192
|
-
color: [...e.areaColor,
|
|
178
|
+
color: [...e.areaColor, 0.1],
|
|
193
179
|
outline: {
|
|
194
180
|
color: e.areaColor,
|
|
195
|
-
width: 2
|
|
196
|
-
style: t ? "solid" : "long-dash"
|
|
181
|
+
width: 2
|
|
197
182
|
}
|
|
198
183
|
},
|
|
199
|
-
attributes:
|
|
184
|
+
attributes: h,
|
|
200
185
|
popupTemplate: {
|
|
201
|
-
title:
|
|
186
|
+
title: `区控 ${e.name}`,
|
|
202
187
|
content: [
|
|
203
188
|
{
|
|
204
189
|
type: "fields",
|
|
205
|
-
fieldInfos:
|
|
190
|
+
fieldInfos: o
|
|
206
191
|
}
|
|
207
192
|
]
|
|
208
193
|
}
|
|
209
194
|
});
|
|
210
|
-
|
|
195
|
+
this.districtControllerLayer.add(c);
|
|
211
196
|
}
|
|
212
|
-
for (
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
197
|
+
for (let t = 0; t < e.subDistricts.length; t++) {
|
|
198
|
+
const s = e.subDistricts[t];
|
|
199
|
+
this.showSubDistrictCross(s);
|
|
200
|
+
}
|
|
201
|
+
const i = [];
|
|
202
|
+
e.crosses = e.crosses.filter(
|
|
203
|
+
(t) => m.isCoordinateValid(t)
|
|
204
|
+
), e.crosses.forEach((t) => {
|
|
205
|
+
if (m.isCoordinateValid(t)) {
|
|
206
|
+
const s = {
|
|
218
207
|
type: "cross",
|
|
219
|
-
id:
|
|
220
|
-
name:
|
|
208
|
+
id: t.id,
|
|
209
|
+
name: t.name,
|
|
221
210
|
color: e.areaColor,
|
|
222
|
-
signalId:
|
|
223
|
-
districtId:
|
|
224
|
-
districtName:
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
isKey: i.isKey
|
|
228
|
-
}, a = new y({
|
|
211
|
+
signalId: t.signalId,
|
|
212
|
+
districtId: e.id,
|
|
213
|
+
districtName: e.name,
|
|
214
|
+
isKey: t.isKey
|
|
215
|
+
}, o = new a({
|
|
229
216
|
geometry: {
|
|
230
217
|
type: "point",
|
|
231
|
-
x:
|
|
232
|
-
y:
|
|
218
|
+
x: t.longitude,
|
|
219
|
+
y: t.latitude
|
|
233
220
|
},
|
|
234
|
-
symbol: this.getCrossGraphicSymbol(
|
|
235
|
-
attributes:
|
|
221
|
+
symbol: this.getCrossGraphicSymbol(s, "marker"),
|
|
222
|
+
attributes: s,
|
|
236
223
|
popupTemplate: {
|
|
237
|
-
title:
|
|
224
|
+
title: t.name,
|
|
238
225
|
content: [
|
|
239
226
|
{
|
|
240
227
|
type: "fields",
|
|
@@ -243,10 +230,6 @@ class M {
|
|
|
243
230
|
fieldName: "districtName",
|
|
244
231
|
label: "区控名称"
|
|
245
232
|
},
|
|
246
|
-
{
|
|
247
|
-
fieldName: "subDistrictName",
|
|
248
|
-
label: "子区名称"
|
|
249
|
-
},
|
|
250
233
|
{
|
|
251
234
|
fieldName: "id",
|
|
252
235
|
label: "路口编号"
|
|
@@ -260,10 +243,106 @@ class M {
|
|
|
260
243
|
]
|
|
261
244
|
}
|
|
262
245
|
});
|
|
263
|
-
|
|
246
|
+
i.push(o);
|
|
264
247
|
} else
|
|
265
|
-
console.log("路口坐标无效",
|
|
266
|
-
}), this.crossLayer.addMany(
|
|
248
|
+
console.log("路口坐标无效", t);
|
|
249
|
+
}), this.crossLayer.addMany(i);
|
|
250
|
+
}
|
|
251
|
+
showSubDistrictCross(e) {
|
|
252
|
+
const r = [];
|
|
253
|
+
e.crosses = e.crosses.filter(
|
|
254
|
+
(i) => m.isCoordinateValid(i)
|
|
255
|
+
), e.crosses.forEach((i) => {
|
|
256
|
+
const t = {
|
|
257
|
+
type: "cross",
|
|
258
|
+
id: i.id,
|
|
259
|
+
name: i.name,
|
|
260
|
+
color: e.areaColor,
|
|
261
|
+
signalId: i.signalId,
|
|
262
|
+
districtId: e.parentId,
|
|
263
|
+
districtName: e.parentName,
|
|
264
|
+
subDistrictId: e.id,
|
|
265
|
+
subDistrictName: e.name,
|
|
266
|
+
isKey: i.isKey
|
|
267
|
+
}, s = new a({
|
|
268
|
+
geometry: {
|
|
269
|
+
type: "point",
|
|
270
|
+
x: i.longitude,
|
|
271
|
+
y: i.latitude
|
|
272
|
+
},
|
|
273
|
+
symbol: this.getCrossGraphicSymbol(t, "marker"),
|
|
274
|
+
attributes: t,
|
|
275
|
+
popupTemplate: {
|
|
276
|
+
title: i.name,
|
|
277
|
+
content: [
|
|
278
|
+
{
|
|
279
|
+
type: "fields",
|
|
280
|
+
fieldInfos: [
|
|
281
|
+
{
|
|
282
|
+
fieldName: "districtName",
|
|
283
|
+
label: "区控名称"
|
|
284
|
+
},
|
|
285
|
+
{
|
|
286
|
+
fieldName: "subDistrictName",
|
|
287
|
+
label: "子区名称"
|
|
288
|
+
},
|
|
289
|
+
{
|
|
290
|
+
fieldName: "id",
|
|
291
|
+
label: "路口编号"
|
|
292
|
+
},
|
|
293
|
+
{
|
|
294
|
+
fieldName: "signalId",
|
|
295
|
+
label: "信号机编号"
|
|
296
|
+
}
|
|
297
|
+
]
|
|
298
|
+
}
|
|
299
|
+
]
|
|
300
|
+
}
|
|
301
|
+
});
|
|
302
|
+
r.push(s);
|
|
303
|
+
}), this.crossLayer.addMany(r);
|
|
304
|
+
}
|
|
305
|
+
async showSubDistrictRoad(e) {
|
|
306
|
+
if (e.crosses.length > 1 && !this.loadedSubDistricts.includes(e.id) && this.openDriveServerUrl && this.openDriveServerUrl !== "") {
|
|
307
|
+
this.loadedSubDistricts.push(e.id);
|
|
308
|
+
const r = await C.get(
|
|
309
|
+
`http://${this.openDriveServerUrl}/api/computable/getRoadsectWithinJunctions`,
|
|
310
|
+
{
|
|
311
|
+
params: {
|
|
312
|
+
junctionIds: e.crosses.map((i) => i.id).join(",")
|
|
313
|
+
}
|
|
314
|
+
}
|
|
315
|
+
);
|
|
316
|
+
if (r.status === 200) {
|
|
317
|
+
const i = r.data.result;
|
|
318
|
+
if (i.length > 0) {
|
|
319
|
+
const t = i.map((c) => new g({ paths: [c] })), s = y.geodesicBuffer(
|
|
320
|
+
t,
|
|
321
|
+
5,
|
|
322
|
+
"meters"
|
|
323
|
+
), o = y.union(
|
|
324
|
+
s
|
|
325
|
+
), h = new a({
|
|
326
|
+
geometry: o,
|
|
327
|
+
symbol: {
|
|
328
|
+
type: "simple-fill",
|
|
329
|
+
color: [...e.areaColor, 0.8],
|
|
330
|
+
outline: {
|
|
331
|
+
color: e.areaColor,
|
|
332
|
+
width: 1
|
|
333
|
+
}
|
|
334
|
+
},
|
|
335
|
+
attributes: {
|
|
336
|
+
districtId: e.parentId,
|
|
337
|
+
districtName: e.parentName,
|
|
338
|
+
subDistrictId: e.id,
|
|
339
|
+
subDistrictName: e.name
|
|
340
|
+
}
|
|
341
|
+
});
|
|
342
|
+
this.subDistrictControllerLayer.add(h);
|
|
343
|
+
}
|
|
344
|
+
}
|
|
345
|
+
}
|
|
267
346
|
}
|
|
268
347
|
/**
|
|
269
348
|
* 生成路口点符号。在不同比例尺下,使用不同的符号
|
|
@@ -271,10 +350,10 @@ class M {
|
|
|
271
350
|
* @param symbolType
|
|
272
351
|
* @returns
|
|
273
352
|
*/
|
|
274
|
-
getCrossGraphicSymbol(e,
|
|
275
|
-
const { isKey:
|
|
276
|
-
if (
|
|
277
|
-
return
|
|
353
|
+
getCrossGraphicSymbol(e, r) {
|
|
354
|
+
const { isKey: i, color: t } = e;
|
|
355
|
+
if (r === "marker")
|
|
356
|
+
return i ? {
|
|
278
357
|
type: "picture-marker",
|
|
279
358
|
url: "/GisViewerAssets/Images/icon_star.png",
|
|
280
359
|
width: "30px",
|
|
@@ -282,14 +361,14 @@ class M {
|
|
|
282
361
|
} : {
|
|
283
362
|
type: "simple-marker",
|
|
284
363
|
style: "circle",
|
|
285
|
-
color:
|
|
364
|
+
color: t,
|
|
286
365
|
size: 8,
|
|
287
366
|
outline: {
|
|
288
367
|
color: "white",
|
|
289
368
|
width: 1
|
|
290
369
|
}
|
|
291
370
|
};
|
|
292
|
-
if (
|
|
371
|
+
if (r === "picture")
|
|
293
372
|
return {
|
|
294
373
|
type: "cim",
|
|
295
374
|
data: {
|
|
@@ -328,7 +407,7 @@ class M {
|
|
|
328
407
|
height: 12,
|
|
329
408
|
horizontalAlignment: "Center",
|
|
330
409
|
offsetX: 0,
|
|
331
|
-
offsetY:
|
|
410
|
+
offsetY: i ? 60 : 40,
|
|
332
411
|
haloSize: 1,
|
|
333
412
|
haloSymbol: {
|
|
334
413
|
type: "CIMPolygonSymbol",
|
|
@@ -367,11 +446,11 @@ class M {
|
|
|
367
446
|
y: 0
|
|
368
447
|
},
|
|
369
448
|
anchorPointUnits: "Relative",
|
|
370
|
-
size:
|
|
449
|
+
size: i ? 45 : 30,
|
|
371
450
|
rotateClockwise: !0,
|
|
372
451
|
textureFilter: "Picture",
|
|
373
|
-
url: `/GisViewerAssets/Images/xhj_${
|
|
374
|
-
offsetY:
|
|
452
|
+
url: `/GisViewerAssets/Images/xhj_${i ? 4 : 1}.png`,
|
|
453
|
+
offsetY: i ? 22 : 15
|
|
375
454
|
}
|
|
376
455
|
]
|
|
377
456
|
}
|
|
@@ -380,5 +459,5 @@ class M {
|
|
|
380
459
|
}
|
|
381
460
|
}
|
|
382
461
|
export {
|
|
383
|
-
|
|
462
|
+
k as default
|
|
384
463
|
};
|
|
@@ -84,7 +84,7 @@ declare const _sfc_main: import("vue").DefineComponent<{
|
|
|
84
84
|
status: number;
|
|
85
85
|
message: string;
|
|
86
86
|
}>;
|
|
87
|
-
showSignalControlArea: (params: any) => import("../types").IResult
|
|
87
|
+
showSignalControlArea: (params: any) => Promise<import("../types").IResult>;
|
|
88
88
|
clearSignalControlArea: () => void;
|
|
89
89
|
locateSignalControlArea: (params: {
|
|
90
90
|
id: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const o=require("vue"),y=require("./stores/index.js");require("./style/index.css");const De=require("./utils/holo-flow/index.js"),Le=require("./utils/map-initializer.js"),O=require("./utils/open-drive-renderer/index.js"),C=require("./utils/overlay.js"),Ae=require("./utils/queue-length.js"),k=require("./utils/road-config-tool/index.js"),Ie=require("./utils/signal-control-area-controller/index.js"),be=require("./utils/traffic-flow.js"),qe={class:"gis-viewer"},Me={style:{position:"absolute",bottom:"10px",left:"10px"}},_e=o.defineComponent({__name:"gis-map",props:{config:{},assetsRoot:{}},emits:["mapLoaded","markerClick","mapClick"],setup(T,{expose:D,emit:L}){const p=o.ref(null);let c,l,i,r,n,a,m,t,s;const d=o.ref(!1);o.onMounted(async()=>{if(y.registerStore(),!p.value)return;document.addEventListener("keydown",g=>{g.ctrlKey&&g.key==="i"&&(d.value=!d.value)});const e=o.getCurrentInstance(),{$gisviewerAssetsRoot:u}=e.appContext.config.globalProperties,S=await(await fetch(h.config)).json();S.assetsRoot=h.assetsRoot||u;const ke=y.default.useAppDataStore;ke.mapConfig=S,l=new Le.default,c=await l.initialize({container:p.value,markerClickCallback:(g,w,v,Te)=>{f("markerClick",g,w,v,Te)},mapClickCallback:(g,w,v)=>{f("mapClick",g,w,v)}}),n=new De.default(c),await n.init(),f("mapLoaded")}),o.onUnmounted(()=>{s==null||s.clearSignalControlArea(),t==null||t.clearOpenDrive(),n==null||n.clearHoloTrace(),n==null||n.clearHoloSignal(),r==null||r.disconnectTrafficFlow()});const A=o.computed(()=>c),I=()=>{const e=y.default.useAppDataStore;e.saveTrackLog=!0},b=()=>{n.downloadTrackLog()},q=async e=>await l.setMapCenter(e),M=async e=>await l.setMapCamera(e),_=async e=>await l.lookAt(e),x=e=>l.setLayerVisibility(e),H=(e,u)=>l.requestCoordinateTransform(e,u),V=e=>{l.cancelCoordinateTransform(e)},N=e=>{l.setMapZoomRange(e)},B=e=>(i||(i=new k.default(c)),i.showLaneNumber(e)),E=()=>{i==null||i.clearLaneNumber()},j=async e=>(i||(i=new k.default(c)),await i.initializeSearch(e)),z=async()=>i==null?void 0:i.calCrossIndicatorArea(),P=async()=>{},Q=async(e,u)=>{r||(r=new be.default(c)),r.connectTrafficFlow(e,u)},F=()=>{r==null||r.disconnectTrafficFlow()},Z=e=>{n.handleVehicleTraceData(e)},K=()=>{n.clearHoloTrace()},U=e=>{n.setInterpolate(e)},G=async e=>{await n.handleSignalData(e)},J=()=>{n.clearHoloSignal()},W=e=>{r==null||r.toggleTrafficInfo(e),n.toggleTrafficInfo(e)},X=e=>{n.togglePause(e)},Y=e=>{r==null||r.toggleTrafficObject(e),n.toggleTrafficObject(e)},R=e=>{n.updatePanelContent(e)},$=async e=>(a||(a=new C.default(c)),a.addOverlays(e)),ee=e=>(a||(a=new C.default(c)),a.addMask(e)),te=()=>{a==null||a.removeMask()},ae=e=>a==null?void 0:a.removeOverlaysByType(e),ne=e=>a==null?void 0:a.removeOverlaysById(e),re=()=>a==null?void 0:a.removeAllOverlays(),se=()=>{a==null||a.showAllOverlays()},oe=e=>{m||(m=new Ae.default(c)),m.updateQueueLength(e)},ce=()=>{m==null||m.removeQueueLength()},ie=async(e,u)=>(t||(t=new O.default(c)),await t.showOpenDriveFromServer(e,u)),le=async e=>(t||(t=new O.default(c)),await t.clearOpenDrive(),await t.showOpenDriveFromFile(e)),ue=async()=>await(t==null?void 0:t.clearOpenDrive()),me=async e=>t?await(t==null?void 0:t.findSumo(e)):{status:-1,message:"未加载OpenDrive地图"},ge=async e=>t?t.selectSumo(e):{status:-1,message:"未加载OpenDrive地图"},pe=async e=>t?t.unselectSumo(e):{status:-1,message:"未加载OpenDrive地图"},de=async e=>t?await t.geometrySearch(e):{status:-1,message:"未加载OpenDrive地图"},fe=async e=>t?await t.getSumoInfo(e):{status:-1,message:"未加载OpenDrive地图"},we=async e=>t?await(t==null?void 0:t.splitLane(e)):{status:-1,message:"未加载OpenDrive地图"},ve=async()=>t?t==null?void 0:t.clearSplitLane():{status:-1,message:"未加载OpenDrive地图"},ye=e=>(s||(s=new Ie.default(c)),s.showSignalControlArea(e)),he=()=>{s==null||s.clearSignalControlArea()},Se=async e=>s?await s.locateSignalControlArea(e):{status:-1,message:"未加载信号控制区"},Oe=async e=>s?await s.highlightSignalControlArea(e):{status:-1,message:"未加载信号控制区"},Ce=()=>s?s.resetHighlight():{status:-1,message:"未加载信号控制区"},h=T,f=L;return D({mapViewer:A,setLayerVisibility:x,setMapCenter:q,lookAt:_,setMapCamera:M,setMapZoomRange:N,requestCoordinateTransform:H,cancelCoordinateTransform:V,addOverlays:$,addMask:ee,removeMask:te,showAllOverlays:se,removeOverlaysByType:ae,removeOverlaysById:ne,removeAllOverlays:re,showLaneNumber:B,clearLaneNumber:E,initializeAreaTool:j,calCrossIndicatorArea:z,calRoadIndicatorArea:P,connectCarFlow:Q,disconnectCarFlow:F,handleHoloVehicleTraceData:Z,clearHoloTrace:K,handleHoloSignalData:G,clearHoloSignal:J,setInterpolate:U,toggleTrafficInfo:W,toggleTrafficObject:Y,toggleVehicleInfo:R,togglePause:X,updateQueueLength:oe,removeQueueLength:ce,showOpenDriveFromServer:ie,showOpenDriveFromFile:le,clearOpenDrive:ue,geometrySearchInOpenDrive:de,findSumoInOpenDrive:me,selectSumoInOpenDrive:ge,unselectSumoInOpenDrive:pe,getSumoInfo:fe,splitOpenDriveLane:we,clearSplitOpenDriveLane:ve,showSignalControlArea:ye,clearSignalControlArea:he,locateSignalControlArea:Se,highlightSignalControlArea:Oe,resetHighlightSignalControlArea:Ce}),(e,u)=>(o.openBlock(),o.createElementBlock("div",qe,[o.createElementVNode("div",{class:"gis-viewer-main",ref_key:"mapContainer",ref:p},[o.withDirectives(o.createElementVNode("div",Me,[o.createElementVNode("button",{style:{"margin-right":"10px"},onClick:I}," 开始记录 "),o.createElementVNode("button",{onClick:b},"下载日志")],512),[[o.vShow,d.value]])],512)]))}});exports.default=_e;
|
|
1
|
+
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const o=require("vue"),y=require("./stores/index.js");require("./style/index.css");const De=require("./utils/holo-flow/index.js"),Le=require("./utils/map-initializer.js"),O=require("./utils/open-drive-renderer/index.js"),C=require("./utils/overlay.js"),Ae=require("./utils/queue-length.js"),k=require("./utils/road-config-tool/index.js"),Ie=require("./utils/signal-control-area-controller/index.js"),be=require("./utils/traffic-flow.js"),qe={class:"gis-viewer"},Me={style:{position:"absolute",bottom:"10px",left:"10px"}},_e=o.defineComponent({__name:"gis-map",props:{config:{},assetsRoot:{}},emits:["mapLoaded","markerClick","mapClick"],setup(T,{expose:D,emit:L}){const p=o.ref(null);let c,l,i,r,n,a,m,t,s;const d=o.ref(!1);o.onMounted(async()=>{if(y.registerStore(),!p.value)return;document.addEventListener("keydown",g=>{g.ctrlKey&&g.key==="i"&&(d.value=!d.value)});const e=o.getCurrentInstance(),{$gisviewerAssetsRoot:u}=e.appContext.config.globalProperties,S=await(await fetch(h.config)).json();S.assetsRoot=h.assetsRoot||u;const ke=y.default.useAppDataStore;ke.mapConfig=S,l=new Le.default,c=await l.initialize({container:p.value,markerClickCallback:(g,w,v,Te)=>{f("markerClick",g,w,v,Te)},mapClickCallback:(g,w,v)=>{f("mapClick",g,w,v)}}),n=new De.default(c),await n.init(),f("mapLoaded")}),o.onUnmounted(()=>{s==null||s.clearSignalControlArea(),t==null||t.clearOpenDrive(),n==null||n.clearHoloTrace(),n==null||n.clearHoloSignal(),r==null||r.disconnectTrafficFlow()});const A=o.computed(()=>c),I=()=>{const e=y.default.useAppDataStore;e.saveTrackLog=!0},b=()=>{n.downloadTrackLog()},q=async e=>await l.setMapCenter(e),M=async e=>await l.setMapCamera(e),_=async e=>await l.lookAt(e),x=e=>l.setLayerVisibility(e),H=(e,u)=>l.requestCoordinateTransform(e,u),V=e=>{l.cancelCoordinateTransform(e)},N=e=>{l.setMapZoomRange(e)},B=e=>(i||(i=new k.default(c)),i.showLaneNumber(e)),E=()=>{i==null||i.clearLaneNumber()},j=async e=>(i||(i=new k.default(c)),await i.initializeSearch(e)),z=async()=>i==null?void 0:i.calCrossIndicatorArea(),P=async()=>{},Q=async(e,u)=>{r||(r=new be.default(c)),r.connectTrafficFlow(e,u)},F=()=>{r==null||r.disconnectTrafficFlow()},Z=e=>{n.handleVehicleTraceData(e)},K=()=>{n.clearHoloTrace()},U=e=>{n.setInterpolate(e)},G=async e=>{await n.handleSignalData(e)},J=()=>{n.clearHoloSignal()},W=e=>{r==null||r.toggleTrafficInfo(e),n.toggleTrafficInfo(e)},X=e=>{n.togglePause(e)},Y=e=>{r==null||r.toggleTrafficObject(e),n.toggleTrafficObject(e)},R=e=>{n.updatePanelContent(e)},$=async e=>(a||(a=new C.default(c)),a.addOverlays(e)),ee=e=>(a||(a=new C.default(c)),a.addMask(e)),te=()=>{a==null||a.removeMask()},ae=e=>a==null?void 0:a.removeOverlaysByType(e),ne=e=>a==null?void 0:a.removeOverlaysById(e),re=()=>a==null?void 0:a.removeAllOverlays(),se=()=>{a==null||a.showAllOverlays()},oe=e=>{m||(m=new Ae.default(c)),m.updateQueueLength(e)},ce=()=>{m==null||m.removeQueueLength()},ie=async(e,u)=>(t||(t=new O.default(c)),await t.showOpenDriveFromServer(e,u)),le=async e=>(t||(t=new O.default(c)),await t.clearOpenDrive(),await t.showOpenDriveFromFile(e)),ue=async()=>await(t==null?void 0:t.clearOpenDrive()),me=async e=>t?await(t==null?void 0:t.findSumo(e)):{status:-1,message:"未加载OpenDrive地图"},ge=async e=>t?t.selectSumo(e):{status:-1,message:"未加载OpenDrive地图"},pe=async e=>t?t.unselectSumo(e):{status:-1,message:"未加载OpenDrive地图"},de=async e=>t?await t.geometrySearch(e):{status:-1,message:"未加载OpenDrive地图"},fe=async e=>t?await t.getSumoInfo(e):{status:-1,message:"未加载OpenDrive地图"},we=async e=>t?await(t==null?void 0:t.splitLane(e)):{status:-1,message:"未加载OpenDrive地图"},ve=async()=>t?t==null?void 0:t.clearSplitLane():{status:-1,message:"未加载OpenDrive地图"},ye=async e=>(s||(s=new Ie.default(c)),await s.showSignalControlArea(e)),he=()=>{s==null||s.clearSignalControlArea()},Se=async e=>s?await s.locateSignalControlArea(e):{status:-1,message:"未加载信号控制区"},Oe=async e=>s?await s.highlightSignalControlArea(e):{status:-1,message:"未加载信号控制区"},Ce=()=>s?s.resetHighlight():{status:-1,message:"未加载信号控制区"},h=T,f=L;return D({mapViewer:A,setLayerVisibility:x,setMapCenter:q,lookAt:_,setMapCamera:M,setMapZoomRange:N,requestCoordinateTransform:H,cancelCoordinateTransform:V,addOverlays:$,addMask:ee,removeMask:te,showAllOverlays:se,removeOverlaysByType:ae,removeOverlaysById:ne,removeAllOverlays:re,showLaneNumber:B,clearLaneNumber:E,initializeAreaTool:j,calCrossIndicatorArea:z,calRoadIndicatorArea:P,connectCarFlow:Q,disconnectCarFlow:F,handleHoloVehicleTraceData:Z,clearHoloTrace:K,handleHoloSignalData:G,clearHoloSignal:J,setInterpolate:U,toggleTrafficInfo:W,toggleTrafficObject:Y,toggleVehicleInfo:R,togglePause:X,updateQueueLength:oe,removeQueueLength:ce,showOpenDriveFromServer:ie,showOpenDriveFromFile:le,clearOpenDrive:ue,geometrySearchInOpenDrive:de,findSumoInOpenDrive:me,selectSumoInOpenDrive:ge,unselectSumoInOpenDrive:pe,getSumoInfo:fe,splitOpenDriveLane:we,clearSplitOpenDriveLane:ve,showSignalControlArea:ye,clearSignalControlArea:he,locateSignalControlArea:Se,highlightSignalControlArea:Oe,resetHighlightSignalControlArea:Ce}),(e,u)=>(o.openBlock(),o.createElementBlock("div",qe,[o.createElementVNode("div",{class:"gis-viewer-main",ref_key:"mapContainer",ref:p},[o.withDirectives(o.createElementVNode("div",Me,[o.createElementVNode("button",{style:{"margin-right":"10px"},onClick:I}," 开始记录 "),o.createElementVNode("button",{onClick:b},"下载日志")],512),[[o.vShow,d.value]])],512)]))}});exports.default=_e;
|
|
@@ -73,7 +73,7 @@ export declare const GisMap: import("@easyest/utils/dist/lib/withinstall").SFCWi
|
|
|
73
73
|
status: number;
|
|
74
74
|
message: string;
|
|
75
75
|
}>;
|
|
76
|
-
showSignalControlArea: (params: any) => import("../types").IResult
|
|
76
|
+
showSignalControlArea: (params: any) => Promise<import("../types").IResult>;
|
|
77
77
|
clearSignalControlArea: () => void;
|
|
78
78
|
locateSignalControlArea: (params: {
|
|
79
79
|
id: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const y=require("@arcgis/core/Graphic"),P=require("@arcgis/core/core/promiseUtils"),N=require("@arcgis/core/geometry"),q=require("@arcgis/core/geometry/geometryEngine"),C=require("@arcgis/core/layers/FeatureLayer"),v=require("@arcgis/core/layers/GraphicsLayer"),J=require("@turf/helpers"),O=require("@turf/line-slice-along"),b=require("axios"),E=require("fast-xml-parser"),R=require("md5"),M=require("pako"),T=require("vue"),H=require("../../stores/index.js"),_=require("../common-utils.js");function D(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 $=D(P),S=D(q),x=D(J);class j{constructor(e){this.junctionNames=new Map,this.projectName="",this.openDriveServer="",this.currentSectionCode="",this.selectedSectionIds=[],this.currentJunctionId="",this.view=e,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:"sectionIndex",alias:"路段序号",type:"string"},{name:"laneId",alias:"车道号",type:"string"},{name:"type",alias:"类型",type:"string"},{name:"sumoId",alias:"sumo编号",type:"string"},{name:"fromNode",alias:"起点路口",type:"string"},{name:"toNode",alias:"终点路口",type:"string"}],objectIdField:"ObjectID",geometryType:"polygon",spatialReference:{wkid:4326},source:[],outFields:["*"],renderer:{type:"unique-value",field:"type",defaultSymbol:{type:"simple-fill",color:[100,100,100],style:"solid",outline:{color:"white",width:1}},uniqueValueInfos:[{value:"shoulder",label:"路肩",symbol:{type:"simple-fill",color:"#008000",style:"solid",outline:{color:"white",width:1}}},{value:"border",label:"路沿",symbol:{type:"simple-fill",color:"#DCDCDC",style:"solid",outline:{color:"white",width:1}}},{value:"driving",label:"机动车道",symbol:{type:"simple-fill",color:[47,79,79,.8],style:"solid",outline:{color:"white",width:1}}},{value:"none",label:"无",symbol:{type:"simple-fill",color:[111,120,135],style:"none",outline:{color:"white",width:1}}},{value:"restricted",label:"禁行区",symbol:{type:"simple-fill",color:"yellow",style:"solid",outline:{color:"yellow",width:2}}},{value:"parking",label:"停车区",symbol:{type:"simple-fill",color:[115,115,115],style:"solid",outline:{color:"white",width:1}}},{value:"median",label:"中央隔离带",symbol:{type:"simple-fill",color:"#008000",style:"solid",outline:{color:"white",width:1}}},{value:"biking",label:"非机动车道",symbol:{type:"simple-fill",color:"#D3D3D3",style:"solid",outline:{color:"white",width:1}}},{value:"sidewalk",label:"人行道",symbol:{type:"simple-fill",color:"#C0C0C0",style:"solid",outline:{color:"white",width:1}}},{value:"junction",label:"路口区域",symbol:{type:"simple-fill",color:"#2F4F4F",style:"solid",outline:{color:"white",width:1}}},{value:"selected",label:"选中车道",symbol:{type:"simple-fill",color:[141,168,211],style:"solid",outline:{color:"white",width:1}}}]}}),this.roadNameLayer=new 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 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.junctionLayer,this.sectionLayer,this.roadNameLayer,this.highlightLayer,this.flashLayer,this.drawLayer,this.splitLaneLayer,this.borderLayer])}static getInstance(e){return this.instance||(this.instance=new j(e)),this.instance}async makeMd5FromFile(e){var t;try{const r=await(await fetch(e)).text(),n=(t=new E.XMLParser({ignoreAttributes:!1,allowBooleanAttributes:!0}).parse(r).OpenDRIVE.userData)==null?void 0:t.border;return{status:0,message:"ok",result:{md5:R(r),border:n}}}catch(i){return{status:-1,message:i.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.md5,console.timeEnd("md5用时"),console.log(t.result.border),this.openDriveServer=e.server;const i=`http://${this.openDriveServer}/api/openDrive/uploadXodr`;let r;try{r=await b.post(i,{},{params:{url:e.file,projectName:this.projectName}})}catch(g){return{status:-1,message:g.message}}if(r.status!==200)return{status:-1,message:r.statusText};console.time("渲染用时");const s=r.data.result.geoSetting;_.default.setGeoData(s.geoReference,s.offsetX,s.offsetY);let c=r.data.result.json;c.startsWith(window.location.protocol)||(c=`${window.location.protocol}//${e.server}${c}`);const a=await(await fetch(c)).arrayBuffer(),o=M.inflate(a,{to:"string"}),l=JSON.parse(o);await this.showAllLanes(l,((m=e.options)==null?void 0:m.showJunctionLane)||!1,((p=e.options)==null?void 0:p.showRoadName)||!0);const d=r.data.result.junctions;this.showJunction(d),e.options&&e.options.centerMap!==!1&&await this.view.goTo(this.allLaneGraphics),this.mouseMoveHandler||this.monitorMouseMove(),this.mouseClickHandler||this.monitorMouseClick();const h=H.default.useAppDataStore;return T.watch(()=>h.isSketching,()=>{var g,f;h.isSketching?((g=this.mouseMoveHandler)==null||g.remove(),this.mouseMoveHandler=void 0,(f=this.mouseClickHandler)==null||f.remove(),this.mouseClickHandler=void 0):(this.monitorMouseMove(),this.monitorMouseClick())}),console.timeEnd("渲染用时"),{status:0,message:"ok"}}async showOpenDriveFromServer(e,t){const i=`http://${e}/api/openDrive/analyzeXodr`,r=await b.get(i,{headers:{projectName:t},params:{analyze:!1,compressed:!0}});if(r.status!==200)throw new Error(`OpenDriveRenderer: ${r.statusText}`);let s=r.data.result.json;s.startsWith(window.location.protocol)||(s=`${window.location.protocol}//${e}${s}`);const n=await(await fetch(s)).arrayBuffer(),a=M.inflate(n,{to:"string"}),o=JSON.parse(a);return await this.showAllLanes(o,!1,!1),{status:0,message:"ok"}}async showAllLanes(e,t,i){const r=await this.laneLayer.queryFeatures();return r.features.length>0&&this.laneLayer.applyEdits({deleteFeatures:r.features}),this.roadNameLayer.visible=i,new Promise(s=>{let c=0;this.allLaneGraphics=[],this.allRefLineGraphics=[];const n=[];for(const o of e){if(!t&&o.junction!=="-1")continue;const{id:l,refLine:d}=o;let h=o.name;h.includes("(")&&(h=h.slice(0,h.indexOf("("))),h=h.replace(/(.)/g,"$1 ");const m=new y({geometry:{type:"polyline",paths:[d]},attributes:{ObjectID:c++,roadId:l,roadName:h}});this.allRefLineGraphics.push(m),o.laneSections.sort((p,g)=>Number(p.id)-Number(g.id));for(let p=0;p<o.laneSections.length;p++){const g=o.laneSections[p],f=Number(g.id);for(const u of g.lanePaths){const w=Number(u.id);if(w===0)continue;const I=u.type,F=[...u.outerPath],A=u.innerPath.concat(F.reverse());if(A.length<=3){console.warn(`lane ${w} has less than 3 points`);continue}A.push(u.innerPath[0]);const k=new N.Polygon({rings:[A]});if(k){const G=new y({geometry:k,attributes:{ObjectID:c++,id:`${l}+${f}+${w}`,fromNode:o.fromNode,toNode:o.toNode,roadId:String(l),roadName:o.name,sectionId:String(f),sectionIndex:p,laneId:w,type:I,sumoId:"",leftLine:u.innerPath,rightLine:u.outerPath}});this.allLaneGraphics.push(G),n.push(G)}}}}const a=setInterval(()=>{if(n.length>0||this.allRefLineGraphics.length>0){if(n.length>0){const o=n.splice(0,100);this.laneLayer.applyEdits({addFeatures:o})}if(this.allRefLineGraphics.length>0){const o=this.allRefLineGraphics.splice(0,10);this.roadNameLayer.applyEdits({addFeatures:o})}}else clearInterval(a),s()},10)})}showJunction(e){const t=[];for(const i of e){if(!i)continue;this.junctionNames.set(i.id,i.name),i.nodeType=i.type;const r=new 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(r)}this.junctionLayer.addMany(t)}monitorMouseMove(){const e=$.debounce(async t=>{var c;const r=(c=(await this.view.hitTest(t,{include:[this.laneLayer,this.junctionLayer]})).results)==null?void 0:c.filter(n=>n.type==="graphic");if(r.length===0){this.currentSectionCode!==""&&(this.currentSectionCode="",this.highlightLayer.removeAll()),this.currentJunctionId!==""&&(this.currentJunctionId=""),this.view.closePopup();return}const s=r[0];if(this.hitGraphic=s.graphic,s.layer.id==="OpenDriveLane"){const n=`${this.hitGraphic.getAttribute("roadId")}+${this.hitGraphic.getAttribute("sectionId")}`;if(this.currentSectionCode===n||this.selectedSectionIds.includes(n)||this.sectionLayer.graphics.findIndex(u=>u.getAttribute("id")===n)>=0)return;this.currentSectionCode=n;const o=this.allLaneGraphics.filter(u=>`${u.attributes.roadId}+${u.attributes.sectionId}`===n),l=S.union(o.map(u=>u.geometry)),d=this.hitGraphic.getAttribute("fromNode"),h=this.hitGraphic.getAttribute("toNode"),m=this.junctionNames.get(d)||d,p=this.junctionNames.get(h)||h,g=new y({geometry:l,symbol:{type:"simple-fill",color:[0,255,255,.5],style:"solid",outline:{color:[0,255,255],width:1}},attributes:{type:"OpenDriveSection",id:n,selected:!1,fromNodeName:m,toNodeName:p,laneCount:o.length},popupTemplate:{title:this.hitGraphic.getAttribute("roadName"),content:[{type:"fields",fieldInfos:[{fieldName:"fromNodeName",label:"起点路口"},{fieldName:"toNodeName",label:"终点路口"},{fieldName:"laneCount",label:"车道数量"}]}]}});this.highlightLayer.removeAll(),this.highlightLayer.add(g);const f=this.view.toMap(t);this.view.openPopup({features:[g],location:f})}else if(s.layer.id==="OpenDriveJunction"){const n=this.hitGraphic.getAttribute("id");if(n===this.currentJunctionId)return;this.currentJunctionId=n,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=$.debounce(async t=>{var a;const r=(a=(await this.view.hitTest(t,{include:[this.highlightLayer,this.junctionLayer,this.sectionLayer]})).results)==null?void 0:a.filter(o=>o.type==="graphic");if(r.length===0)return;const s=r[0].graphic,c=s.getAttribute("type"),n=s.getAttribute("id");if(c==="OpenDriveJunction")if(s.getAttribute("selected")===!1){const o=`http://${this.openDriveServer}/api/sumo/getSumoJunction`,l=await b.get(o,{params:{id:n,projectName:this.projectName}});l.status===200&&l.data.status===0&&(this.openDriveClickCallback&&this.openDriveClickCallback({type:"OpenDriveJunction",id:n,details:l.data.result}),s.setAttribute("selected",!0),s.symbol.url="/GisViewerAssets/Images/point_red.png",this.increasePictureMarkerSize(s,50))}else{this.openDriveClickCallback&&this.openDriveClickCallback({type:"OpenDriveJunction",id:n,details:void 0}),s.setAttribute("selected",!1);const o=s.getAttribute("crossId");s.symbol.url=o?"/GisViewerAssets/Images/point_green.png":"/GisViewerAssets/Images/point_yellow.png",this.decreasePictureMarkerSize(s,30)}else if(c==="OpenDriveSection")if(s.layer.id==="OpenDriveHighlight"){this.highlightLayer.remove(s),this.sectionLayer.add(s),s.setAttribute("selected",!0),this.selectedSectionIds.push(n);const o=`http://${this.openDriveServer}/api/sumo/getSumoEdge`,l=await b.get(o,{params:{id:n,projectName:this.projectName}});if(l.status===200&&l.data.status===0&&this.openDriveClickCallback){const d=l.data.result.obj_id;s.setAttribute("edgeId",d),this.openDriveClickCallback({type:"OpenDriveSection",id:d,details:l.data.result})}}else this.sectionLayer.remove(s),this.selectedSectionIds=this.selectedSectionIds.filter(o=>o!==n),this.openDriveClickCallback&&this.openDriveClickCallback({type:"OpenDriveSection",id:s.getAttribute("edgeId"),details:void 0})});this.mouseClickHandler=this.view.on("immediate-click",async t=>{e(t).catch(()=>{})})}increasePictureMarkerSize(e,t){const i=setInterval(()=>{const r=e.symbol,s=r.width;s<t?e.symbol={type:"picture-marker",url:r.url,width:s+1,height:s+1}:clearInterval(i)},20)}decreasePictureMarkerSize(e,t){const i=setInterval(()=>{const r=e.symbol,s=r.width;s>t?e.symbol={type:"picture-marker",url:r.url,width:s-1,height:s-1}:clearInterval(i)},20)}async getSumoInfo(e){switch(e.type){case"junction":{const t=`http://${this.openDriveServer}/api/sumo/getSumoJunction`,i=await b.get(t,{params:{id:e.id,projectName:this.projectName}});return i.status===200?i.data:{status:-1,message:`路口信息查询失败: ${e.id}`}}case"edge":{const t=e.id.split("#");let i=t[0];i.startsWith("-")&&(i=i.slice(1));let r=0;t.length===2&&(r=Number(t[1]));const s=this.allLaneGraphics.find(c=>c.getAttribute("roadId")===i&&c.getAttribute("sectionIndex")===r);if(s){const c=`${i}+${s.getAttribute("sectionId")}`,n=`http://${this.openDriveServer}/api/sumo/getSumoEdge`,a=await b.get(n,{params:{id:c,projectName:this.projectName}});return a.status===200?a.data:{status:-1,message:`路段信息查询失败: ${c}`}}else return{status:-1,message:"未知类型"}}default:return{status:-1,message:"未知类型"}}}async clearOpenDrive(){var t,i;let e=await this.laneLayer.queryFeatures();e.features.length>0&&await this.laneLayer.applyEdits({deleteFeatures:e.features}),e=await this.roadNameLayer.queryFeatures(),e.features.length>0&&await this.roadNameLayer.applyEdits({deleteFeatures:e.features}),this.highlightLayer.removeAll(),this.junctionLayer.removeAll(),this.sectionLayer.removeAll(),this.flashLayer.removeAll(),(t=this.mouseMoveHandler)==null||t.remove(),this.mouseMoveHandler=void 0,(i=this.mouseClickHandler)==null||i.remove(),this.mouseClickHandler=void 0}async findSumo(e){const{type:t,id:i}=e,r=e.flash===void 0?!0:e.flash;if(t==="junction")return await this.findJunction(i,r);if(t==="edge"){const s=i.split("_");if(s.length>2)return{status:-1,message:"id格式错误"};const c=s.length===2?Number(s[1]):void 0,n=s[0].split("#");if(n.length>2)return{status:-1,message:"id格式错误"};const a=n[0],o=n.length===2?Number(n[1]):void 0;return await this.findLane({roadsectId:a,segmentId:o,laneId:c,flash:r})}else return{status:-1,message:"未知类型"}}async findJunction(e,t){const i=this.junctionLayer.graphics.find(r=>r.attributes.id===e);if(!i)return{status:-1,message:"未找到。请检查路口编号"};if(t){const r=new y({geometry:i.geometry,symbol:{type:"simple-marker",style:"circle",size:30,color:[255,0,0,.6],outline:{color:"red",width:1}}});this.flashGraphic(r)}return await this.view.goTo(i.geometry,{duration:1e3}),{status:0,message:"ok"}}async findLane(e){let{roadsectId:t,segmentId:i,laneId:r}=e;t.startsWith("-")&&(t=t.slice(1));let s=this.allLaneGraphics.filter(a=>a.attributes.roadId===t);if(s.length===0)return{status:-1,message:"未找到。请检查路段编号"};if(i!==void 0){const a=[];if(s.forEach(o=>{const l=Number(o.attributes.sectionId);a.indexOf(l)===-1&&a.push(l)}),a.sort((o,l)=>o-l),i>a.length-1)return{status:-1,message:"未找到。请检查基本段编号"};i=a[i],s=s.filter(o=>Number(o.attributes.sectionId)===i)}if(r!==void 0){const a=[];if(s.forEach(o=>{const l=Number(o.attributes.laneId);a.indexOf(l)===-1&&a.push(l)}),a.sort((o,l)=>o-l),r>a.length-1)return{status:-1,message:"未找到。请检查车道编号"};r=a[r],s=s.filter(o=>Number(o.attributes.laneId)===r)}const c=s.map(a=>a.geometry),n=S.union(c);if(e.flash){const a=new y({geometry:n,symbol:{type:"simple-fill",color:[255,0,0,.5],style:"solid",outline:{color:"red",width:0}}});this.flashGraphic(a)}return await this.view.goTo(n,{duration:1e3}),{status:0,message:"ok"}}flashGraphic(e){this.flashLayer.removeAll(),this.flashLayer.add(e);let t=0,i=!0;const r=setInterval(()=>{i?(this.flashLayer.opacity-=.02,this.flashLayer.opacity<=.1&&(i=!1,t++)):(this.flashLayer.opacity+=.02,this.flashLayer.opacity>=1&&(i=!0)),t>=5&&(this.flashLayer.removeAll(),this.flashLayer.opacity=1,clearInterval(r))},10)}unselectSumo(e){if((!e||e.type==="junction")&&this.junctionLayer.graphics.forEach(t=>{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"){let t;!e||!e.id||e.id===""?t=this.sectionLayer.graphics.toArray():t=this.sectionLayer.graphics.filter(i=>i.getAttribute("edgeId")===e.id).toArray(),t.length>0&&(t.forEach(i=>{const r=i.getAttribute("id");this.selectedSectionIds=this.selectedSectionIds.filter(s=>s!==r)}),this.sectionLayer.removeMany(t))}return{status:0,message:"ok"}}selectSumo(e){switch(e.type){case"junction":return this.junctionLayer.graphics.forEach(t=>{if(e.id===t.getAttribute("id"))return t.setAttribute("selected",!0),t.symbol.url="/GisViewerAssets/Images/point_red.png",this.increasePictureMarkerSize(t,50),{status:0,message:"ok"}}),{status:-1,message:"未找到路口"};case"edge":{const t=e.id.split("#");let i=String(t[0]);i.startsWith("-")&&(i=i.slice(1));let r=0;t.length===2&&(r=Number(t[1]));let s=[];if(t.length===1?s=this.allLaneGraphics.filter(c=>c.getAttribute("roadId")===i):t.length===2&&(s=this.allLaneGraphics.filter(c=>c.getAttribute("roadId")===i&&c.getAttribute("sectionIndex")===r)),s.length>0){const c=new Map;return s.forEach(n=>{const a=n.getAttribute("roadId")+"+"+n.getAttribute("sectionId");this.selectedSectionIds.includes(a)||this.selectedSectionIds.push(a);let o=c.get(a);o?o.push(n.geometry):(o=[n.geometry],c.set(a,o))}),c.forEach((n,a)=>{const o=S.union(n),l=new y({geometry:o,symbol:{type:"simple-fill",color:[0,255,255,.5],style:"solid",outline:{color:[0,255,255],width:1}},attributes:{type:"OpenDriveSection",id:a,edgeId:e.id,selected:!0}});this.sectionLayer.add(l)}),{status:0,message:"ok"}}else return{status:-1,message:"未找到路段"}}default:return{status:-1,message:"未知类型"}}}async geometrySearch(e){const t=new N.Polygon({rings:[e]}),i=await this.laneLayer.queryFeatures({geometry:t,outFields:["*"]}),r=[],s=[];for(const a of i.features){const o=a.getAttribute("roadId"),l=a.getAttribute("sectionIndex"),d=`${o}#${l}`;if(r.indexOf(d)===-1){r.push(d),this.selectSumo({type:"edge",id:d});const h=`http://${this.openDriveServer}/api/sumo/getSumoEdge`,m=await b.get(h,{params:{id:`${o}+${a.getAttribute("sectionId")}`,projectName:this.projectName}});m.status===200&&m.data.status===0&&s.push(m.data.result)}}const c=this.junctionLayer.graphics.filter(a=>{const o=a.geometry;return S.contains(t,o)}),n=[];for(const a of c){const o=a.getAttribute("id");this.selectSumo({type:"junction",id:o});const l=`http://${this.openDriveServer}/api/sumo/getSumoJunction`,d=await b.get(l,{params:{id:o,projectName:this.projectName}});d.status===200&&d.data.status===0&&n.push(d.data.result)}return{status:0,message:"ok",result:{junctions:n,edges:s}}}async splitLane(e){const i=e.id.split("_");if(i.length!==2)return{status:-1,message:"车道编号格式错误"};const r=Number(i[1]),s=i[0].split("#"),c=s.length===2?Number(s[1]):0;let n=s[0];n.startsWith("-")&&(n=n.slice(1));const a=this.allLaneGraphics.filter(I=>I.getAttribute("roadId")===n&&I.getAttribute("sectionIndex")===c);if(a.length===0)return{status:-1,message:"未找到路段"};const o=a.length-r,l=a.find(I=>Math.abs(I.getAttribute("laneId"))===o);if(!l)return{status:-1,message:"未找到车道"};const d=e.start||0,h=e.end||100,m=x.lineString(l.getAttribute("leftLine")),p=O.lineSliceAlong(m,d,h,{units:"meters"}),g=x.lineString(l.getAttribute("rightLine")),f=O.lineSliceAlong(g,d,h,{units:"meters"}),u=p.geometry.coordinates.concat(f.geometry.coordinates.reverse());u.push(u[u.length-1]);const w=new y({geometry:new N.Polygon({rings:[u]}),attributes:{ObjectID:l.getAttribute("ObjectID"),id:l.getAttribute("id"),fromNode:l.getAttribute("fromNode"),toNode:l.getAttribute("toNode"),roadId:l.getAttribute("roadId"),roadName:l.getAttribute("roadName"),sectionId:l.getAttribute("sectionId"),sectionIndex:l.getAttribute("sectionIndex"),laneId:l.getAttribute("laneId"),type:l.getAttribute("type"),sumoId:l.getAttribute("sumoId"),leftLine:p.geometry.coordinates,rightLine:f.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=j;
|
|
1
|
+
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const y=require("@arcgis/core/Graphic"),P=require("@arcgis/core/core/promiseUtils"),N=require("@arcgis/core/geometry"),q=require("@arcgis/core/geometry/geometryEngine"),C=require("@arcgis/core/layers/FeatureLayer"),v=require("@arcgis/core/layers/GraphicsLayer"),J=require("@turf/helpers"),O=require("@turf/line-slice-along"),b=require("axios"),E=require("fast-xml-parser"),R=require("md5"),x=require("pako"),T=require("vue"),H=require("../../stores/index.js"),_=require("../common-utils.js");function D(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=D(P),S=D(q),$=D(J);class j{constructor(e){this.junctionNames=new Map,this.projectName="",this.openDriveServer="",this.currentSectionCode="",this.selectedSectionIds=[],this.currentJunctionId="",this.view=e,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:"sectionIndex",alias:"路段序号",type:"string"},{name:"laneId",alias:"车道号",type:"string"},{name:"type",alias:"类型",type:"string"},{name:"sumoId",alias:"sumo编号",type:"string"},{name:"fromNode",alias:"起点路口",type:"string"},{name:"toNode",alias:"终点路口",type:"string"}],objectIdField:"ObjectID",geometryType:"polygon",spatialReference:{wkid:4326},source:[],outFields:["*"],renderer:{type:"unique-value",field:"type",defaultSymbol:{type:"simple-fill",color:[100,100,100],style:"solid",outline:{color:"white",width:1}},uniqueValueInfos:[{value:"shoulder",label:"路肩",symbol:{type:"simple-fill",color:"#008000",style:"solid",outline:{color:"white",width:1}}},{value:"border",label:"路沿",symbol:{type:"simple-fill",color:"#DCDCDC",style:"solid",outline:{color:"white",width:1}}},{value:"driving",label:"机动车道",symbol:{type:"simple-fill",color:[47,79,79,.8],style:"solid",outline:{color:"white",width:1}}},{value:"none",label:"无",symbol:{type:"simple-fill",color:[111,120,135],style:"none",outline:{color:"white",width:1}}},{value:"restricted",label:"禁行区",symbol:{type:"simple-fill",color:"yellow",style:"solid",outline:{color:"yellow",width:2}}},{value:"parking",label:"停车区",symbol:{type:"simple-fill",color:[115,115,115],style:"solid",outline:{color:"white",width:1}}},{value:"median",label:"中央隔离带",symbol:{type:"simple-fill",color:"#008000",style:"solid",outline:{color:"white",width:1}}},{value:"biking",label:"非机动车道",symbol:{type:"simple-fill",color:"#D3D3D3",style:"solid",outline:{color:"white",width:1}}},{value:"sidewalk",label:"人行道",symbol:{type:"simple-fill",color:"#C0C0C0",style:"solid",outline:{color:"white",width:1}}},{value:"junction",label:"路口区域",symbol:{type:"simple-fill",color:"#2F4F4F",style:"solid",outline:{color:"white",width:1}}},{value:"selected",label:"选中车道",symbol:{type:"simple-fill",color:[141,168,211],style:"solid",outline:{color:"white",width:1}}}]}}),this.roadNameLayer=new 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 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.junctionLayer,this.sectionLayer,this.roadNameLayer,this.highlightLayer,this.flashLayer,this.drawLayer,this.splitLaneLayer,this.borderLayer])}static getInstance(e){return this.instance||(this.instance=new j(e)),this.instance}async makeMd5FromFile(e){var t;try{const r=await(await fetch(e)).text(),n=(t=new E.XMLParser({ignoreAttributes:!1,allowBooleanAttributes:!0}).parse(r).OpenDRIVE.userData)==null?void 0:t.border;return{status:0,message:"ok",result:{md5:R(r),border:n}}}catch(i){return{status:-1,message:i.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.md5,console.timeEnd("md5用时"),console.log(t.result.border),this.openDriveServer=e.server;const i=`http://${this.openDriveServer}/api/openDrive/uploadXodr`;let r;try{r=await b.post(i,{},{params:{url:e.file,projectName:this.projectName}})}catch(m){return{status:-1,message:m.message}}if(r.status!==200)return{status:-1,message:r.statusText};console.time("渲染用时");const s=r.data.result.geoSetting;_.default.setGeoData(s.geoReference,s.offsetX,s.offsetY);let c=r.data.result.json;c.startsWith(window.location.protocol)||(c=`${window.location.protocol}//${e.server}${c}`);const a=await(await fetch(c)).arrayBuffer(),o=x.inflate(a,{to:"string"}),l=JSON.parse(o);await this.showAllLanes(l,((g=e.options)==null?void 0:g.showJunctionLane)||!1,((p=e.options)==null?void 0:p.showRoadName)||!0);const d=r.data.result.junctions;this.showJunction(d),e.options&&e.options.centerMap!==!1&&await this.view.goTo(this.allLaneGraphics),this.mouseMoveHandler||this.monitorMouseMove(),this.mouseClickHandler||this.monitorMouseClick();const h=H.default.useAppDataStore;return T.watch(()=>h.isSketching,()=>{var m,f;h.isSketching?((m=this.mouseMoveHandler)==null||m.remove(),this.mouseMoveHandler=void 0,(f=this.mouseClickHandler)==null||f.remove(),this.mouseClickHandler=void 0):(this.monitorMouseMove(),this.monitorMouseClick())}),console.timeEnd("渲染用时"),{status:0,message:"ok"}}async showOpenDriveFromServer(e,t){const i=`http://${e}/api/openDrive/analyzeXodr`,r=await b.get(i,{headers:{projectName:t},params:{analyze:!1,compressed:!0}});if(r.status!==200)throw new Error(`OpenDriveRenderer: ${r.statusText}`);let s=r.data.result.json;s.startsWith(window.location.protocol)||(s=`${window.location.protocol}//${e}${s}`);const n=await(await fetch(s)).arrayBuffer(),a=x.inflate(n,{to:"string"}),o=JSON.parse(a);return await this.showAllLanes(o,!1,!1),{status:0,message:"ok"}}async showAllLanes(e,t,i){const r=await this.laneLayer.queryFeatures();return r.features.length>0&&this.laneLayer.applyEdits({deleteFeatures:r.features}),this.roadNameLayer.visible=i,new Promise(s=>{let c=0;this.allLaneGraphics=[],this.allRefLineGraphics=[];const n=[];for(const o of e){if(!t&&o.junction!=="-1")continue;const{id:l,refLine:d}=o;let h=o.name;h.includes("(")&&(h=h.slice(0,h.indexOf("("))),h=h.replace(/(.)/g,"$1 ");const g=new y({geometry:{type:"polyline",paths:[d]},attributes:{ObjectID:c++,roadId:l,roadName:h}});this.allRefLineGraphics.push(g),o.laneSections.sort((p,m)=>Number(p.id)-Number(m.id));for(let p=0;p<o.laneSections.length;p++){const m=o.laneSections[p],f=Number(m.id);for(const u of m.lanePaths){const w=Number(u.id);if(w===0)continue;const I=u.type,F=[...u.outerPath],A=u.innerPath.concat(F.reverse());if(A.length<=3){console.warn(`lane ${w} has less than 3 points`);continue}A.push(u.innerPath[0]);const k=new N.Polygon({rings:[A]});if(k){const G=new y({geometry:k,attributes:{ObjectID:c++,id:`${l}+${f}+${w}`,fromNode:o.fromNode,toNode:o.toNode,roadId:String(l),roadName:o.name,sectionId:String(f),sectionIndex:p,laneId:w,type:I,sumoId:"",leftLine:u.innerPath,rightLine:u.outerPath}});this.allLaneGraphics.push(G),n.push(G)}}}}const a=setInterval(()=>{if(n.length>0||this.allRefLineGraphics.length>0){if(n.length>0){const o=n.splice(0,100);this.laneLayer.applyEdits({addFeatures:o})}if(this.allRefLineGraphics.length>0){const o=this.allRefLineGraphics.splice(0,10);this.roadNameLayer.applyEdits({addFeatures:o})}}else clearInterval(a),s()},10)})}showJunction(e){const t=[];for(const i of e){if(!i)continue;this.junctionNames.set(i.id,i.name),i.nodeType=i.type;const r=new 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/xhj_1.png":"/GisViewerAssets/Images/xhj_2.png",width:"18px",height:"28px",yoffset:"9px"},popupTemplate:{title:i.name,content:[{type:"fields",fieldInfos:[{fieldName:"id",label:"路口编号"},{fieldName:"crossId",label:"信号机编号"}]}]}});t.push(r)}this.junctionLayer.addMany(t)}monitorMouseMove(){const e=M.debounce(async t=>{var c;const r=(c=(await this.view.hitTest(t,{include:[this.laneLayer,this.junctionLayer]})).results)==null?void 0:c.filter(n=>n.type==="graphic");if(r.length===0){this.currentSectionCode!==""&&(this.currentSectionCode="",this.highlightLayer.removeAll()),this.currentJunctionId!==""&&(this.currentJunctionId=""),this.view.closePopup();return}const s=r[0];if(this.hitGraphic=s.graphic,s.layer.id==="OpenDriveLane"){const n=`${this.hitGraphic.getAttribute("roadId")}+${this.hitGraphic.getAttribute("sectionId")}`;if(this.currentSectionCode===n||this.selectedSectionIds.includes(n)||this.sectionLayer.graphics.findIndex(u=>u.getAttribute("id")===n)>=0)return;this.currentSectionCode=n;const o=this.allLaneGraphics.filter(u=>`${u.attributes.roadId}+${u.attributes.sectionId}`===n),l=S.union(o.map(u=>u.geometry)),d=this.hitGraphic.getAttribute("fromNode"),h=this.hitGraphic.getAttribute("toNode"),g=this.junctionNames.get(d)||d,p=this.junctionNames.get(h)||h,m=new y({geometry:l,symbol:{type:"simple-fill",color:[0,255,255,.5],style:"solid",outline:{color:[0,255,255],width:1}},attributes:{type:"OpenDriveSection",id:n,selected:!1,fromNodeName:g,toNodeName:p,laneCount:o.length},popupTemplate:{title:this.hitGraphic.getAttribute("roadName"),content:[{type:"fields",fieldInfos:[{fieldName:"fromNodeName",label:"起点路口"},{fieldName:"toNodeName",label:"终点路口"},{fieldName:"laneCount",label:"车道数量"}]}]}});this.highlightLayer.removeAll(),this.highlightLayer.add(m);const f=this.view.toMap(t);this.view.openPopup({features:[m],location:f})}else if(s.layer.id==="OpenDriveJunction"){const n=this.hitGraphic.getAttribute("id");if(n===this.currentJunctionId)return;this.currentJunctionId=n,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 r=(a=(await this.view.hitTest(t,{include:[this.highlightLayer,this.junctionLayer,this.sectionLayer]})).results)==null?void 0:a.filter(o=>o.type==="graphic");if(r.length===0)return;const s=r[0].graphic,c=s.getAttribute("type"),n=s.getAttribute("id");if(c==="OpenDriveJunction")if(s.getAttribute("selected")===!1){const o=`http://${this.openDriveServer}/api/sumo/getSumoJunction`,l=await b.get(o,{params:{id:n,projectName:this.projectName}});l.status===200&&l.data.status===0&&(this.openDriveClickCallback&&this.openDriveClickCallback({type:"OpenDriveJunction",id:n,details:l.data.result}),s.setAttribute("selected",!0),s.symbol.url="/GisViewerAssets/Images/point_red.png",this.increasePictureMarkerSize(s,50))}else{this.openDriveClickCallback&&this.openDriveClickCallback({type:"OpenDriveJunction",id:n,details:void 0}),s.setAttribute("selected",!1);const o=s.getAttribute("crossId");s.symbol.url=o?"/GisViewerAssets/Images/point_green.png":"/GisViewerAssets/Images/point_yellow.png",this.decreasePictureMarkerSize(s,30)}else if(c==="OpenDriveSection")if(s.layer.id==="OpenDriveHighlight"){this.highlightLayer.remove(s),this.sectionLayer.add(s),s.setAttribute("selected",!0),this.selectedSectionIds.push(n);const o=`http://${this.openDriveServer}/api/sumo/getSumoEdge`,l=await b.get(o,{params:{id:n,projectName:this.projectName}});if(l.status===200&&l.data.status===0&&this.openDriveClickCallback){const d=l.data.result.obj_id;s.setAttribute("edgeId",d),this.openDriveClickCallback({type:"OpenDriveSection",id:d,details:l.data.result})}}else this.sectionLayer.remove(s),this.selectedSectionIds=this.selectedSectionIds.filter(o=>o!==n),this.openDriveClickCallback&&this.openDriveClickCallback({type:"OpenDriveSection",id:s.getAttribute("edgeId"),details:void 0})});this.mouseClickHandler=this.view.on("immediate-click",async t=>{e(t).catch(()=>{})})}increasePictureMarkerSize(e,t){const i=setInterval(()=>{const r=e.symbol,s=r.width;s<t?e.symbol={type:"picture-marker",url:r.url,width:s+1,height:s+1}:clearInterval(i)},20)}decreasePictureMarkerSize(e,t){const i=setInterval(()=>{const r=e.symbol,s=r.width;s>t?e.symbol={type:"picture-marker",url:r.url,width:s-1,height:s-1}:clearInterval(i)},20)}async getSumoInfo(e){switch(e.type){case"junction":{const t=`http://${this.openDriveServer}/api/sumo/getSumoJunction`,i=await b.get(t,{params:{id:e.id,projectName:this.projectName}});return i.status===200?i.data:{status:-1,message:`路口信息查询失败: ${e.id}`}}case"edge":{const t=e.id.split("#");let i=t[0];i.startsWith("-")&&(i=i.slice(1));let r=0;t.length===2&&(r=Number(t[1]));const s=this.allLaneGraphics.find(c=>c.getAttribute("roadId")===i&&c.getAttribute("sectionIndex")===r);if(s){const c=`${i}+${s.getAttribute("sectionId")}`,n=`http://${this.openDriveServer}/api/sumo/getSumoEdge`,a=await b.get(n,{params:{id:c,projectName:this.projectName}});return a.status===200?a.data:{status:-1,message:`路段信息查询失败: ${c}`}}else return{status:-1,message:"未知类型"}}default:return{status:-1,message:"未知类型"}}}async clearOpenDrive(){var t,i;let e=await this.laneLayer.queryFeatures();e.features.length>0&&await this.laneLayer.applyEdits({deleteFeatures:e.features}),e=await this.roadNameLayer.queryFeatures(),e.features.length>0&&await this.roadNameLayer.applyEdits({deleteFeatures:e.features}),this.highlightLayer.removeAll(),this.junctionLayer.removeAll(),this.sectionLayer.removeAll(),this.flashLayer.removeAll(),(t=this.mouseMoveHandler)==null||t.remove(),this.mouseMoveHandler=void 0,(i=this.mouseClickHandler)==null||i.remove(),this.mouseClickHandler=void 0}async findSumo(e){const{type:t,id:i}=e,r=e.flash===void 0?!0:e.flash;if(t==="junction")return await this.findJunction(i,r);if(t==="edge"){const s=i.split("_");if(s.length>2)return{status:-1,message:"id格式错误"};const c=s.length===2?Number(s[1]):void 0,n=s[0].split("#");if(n.length>2)return{status:-1,message:"id格式错误"};const a=n[0],o=n.length===2?Number(n[1]):void 0;return await this.findLane({roadsectId:a,segmentId:o,laneId:c,flash:r})}else return{status:-1,message:"未知类型"}}async findJunction(e,t){const i=this.junctionLayer.graphics.find(r=>r.attributes.id===e);if(!i)return{status:-1,message:"未找到。请检查路口编号"};if(t){const r=new y({geometry:i.geometry,symbol:{type:"simple-marker",style:"circle",size:30,color:[0,0,255,.6],outline:{color:"blue",width:1}}});this.flashGraphic(r)}return await this.view.goTo(i.geometry,{duration:1e3}),{status:0,message:"ok"}}async findLane(e){let{roadsectId:t,segmentId:i,laneId:r}=e;t.startsWith("-")&&(t=t.slice(1));let s=this.allLaneGraphics.filter(a=>a.attributes.roadId===t);if(s.length===0)return{status:-1,message:"未找到。请检查路段编号"};if(i!==void 0){const a=[];if(s.forEach(o=>{const l=Number(o.attributes.sectionId);a.indexOf(l)===-1&&a.push(l)}),a.sort((o,l)=>o-l),i>a.length-1)return{status:-1,message:"未找到。请检查基本段编号"};i=a[i],s=s.filter(o=>Number(o.attributes.sectionId)===i)}if(r!==void 0){const a=[];if(s.forEach(o=>{const l=Number(o.attributes.laneId);a.indexOf(l)===-1&&a.push(l)}),a.sort((o,l)=>o-l),r>a.length-1)return{status:-1,message:"未找到。请检查车道编号"};r=a[r],s=s.filter(o=>Number(o.attributes.laneId)===r)}const c=s.map(a=>a.geometry),n=S.union(c);if(e.flash){const a=new y({geometry:n,symbol:{type:"simple-fill",color:[0,0,255,.6],style:"solid",outline:{width:0}}});this.flashGraphic(a)}return await this.view.goTo(n,{duration:1e3}),{status:0,message:"ok"}}flashGraphic(e){this.flashLayer.removeAll(),this.flashLayer.add(e);let t=0,i=!0;const r=setInterval(()=>{i?(this.flashLayer.opacity-=.02,this.flashLayer.opacity<=.1&&(i=!1,t++)):(this.flashLayer.opacity+=.02,this.flashLayer.opacity>=1&&(i=!0)),t>=5&&(this.flashLayer.removeAll(),this.flashLayer.opacity=1,clearInterval(r))},10)}unselectSumo(e){if((!e||e.type==="junction")&&this.junctionLayer.graphics.forEach(t=>{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"){let t;!e||!e.id||e.id===""?t=this.sectionLayer.graphics.toArray():t=this.sectionLayer.graphics.filter(i=>i.getAttribute("edgeId")===e.id).toArray(),t.length>0&&(t.forEach(i=>{const r=i.getAttribute("id");this.selectedSectionIds=this.selectedSectionIds.filter(s=>s!==r)}),this.sectionLayer.removeMany(t))}return{status:0,message:"ok"}}selectSumo(e){switch(e.type){case"junction":return this.junctionLayer.graphics.forEach(t=>{if(e.id===t.getAttribute("id"))return t.setAttribute("selected",!0),t.symbol.url="/GisViewerAssets/Images/point_red.png",this.increasePictureMarkerSize(t,50),{status:0,message:"ok"}}),{status:-1,message:"未找到路口"};case"edge":{const t=e.id.split("#");let i=String(t[0]);i.startsWith("-")&&(i=i.slice(1));let r=0;t.length===2&&(r=Number(t[1]));let s=[];if(t.length===1?s=this.allLaneGraphics.filter(c=>c.getAttribute("roadId")===i):t.length===2&&(s=this.allLaneGraphics.filter(c=>c.getAttribute("roadId")===i&&c.getAttribute("sectionIndex")===r)),s.length>0){const c=new Map;return s.forEach(n=>{const a=n.getAttribute("roadId")+"+"+n.getAttribute("sectionId");this.selectedSectionIds.includes(a)||this.selectedSectionIds.push(a);let o=c.get(a);o?o.push(n.geometry):(o=[n.geometry],c.set(a,o))}),c.forEach((n,a)=>{const o=S.union(n),l=new y({geometry:o,symbol:{type:"simple-fill",color:[0,255,255,.5],style:"solid",outline:{color:[0,255,255],width:1}},attributes:{type:"OpenDriveSection",id:a,edgeId:e.id,selected:!0}});this.sectionLayer.add(l)}),{status:0,message:"ok"}}else return{status:-1,message:"未找到路段"}}default:return{status:-1,message:"未知类型"}}}async geometrySearch(e){const t=new N.Polygon({rings:[e]}),i=await this.laneLayer.queryFeatures({geometry:t,outFields:["*"]}),r=[],s=[];for(const a of i.features){const o=a.getAttribute("roadId"),l=a.getAttribute("sectionIndex"),d=`${o}#${l}`;if(r.indexOf(d)===-1){r.push(d),this.selectSumo({type:"edge",id:d});const h=`http://${this.openDriveServer}/api/sumo/getSumoEdge`,g=await b.get(h,{params:{id:`${o}+${a.getAttribute("sectionId")}`,projectName:this.projectName}});g.status===200&&g.data.status===0&&s.push(g.data.result)}}const c=this.junctionLayer.graphics.filter(a=>{const o=a.geometry;return S.contains(t,o)}),n=[];for(const a of c){const o=a.getAttribute("id");this.selectSumo({type:"junction",id:o});const l=`http://${this.openDriveServer}/api/sumo/getSumoJunction`,d=await b.get(l,{params:{id:o,projectName:this.projectName}});d.status===200&&d.data.status===0&&n.push(d.data.result)}return{status:0,message:"ok",result:{junctions:n,edges:s}}}async splitLane(e){const i=e.id.split("_");if(i.length!==2)return{status:-1,message:"车道编号格式错误"};const r=Number(i[1]),s=i[0].split("#"),c=s.length===2?Number(s[1]):0;let n=s[0];n.startsWith("-")&&(n=n.slice(1));const a=this.allLaneGraphics.filter(I=>I.getAttribute("roadId")===n&&I.getAttribute("sectionIndex")===c);if(a.length===0)return{status:-1,message:"未找到路段"};const o=a.length-r,l=a.find(I=>Math.abs(I.getAttribute("laneId"))===o);if(!l)return{status:-1,message:"未找到车道"};const d=e.start||0,h=e.end||100,g=$.lineString(l.getAttribute("leftLine")),p=O.lineSliceAlong(g,d,h,{units:"meters"}),m=$.lineString(l.getAttribute("rightLine")),f=O.lineSliceAlong(m,d,h,{units:"meters"}),u=p.geometry.coordinates.concat(f.geometry.coordinates.reverse());u.push(u[u.length-1]);const w=new y({geometry:new N.Polygon({rings:[u]}),attributes:{ObjectID:l.getAttribute("ObjectID"),id:l.getAttribute("id"),fromNode:l.getAttribute("fromNode"),toNode:l.getAttribute("toNode"),roadId:l.getAttribute("roadId"),roadName:l.getAttribute("roadName"),sectionId:l.getAttribute("sectionId"),sectionIndex:l.getAttribute("sectionIndex"),laneId:l.getAttribute("laneId"),type:l.getAttribute("type"),sumoId:l.getAttribute("sumoId"),leftLine:p.geometry.coordinates,rightLine:f.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=j;
|
|
@@ -5,10 +5,12 @@ export default class SignalControlAreaController {
|
|
|
5
5
|
private subDistrictControllerLayer;
|
|
6
6
|
private crossLayer;
|
|
7
7
|
private highlightLayer;
|
|
8
|
+
private districtControllers;
|
|
8
9
|
private watchHandle?;
|
|
10
|
+
private openDriveServerUrl;
|
|
9
11
|
private readonly crossScale;
|
|
10
12
|
constructor(view: __esri.MapView | __esri.SceneView);
|
|
11
|
-
showSignalControlArea(params: any): IResult
|
|
13
|
+
showSignalControlArea(params: any): Promise<IResult>;
|
|
12
14
|
clearSignalControlArea(): IResult;
|
|
13
15
|
locateSignalControlArea(params: {
|
|
14
16
|
id: string;
|
|
@@ -25,12 +27,14 @@ export default class SignalControlAreaController {
|
|
|
25
27
|
*/
|
|
26
28
|
private findAreaGraphic;
|
|
27
29
|
/**
|
|
28
|
-
*
|
|
30
|
+
* 显示区控
|
|
29
31
|
* @param districtController
|
|
30
|
-
* @param isDistrict 是否是区控
|
|
31
32
|
* @returns
|
|
32
33
|
*/
|
|
33
|
-
private
|
|
34
|
+
private showDistrict;
|
|
35
|
+
private showSubDistrictCross;
|
|
36
|
+
private loadedSubDistricts;
|
|
37
|
+
private showSubDistrictRoad;
|
|
34
38
|
/**
|
|
35
39
|
* 生成路口点符号。在不同比例尺下,使用不同的符号
|
|
36
40
|
* @param attributes
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const f=require("@arcgis/core/core/reactiveUtils.js"),
|
|
1
|
+
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const f=require("@arcgis/core/core/reactiveUtils.js"),b=require("@arcgis/core/geometry"),C=require("@arcgis/core/geometry/geometryEngine.js"),l=require("@arcgis/core/Graphic"),n=require("@arcgis/core/layers/GraphicsLayer"),v=require("@turf/buffer"),S=require("@turf/concave"),L=require("@turf/helpers"),w=require("axios"),I=require("../../stores/index.js"),y=require("../common-utils.js"),A=require("./district-controller.js");function d(a){const e=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(a){for(const i in a)if(i!=="default"){const r=Object.getOwnPropertyDescriptor(a,i);Object.defineProperty(e,i,r.get?r:{enumerable:!0,get:()=>a[i]})}}return e.default=a,Object.freeze(e)}const D=d(f),m=d(C),c=d(L);class N{constructor(e){this.districtControllers=[],this.crossScale=5e3,this.loadedSubDistricts=[],this.view=e;const r=I.default.useAppDataStore.mapConfig;this.openDriveServerUrl=r.openDriveServer.url,this.districtControllerLayer=new n({id:"districtControllerLayer",maxScale:144447,minScale:1155582}),this.subDistrictControllerLayer=new n({id:"subDistrictControllerLayer",maxScale:0,minScale:144447}),this.crossLayer=new n({id:"crossLayer",maxScale:0,minScale:36112}),this.highlightLayer=new n({id:"highlightLayer"}),this.view.map.addMany([this.districtControllerLayer,this.subDistrictControllerLayer,this.crossLayer,this.highlightLayer])}async showSignalControlArea(e){console.time("showSignalControlArea"),this.districtControllerLayer.removeAll(),this.subDistrictControllerLayer.removeAll(),this.crossLayer.removeAll(),this.highlightLayer.removeAll(),this.districtControllerLayer.visible=!0,this.subDistrictControllerLayer.visible=!0;for(const i of e){const r=new A.default(i);this.showDistrict(r),this.districtControllers.push(r)}this.watchHandle=D.watch(()=>this.view.scale,(i,r)=>{i>this.crossScale&&r<=this.crossScale?(this.crossLayer.graphics.forEach(t=>{t.symbol=this.getCrossGraphicSymbol(t.attributes,"marker")}),this.highlightLayer.graphics.forEach(t=>{t.getAttribute("type")==="cross"&&(t.symbol=this.getCrossGraphicSymbol(t.attributes,"marker"))})):i<=this.crossScale&&r>this.crossScale&&(this.crossLayer.graphics.forEach(t=>{t.symbol=this.getCrossGraphicSymbol(t.attributes,"picture")}),this.highlightLayer.graphics.forEach(t=>{t.getAttribute("type")==="cross"&&(t.symbol=this.getCrossGraphicSymbol(t.attributes,"picture"))}))});for(const i of this.districtControllers)for(const r of i.subDistricts)await this.showSubDistrictRoad(r);return console.timeEnd("showSignalControlArea"),{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 i=this.findAreaGraphic(e.id);return i?(i[0].attributes.type==="cross"?await this.view.goTo({target:i,scale:1500}):await this.view.goTo(i),{status:0,message:"ok"}):{status:1,message:"未找到"}}showPopup(e){const i=e.geometry.type==="point"?e.geometry:e.geometry.centroid;this.view.openPopup({features:[e],location:i})}async highlightSignalControlArea(e){if(!e.id||e.id==="")return{status:1,message:"请输入id"};this.highlightLayer.removeAll(),this.districtControllerLayer.visible=!1,this.subDistrictControllerLayer.visible=!1,this.crossLayer.visible=!1;for(const s of this.districtControllers)for(const o of s.subDistricts)(o.id===e.id||o.parentId===e.id)&&await this.showSubDistrictRoad(o);const i=this.districtControllerLayer.graphics.filter(s=>s.getAttribute("id")===e.id).toArray().map(s=>s.clone()),r=this.subDistrictControllerLayer.graphics.filter(s=>s.getAttribute("districtId")===e.id||s.getAttribute("subDistrictId")===e.id).toArray().map(s=>s.clone()),t=this.crossLayer.graphics.filter(s=>s.getAttribute("id")===e.id||s.getAttribute("districtId")===e.id||s.getAttribute("subDistrictId")===e.id).toArray().map(s=>s.clone());return i.length>0&&this.highlightLayer.addMany(i),r.length>0&&this.highlightLayer.addMany(r),t.length>0&&this.highlightLayer.addMany(t),this.highlightLayer.graphics.length===0?{status:1,message:"未找到"}:(i.length>0?await this.view.goTo(i):r.length>0?await this.view.goTo({target:r,scale:this.crossScale-500}):t.length>1?await this.view.goTo(t):await this.view.goTo({target:t[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 i=this.districtControllerLayer.graphics.filter(r=>r.attributes.id===e);if(i||(i=this.subDistrictControllerLayer.graphics.filter(r=>r.attributes.getAttribute("subDistrictId")===e)),i||(i=this.crossLayer.graphics.filter(r=>r.attributes.id===e)),i.length!==0)return i.toArray()}showDistrict(e){const i=e.getAllCrossCoordinates();if(i.length>=2){let t=null;if(i.length===2)t=c.lineString(i);else if(i.length>2){const g=c.featureCollection(i.map(p=>c.point(p)));t=S(g)}t||(t=c.lineString(i));const s=v(t.geometry,200,{units:"meters"}),o=[{fieldName:"id",label:"区控编号"},{fieldName:"crossCount",label:"路口数量"},{fieldName:"subDistrictCount",label:"子区数量"}],h={type:"signalControlArea",id:e.id,name:e.name,parentId:e.parentId,parentName:e.parentName,crossCount:e.crossCount,subDistrictCount:e.subDistrictCount},u=new l({geometry:{type:"polygon",rings:s.geometry.coordinates},symbol:{type:"simple-fill",color:[...e.areaColor,.1],outline:{color:e.areaColor,width:2}},attributes:h,popupTemplate:{title:`区控 ${e.name}`,content:[{type:"fields",fieldInfos:o}]}});this.districtControllerLayer.add(u)}for(let t=0;t<e.subDistricts.length;t++){const s=e.subDistricts[t];this.showSubDistrictCross(s)}const r=[];e.crosses=e.crosses.filter(t=>y.default.isCoordinateValid(t)),e.crosses.forEach(t=>{if(y.default.isCoordinateValid(t)){const s={type:"cross",id:t.id,name:t.name,color:e.areaColor,signalId:t.signalId,districtId:e.id,districtName:e.name,isKey:t.isKey},o=new l({geometry:{type:"point",x:t.longitude,y:t.latitude},symbol:this.getCrossGraphicSymbol(s,"marker"),attributes:s,popupTemplate:{title:t.name,content:[{type:"fields",fieldInfos:[{fieldName:"districtName",label:"区控名称"},{fieldName:"id",label:"路口编号"},{fieldName:"signalId",label:"信号机编号"}]}]}});r.push(o)}else console.log("路口坐标无效",t)}),this.crossLayer.addMany(r)}showSubDistrictCross(e){const i=[];e.crosses=e.crosses.filter(r=>y.default.isCoordinateValid(r)),e.crosses.forEach(r=>{const t={type:"cross",id:r.id,name:r.name,color:e.areaColor,signalId:r.signalId,districtId:e.parentId,districtName:e.parentName,subDistrictId:e.id,subDistrictName:e.name,isKey:r.isKey},s=new l({geometry:{type:"point",x:r.longitude,y:r.latitude},symbol:this.getCrossGraphicSymbol(t,"marker"),attributes:t,popupTemplate:{title:r.name,content:[{type:"fields",fieldInfos:[{fieldName:"districtName",label:"区控名称"},{fieldName:"subDistrictName",label:"子区名称"},{fieldName:"id",label:"路口编号"},{fieldName:"signalId",label:"信号机编号"}]}]}});i.push(s)}),this.crossLayer.addMany(i)}async showSubDistrictRoad(e){if(e.crosses.length>1&&!this.loadedSubDistricts.includes(e.id)&&this.openDriveServerUrl&&this.openDriveServerUrl!==""){this.loadedSubDistricts.push(e.id);const i=await w.get(`http://${this.openDriveServerUrl}/api/computable/getRoadsectWithinJunctions`,{params:{junctionIds:e.crosses.map(r=>r.id).join(",")}});if(i.status===200){const r=i.data.result;if(r.length>0){const t=r.map(u=>new b.Polyline({paths:[u]})),s=m.geodesicBuffer(t,5,"meters"),o=m.union(s),h=new l({geometry:o,symbol:{type:"simple-fill",color:[...e.areaColor,.8],outline:{color:e.areaColor,width:1}},attributes:{districtId:e.parentId,districtName:e.parentName,subDistrictId:e.id,subDistrictName:e.name}});this.subDistrictControllerLayer.add(h)}}}}getCrossGraphicSymbol(e,i){const{isKey:r,color:t}=e;if(i==="marker")return r?{type:"picture-marker",url:"/GisViewerAssets/Images/icon_star.png",width:"30px",height:"30px"}:{type:"simple-marker",style:"circle",color:t,size:8,outline:{color:"white",width:1}};if(i==="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?60:40,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`,offsetY:r?22:15}]}}}}}exports.default=N;
|