gisviewer-vue3-arcgis 1.0.265 → 1.0.266
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 +31 -31
- package/es/src/gis-map/index.d.ts +1 -1
- package/es/src/gis-map/utils/open-drive-renderer/index.d.ts +6 -1
- package/es/src/gis-map/utils/open-drive-renderer/index.mjs +15 -12
- 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.d.ts +6 -1
- package/lib/src/gis-map/utils/open-drive-renderer/index.js +1 -1
- package/package.json +1 -1
|
@@ -150,7 +150,7 @@ declare const _sfc_main: import("vue").DefineComponent<{
|
|
|
150
150
|
status: number;
|
|
151
151
|
message: string;
|
|
152
152
|
}>;
|
|
153
|
-
clearBlockOpenDriveLane: () => void | {
|
|
153
|
+
clearBlockOpenDriveLane: (params: IBlockOpenDriveLaneParams) => void | {
|
|
154
154
|
status: number;
|
|
155
155
|
message: string;
|
|
156
156
|
};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { defineComponent as gt, ref as _, reactive as ft, onMounted as yt, getCurrentInstance as wt, onUnmounted as Ct, computed as
|
|
2
|
-
import G, { registerStore as
|
|
1
|
+
import { defineComponent as gt, ref as _, reactive as ft, onMounted as yt, getCurrentInstance as wt, onUnmounted as Ct, computed as vt, openBlock as T, createElementBlock as x, createElementVNode as y, withDirectives as St, vShow as ht, Fragment as bt, renderList as Ot, createBlock as At } from "vue";
|
|
2
|
+
import G, { registerStore as kt } from "./stores/index.mjs";
|
|
3
3
|
import "./style/index.css";
|
|
4
|
-
import
|
|
4
|
+
import Dt from "./utils/dbscan-cluster/index.mjs";
|
|
5
5
|
import Lt from "./utils/detect-gpu.mjs";
|
|
6
6
|
import Tt from "./utils/edpass-device-controller.mjs";
|
|
7
7
|
import H from "./utils/green-wave-band-controller/index.mjs";
|
|
@@ -27,14 +27,14 @@ const xt = { class: "gis-viewer" }, Gt = { style: { position: "absolute", bottom
|
|
|
27
27
|
const h = _(null);
|
|
28
28
|
let n, p, c, o, r, s, g, t, l, a, d, w, b, f;
|
|
29
29
|
const O = _(!1);
|
|
30
|
-
|
|
30
|
+
kt();
|
|
31
31
|
const B = G.useAppDataStore, M = ft([]), P = (e) => Math.log2(591657527591555e-6 / e);
|
|
32
32
|
let C = null, V = null;
|
|
33
33
|
const A = (e) => {
|
|
34
34
|
if (!Number.isFinite(e))
|
|
35
35
|
return;
|
|
36
36
|
const u = Math.round(e);
|
|
37
|
-
u !== V && (V = u,
|
|
37
|
+
u !== V && (V = u, v("update:zoom", u));
|
|
38
38
|
};
|
|
39
39
|
Lt(), yt(async () => {
|
|
40
40
|
if (!h.value)
|
|
@@ -46,33 +46,33 @@ const xt = { class: "gis-viewer" }, Gt = { style: { position: "absolute", bottom
|
|
|
46
46
|
i.assetsRoot = z.assetsRoot || u, B.mapConfig = i, p = new Mt(), B.mapInitializer = p, n = await p.initialize({
|
|
47
47
|
container: h.value,
|
|
48
48
|
mapConfig: i,
|
|
49
|
-
markerClickCallback: (m,
|
|
50
|
-
|
|
49
|
+
markerClickCallback: (m, D, L, dt) => {
|
|
50
|
+
v("markerClick", m, D, L, dt);
|
|
51
51
|
},
|
|
52
|
-
mapClickCallback: (m,
|
|
53
|
-
|
|
52
|
+
mapClickCallback: (m, D, L) => {
|
|
53
|
+
v("mapClick", m, D, L);
|
|
54
54
|
}
|
|
55
55
|
});
|
|
56
|
-
const
|
|
57
|
-
typeof
|
|
56
|
+
const S = n.zoom ?? (n.scale ? P(n.scale) : void 0);
|
|
57
|
+
typeof S == "number" && A(S);
|
|
58
58
|
const pt = n.zoom !== void 0 ? n.watch("zoom", (m) => {
|
|
59
59
|
A(m);
|
|
60
60
|
}) : n.watch("scale", (m) => {
|
|
61
61
|
typeof m == "number" && m > 0 && A(P(m));
|
|
62
62
|
});
|
|
63
|
-
C = () => pt.remove(), r = new It(n, M), await r.init(),
|
|
63
|
+
C = () => pt.remove(), r = new It(n, M), await r.init(), v("mapLoaded");
|
|
64
64
|
}), Ct(() => {
|
|
65
65
|
a == null || a.clearSignalControlArea(), t == null || t.clearOpenDrive(), r.clearHoloTrace(), r.clearHoloSignal(), o == null || o.disconnectTrafficFlow(), C == null || C(), C = null;
|
|
66
66
|
});
|
|
67
|
-
const J =
|
|
67
|
+
const J = vt(() => n), U = () => {
|
|
68
68
|
const e = G.useAppDataStore;
|
|
69
69
|
e.saveTrackLog = !0;
|
|
70
70
|
}, $ = () => {
|
|
71
71
|
r.downloadTrackLog();
|
|
72
72
|
}, q = () => {
|
|
73
|
-
|
|
73
|
+
k("vehicleId");
|
|
74
74
|
}, K = () => {
|
|
75
|
-
|
|
75
|
+
k("plateNumber");
|
|
76
76
|
}, F = async (e) => await p.setMapCenter(e), X = async (e) => await p.setMapCamera(e), Y = (e) => p.setMapZoom(e), R = async (e) => await p.lookAt(e), ee = (e) => p.setLayerVisibility(e), te = (e, u) => p.requestCoordinateTransform(e, u), ne = (e) => {
|
|
77
77
|
p.cancelCoordinateTransform(e);
|
|
78
78
|
}, ae = (e) => {
|
|
@@ -100,17 +100,17 @@ const xt = { class: "gis-viewer" }, Gt = { style: { position: "absolute", bottom
|
|
|
100
100
|
r.clearHoloSignal();
|
|
101
101
|
}, Ce = (e) => {
|
|
102
102
|
o == null || o.toggleTrafficInfo(e), r == null || r.toggleTrafficInfo(e);
|
|
103
|
-
}, Se = (e) => {
|
|
104
|
-
r == null || r.togglePause(e);
|
|
105
103
|
}, ve = (e) => {
|
|
104
|
+
r == null || r.togglePause(e);
|
|
105
|
+
}, Se = (e) => {
|
|
106
106
|
o == null || o.toggleTrafficObject(e), r == null || r.toggleTrafficObject(e);
|
|
107
|
-
},
|
|
107
|
+
}, k = (e) => {
|
|
108
108
|
r == null || r.updatePanelContent(e);
|
|
109
|
-
}, he = async (e) => (s || (s = new N(n)), s.addOverlays(e)), be = async (e) => (f || (f = new
|
|
109
|
+
}, he = async (e) => (s || (s = new N(n)), s.addOverlays(e)), be = async (e) => (f || (f = new Dt(n)), f.addClusterPoints(e)), Oe = () => {
|
|
110
110
|
f == null || f.removeAllClusterPoints();
|
|
111
|
-
}, Ae = (e) => (s || (s = new N(n)), s.addMask(e)),
|
|
111
|
+
}, Ae = (e) => (s || (s = new N(n)), s.addMask(e)), ke = () => {
|
|
112
112
|
s == null || s.removeMask();
|
|
113
|
-
},
|
|
113
|
+
}, De = (e) => s == null ? void 0 : s.removeOverlaysByType(e), Le = (e) => s == null ? void 0 : s.removeOverlaysById(e), Te = () => s == null ? void 0 : s.removeAllOverlays(), Ie = () => {
|
|
114
114
|
s == null || s.showAllOverlays();
|
|
115
115
|
}, Be = (e) => {
|
|
116
116
|
g || (g = new Vt(n)), g.updateQueueLength(e);
|
|
@@ -146,7 +146,7 @@ const xt = { class: "gis-viewer" }, Gt = { style: { position: "absolute", bottom
|
|
|
146
146
|
}, je = async (e) => t ? t == null ? void 0 : t.blockLane(e) : {
|
|
147
147
|
status: -1,
|
|
148
148
|
message: "未加载OpenDrive地图"
|
|
149
|
-
}, Je = () => t ? t == null ? void 0 : t.
|
|
149
|
+
}, Je = (e) => t ? t == null ? void 0 : t.clearBlockLane(e) : {
|
|
150
150
|
status: -1,
|
|
151
151
|
message: "未加载OpenDrive地图"
|
|
152
152
|
}, Ue = async (e) => (a || (a = new I(n)), await a.showSignalControlArea(e)), $e = async (e) => (a || (a = new I(n)), await a.showDistrict(e)), qe = async (e) => (a || (a = new I(n)), await a.showSubDistrict(e)), Ke = async () => await (a == null ? void 0 : a.clearSignalControlArea()), Fe = (e) => a == null ? void 0 : a.setLayerVisibility(e), Xe = async (e) => a ? await (a == null ? void 0 : a.locateSignalControlArea(e)) : { status: -1, message: "未加载信号控制区" }, Ye = async (e) => a ? await a.highlightSignalControlArea(e) : { status: -1, message: "未加载信号控制区" }, Re = () => a ? a.resetHighlight() : { status: -1, message: "未加载信号控制区" }, et = (e) => (l || (l = new zt(n)), l.showSubSignalControlArea(e)), tt = (e) => l ? l.editSubSignalControlArea(e) : { status: -1, message: "未加载信号控制区" }, nt = () => l ? l.stopEditSubSignalControlArea() : { status: -1, message: "未加载信号控制区" }, at = (e) => l ? l.selectSubSignalControlAreaCross(e) : { status: -1, message: "未加载信号控制区" }, rt = (e) => l ? l.unselectSubSignalControlAreaCross(e) : { status: -1, message: "未加载信号控制区" }, st = (e) => {
|
|
@@ -160,7 +160,7 @@ const xt = { class: "gis-viewer" }, Gt = { style: { position: "absolute", bottom
|
|
|
160
160
|
if (!w)
|
|
161
161
|
return { status: -1, message: "未加载警务管辖区" };
|
|
162
162
|
w.clearJurisdiction();
|
|
163
|
-
}, mt = async (e) => (b || (b = new Tt(n)), await b.setEdpassLayerVisibility(e)), z = Z,
|
|
163
|
+
}, mt = async (e) => (b || (b = new Tt(n)), await b.setEdpassLayerVisibility(e)), z = Z, v = j;
|
|
164
164
|
return Q({
|
|
165
165
|
mapViewer: J,
|
|
166
166
|
setLayerVisibility: ee,
|
|
@@ -175,9 +175,9 @@ const xt = { class: "gis-viewer" }, Gt = { style: { position: "absolute", bottom
|
|
|
175
175
|
addClusterPoints: be,
|
|
176
176
|
removeAllClusterPoints: Oe,
|
|
177
177
|
addMask: Ae,
|
|
178
|
-
removeMask:
|
|
178
|
+
removeMask: ke,
|
|
179
179
|
showAllOverlays: Ie,
|
|
180
|
-
removeOverlaysByType:
|
|
180
|
+
removeOverlaysByType: De,
|
|
181
181
|
removeOverlaysById: Le,
|
|
182
182
|
removeAllOverlays: Te,
|
|
183
183
|
showLaneNumber: re,
|
|
@@ -195,9 +195,9 @@ const xt = { class: "gis-viewer" }, Gt = { style: { position: "absolute", bottom
|
|
|
195
195
|
clearHoloSignal: we,
|
|
196
196
|
setInterpolate: de,
|
|
197
197
|
toggleTrafficInfo: Ce,
|
|
198
|
-
toggleTrafficObject:
|
|
199
|
-
toggleVehicleInfo:
|
|
200
|
-
togglePause:
|
|
198
|
+
toggleTrafficObject: Se,
|
|
199
|
+
toggleVehicleInfo: k,
|
|
200
|
+
togglePause: ve,
|
|
201
201
|
updateQueueLength: Be,
|
|
202
202
|
removeQueueLength: Me,
|
|
203
203
|
showOpenDriveFromServer: Pe,
|
|
@@ -240,7 +240,7 @@ const xt = { class: "gis-viewer" }, Gt = { style: { position: "absolute", bottom
|
|
|
240
240
|
ref_key: "mapContainer",
|
|
241
241
|
ref: h
|
|
242
242
|
}, [
|
|
243
|
-
|
|
243
|
+
St(y("div", Gt, [
|
|
244
244
|
y("button", {
|
|
245
245
|
style: { "margin-right": "10px" },
|
|
246
246
|
onClick: U
|
|
@@ -258,8 +258,8 @@ const xt = { class: "gis-viewer" }, Gt = { style: { position: "absolute", bottom
|
|
|
258
258
|
[ht, O.value]
|
|
259
259
|
])
|
|
260
260
|
], 512),
|
|
261
|
-
(T(!0), x(bt, null, Ot(M, (i,
|
|
262
|
-
key:
|
|
261
|
+
(T(!0), x(bt, null, Ot(M, (i, S) => (T(), At(Bt, {
|
|
262
|
+
key: S,
|
|
263
263
|
"display-mode": i.displayMode,
|
|
264
264
|
flash: i.flash,
|
|
265
265
|
"road-id": i.crossId,
|
|
@@ -134,7 +134,7 @@ export declare const GisMap: import("@easyest/utils/dist/lib/withinstall").SFCWi
|
|
|
134
134
|
status: number;
|
|
135
135
|
message: string;
|
|
136
136
|
}>;
|
|
137
|
-
clearBlockOpenDriveLane: () => void | {
|
|
137
|
+
clearBlockOpenDriveLane: (params: import("../types").IBlockOpenDriveLaneParams) => void | {
|
|
138
138
|
status: number;
|
|
139
139
|
message: string;
|
|
140
140
|
};
|
|
@@ -118,12 +118,17 @@ export default class OpenDriveRenderer {
|
|
|
118
118
|
* @returns
|
|
119
119
|
*/
|
|
120
120
|
splitLane(params: ISplitOpenDriveLaneParams): Promise<IResult>;
|
|
121
|
+
clearSplitLane(): void;
|
|
121
122
|
/**
|
|
122
123
|
* 封闭车道,使用可计算路网的id
|
|
123
124
|
* @param params
|
|
124
125
|
*/
|
|
125
126
|
blockLane(params: IBlockOpenDriveLaneParams): void;
|
|
126
|
-
|
|
127
|
+
/**
|
|
128
|
+
* 解除封闭车道,使用可计算路网id
|
|
129
|
+
* @param params
|
|
130
|
+
*/
|
|
131
|
+
clearBlockLane(params: IBlockOpenDriveLaneParams): void;
|
|
127
132
|
selectComputable(params: IFindSumoParams): void;
|
|
128
133
|
/**
|
|
129
134
|
* 更新所有路口的symbol
|
|
@@ -1099,6 +1099,9 @@ class O {
|
|
|
1099
1099
|
});
|
|
1100
1100
|
return this.splitLaneLayer.add(f), A.viewGoto(this.view, [f]), { status: 0, message: "ok", result: { coordinates: m } };
|
|
1101
1101
|
}
|
|
1102
|
+
clearSplitLane() {
|
|
1103
|
+
this.splitLaneLayer.removeAll();
|
|
1104
|
+
}
|
|
1102
1105
|
/**
|
|
1103
1106
|
* 封闭车道,使用可计算路网的id
|
|
1104
1107
|
* @param params
|
|
@@ -1110,13 +1113,7 @@ class O {
|
|
|
1110
1113
|
return t.startsWith("-") && (t = t.slice(1)), s.getAttribute("roadId") === e.roadsectId && ((l = s.getAttribute("roadsectBaseIds")) == null ? void 0 : l.includes(e.roadsectBaseId)) && t === String(e.laneId);
|
|
1111
1114
|
}), o = i.map((s) => {
|
|
1112
1115
|
const t = s.clone();
|
|
1113
|
-
return
|
|
1114
|
-
i[0].getAttribute("roadsectBaseIds"),
|
|
1115
|
-
this.selectedSectionIds,
|
|
1116
|
-
this.selectedSectionIds.includes(
|
|
1117
|
-
i[0].getAttribute("roadsectBaseIds")
|
|
1118
|
-
)
|
|
1119
|
-
), t.symbol = {
|
|
1116
|
+
return t.symbol = {
|
|
1120
1117
|
type: "simple-fill",
|
|
1121
1118
|
color: this.selectedSectionIds.includes(
|
|
1122
1119
|
i[0].getAttribute("roadsectBaseIds")
|
|
@@ -1128,14 +1125,20 @@ class O {
|
|
|
1128
1125
|
});
|
|
1129
1126
|
this.splitLaneLayer.addMany(o), A.viewGoto(this.view, o);
|
|
1130
1127
|
}
|
|
1131
|
-
|
|
1132
|
-
|
|
1128
|
+
/**
|
|
1129
|
+
* 解除封闭车道,使用可计算路网id
|
|
1130
|
+
* @param params
|
|
1131
|
+
*/
|
|
1132
|
+
clearBlockLane(e) {
|
|
1133
|
+
const i = this.splitLaneLayer.graphics.filter((o) => {
|
|
1134
|
+
const s = o.getAttribute("roadId"), t = o.getAttribute("roadsectBaseIds");
|
|
1135
|
+
let l = String(o.getAttribute("laneId"));
|
|
1136
|
+
return l.startsWith("-") && (l = l.slice(1)), s === e.roadsectId && (t == null ? void 0 : t.includes(e.roadsectBaseId)) && l === String(e.laneId);
|
|
1137
|
+
});
|
|
1138
|
+
this.splitLaneLayer.removeMany(i.toArray());
|
|
1133
1139
|
}
|
|
1134
1140
|
selectComputable(e) {
|
|
1135
1141
|
if (e.type === "roadsectBase") {
|
|
1136
|
-
this.allLaneGraphics.forEach((o) => {
|
|
1137
|
-
o.getAttribute("roadsectBaseIds") || console.log(o.attributes);
|
|
1138
|
-
});
|
|
1139
1142
|
const i = this.allLaneGraphics.filter((o) => {
|
|
1140
1143
|
var s;
|
|
1141
1144
|
return (s = o.getAttribute("roadsectBaseIds")) == null ? void 0 : s.includes(e.id);
|
|
@@ -150,7 +150,7 @@ declare const _sfc_main: import("vue").DefineComponent<{
|
|
|
150
150
|
status: number;
|
|
151
151
|
message: string;
|
|
152
152
|
}>;
|
|
153
|
-
clearBlockOpenDriveLane: () => void | {
|
|
153
|
+
clearBlockOpenDriveLane: (params: IBlockOpenDriveLaneParams) => void | {
|
|
154
154
|
status: number;
|
|
155
155
|
message: string;
|
|
156
156
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const r=require("vue"),T=require("./stores/index.js");require("./style/index.css");const dt=require("./utils/dbscan-cluster/index.js"),mt=require("./utils/detect-gpu.js"),pt=require("./utils/edpass-device-controller.js"),x=require("./utils/green-wave-band-controller/index.js"),gt=require("./utils/holo-flow/index.js"),ft=require("./utils/holo-flow/signal-countdown-panel.vue.js"),yt=require("./utils/map-initializer.js"),P=require("./utils/open-drive-renderer/index.js"),z=require("./utils/overlay.js"),wt=require("./utils/police-jurisdiction.js"),vt=require("./utils/queue-length.js"),E=require("./utils/road-config-tool/index.js"),St=require("./utils/signal-control-area/edit-area.js"),q=require("./utils/signal-control-area/show-area.js"),ht=require("./utils/traffic-flow.js"),Ct={class:"gis-viewer"},bt={style:{position:"absolute",bottom:"80px",left:"10px","z-index":"9999"}},Ot=r.defineComponent({__name:"gis-map",props:{config:{},assetsRoot:{}},emits:["mapLoaded","markerClick","mapClick","update:zoom"],setup(N,{expose:H,emit:G}){const C=r.ref(null);let a,p,l,i,s,o,f,t,u,n,g,w,b,y;const O=r.ref(!1);T.registerStore();const
|
|
1
|
+
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const r=require("vue"),T=require("./stores/index.js");require("./style/index.css");const dt=require("./utils/dbscan-cluster/index.js"),mt=require("./utils/detect-gpu.js"),pt=require("./utils/edpass-device-controller.js"),x=require("./utils/green-wave-band-controller/index.js"),gt=require("./utils/holo-flow/index.js"),ft=require("./utils/holo-flow/signal-countdown-panel.vue.js"),yt=require("./utils/map-initializer.js"),P=require("./utils/open-drive-renderer/index.js"),z=require("./utils/overlay.js"),wt=require("./utils/police-jurisdiction.js"),vt=require("./utils/queue-length.js"),E=require("./utils/road-config-tool/index.js"),St=require("./utils/signal-control-area/edit-area.js"),q=require("./utils/signal-control-area/show-area.js"),ht=require("./utils/traffic-flow.js"),Ct={class:"gis-viewer"},bt={style:{position:"absolute",bottom:"80px",left:"10px","z-index":"9999"}},Ot=r.defineComponent({__name:"gis-map",props:{config:{},assetsRoot:{}},emits:["mapLoaded","markerClick","mapClick","update:zoom"],setup(N,{expose:H,emit:G}){const C=r.ref(null);let a,p,l,i,s,o,f,t,u,n,g,w,b,y;const O=r.ref(!1);T.registerStore();const B=T.default.useAppDataStore,V=r.reactive([]),_=e=>Math.log2(591657527591555e-6/e);let v=null,I=null;const k=e=>{if(!Number.isFinite(e))return;const d=Math.round(e);d!==I&&(I=d,S("update:zoom",d))};mt.default(),r.onMounted(async()=>{if(!C.value)return;document.addEventListener("keydown",m=>{m.ctrlKey&&m.key==="i"&&(O.value=!O.value)});const e=r.getCurrentInstance(),{$gisviewerAssetsRoot:d}=e.appContext.config.globalProperties,c=await(await fetch(M.config)).json();c.assetsRoot=M.assetsRoot||d,B.mapConfig=c,p=new yt.default,B.mapInitializer=p,a=await p.initialize({container:C.value,mapConfig:c,markerClickCallback:(m,D,L,ut)=>{S("markerClick",m,D,L,ut)},mapClickCallback:(m,D,L)=>{S("mapClick",m,D,L)}});const h=a.zoom??(a.scale?_(a.scale):void 0);typeof h=="number"&&k(h);const lt=a.zoom!==void 0?a.watch("zoom",m=>{k(m)}):a.watch("scale",m=>{typeof m=="number"&&m>0&&k(_(m))});v=()=>lt.remove(),s=new gt.default(a,V),await s.init(),S("mapLoaded")}),r.onUnmounted(()=>{n==null||n.clearSignalControlArea(),t==null||t.clearOpenDrive(),s.clearHoloTrace(),s.clearHoloSignal(),i==null||i.disconnectTrafficFlow(),v==null||v(),v=null});const Z=r.computed(()=>a),W=()=>{const e=T.default.useAppDataStore;e.saveTrackLog=!0},j=()=>{s.downloadTrackLog()},J=()=>{A("vehicleId")},Q=()=>{A("plateNumber")},U=async e=>await p.setMapCenter(e),K=async e=>await p.setMapCamera(e),F=e=>p.setMapZoom(e),X=async e=>await p.lookAt(e),Y=e=>p.setLayerVisibility(e),R=(e,d)=>p.requestCoordinateTransform(e,d),$=e=>{p.cancelCoordinateTransform(e)},ee=e=>{p.setMapZoomRange(e)},te=e=>(l||(l=new E.default(a)),l.showLaneNumber(e)),ae=()=>{l==null||l.clearLaneNumber()},ne=async e=>(l||(l=new E.default(a)),await l.initializeSearch(e)),se=async()=>l==null?void 0:l.calCrossIndicatorArea(),re=async()=>{},oe=async(e,d)=>{i||(i=new ht.default(a)),i.connectTrafficFlow(e,d)},ie=()=>{i==null||i.disconnectTrafficFlow()},ce=async e=>{s.handleVehicleTraceData(e)},le=()=>{s.clearHoloTrace()},ue=e=>{s.setInterpolate(e)},de=async e=>{await s.handleSignalData(e)},me=async e=>{await s.initializeLampGroup(e)},pe=e=>{s.handleUniSignalData(e)},ge=()=>{s.clearHoloSignal()},fe=e=>{i==null||i.toggleTrafficInfo(e),s==null||s.toggleTrafficInfo(e)},ye=e=>{s==null||s.togglePause(e)},we=e=>{i==null||i.toggleTrafficObject(e),s==null||s.toggleTrafficObject(e)},A=e=>{s==null||s.updatePanelContent(e)},ve=async e=>(o||(o=new z.default(a)),o.addOverlays(e)),Se=async e=>(y||(y=new dt.default(a)),y.addClusterPoints(e)),he=()=>{y==null||y.removeAllClusterPoints()},Ce=e=>(o||(o=new z.default(a)),o.addMask(e)),be=()=>{o==null||o.removeMask()},Oe=e=>o==null?void 0:o.removeOverlaysByType(e),ke=e=>o==null?void 0:o.removeOverlaysById(e),Ae=()=>o==null?void 0:o.removeAllOverlays(),De=()=>{o==null||o.showAllOverlays()},Le=e=>{f||(f=new vt.default(a)),f.updateQueueLength(e)},Te=()=>{f==null||f.removeQueueLength()},qe=async(e,d)=>(t||(t=new P.default(a)),await t.showOpenDriveFromServer(e,d)),Be=async e=>(t||(t=new P.default(a)),await t.clearOpenDrive(),await t.showOpenDriveFromFile(e)),Ve=e=>t?t.setOpendriveVisibility(e):{status:-1,message:"未加载OpenDrive地图"},_e=async()=>await(t==null?void 0:t.clearOpenDrive()),Ie=async e=>t?await(t==null?void 0:t.findSumo(e)):{status:-1,message:"未加载OpenDrive地图"},Me=async e=>t?t.selectSumo(e):{status:-1,message:"未加载OpenDrive地图"},xe=async e=>t?t.unselectSumo(e):{status:-1,message:"未加载OpenDrive地图"},Pe=async e=>t?t.selectComputable(e):{status:-1,message:"未加载OpenDrive地图"},ze=async e=>t?await t.geometrySearch(e):{status:-1,message:"未加载OpenDrive地图"},Ee=async e=>t?await t.getSumoInfo(e):{status:-1,message:"未加载OpenDrive地图"},Ne=async e=>t?await(t==null?void 0:t.splitLane(e)):{status:-1,message:"未加载OpenDrive地图"},He=async()=>t?t==null?void 0:t.clearSplitLane():{status:-1,message:"未加载OpenDrive地图"},Ge=async e=>t?t==null?void 0:t.blockLane(e):{status:-1,message:"未加载OpenDrive地图"},Ze=e=>t?t==null?void 0:t.clearBlockLane(e):{status:-1,message:"未加载OpenDrive地图"},We=async e=>(n||(n=new q.default(a)),await n.showSignalControlArea(e)),je=async e=>(n||(n=new q.default(a)),await n.showDistrict(e)),Je=async e=>(n||(n=new q.default(a)),await n.showSubDistrict(e)),Qe=async()=>await(n==null?void 0:n.clearSignalControlArea()),Ue=e=>n==null?void 0:n.setLayerVisibility(e),Ke=async e=>n?await(n==null?void 0:n.locateSignalControlArea(e)):{status:-1,message:"未加载信号控制区"},Fe=async e=>n?await n.highlightSignalControlArea(e):{status:-1,message:"未加载信号控制区"},Xe=()=>n?n.resetHighlight():{status:-1,message:"未加载信号控制区"},Ye=e=>(u||(u=new St.default(a)),u.showSubSignalControlArea(e)),Re=e=>u?u.editSubSignalControlArea(e):{status:-1,message:"未加载信号控制区"},$e=()=>u?u.stopEditSubSignalControlArea():{status:-1,message:"未加载信号控制区"},et=e=>u?u.selectSubSignalControlAreaCross(e):{status:-1,message:"未加载信号控制区"},tt=e=>u?u.unselectSubSignalControlAreaCross(e):{status:-1,message:"未加载信号控制区"},at=e=>{if(!u)return{status:-1,message:"未加载信号控制区"}},nt=e=>(g||(g=new x.default(a)),g.addGreenWaveBand(e)),st=()=>{if(!g)return{status:-1,message:"未加载绿波带"};g.stopAddGreenWaveBand()},rt=async e=>(g||(g=new x.default(a)),await g.showGreenWaveBand(e)),ot=async e=>(w||(w=new wt.default(a)),await w.showJurisdiction(e)),it=()=>{if(!w)return{status:-1,message:"未加载警务管辖区"};w.clearJurisdiction()},ct=async e=>(b||(b=new pt.default(a)),await b.setEdpassLayerVisibility(e)),M=N,S=G;return H({mapViewer:Z,setLayerVisibility:Y,setMapCenter:U,lookAt:X,setMapCamera:K,setMapZoom:F,setMapZoomRange:ee,requestCoordinateTransform:R,cancelCoordinateTransform:$,addOverlays:ve,addClusterPoints:Se,removeAllClusterPoints:he,addMask:Ce,removeMask:be,showAllOverlays:De,removeOverlaysByType:Oe,removeOverlaysById:ke,removeAllOverlays:Ae,showLaneNumber:te,clearLaneNumber:ae,initializeAreaTool:ne,calCrossIndicatorArea:se,calRoadIndicatorArea:re,connectCarFlow:oe,disconnectCarFlow:ie,handleHoloVehicleTraceData:ce,clearHoloTrace:le,initializeLampGroup:me,handleUniSignalData:pe,handleHoloSignalData:de,clearHoloSignal:ge,setInterpolate:ue,toggleTrafficInfo:fe,toggleTrafficObject:we,toggleVehicleInfo:A,togglePause:ye,updateQueueLength:Le,removeQueueLength:Te,showOpenDriveFromServer:qe,showOpenDriveFromFile:Be,clearOpenDrive:_e,setOpendriveVisibility:Ve,geometrySearchInOpenDrive:ze,findSumoInOpenDrive:Ie,selectSumoInOpenDrive:Me,unselectSumoInOpenDrive:xe,selectComputableInOpenDrive:Pe,getSumoInfo:Ee,splitOpenDriveLane:Ne,clearSplitOpenDriveLane:He,blockOpenDriveLane:Ge,clearBlockOpenDriveLane:Ze,showSignalControlArea:We,showDistrictArea:je,showSubDistrictArea:Je,clearSignalControlArea:Qe,setSignalControlAreaVisibility:Ue,locateSignalControlArea:Ke,highlightSignalControlArea:Fe,resetHighlightSignalControlArea:Xe,showSubSignalControlArea:Ye,editSubSignalControlArea:Re,stopEditSubSignalControlArea:$e,selectSubSignalControlAreaCross:et,unselectSubSignalControlAreaCross:tt,changeSubSignalControlAreaBorderVisibility:at,addGreenWaveBand:nt,stopAddGreenWaveBand:st,showGreenWaveBand:rt,showPoliceArea:ot,clearPoliceArea:it,setEdpassLayerVisibility:ct}),(e,d)=>(r.openBlock(),r.createElementBlock("div",Ct,[r.createElementVNode("div",{class:"gis-viewer-main",ref_key:"mapContainer",ref:C},[r.withDirectives(r.createElementVNode("div",bt,[r.createElementVNode("button",{style:{"margin-right":"10px"},onClick:W}," 开始记录 "),r.createElementVNode("button",{style:{"margin-right":"10px"},onClick:j}," 下载日志 "),r.createElementVNode("button",{style:{"margin-right":"10px"},onClick:J}," 显示车辆id "),r.createElementVNode("button",{onClick:Q},"显示车辆号牌")],512),[[r.vShow,O.value]])],512),(r.openBlock(!0),r.createElementBlock(r.Fragment,null,r.renderList(V,(c,h)=>(r.openBlock(),r.createBlock(ft.default,{key:h,"display-mode":c.displayMode,flash:c.flash,"road-id":c.crossId,"cross-id":c.roadId,"map-point":c.mapPoint,"stop-line":c.stopLine,position:c.position,rotation:c.rotation,scale:c.scale,"lamp-status":c.lampStatus},null,8,["display-mode","flash","road-id","cross-id","map-point","stop-line","position","rotation","scale","lamp-status"]))),128))]))}});exports.default=Ot;
|
|
@@ -134,7 +134,7 @@ export declare const GisMap: import("@easyest/utils/dist/lib/withinstall").SFCWi
|
|
|
134
134
|
status: number;
|
|
135
135
|
message: string;
|
|
136
136
|
}>;
|
|
137
|
-
clearBlockOpenDriveLane: () => void | {
|
|
137
|
+
clearBlockOpenDriveLane: (params: import("../types").IBlockOpenDriveLaneParams) => void | {
|
|
138
138
|
status: number;
|
|
139
139
|
message: string;
|
|
140
140
|
};
|
|
@@ -118,12 +118,17 @@ export default class OpenDriveRenderer {
|
|
|
118
118
|
* @returns
|
|
119
119
|
*/
|
|
120
120
|
splitLane(params: ISplitOpenDriveLaneParams): Promise<IResult>;
|
|
121
|
+
clearSplitLane(): void;
|
|
121
122
|
/**
|
|
122
123
|
* 封闭车道,使用可计算路网的id
|
|
123
124
|
* @param params
|
|
124
125
|
*/
|
|
125
126
|
blockLane(params: IBlockOpenDriveLaneParams): void;
|
|
126
|
-
|
|
127
|
+
/**
|
|
128
|
+
* 解除封闭车道,使用可计算路网id
|
|
129
|
+
* @param params
|
|
130
|
+
*/
|
|
131
|
+
clearBlockLane(params: IBlockOpenDriveLaneParams): void;
|
|
127
132
|
selectComputable(params: IFindSumoParams): void;
|
|
128
133
|
/**
|
|
129
134
|
* 更新所有路口的symbol
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const I=require("@arcgis/core/Graphic"),J=require("@arcgis/core/core/promiseUtils"),E=require("@arcgis/core/core/reactiveUtils.js"),A=require("@arcgis/core/geometry"),q=require("@arcgis/core/geometry/geometryEngine"),x=require("@arcgis/core/layers/FeatureLayer"),v=require("@arcgis/core/layers/GraphicsLayer"),T=require("@turf/helpers"),O=require("@turf/line-slice-along"),w=require("axios"),_=require("fast-xml-parser"),R=require("md5"),M=require("pako"),z=require("vue"),H=require("../../stores/index.js"),k=require("../common-utils.js");function N(S){const e=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(S){for(const t in S)if(t!=="default"){const s=Object.getOwnPropertyDescriptor(S,t);Object.defineProperty(e,t,s.get?s:{enumerable:!0,get:()=>S[t]})}}return e.default=S,Object.freeze(e)}const P=N(J),U=N(E),L=N(q),B=N(T);class C{constructor(e){this.junctionNames=new Map,this.junctionScale=5e3,this.xodrBorder=[],this.projectName="",this.openDriveServer="",this.currentSectionCode="",this.selectedSectionIds=[],this.currentJunctionId="",this.view=e,this.laneLayer=new x({id:"OpenDriveLane",fields:[{name:"ObjectID",alias:"ObjectID",type:"oid"},{name:"id",alias:"编号",type:"string"},{name:"roadId",alias:"道路号",type:"string"},{name:"roadName",alias:"道路名称",type:"string"},{name:"sectionId",alias:"路段号",type:"string"},{name:"sectionIndex",alias:"路段序号",type:"string"},{name:"laneId",alias:"车道号",type:"string"},{name:"type",alias:"类型",type:"string"},{name:"sumoId",alias:"sumo编号",type:"string"},{name:"fromNode",alias:"起点路口",type:"string"},{name:"toNode",alias:"终点路口",type:"string"},{name:"roadsectBaseIds",alias:"基本段编号",type:"string"}],objectIdField:"ObjectID",geometryType:"polygon",spatialReference:{wkid:4326},source:[],outFields:["*"],renderer:{type:"unique-value",field:"type",defaultSymbol:{type:"simple-fill",color:[100,100,100],style:"solid",outline:{color:"white",width:1}},uniqueValueInfos:[{value:"shoulder",label:"路肩",symbol:{type:"simple-fill",color:"#008000",style:"solid",outline:{color:"white",width:1}}},{value:"border",label:"路沿",symbol:{type:"simple-fill",color:"#DCDCDC",style:"solid",outline:{color:"white",width:1}}},{value:"driving",label:"机动车道",symbol:{type:"simple-fill",color:[47,79,79,.8],style:"solid",outline:{color:"white",width:1}}},{value:"none",label:"无",symbol:{type:"simple-fill",color:[111,120,135],style:"none",outline:{color:"white",width:1}}},{value:"restricted",label:"禁行区",symbol:{type:"simple-fill",color:"yellow",style:"solid",outline:{color:"yellow",width:2}}},{value:"parking",label:"停车区",symbol:{type:"simple-fill",color:[115,115,115],style:"solid",outline:{color:"white",width:1}}},{value:"median",label:"中央隔离带",symbol:{type:"simple-fill",color:"#008000",style:"solid",outline:{color:"white",width:1}}},{value:"biking",label:"非机动车道",symbol:{type:"simple-fill",color:"#D3D3D3",style:"solid",outline:{color:"white",width:1}}},{value:"sidewalk",label:"人行道",symbol:{type:"simple-fill",color:"#C0C0C0",style:"solid",outline:{color:"white",width:1}}},{value:"junction",label:"路口区域",symbol:{type:"simple-fill",color:"#2F4F4F",style:"solid",outline:{color:"white",width:1}}},{value:"selected",label:"选中车道",symbol:{type:"simple-fill",color:[141,168,211],style:"solid",outline:{color:"white",width:1}}}]}}),this.roadNameLayer=new x({id:"OpenDriveRoadName",fields:[{name:"ObjectID",alias:"ObjectID",type:"oid"},{name:"roadId",alias:"道路号",type:"string"},{name:"roadName",alias:"道路名称",type:"string"}],objectIdField:"ObjectID",geometryType:"polyline",spatialReference:{wkid:4326},source:[],renderer:{type:"simple",symbol:{type:"simple-line",style:"solid",color:[0,0,0,0],width:1}},labelingInfo:[{symbol:{type:"text",color:"black",haloColor:"white",haloSize:1,font:{size:12,family:"sans-serif"}},labelPlacement:this.view.type==="2d"?"center-along":void 0,labelExpressionInfo:{expression:"$feature.roadName"}}]}),this.junctionLayer=new v({id:"OpenDriveJunction"}),this.sectionLayer=new v({id:"OpenDriveSection"}),this.highlightLayer=new v({id:"OpenDriveHighlight"}),this.flashLayer=new v({id:"OpenDriveFlash"}),this.drawLayer=new v({id:"Draw"}),this.splitLaneLayer=new v({id:"SplitLane"}),this.borderLayer=new v({id:"OpenDriveBorder"}),this.view.map.addMany([this.laneLayer,this.sectionLayer,this.roadNameLayer,this.junctionLayer,this.highlightLayer,this.flashLayer,this.drawLayer,this.splitLaneLayer,this.borderLayer])}static getInstance(e){return this.instance||(this.instance=new C(e)),this.instance}async makeMd5FromFile(e){var t;try{const o=await(await fetch(e)).text();let r=(t=new _.XMLParser({ignoreAttributes:!1,allowBooleanAttributes:!0}).parse(o).OpenDRIVE.userData)==null?void 0:t.border;return r?r=JSON.parse(r):r=[],{status:0,message:"ok",result:{md5:R(o),border:r}}}catch(s){return{status:-1,message:s.message}}}async showOpenDriveFromFile(e){var d,m,u;this.openDriveClickCallback=e.selectedCallback,this.scaleWatch=U.watch(()=>this.view.scale,(h,p)=>{h>this.junctionScale&&p<=this.junctionScale?this.updateAllJunctionSymbol("marker"):h<=this.junctionScale&&p>this.junctionScale&&this.updateAllJunctionSymbol("picture")});let t=e.file.split("/").pop()||"";t=t.split(".").slice(0,-1).join("."),this.openDriveServer=e.server;const s=`http://${this.openDriveServer}/api/openDrive/uploadXodr`;let o;try{o=await w.post(s,{},{params:{url:e.file,projectName:t}})}catch(h){return{status:-1,message:h.message}}if(o.status!==200)return{status:-1,message:o.statusText};console.time("渲染用时");const i=o.data.result.geoSetting;k.default.setGeoData(i.geoReference,i.offsetX,i.offsetY);let l=o.data.result.json;l.startsWith(window.location.protocol)||(l=`${window.location.protocol}//${e.server}${l}`);const r=await fetch(l);let a;if(l.endsWith("bin")){const h=await r.arrayBuffer(),p=M.inflate(h,{to:"string"});a=JSON.parse(p)}else a=await r.json();if(await this.showAllLanes(a,((d=e.options)==null?void 0:d.showJunctionLane)||!1,((m=e.options)==null?void 0:m.showRoadName)||!0),((u=e.options)==null?void 0:u.showJunctionPoint)!==!1){const h=o.data.result.junctions;this.showJunction(h)}e.options&&e.options.centerMap!==!1&&await this.view.goTo(this.allLaneGraphics),this.mouseMoveHandler||this.monitorMouseMove(),this.mouseClickHandler||this.monitorMouseClick();const n=H.default.useAppDataStore;return z.watch(()=>n.isSketching,()=>{var h,p;n.isSketching?((h=this.mouseMoveHandler)==null||h.remove(),this.mouseMoveHandler=void 0,(p=this.mouseClickHandler)==null||p.remove(),this.mouseClickHandler=void 0):(this.monitorMouseMove(),this.monitorMouseClick())}),console.timeEnd("渲染用时"),{status:0,message:"ok"}}async showOpenDriveFromServer(e,t){const s=`http://${e}/api/openDrive/analyzeXodr`,o=await w.get(s,{headers:{projectName:t},params:{analyze:!1,compressed:!0}});if(o.status!==200)throw new Error(`OpenDriveRenderer: ${o.statusText}`);let i=o.data.result.json;i.startsWith(window.location.protocol)||(i=`${window.location.protocol}//${e}${i}`);const l=await fetch(i);let r;if(i.endsWith("bin")){const a=await l.arrayBuffer(),c=M.inflate(a,{to:"string"});r=JSON.parse(c)}else r=await l.json();return await this.showAllLanes(r,!1,!1),{status:0,message:"ok"}}async showAllLanes(e,t,s){const o=await this.laneLayer.queryFeatures();return o.features.length>0&&this.laneLayer.applyEdits({deleteFeatures:o.features}),this.roadNameLayer.visible=s,new Promise(i=>{var c;let l=0;this.allLaneGraphics=[],this.allRefLineGraphics=[];const r=[];for(const n of e){if(!t&&n.junction!=="-1")continue;const{id:d,refLine:m}=n;let u=n.name;u.includes("(")&&(u=u.slice(0,u.indexOf("("))),u=u.replace(/(.)/g,"$1 ");const h=new I({geometry:{type:"polyline",paths:[m]},attributes:{ObjectID:l++,roadId:d,roadName:u}});this.allRefLineGraphics.push(h),n.laneSections.sort((p,g)=>Number(p.id)-Number(g.id));for(let p=0;p<n.laneSections.length;p++){const g=n.laneSections[p],y=Number(g.id);for(const f of g.lanePaths){const b=Number(f.id);if(b===0)continue;const $=f.type,F=[...f.outerPath],j=f.innerPath.concat(F.reverse());if(j.length<=3){console.warn(`lane ${b} has less than 3 points`);continue}j.push(f.innerPath[0]);const D=new A.Polygon({rings:[j]});if(D){const G=new I({geometry:D,attributes:{ObjectID:l++,id:`${d}+${y}+${b}`,fromNode:n.fromNode,toNode:n.toNode,roadId:String(d),roadName:n.name,sectionId:String(y),sectionIndex:p,laneId:b,type:$,sumoId:"",leftLine:f.innerPath,rightLine:f.outerPath,roadsectBaseIds:(c=g.roadsectBaseIds)==null?void 0:c.toString()}});this.allLaneGraphics.push(G),r.push(G)}}}}const a=setInterval(()=>{if(r.length>0||this.allRefLineGraphics.length>0){if(r.length>0){const n=r.splice(0,100);this.laneLayer.applyEdits({addFeatures:n})}if(this.allRefLineGraphics.length>0){const n=this.allRefLineGraphics.splice(0,10);this.roadNameLayer.applyEdits({addFeatures:n})}}else clearInterval(a),i()},10)})}showJunction(e){const t=[];let s;this.xodrBorder.length>0&&(s=new A.Polygon({rings:[this.xodrBorder]}));for(const o of e)if(o&&(this.junctionNames.set(o.id,o.name),o.nodeType=o.type,o.crossId)){const i=new A.Point({x:o.coordinates[0],y:o.coordinates[1]});let l=!0;if(s&&(l=L.contains(s,i)),l){const r=new I({geometry:i,attributes:{...o,selected:!1,type:"OpenDriveJunction"},symbol:this.getCrossGraphicSymbol(o,"marker")});t.push(r)}}this.junctionLayer.addMany(t)}monitorMouseMove(){const e=P.debounce(async t=>{var l;const o=(l=(await this.view.hitTest(t,{include:[this.laneLayer,this.junctionLayer]})).results)==null?void 0:l.filter(r=>r.type==="graphic");if(o.length===0){this.currentSectionCode!==""&&(this.currentSectionCode="",this.highlightLayer.removeAll()),this.currentJunctionId!==""&&(this.currentJunctionId=""),this.view.closePopup();return}const i=o[0];if(this.hitGraphic=i.graphic,i.layer.id==="OpenDriveLane"){const r=`${this.hitGraphic.getAttribute("roadId")}+${this.hitGraphic.getAttribute("sectionId")}`,a=this.hitGraphic.getAttribute("roadsectBaseIds");if(this.currentSectionCode===r||this.selectedSectionIds.includes(a)||this.sectionLayer.graphics.findIndex(y=>y.getAttribute("id")===r)>=0)return;this.currentSectionCode=r;const n=this.allLaneGraphics.filter(y=>`${y.attributes.roadId}+${y.attributes.sectionId}`===r),d=L.union(n.map(y=>y.geometry)),m=this.hitGraphic.getAttribute("fromNode"),u=this.hitGraphic.getAttribute("toNode"),h=this.junctionNames.get(m)||m,p=this.junctionNames.get(u)||u,g=new I({geometry:d,symbol:{type:"simple-fill",color:[0,255,255,.5],style:"solid",outline:{color:[0,255,255],width:1}},attributes:{type:"OpenDriveSection",id:r,selected:!1,fromNodeName:h,toNodeName:p,laneCount:n.length,roadsectBaseIds:this.hitGraphic.getAttribute("roadsectBaseIds"),roadId:this.hitGraphic.getAttribute("roadId")},popupTemplate:{title:this.hitGraphic.getAttribute("roadName"),content:[{type:"fields",fieldInfos:[{fieldName:"fromNodeName",label:"起点路口"},{fieldName:"toNodeName",label:"终点路口"},{fieldName:"laneCount",label:"车道数量"}]}]}});this.highlightLayer.removeAll(),this.highlightLayer.add(g)}else if(i.layer.id==="OpenDriveJunction"){const r=this.hitGraphic.getAttribute("id");if(r===this.currentJunctionId)return;this.currentJunctionId=r}});this.mouseMoveHandler=this.view.on("pointer-move",async t=>{e(t).catch(()=>{})})}monitorMouseClick(){const e=P.debounce(async t=>{var a;const o=(a=(await this.view.hitTest(t,{include:[this.highlightLayer,this.junctionLayer,this.sectionLayer]})).results)==null?void 0:a.filter(c=>c.type==="graphic");if(o.length===0)return;const i=o[0].graphic,l=i.getAttribute("type"),r=i.getAttribute("id");if(l==="OpenDriveJunction")if(i.getAttribute("selected")===!1){const c=`http://${this.openDriveServer}/api/sumo/getSumoJunction`,n=await w.get(c,{params:{id:r,projectName:this.projectName}});n.status===200&&n.data.status===0&&(this.openDriveClickCallback&&this.openDriveClickCallback({type:"OpenDriveJunction",id:r,details:n.data.result}),i.setAttribute("selected",!0),i.symbol={type:"picture-marker",url:"/GisViewerAssets/Images/point_red.png",width:"20px",height:"20px"},this.increasePictureMarkerSize(i,50))}else this.openDriveClickCallback&&this.openDriveClickCallback({type:"OpenDriveJunction",id:r,details:void 0}),i.setAttribute("selected",!1),i.symbol=this.getCrossGraphicSymbol(i.attributes,this.view.scale<this.junctionScale?"picture":"marker");else l==="OpenDriveSection"&&(i.layer.id==="OpenDriveHighlight"?(this.highlightLayer.removeAll(),this.sectionLayer.removeAll(),this.selectedSectionIds=[],this.sectionLayer.add(i),i.setAttribute("selected",!0),this.selectedSectionIds.push(r),this.splitLaneLayer.graphics.filter(n=>n.getAttribute("roadsectBaseIds")===i.getAttribute("roadsectBaseIds")).forEach(n=>n.symbol={type:"simple-fill",color:[255,69,0],outline:{color:"red",width:2}}),this.openDriveClickCallback&&this.openDriveClickCallback({type:"OpenDriveSection",id:i.getAttribute("id"),details:{roadsectId:i.getAttribute("roadId"),roadsectBaseIds:i.getAttribute("roadsectBaseIds")}})):(this.splitLaneLayer.graphics.filter(n=>n.getAttribute("roadsectBaseIds")===i.getAttribute("roadsectBaseIds")).forEach(n=>n.symbol={type:"simple-fill",color:[255,0,0,.8],outline:{color:"red",width:1}}),this.sectionLayer.remove(i),this.selectedSectionIds=[],this.openDriveClickCallback&&this.openDriveClickCallback({type:"CloseOpenDriveSection",id:i.getAttribute("roadsectBaseIds"),details:{roadsectId:i.getAttribute("roadId"),roadsectBaseIds:i.getAttribute("roadsectBaseIds")}})))});this.mouseClickHandler=this.view.on("immediate-click",async t=>{e(t).catch(()=>{})})}increasePictureMarkerSize(e,t){const s=setInterval(()=>{const o=e.symbol,i=o.width;i<t?e.symbol={type:"picture-marker",url:o.url,width:i+1,height:i+1}:clearInterval(s)},20)}decreasePictureMarkerSize(e,t){const s=setInterval(()=>{const o=e.symbol,i=o.width;i>t?e.symbol={type:"picture-marker",url:o.url,width:i-1,height:i-1}:clearInterval(s)},20)}async getSumoInfo(e){switch(e.type){case"junction":{const t=`http://${this.openDriveServer}/api/sumo/getSumoJunction`,s=await w.get(t,{params:{id:e.id,projectName:this.projectName}});return s.status===200?s.data:{status:-1,message:`路口信息查询失败: ${e.id}`}}case"edge":{const t=e.id.split("#");let s=t[0];s.startsWith("-")&&(s=s.slice(1));let o=0;t.length===2&&(o=Number(t[1]));const i=this.allLaneGraphics.find(l=>l.getAttribute("roadId")===s&&l.getAttribute("sectionIndex")===o);if(i){const l=`${s}+${i.getAttribute("sectionId")}`,r=`http://${this.openDriveServer}/api/sumo/getSumoEdge`,a=await w.get(r,{params:{id:l,projectName:this.projectName}});return a.status===200?a.data:{status:-1,message:`路段信息查询失败: ${l}`}}else return{status:-1,message:"未知类型"}}default:return{status:-1,message:"未知类型"}}}setOpendriveVisibility(e){this.laneLayer.visible=e}async clearOpenDrive(){var t,s,o;let e=await this.laneLayer.queryFeatures();e.features.length>0&&await this.laneLayer.applyEdits({deleteFeatures:e.features}),e=await this.roadNameLayer.queryFeatures(),e.features.length>0&&await this.roadNameLayer.applyEdits({deleteFeatures:e.features}),this.highlightLayer.removeAll(),this.junctionLayer.removeAll(),this.sectionLayer.removeAll(),this.flashLayer.removeAll(),this.borderLayer.removeAll(),(t=this.mouseMoveHandler)==null||t.remove(),this.mouseMoveHandler=void 0,(s=this.mouseClickHandler)==null||s.remove(),this.mouseClickHandler=void 0,(o=this.scaleWatch)==null||o.remove(),this.scaleWatch=void 0}async findSumo(e){const{type:t,id:s}=e,o=e.flash===void 0?!0:e.flash;if(t==="junction")return await this.findJunction(s,o);if(t==="edge"){const i=s.split("_");if(i.length>2)return{status:-1,message:"id格式错误"};const l=i.length===2?Number(i[1]):void 0,r=i[0].split("#");if(r.length>2)return{status:-1,message:"id格式错误"};const a=r[0],c=r.length===2?Number(r[1]):void 0;return await this.findLane({roadsectId:a,segmentId:c,laneId:l,flash:o})}else return{status:-1,message:"未知类型"}}async findJunction(e,t){const s=this.junctionLayer.graphics.find(o=>o.attributes.id===e);if(!s)return{status:-1,message:"未找到。请检查路口编号"};if(t){const o=new I({geometry:s.geometry,symbol:{type:"simple-marker",style:"circle",size:30,color:[0,255,255,.8],outline:{color:[0,255,255],width:1}}});this.flashGraphic(o)}return await this.view.goTo(s.geometry,{duration:1e3}),{status:0,message:"ok"}}async findLane(e){let{roadsectId:t,segmentId:s,laneId:o}=e;t.startsWith("-")&&(t=t.slice(1));let i=this.allLaneGraphics.filter(a=>a.attributes.roadId===t);if(i.length===0)return{status:-1,message:"未找到。请检查路段编号"};if(s!==void 0){const a=[];if(i.forEach(c=>{const n=Number(c.attributes.sectionId);a.indexOf(n)===-1&&a.push(n)}),a.sort((c,n)=>c-n),s>a.length-1)return{status:-1,message:"未找到。请检查基本段编号"};s=a[s],i=i.filter(c=>Number(c.attributes.sectionId)===s)}if(o!==void 0){const a=[];if(i.forEach(c=>{const n=Number(c.attributes.laneId);a.indexOf(n)===-1&&a.push(n)}),a.sort((c,n)=>c-n),o>a.length-1)return{status:-1,message:"未找到。请检查车道编号"};o=a[o],i=i.filter(c=>Number(c.attributes.laneId)===o)}const l=i.map(a=>a.geometry),r=L.union(l);if(e.flash){const a=new I({geometry:r,symbol:{type:"simple-fill",color:[0,255,255,.6],style:"solid",outline:{width:0}}});this.flashGraphic(a)}return await this.view.goTo(r,{duration:1e3}),{status:0,message:"ok"}}flashGraphic(e){this.flashLayer.removeAll(),this.flashLayer.add(e);let t=0,s=!0;const o=setInterval(()=>{s?(this.flashLayer.opacity-=.02,this.flashLayer.opacity<=.1&&(s=!1,t++)):(this.flashLayer.opacity+=.02,this.flashLayer.opacity>=1&&(s=!0)),t>=5&&(this.flashLayer.removeAll(),this.flashLayer.opacity=1,clearInterval(o))},10)}unselectSumo(e){if(e?e.type==="junction"&&this.junctionLayer.graphics.forEach(t=>{(!e||!e.id||e.id===""||e.id===t.getAttribute("id"))&&t.getAttribute("selected")&&(t.setAttribute("selected",!1),t.symbol=this.getCrossGraphicSymbol(t.attributes,this.view.scale<this.junctionScale?"picture":"marker"))}):(this.highlightLayer.removeAll(),this.sectionLayer.removeAll(),this.selectedSectionIds=[],this.splitLaneLayer.removeAll()),!e||e.type==="edge"){let t;!e||!e.id||e.id===""?t=this.sectionLayer.graphics.toArray():t=this.sectionLayer.graphics.filter(s=>s.getAttribute("edgeId")===e.id).toArray(),t.length>0&&(t.forEach(s=>{const o=s.getAttribute("id");this.selectedSectionIds=this.selectedSectionIds.filter(i=>i!==o)}),this.sectionLayer.removeMany(t))}return{status:0,message:"ok"}}async selectSumo(e){switch(e.type){case"junction":return this.junctionLayer.graphics.forEach(t=>{if(e.id===t.getAttribute("id"))return t.setAttribute("selected",!0),t.symbol.url="/GisViewerAssets/Images/point_red.png",this.increasePictureMarkerSize(t,50),{status:0,message:"ok"}}),{status:-1,message:"未找到路口"};case"edge":{const t=e.id.split("#");let s=String(t[0]);s.startsWith("-")&&(s=s.slice(1));let o=0;t.length===2&&(o=Number(t[1]));let i=[];if(t.length===1?i=this.allLaneGraphics.filter(l=>l.getAttribute("roadId")===s):t.length===2&&(i=this.allLaneGraphics.filter(l=>l.getAttribute("roadId")===s&&l.getAttribute("sectionIndex")===o)),i.length>0){const l=new Map;return i.forEach(r=>{const a=r.getAttribute("roadId")+"+"+r.getAttribute("sectionId");this.selectedSectionIds.includes(a)||this.selectedSectionIds.push(a);let c=l.get(a);c?c.push(r.geometry):(c=[r.geometry],l.set(a,c))}),l.forEach(async(r,a)=>{const c=L.union(r),n=new I({geometry:c,symbol:{type:"simple-fill",color:[0,255,255,.5],style:"solid",outline:{color:[0,255,255],width:1}},attributes:{type:"OpenDriveSection",id:a,edgeId:e.id,selected:!0}});this.sectionLayer.add(n),await this.view.goTo(n)}),{status:0,message:"ok"}}else return{status:-1,message:"未找到路段"}}default:return{status:-1,message:"未知类型"}}}async geometrySearch(e){const t=new A.Polygon({rings:[e]}),s=await this.laneLayer.queryFeatures({geometry:t,outFields:["*"]}),o=[],i=[];for(const a of s.features){const c=a.getAttribute("roadId"),n=a.getAttribute("sectionIndex"),d=`${c}#${n}`;if(o.indexOf(d)===-1){o.push(d),this.selectSumo({type:"edge",id:d});const m=`http://${this.openDriveServer}/api/sumo/getSumoEdge`,u=await w.get(m,{params:{id:`${c}+${a.getAttribute("sectionId")}`,projectName:this.projectName}});u.status===200&&u.data.status===0&&i.push(u.data.result)}}const l=this.junctionLayer.graphics.filter(a=>{const c=a.geometry;return L.contains(t,c)}),r=[];for(const a of l){const c=a.getAttribute("id");this.selectSumo({type:"junction",id:c});const n=`http://${this.openDriveServer}/api/sumo/getSumoJunction`,d=await w.get(n,{params:{id:c,projectName:this.projectName}});d.status===200&&d.data.status===0&&r.push(d.data.result)}return{status:0,message:"ok",result:{junctions:r,edges:i}}}async splitLane(e){const s=e.id.split("_");if(s.length!==2)return{status:-1,message:"车道编号格式错误"};const o=Number(s[1]),i=s[0].split("#"),l=i.length===2?Number(i[1]):0;let r=i[0];r.startsWith("-")&&(r=r.slice(1));const a=this.allLaneGraphics.filter(b=>b.getAttribute("roadId")===r&&b.getAttribute("sectionIndex")===l);if(a.length===0)return{status:-1,message:"未找到路段"};const c=a.length-o,n=a.find(b=>Math.abs(b.getAttribute("laneId"))===c);if(!n)return{status:-1,message:"未找到车道"};const d=e.start||0,m=e.end||100,u=B.lineString(n.getAttribute("leftLine")),h=O.lineSliceAlong(u,d,m,{units:"meters"}),p=B.lineString(n.getAttribute("rightLine")),g=O.lineSliceAlong(p,d,m,{units:"meters"}),y=h.geometry.coordinates.concat(g.geometry.coordinates.reverse());y.push(y[y.length-1]);const f=new I({geometry:new A.Polygon({rings:[y]}),attributes:{ObjectID:n.getAttribute("ObjectID"),id:n.getAttribute("id"),fromNode:n.getAttribute("fromNode"),toNode:n.getAttribute("toNode"),roadId:n.getAttribute("roadId"),roadName:n.getAttribute("roadName"),sectionId:n.getAttribute("sectionId"),sectionIndex:n.getAttribute("sectionIndex"),laneId:n.getAttribute("laneId"),type:n.getAttribute("type"),sumoId:n.getAttribute("sumoId"),leftLine:h.geometry.coordinates,rightLine:g.geometry.coordinates},symbol:{type:"simple-fill",color:[255,0,0,.8],outline:{color:"red"}}});return this.splitLaneLayer.add(f),k.default.viewGoto(this.view,[f]),{status:0,message:"ok",result:{coordinates:y}}}blockLane(e){const t=this.allLaneGraphics.filter(o=>{var l;let i=String(o.getAttribute("laneId"));return i.startsWith("-")&&(i=i.slice(1)),o.getAttribute("roadId")===e.roadsectId&&((l=o.getAttribute("roadsectBaseIds"))==null?void 0:l.includes(e.roadsectBaseId))&&i===String(e.laneId)}),s=t.map(o=>{const i=o.clone();return console.log(t[0].getAttribute("roadsectBaseIds"),this.selectedSectionIds,this.selectedSectionIds.includes(t[0].getAttribute("roadsectBaseIds"))),i.symbol={type:"simple-fill",color:this.selectedSectionIds.includes(t[0].getAttribute("roadsectBaseIds"))?[255,69,0,.8]:[255,0,0,.8],outline:{color:"red"}},i});this.splitLaneLayer.addMany(s),k.default.viewGoto(this.view,s)}clearSplitLane(){this.splitLaneLayer.removeAll()}selectComputable(e){if(e.type==="roadsectBase"){this.allLaneGraphics.forEach(s=>{s.getAttribute("roadsectBaseIds")||console.log(s.attributes)});const t=this.allLaneGraphics.filter(s=>{var o;return(o=s.getAttribute("roadsectBaseIds"))==null?void 0:o.includes(e.id)});if(t.length>0){const s=L.union(t.map(r=>r.geometry)),o=t[0].getAttribute("roadsectBaseIds"),i=new I({geometry:s,symbol:{type:"simple-fill",color:[0,255,255,.5],style:"solid",outline:{color:[0,255,255],width:1}},attributes:{type:"OpenDriveSection",roadsectBaseIds:o}});this.sectionLayer.removeAll(),this.sectionLayer.add(i),k.default.viewGoto(this.view,[i]),this.selectedSectionIds=[o];const l=this.splitLaneLayer.graphics.filter(r=>{var a;return(a=r.getAttribute("roadsectBaseIds"))==null?void 0:a.includes(e.id)});l.length>0&&l.forEach(r=>r.symbol={type:"simple-fill",color:[255,69,0],outline:{color:"red",width:2}})}}}updateAllJunctionSymbol(e){const t=this.junctionLayer.graphics.clone();this.junctionLayer.removeAll(),t.forEach(s=>{s.getAttribute("selected")||(s.symbol=this.getCrossGraphicSymbol(s.attributes,e))}),this.junctionLayer.addMany(t.toArray())}getCrossGraphicSymbol(e,t){const s=e.crossId!==""&&e.crossId!==void 0&&e.crossId!==null;if(t==="marker")return{type:"picture-marker",url:`/GisViewerAssets/Images/cross/${s?"gis_xhj_blue":"gis_lkcz_xz"}.png`,width:"32px",height:"32px"};if(t==="picture")return s?{type:"cim",data:{type:"CIMSymbolReference",primitiveOverrides:[{type:"CIMPrimitiveOverride",primitiveName:"textGraphic",propertyName:"TextString",valueExpressionInfo:{type:"CIMExpressionInfo",title:"Custom",expression:'Replace($feature.name, "与", "/") + " " + $feature.crossId',returnType:"Default"}}],symbol:{type:"CIMPointSymbol",symbolLayers:[{type:"CIMVectorMarker",size:32,colorLocked:!0,anchorPointUnits:"Relative",frame:{xmin:-16,ymin:-16,xmax:16,ymax:16},markerGraphics:[{type:"CIMMarkerGraphic",primitiveName:"textGraphic",geometry:{x:0,y:0},symbol:{type:"CIMTextSymbol",height:12,horizontalAlignment:"Center",offsetX:0,offsetY:s?25:15,haloSize:2,haloSymbol:{type:"CIMPolygonSymbol",symbolLayers:[{type:"CIMSolidFill",enable:!0,color:[255,255,255,255]}]},symbol:{type:"CIMPolygonSymbol",symbolLayers:[{type:"CIMSolidFill",enable:!0,color:[0,0,0,255]}]},verticalAlignment:"Center"},textString:""}],scaleSymbolsProportionally:!0,respectFrame:!0},{type:"CIMPictureMarker",enable:!0,anchorPoint:{x:0,y:0},anchorPointUnits:"Relative",size:32,rotateClockwise:!0,textureFilter:"Picture",url:"/GisViewerAssets/Images/cross/gis_xhj_blue.png"}]}}}:{type:"picture-marker",url:"/GisViewerAssets/Images/cross/gis_lkcz_xz.png",width:"32px",height:"32px"}}}exports.default=C;
|
|
1
|
+
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const I=require("@arcgis/core/Graphic"),J=require("@arcgis/core/core/promiseUtils"),E=require("@arcgis/core/core/reactiveUtils.js"),A=require("@arcgis/core/geometry"),q=require("@arcgis/core/geometry/geometryEngine"),x=require("@arcgis/core/layers/FeatureLayer"),v=require("@arcgis/core/layers/GraphicsLayer"),T=require("@turf/helpers"),O=require("@turf/line-slice-along"),w=require("axios"),_=require("fast-xml-parser"),R=require("md5"),M=require("pako"),z=require("vue"),H=require("../../stores/index.js"),k=require("../common-utils.js");function N(S){const e=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(S){for(const i in S)if(i!=="default"){const s=Object.getOwnPropertyDescriptor(S,i);Object.defineProperty(e,i,s.get?s:{enumerable:!0,get:()=>S[i]})}}return e.default=S,Object.freeze(e)}const P=N(J),U=N(E),L=N(q),B=N(T);class C{constructor(e){this.junctionNames=new Map,this.junctionScale=5e3,this.xodrBorder=[],this.projectName="",this.openDriveServer="",this.currentSectionCode="",this.selectedSectionIds=[],this.currentJunctionId="",this.view=e,this.laneLayer=new x({id:"OpenDriveLane",fields:[{name:"ObjectID",alias:"ObjectID",type:"oid"},{name:"id",alias:"编号",type:"string"},{name:"roadId",alias:"道路号",type:"string"},{name:"roadName",alias:"道路名称",type:"string"},{name:"sectionId",alias:"路段号",type:"string"},{name:"sectionIndex",alias:"路段序号",type:"string"},{name:"laneId",alias:"车道号",type:"string"},{name:"type",alias:"类型",type:"string"},{name:"sumoId",alias:"sumo编号",type:"string"},{name:"fromNode",alias:"起点路口",type:"string"},{name:"toNode",alias:"终点路口",type:"string"},{name:"roadsectBaseIds",alias:"基本段编号",type:"string"}],objectIdField:"ObjectID",geometryType:"polygon",spatialReference:{wkid:4326},source:[],outFields:["*"],renderer:{type:"unique-value",field:"type",defaultSymbol:{type:"simple-fill",color:[100,100,100],style:"solid",outline:{color:"white",width:1}},uniqueValueInfos:[{value:"shoulder",label:"路肩",symbol:{type:"simple-fill",color:"#008000",style:"solid",outline:{color:"white",width:1}}},{value:"border",label:"路沿",symbol:{type:"simple-fill",color:"#DCDCDC",style:"solid",outline:{color:"white",width:1}}},{value:"driving",label:"机动车道",symbol:{type:"simple-fill",color:[47,79,79,.8],style:"solid",outline:{color:"white",width:1}}},{value:"none",label:"无",symbol:{type:"simple-fill",color:[111,120,135],style:"none",outline:{color:"white",width:1}}},{value:"restricted",label:"禁行区",symbol:{type:"simple-fill",color:"yellow",style:"solid",outline:{color:"yellow",width:2}}},{value:"parking",label:"停车区",symbol:{type:"simple-fill",color:[115,115,115],style:"solid",outline:{color:"white",width:1}}},{value:"median",label:"中央隔离带",symbol:{type:"simple-fill",color:"#008000",style:"solid",outline:{color:"white",width:1}}},{value:"biking",label:"非机动车道",symbol:{type:"simple-fill",color:"#D3D3D3",style:"solid",outline:{color:"white",width:1}}},{value:"sidewalk",label:"人行道",symbol:{type:"simple-fill",color:"#C0C0C0",style:"solid",outline:{color:"white",width:1}}},{value:"junction",label:"路口区域",symbol:{type:"simple-fill",color:"#2F4F4F",style:"solid",outline:{color:"white",width:1}}},{value:"selected",label:"选中车道",symbol:{type:"simple-fill",color:[141,168,211],style:"solid",outline:{color:"white",width:1}}}]}}),this.roadNameLayer=new x({id:"OpenDriveRoadName",fields:[{name:"ObjectID",alias:"ObjectID",type:"oid"},{name:"roadId",alias:"道路号",type:"string"},{name:"roadName",alias:"道路名称",type:"string"}],objectIdField:"ObjectID",geometryType:"polyline",spatialReference:{wkid:4326},source:[],renderer:{type:"simple",symbol:{type:"simple-line",style:"solid",color:[0,0,0,0],width:1}},labelingInfo:[{symbol:{type:"text",color:"black",haloColor:"white",haloSize:1,font:{size:12,family:"sans-serif"}},labelPlacement:this.view.type==="2d"?"center-along":void 0,labelExpressionInfo:{expression:"$feature.roadName"}}]}),this.junctionLayer=new v({id:"OpenDriveJunction"}),this.sectionLayer=new v({id:"OpenDriveSection"}),this.highlightLayer=new v({id:"OpenDriveHighlight"}),this.flashLayer=new v({id:"OpenDriveFlash"}),this.drawLayer=new v({id:"Draw"}),this.splitLaneLayer=new v({id:"SplitLane"}),this.borderLayer=new v({id:"OpenDriveBorder"}),this.view.map.addMany([this.laneLayer,this.sectionLayer,this.roadNameLayer,this.junctionLayer,this.highlightLayer,this.flashLayer,this.drawLayer,this.splitLaneLayer,this.borderLayer])}static getInstance(e){return this.instance||(this.instance=new C(e)),this.instance}async makeMd5FromFile(e){var i;try{const o=await(await fetch(e)).text();let r=(i=new _.XMLParser({ignoreAttributes:!1,allowBooleanAttributes:!0}).parse(o).OpenDRIVE.userData)==null?void 0:i.border;return r?r=JSON.parse(r):r=[],{status:0,message:"ok",result:{md5:R(o),border:r}}}catch(s){return{status:-1,message:s.message}}}async showOpenDriveFromFile(e){var d,m,u;this.openDriveClickCallback=e.selectedCallback,this.scaleWatch=U.watch(()=>this.view.scale,(h,p)=>{h>this.junctionScale&&p<=this.junctionScale?this.updateAllJunctionSymbol("marker"):h<=this.junctionScale&&p>this.junctionScale&&this.updateAllJunctionSymbol("picture")});let i=e.file.split("/").pop()||"";i=i.split(".").slice(0,-1).join("."),this.openDriveServer=e.server;const s=`http://${this.openDriveServer}/api/openDrive/uploadXodr`;let o;try{o=await w.post(s,{},{params:{url:e.file,projectName:i}})}catch(h){return{status:-1,message:h.message}}if(o.status!==200)return{status:-1,message:o.statusText};console.time("渲染用时");const t=o.data.result.geoSetting;k.default.setGeoData(t.geoReference,t.offsetX,t.offsetY);let l=o.data.result.json;l.startsWith(window.location.protocol)||(l=`${window.location.protocol}//${e.server}${l}`);const r=await fetch(l);let a;if(l.endsWith("bin")){const h=await r.arrayBuffer(),p=M.inflate(h,{to:"string"});a=JSON.parse(p)}else a=await r.json();if(await this.showAllLanes(a,((d=e.options)==null?void 0:d.showJunctionLane)||!1,((m=e.options)==null?void 0:m.showRoadName)||!0),((u=e.options)==null?void 0:u.showJunctionPoint)!==!1){const h=o.data.result.junctions;this.showJunction(h)}e.options&&e.options.centerMap!==!1&&await this.view.goTo(this.allLaneGraphics),this.mouseMoveHandler||this.monitorMouseMove(),this.mouseClickHandler||this.monitorMouseClick();const n=H.default.useAppDataStore;return z.watch(()=>n.isSketching,()=>{var h,p;n.isSketching?((h=this.mouseMoveHandler)==null||h.remove(),this.mouseMoveHandler=void 0,(p=this.mouseClickHandler)==null||p.remove(),this.mouseClickHandler=void 0):(this.monitorMouseMove(),this.monitorMouseClick())}),console.timeEnd("渲染用时"),{status:0,message:"ok"}}async showOpenDriveFromServer(e,i){const s=`http://${e}/api/openDrive/analyzeXodr`,o=await w.get(s,{headers:{projectName:i},params:{analyze:!1,compressed:!0}});if(o.status!==200)throw new Error(`OpenDriveRenderer: ${o.statusText}`);let t=o.data.result.json;t.startsWith(window.location.protocol)||(t=`${window.location.protocol}//${e}${t}`);const l=await fetch(t);let r;if(t.endsWith("bin")){const a=await l.arrayBuffer(),c=M.inflate(a,{to:"string"});r=JSON.parse(c)}else r=await l.json();return await this.showAllLanes(r,!1,!1),{status:0,message:"ok"}}async showAllLanes(e,i,s){const o=await this.laneLayer.queryFeatures();return o.features.length>0&&this.laneLayer.applyEdits({deleteFeatures:o.features}),this.roadNameLayer.visible=s,new Promise(t=>{var c;let l=0;this.allLaneGraphics=[],this.allRefLineGraphics=[];const r=[];for(const n of e){if(!i&&n.junction!=="-1")continue;const{id:d,refLine:m}=n;let u=n.name;u.includes("(")&&(u=u.slice(0,u.indexOf("("))),u=u.replace(/(.)/g,"$1 ");const h=new I({geometry:{type:"polyline",paths:[m]},attributes:{ObjectID:l++,roadId:d,roadName:u}});this.allRefLineGraphics.push(h),n.laneSections.sort((p,g)=>Number(p.id)-Number(g.id));for(let p=0;p<n.laneSections.length;p++){const g=n.laneSections[p],y=Number(g.id);for(const f of g.lanePaths){const b=Number(f.id);if(b===0)continue;const $=f.type,F=[...f.outerPath],j=f.innerPath.concat(F.reverse());if(j.length<=3){console.warn(`lane ${b} has less than 3 points`);continue}j.push(f.innerPath[0]);const D=new A.Polygon({rings:[j]});if(D){const G=new I({geometry:D,attributes:{ObjectID:l++,id:`${d}+${y}+${b}`,fromNode:n.fromNode,toNode:n.toNode,roadId:String(d),roadName:n.name,sectionId:String(y),sectionIndex:p,laneId:b,type:$,sumoId:"",leftLine:f.innerPath,rightLine:f.outerPath,roadsectBaseIds:(c=g.roadsectBaseIds)==null?void 0:c.toString()}});this.allLaneGraphics.push(G),r.push(G)}}}}const a=setInterval(()=>{if(r.length>0||this.allRefLineGraphics.length>0){if(r.length>0){const n=r.splice(0,100);this.laneLayer.applyEdits({addFeatures:n})}if(this.allRefLineGraphics.length>0){const n=this.allRefLineGraphics.splice(0,10);this.roadNameLayer.applyEdits({addFeatures:n})}}else clearInterval(a),t()},10)})}showJunction(e){const i=[];let s;this.xodrBorder.length>0&&(s=new A.Polygon({rings:[this.xodrBorder]}));for(const o of e)if(o&&(this.junctionNames.set(o.id,o.name),o.nodeType=o.type,o.crossId)){const t=new A.Point({x:o.coordinates[0],y:o.coordinates[1]});let l=!0;if(s&&(l=L.contains(s,t)),l){const r=new I({geometry:t,attributes:{...o,selected:!1,type:"OpenDriveJunction"},symbol:this.getCrossGraphicSymbol(o,"marker")});i.push(r)}}this.junctionLayer.addMany(i)}monitorMouseMove(){const e=P.debounce(async i=>{var l;const o=(l=(await this.view.hitTest(i,{include:[this.laneLayer,this.junctionLayer]})).results)==null?void 0:l.filter(r=>r.type==="graphic");if(o.length===0){this.currentSectionCode!==""&&(this.currentSectionCode="",this.highlightLayer.removeAll()),this.currentJunctionId!==""&&(this.currentJunctionId=""),this.view.closePopup();return}const t=o[0];if(this.hitGraphic=t.graphic,t.layer.id==="OpenDriveLane"){const r=`${this.hitGraphic.getAttribute("roadId")}+${this.hitGraphic.getAttribute("sectionId")}`,a=this.hitGraphic.getAttribute("roadsectBaseIds");if(this.currentSectionCode===r||this.selectedSectionIds.includes(a)||this.sectionLayer.graphics.findIndex(y=>y.getAttribute("id")===r)>=0)return;this.currentSectionCode=r;const n=this.allLaneGraphics.filter(y=>`${y.attributes.roadId}+${y.attributes.sectionId}`===r),d=L.union(n.map(y=>y.geometry)),m=this.hitGraphic.getAttribute("fromNode"),u=this.hitGraphic.getAttribute("toNode"),h=this.junctionNames.get(m)||m,p=this.junctionNames.get(u)||u,g=new I({geometry:d,symbol:{type:"simple-fill",color:[0,255,255,.5],style:"solid",outline:{color:[0,255,255],width:1}},attributes:{type:"OpenDriveSection",id:r,selected:!1,fromNodeName:h,toNodeName:p,laneCount:n.length,roadsectBaseIds:this.hitGraphic.getAttribute("roadsectBaseIds"),roadId:this.hitGraphic.getAttribute("roadId")},popupTemplate:{title:this.hitGraphic.getAttribute("roadName"),content:[{type:"fields",fieldInfos:[{fieldName:"fromNodeName",label:"起点路口"},{fieldName:"toNodeName",label:"终点路口"},{fieldName:"laneCount",label:"车道数量"}]}]}});this.highlightLayer.removeAll(),this.highlightLayer.add(g)}else if(t.layer.id==="OpenDriveJunction"){const r=this.hitGraphic.getAttribute("id");if(r===this.currentJunctionId)return;this.currentJunctionId=r}});this.mouseMoveHandler=this.view.on("pointer-move",async i=>{e(i).catch(()=>{})})}monitorMouseClick(){const e=P.debounce(async i=>{var a;const o=(a=(await this.view.hitTest(i,{include:[this.highlightLayer,this.junctionLayer,this.sectionLayer]})).results)==null?void 0:a.filter(c=>c.type==="graphic");if(o.length===0)return;const t=o[0].graphic,l=t.getAttribute("type"),r=t.getAttribute("id");if(l==="OpenDriveJunction")if(t.getAttribute("selected")===!1){const c=`http://${this.openDriveServer}/api/sumo/getSumoJunction`,n=await w.get(c,{params:{id:r,projectName:this.projectName}});n.status===200&&n.data.status===0&&(this.openDriveClickCallback&&this.openDriveClickCallback({type:"OpenDriveJunction",id:r,details:n.data.result}),t.setAttribute("selected",!0),t.symbol={type:"picture-marker",url:"/GisViewerAssets/Images/point_red.png",width:"20px",height:"20px"},this.increasePictureMarkerSize(t,50))}else this.openDriveClickCallback&&this.openDriveClickCallback({type:"OpenDriveJunction",id:r,details:void 0}),t.setAttribute("selected",!1),t.symbol=this.getCrossGraphicSymbol(t.attributes,this.view.scale<this.junctionScale?"picture":"marker");else l==="OpenDriveSection"&&(t.layer.id==="OpenDriveHighlight"?(this.highlightLayer.removeAll(),this.sectionLayer.removeAll(),this.selectedSectionIds=[],this.sectionLayer.add(t),t.setAttribute("selected",!0),this.selectedSectionIds.push(r),this.splitLaneLayer.graphics.filter(n=>n.getAttribute("roadsectBaseIds")===t.getAttribute("roadsectBaseIds")).forEach(n=>n.symbol={type:"simple-fill",color:[255,69,0],outline:{color:"red",width:2}}),this.openDriveClickCallback&&this.openDriveClickCallback({type:"OpenDriveSection",id:t.getAttribute("id"),details:{roadsectId:t.getAttribute("roadId"),roadsectBaseIds:t.getAttribute("roadsectBaseIds")}})):(this.splitLaneLayer.graphics.filter(n=>n.getAttribute("roadsectBaseIds")===t.getAttribute("roadsectBaseIds")).forEach(n=>n.symbol={type:"simple-fill",color:[255,0,0,.8],outline:{color:"red",width:1}}),this.sectionLayer.remove(t),this.selectedSectionIds=[],this.openDriveClickCallback&&this.openDriveClickCallback({type:"CloseOpenDriveSection",id:t.getAttribute("roadsectBaseIds"),details:{roadsectId:t.getAttribute("roadId"),roadsectBaseIds:t.getAttribute("roadsectBaseIds")}})))});this.mouseClickHandler=this.view.on("immediate-click",async i=>{e(i).catch(()=>{})})}increasePictureMarkerSize(e,i){const s=setInterval(()=>{const o=e.symbol,t=o.width;t<i?e.symbol={type:"picture-marker",url:o.url,width:t+1,height:t+1}:clearInterval(s)},20)}decreasePictureMarkerSize(e,i){const s=setInterval(()=>{const o=e.symbol,t=o.width;t>i?e.symbol={type:"picture-marker",url:o.url,width:t-1,height:t-1}:clearInterval(s)},20)}async getSumoInfo(e){switch(e.type){case"junction":{const i=`http://${this.openDriveServer}/api/sumo/getSumoJunction`,s=await w.get(i,{params:{id:e.id,projectName:this.projectName}});return s.status===200?s.data:{status:-1,message:`路口信息查询失败: ${e.id}`}}case"edge":{const i=e.id.split("#");let s=i[0];s.startsWith("-")&&(s=s.slice(1));let o=0;i.length===2&&(o=Number(i[1]));const t=this.allLaneGraphics.find(l=>l.getAttribute("roadId")===s&&l.getAttribute("sectionIndex")===o);if(t){const l=`${s}+${t.getAttribute("sectionId")}`,r=`http://${this.openDriveServer}/api/sumo/getSumoEdge`,a=await w.get(r,{params:{id:l,projectName:this.projectName}});return a.status===200?a.data:{status:-1,message:`路段信息查询失败: ${l}`}}else return{status:-1,message:"未知类型"}}default:return{status:-1,message:"未知类型"}}}setOpendriveVisibility(e){this.laneLayer.visible=e}async clearOpenDrive(){var i,s,o;let e=await this.laneLayer.queryFeatures();e.features.length>0&&await this.laneLayer.applyEdits({deleteFeatures:e.features}),e=await this.roadNameLayer.queryFeatures(),e.features.length>0&&await this.roadNameLayer.applyEdits({deleteFeatures:e.features}),this.highlightLayer.removeAll(),this.junctionLayer.removeAll(),this.sectionLayer.removeAll(),this.flashLayer.removeAll(),this.borderLayer.removeAll(),(i=this.mouseMoveHandler)==null||i.remove(),this.mouseMoveHandler=void 0,(s=this.mouseClickHandler)==null||s.remove(),this.mouseClickHandler=void 0,(o=this.scaleWatch)==null||o.remove(),this.scaleWatch=void 0}async findSumo(e){const{type:i,id:s}=e,o=e.flash===void 0?!0:e.flash;if(i==="junction")return await this.findJunction(s,o);if(i==="edge"){const t=s.split("_");if(t.length>2)return{status:-1,message:"id格式错误"};const l=t.length===2?Number(t[1]):void 0,r=t[0].split("#");if(r.length>2)return{status:-1,message:"id格式错误"};const a=r[0],c=r.length===2?Number(r[1]):void 0;return await this.findLane({roadsectId:a,segmentId:c,laneId:l,flash:o})}else return{status:-1,message:"未知类型"}}async findJunction(e,i){const s=this.junctionLayer.graphics.find(o=>o.attributes.id===e);if(!s)return{status:-1,message:"未找到。请检查路口编号"};if(i){const o=new I({geometry:s.geometry,symbol:{type:"simple-marker",style:"circle",size:30,color:[0,255,255,.8],outline:{color:[0,255,255],width:1}}});this.flashGraphic(o)}return await this.view.goTo(s.geometry,{duration:1e3}),{status:0,message:"ok"}}async findLane(e){let{roadsectId:i,segmentId:s,laneId:o}=e;i.startsWith("-")&&(i=i.slice(1));let t=this.allLaneGraphics.filter(a=>a.attributes.roadId===i);if(t.length===0)return{status:-1,message:"未找到。请检查路段编号"};if(s!==void 0){const a=[];if(t.forEach(c=>{const n=Number(c.attributes.sectionId);a.indexOf(n)===-1&&a.push(n)}),a.sort((c,n)=>c-n),s>a.length-1)return{status:-1,message:"未找到。请检查基本段编号"};s=a[s],t=t.filter(c=>Number(c.attributes.sectionId)===s)}if(o!==void 0){const a=[];if(t.forEach(c=>{const n=Number(c.attributes.laneId);a.indexOf(n)===-1&&a.push(n)}),a.sort((c,n)=>c-n),o>a.length-1)return{status:-1,message:"未找到。请检查车道编号"};o=a[o],t=t.filter(c=>Number(c.attributes.laneId)===o)}const l=t.map(a=>a.geometry),r=L.union(l);if(e.flash){const a=new I({geometry:r,symbol:{type:"simple-fill",color:[0,255,255,.6],style:"solid",outline:{width:0}}});this.flashGraphic(a)}return await this.view.goTo(r,{duration:1e3}),{status:0,message:"ok"}}flashGraphic(e){this.flashLayer.removeAll(),this.flashLayer.add(e);let i=0,s=!0;const o=setInterval(()=>{s?(this.flashLayer.opacity-=.02,this.flashLayer.opacity<=.1&&(s=!1,i++)):(this.flashLayer.opacity+=.02,this.flashLayer.opacity>=1&&(s=!0)),i>=5&&(this.flashLayer.removeAll(),this.flashLayer.opacity=1,clearInterval(o))},10)}unselectSumo(e){if(e?e.type==="junction"&&this.junctionLayer.graphics.forEach(i=>{(!e||!e.id||e.id===""||e.id===i.getAttribute("id"))&&i.getAttribute("selected")&&(i.setAttribute("selected",!1),i.symbol=this.getCrossGraphicSymbol(i.attributes,this.view.scale<this.junctionScale?"picture":"marker"))}):(this.highlightLayer.removeAll(),this.sectionLayer.removeAll(),this.selectedSectionIds=[],this.splitLaneLayer.removeAll()),!e||e.type==="edge"){let i;!e||!e.id||e.id===""?i=this.sectionLayer.graphics.toArray():i=this.sectionLayer.graphics.filter(s=>s.getAttribute("edgeId")===e.id).toArray(),i.length>0&&(i.forEach(s=>{const o=s.getAttribute("id");this.selectedSectionIds=this.selectedSectionIds.filter(t=>t!==o)}),this.sectionLayer.removeMany(i))}return{status:0,message:"ok"}}async selectSumo(e){switch(e.type){case"junction":return this.junctionLayer.graphics.forEach(i=>{if(e.id===i.getAttribute("id"))return i.setAttribute("selected",!0),i.symbol.url="/GisViewerAssets/Images/point_red.png",this.increasePictureMarkerSize(i,50),{status:0,message:"ok"}}),{status:-1,message:"未找到路口"};case"edge":{const i=e.id.split("#");let s=String(i[0]);s.startsWith("-")&&(s=s.slice(1));let o=0;i.length===2&&(o=Number(i[1]));let t=[];if(i.length===1?t=this.allLaneGraphics.filter(l=>l.getAttribute("roadId")===s):i.length===2&&(t=this.allLaneGraphics.filter(l=>l.getAttribute("roadId")===s&&l.getAttribute("sectionIndex")===o)),t.length>0){const l=new Map;return t.forEach(r=>{const a=r.getAttribute("roadId")+"+"+r.getAttribute("sectionId");this.selectedSectionIds.includes(a)||this.selectedSectionIds.push(a);let c=l.get(a);c?c.push(r.geometry):(c=[r.geometry],l.set(a,c))}),l.forEach(async(r,a)=>{const c=L.union(r),n=new I({geometry:c,symbol:{type:"simple-fill",color:[0,255,255,.5],style:"solid",outline:{color:[0,255,255],width:1}},attributes:{type:"OpenDriveSection",id:a,edgeId:e.id,selected:!0}});this.sectionLayer.add(n),await this.view.goTo(n)}),{status:0,message:"ok"}}else return{status:-1,message:"未找到路段"}}default:return{status:-1,message:"未知类型"}}}async geometrySearch(e){const i=new A.Polygon({rings:[e]}),s=await this.laneLayer.queryFeatures({geometry:i,outFields:["*"]}),o=[],t=[];for(const a of s.features){const c=a.getAttribute("roadId"),n=a.getAttribute("sectionIndex"),d=`${c}#${n}`;if(o.indexOf(d)===-1){o.push(d),this.selectSumo({type:"edge",id:d});const m=`http://${this.openDriveServer}/api/sumo/getSumoEdge`,u=await w.get(m,{params:{id:`${c}+${a.getAttribute("sectionId")}`,projectName:this.projectName}});u.status===200&&u.data.status===0&&t.push(u.data.result)}}const l=this.junctionLayer.graphics.filter(a=>{const c=a.geometry;return L.contains(i,c)}),r=[];for(const a of l){const c=a.getAttribute("id");this.selectSumo({type:"junction",id:c});const n=`http://${this.openDriveServer}/api/sumo/getSumoJunction`,d=await w.get(n,{params:{id:c,projectName:this.projectName}});d.status===200&&d.data.status===0&&r.push(d.data.result)}return{status:0,message:"ok",result:{junctions:r,edges:t}}}async splitLane(e){const s=e.id.split("_");if(s.length!==2)return{status:-1,message:"车道编号格式错误"};const o=Number(s[1]),t=s[0].split("#"),l=t.length===2?Number(t[1]):0;let r=t[0];r.startsWith("-")&&(r=r.slice(1));const a=this.allLaneGraphics.filter(b=>b.getAttribute("roadId")===r&&b.getAttribute("sectionIndex")===l);if(a.length===0)return{status:-1,message:"未找到路段"};const c=a.length-o,n=a.find(b=>Math.abs(b.getAttribute("laneId"))===c);if(!n)return{status:-1,message:"未找到车道"};const d=e.start||0,m=e.end||100,u=B.lineString(n.getAttribute("leftLine")),h=O.lineSliceAlong(u,d,m,{units:"meters"}),p=B.lineString(n.getAttribute("rightLine")),g=O.lineSliceAlong(p,d,m,{units:"meters"}),y=h.geometry.coordinates.concat(g.geometry.coordinates.reverse());y.push(y[y.length-1]);const f=new I({geometry:new A.Polygon({rings:[y]}),attributes:{ObjectID:n.getAttribute("ObjectID"),id:n.getAttribute("id"),fromNode:n.getAttribute("fromNode"),toNode:n.getAttribute("toNode"),roadId:n.getAttribute("roadId"),roadName:n.getAttribute("roadName"),sectionId:n.getAttribute("sectionId"),sectionIndex:n.getAttribute("sectionIndex"),laneId:n.getAttribute("laneId"),type:n.getAttribute("type"),sumoId:n.getAttribute("sumoId"),leftLine:h.geometry.coordinates,rightLine:g.geometry.coordinates},symbol:{type:"simple-fill",color:[255,0,0,.8],outline:{color:"red"}}});return this.splitLaneLayer.add(f),k.default.viewGoto(this.view,[f]),{status:0,message:"ok",result:{coordinates:y}}}clearSplitLane(){this.splitLaneLayer.removeAll()}blockLane(e){const i=this.allLaneGraphics.filter(o=>{var l;let t=String(o.getAttribute("laneId"));return t.startsWith("-")&&(t=t.slice(1)),o.getAttribute("roadId")===e.roadsectId&&((l=o.getAttribute("roadsectBaseIds"))==null?void 0:l.includes(e.roadsectBaseId))&&t===String(e.laneId)}),s=i.map(o=>{const t=o.clone();return t.symbol={type:"simple-fill",color:this.selectedSectionIds.includes(i[0].getAttribute("roadsectBaseIds"))?[255,69,0,.8]:[255,0,0,.8],outline:{color:"red"}},t});this.splitLaneLayer.addMany(s),k.default.viewGoto(this.view,s)}clearBlockLane(e){const i=this.splitLaneLayer.graphics.filter(s=>{const o=s.getAttribute("roadId"),t=s.getAttribute("roadsectBaseIds");let l=String(s.getAttribute("laneId"));return l.startsWith("-")&&(l=l.slice(1)),o===e.roadsectId&&(t==null?void 0:t.includes(e.roadsectBaseId))&&l===String(e.laneId)});this.splitLaneLayer.removeMany(i.toArray())}selectComputable(e){if(e.type==="roadsectBase"){const i=this.allLaneGraphics.filter(s=>{var o;return(o=s.getAttribute("roadsectBaseIds"))==null?void 0:o.includes(e.id)});if(i.length>0){const s=L.union(i.map(r=>r.geometry)),o=i[0].getAttribute("roadsectBaseIds"),t=new I({geometry:s,symbol:{type:"simple-fill",color:[0,255,255,.5],style:"solid",outline:{color:[0,255,255],width:1}},attributes:{type:"OpenDriveSection",roadsectBaseIds:o}});this.sectionLayer.removeAll(),this.sectionLayer.add(t),k.default.viewGoto(this.view,[t]),this.selectedSectionIds=[o];const l=this.splitLaneLayer.graphics.filter(r=>{var a;return(a=r.getAttribute("roadsectBaseIds"))==null?void 0:a.includes(e.id)});l.length>0&&l.forEach(r=>r.symbol={type:"simple-fill",color:[255,69,0],outline:{color:"red",width:2}})}}}updateAllJunctionSymbol(e){const i=this.junctionLayer.graphics.clone();this.junctionLayer.removeAll(),i.forEach(s=>{s.getAttribute("selected")||(s.symbol=this.getCrossGraphicSymbol(s.attributes,e))}),this.junctionLayer.addMany(i.toArray())}getCrossGraphicSymbol(e,i){const s=e.crossId!==""&&e.crossId!==void 0&&e.crossId!==null;if(i==="marker")return{type:"picture-marker",url:`/GisViewerAssets/Images/cross/${s?"gis_xhj_blue":"gis_lkcz_xz"}.png`,width:"32px",height:"32px"};if(i==="picture")return s?{type:"cim",data:{type:"CIMSymbolReference",primitiveOverrides:[{type:"CIMPrimitiveOverride",primitiveName:"textGraphic",propertyName:"TextString",valueExpressionInfo:{type:"CIMExpressionInfo",title:"Custom",expression:'Replace($feature.name, "与", "/") + " " + $feature.crossId',returnType:"Default"}}],symbol:{type:"CIMPointSymbol",symbolLayers:[{type:"CIMVectorMarker",size:32,colorLocked:!0,anchorPointUnits:"Relative",frame:{xmin:-16,ymin:-16,xmax:16,ymax:16},markerGraphics:[{type:"CIMMarkerGraphic",primitiveName:"textGraphic",geometry:{x:0,y:0},symbol:{type:"CIMTextSymbol",height:12,horizontalAlignment:"Center",offsetX:0,offsetY:s?25:15,haloSize:2,haloSymbol:{type:"CIMPolygonSymbol",symbolLayers:[{type:"CIMSolidFill",enable:!0,color:[255,255,255,255]}]},symbol:{type:"CIMPolygonSymbol",symbolLayers:[{type:"CIMSolidFill",enable:!0,color:[0,0,0,255]}]},verticalAlignment:"Center"},textString:""}],scaleSymbolsProportionally:!0,respectFrame:!0},{type:"CIMPictureMarker",enable:!0,anchorPoint:{x:0,y:0},anchorPointUnits:"Relative",size:32,rotateClockwise:!0,textureFilter:"Picture",url:"/GisViewerAssets/Images/cross/gis_xhj_blue.png"}]}}}:{type:"picture-marker",url:"/GisViewerAssets/Images/cross/gis_lkcz_xz.png",width:"32px",height:"32px"}}}exports.default=C;
|