gisviewer-vue3-arcgis 1.0.154 → 1.0.155
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 +3 -1
- package/es/src/gis-map/gis-map.vue.mjs +120 -116
- package/es/src/gis-map/index.d.ts +2 -0
- package/es/src/gis-map/utils/holo-flow/index.d.ts +1 -2
- package/es/src/gis-map/utils/holo-flow/index.mjs +19 -12
- package/es/src/gis-map/utils/holo-flow/signal-holo-flow-lsr.d.ts +9 -0
- package/es/src/gis-map/utils/holo-flow/signal-holo-flow-lsr.mjs +43 -0
- package/es/src/gis-map/utils/holo-flow/signal-holo-flow.d.ts +3 -4
- package/es/src/gis-map/utils/open-drive-renderer/index.d.ts +1 -0
- package/es/src/gis-map/utils/open-drive-renderer/index.mjs +27 -21
- package/es/src/gis-map/utils/overlay.d.ts +3 -1
- package/es/src/gis-map/utils/overlay.mjs +75 -43
- package/es/src/types/index.d.ts +5 -0
- package/lib/src/gis-map/gis-map.vue.d.ts +3 -1
- package/lib/src/gis-map/gis-map.vue.js +1 -1
- package/lib/src/gis-map/index.d.ts +2 -0
- package/lib/src/gis-map/utils/holo-flow/index.d.ts +1 -2
- package/lib/src/gis-map/utils/holo-flow/index.js +1 -1
- package/lib/src/gis-map/utils/holo-flow/signal-holo-flow-lsr.d.ts +9 -0
- package/lib/src/gis-map/utils/holo-flow/signal-holo-flow-lsr.js +1 -0
- package/lib/src/gis-map/utils/holo-flow/signal-holo-flow.d.ts +3 -4
- package/lib/src/gis-map/utils/open-drive-renderer/index.d.ts +1 -0
- package/lib/src/gis-map/utils/open-drive-renderer/index.js +1 -1
- package/lib/src/gis-map/utils/overlay.d.ts +3 -1
- package/lib/src/gis-map/utils/overlay.js +1 -1
- package/lib/src/types/index.d.ts +5 -0
- package/package.json +1 -1
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import MapView from '@arcgis/core/views/MapView';
|
|
2
2
|
import SceneView from '@arcgis/core/views/SceneView';
|
|
3
|
-
import { IFindSumoParams, ILaneNumberParams, ILayerVisibleParams, ILookAtParams, IOverlayParam, IQueueLengthParams, ISetMapCameraParams, ISetMapCenterParams, IShowOpenDriveFromFileParams, ISplitOpenDriveLaneParams, IStartCrossBufferParam, IToggleTrafficInfoParams, IUnselectSumoParams } from '../types';
|
|
3
|
+
import { IFindSumoParams, ILaneNumberParams, ILayerVisibleParams, ILookAtParams, IMaskParam, IOverlayParam, IQueueLengthParams, ISetMapCameraParams, ISetMapCenterParams, IShowOpenDriveFromFileParams, ISplitOpenDriveLaneParams, IStartCrossBufferParam, IToggleTrafficInfoParams, IUnselectSumoParams } from '../types';
|
|
4
4
|
import HoloFlow from './utils/holo-flow';
|
|
5
5
|
import MapInitializer from './utils/map-initializer';
|
|
6
6
|
import OpenDriveRenderer from './utils/open-drive-renderer';
|
|
@@ -63,6 +63,8 @@ declare const _sfc_main: import("vue").DefineComponent<{
|
|
|
63
63
|
toggleTrafficObject: (params: IToggleTrafficInfoParams) => void;
|
|
64
64
|
toggleVehicleInfo: (contentType: string) => void;
|
|
65
65
|
addOverlays: (params: IOverlayParam) => Promise<import("../types").IResult>;
|
|
66
|
+
addMask: (params: IMaskParam) => void;
|
|
67
|
+
removeMask: () => void;
|
|
66
68
|
removeOverlaysByType: (types: string[]) => import("../types").IResult;
|
|
67
69
|
removeOverlaysById: (ids: string[]) => import("../types").IResult;
|
|
68
70
|
removeAllOverlays: () => import("../types").IResult;
|
|
@@ -1,176 +1,180 @@
|
|
|
1
|
-
import { defineComponent as
|
|
2
|
-
import O, { registerStore as
|
|
1
|
+
import { defineComponent as Le, ref as S, onMounted as Ae, getCurrentInstance as Ie, onUnmounted as be, computed as Me, openBlock as _e, createElementBlock as He, createElementVNode as p, withDirectives as xe, vShow as Ve } from "vue";
|
|
2
|
+
import O, { registerStore as Be } from "./stores/index.mjs";
|
|
3
3
|
import "./style/index.css";
|
|
4
|
-
import
|
|
5
|
-
import
|
|
4
|
+
import ze from "./utils/holo-flow/index.mjs";
|
|
5
|
+
import Ne from "./utils/map-initializer.mjs";
|
|
6
6
|
import C from "./utils/open-drive-renderer/index.mjs";
|
|
7
|
-
import
|
|
8
|
-
import
|
|
9
|
-
import
|
|
10
|
-
import
|
|
11
|
-
import
|
|
12
|
-
const
|
|
7
|
+
import k from "./utils/overlay.mjs";
|
|
8
|
+
import Qe from "./utils/queue-length.mjs";
|
|
9
|
+
import T from "./utils/road-config-tool/index.mjs";
|
|
10
|
+
import je from "./utils/signal-control-area-controller/index.mjs";
|
|
11
|
+
import Pe from "./utils/traffic-flow.mjs";
|
|
12
|
+
const Ee = { class: "gis-viewer" }, Fe = { style: { position: "absolute", bottom: "10px", left: "10px" } }, et = /* @__PURE__ */ Le({
|
|
13
13
|
__name: "gis-map",
|
|
14
14
|
props: {
|
|
15
15
|
config: {},
|
|
16
16
|
assetsRoot: {}
|
|
17
17
|
},
|
|
18
18
|
emits: ["mapLoaded", "markerClick", "mapClick"],
|
|
19
|
-
setup(
|
|
19
|
+
setup(D, { expose: L, emit: A }) {
|
|
20
20
|
const g = S(null);
|
|
21
|
-
let
|
|
21
|
+
let s, c, i, r, n, a, u, t, o;
|
|
22
22
|
const f = S(!1);
|
|
23
|
-
|
|
24
|
-
if (
|
|
23
|
+
Ae(async () => {
|
|
24
|
+
if (Be(), !g.value)
|
|
25
25
|
return;
|
|
26
26
|
document.addEventListener("keydown", (m) => {
|
|
27
27
|
m.ctrlKey && m.key === "i" && (f.value = !f.value);
|
|
28
28
|
});
|
|
29
|
-
const e =
|
|
30
|
-
h.assetsRoot =
|
|
31
|
-
const
|
|
32
|
-
|
|
29
|
+
const e = Ie(), { $gisviewerAssetsRoot: l } = e.appContext.config.globalProperties, h = await (await fetch(y.config)).json();
|
|
30
|
+
h.assetsRoot = y.assetsRoot || l;
|
|
31
|
+
const Te = O.useAppDataStore;
|
|
32
|
+
Te.mapConfig = h, c = new Ne(), s = await c.initialize({
|
|
33
33
|
container: g.value,
|
|
34
|
-
markerClickCallback: (m,
|
|
35
|
-
w("markerClick", m,
|
|
34
|
+
markerClickCallback: (m, d, v, De) => {
|
|
35
|
+
w("markerClick", m, d, v, De);
|
|
36
36
|
},
|
|
37
|
-
mapClickCallback: (m,
|
|
38
|
-
w("mapClick", m,
|
|
37
|
+
mapClickCallback: (m, d, v) => {
|
|
38
|
+
w("mapClick", m, d, v);
|
|
39
39
|
}
|
|
40
|
-
}),
|
|
41
|
-
}),
|
|
42
|
-
o == null || o.clearSignalControlArea(), t == null || t.clearOpenDrive(),
|
|
40
|
+
}), n = new ze(s), await n.init(), w("mapLoaded");
|
|
41
|
+
}), be(() => {
|
|
42
|
+
o == null || o.clearSignalControlArea(), t == null || t.clearOpenDrive(), n == null || n.clearHoloTrace(), n == null || n.clearHoloSignal(), r == null || r.disconnectTrafficFlow();
|
|
43
43
|
});
|
|
44
|
-
const
|
|
44
|
+
const I = Me(() => s), b = () => {
|
|
45
45
|
const e = O.useAppDataStore;
|
|
46
46
|
e.saveTrackLog = !0;
|
|
47
|
-
},
|
|
48
|
-
|
|
49
|
-
}, _ = async (e) => await c.setMapCenter(e), H = async (e) => await c.setMapCamera(e), x = async (e) => await c.lookAt(e),
|
|
47
|
+
}, M = () => {
|
|
48
|
+
n.downloadTrackLog();
|
|
49
|
+
}, _ = async (e) => await c.setMapCenter(e), H = async (e) => await c.setMapCamera(e), x = async (e) => await c.lookAt(e), V = (e) => c.setLayerVisibility(e), B = (e, l) => c.requestCoordinateTransform(e, l), z = (e) => {
|
|
50
50
|
c.cancelCoordinateTransform(e);
|
|
51
|
-
},
|
|
51
|
+
}, N = (e) => {
|
|
52
52
|
c.setMapZoomRange(e);
|
|
53
|
-
},
|
|
54
|
-
|
|
55
|
-
},
|
|
56
|
-
},
|
|
57
|
-
|
|
58
|
-
},
|
|
59
|
-
|
|
60
|
-
},
|
|
61
|
-
|
|
62
|
-
},
|
|
63
|
-
|
|
64
|
-
},
|
|
65
|
-
|
|
66
|
-
},
|
|
67
|
-
await
|
|
68
|
-
},
|
|
69
|
-
|
|
70
|
-
}, J = (e) => {
|
|
71
|
-
n == null || n.toggleTrafficInfo(e), a.toggleTrafficInfo(e);
|
|
53
|
+
}, Q = (e) => (i || (i = new T(s)), i.showLaneNumber(e)), j = () => {
|
|
54
|
+
i == null || i.clearLaneNumber();
|
|
55
|
+
}, P = async (e) => (i || (i = new T(s)), await i.initializeSearch(e)), E = async () => i == null ? void 0 : i.calCrossIndicatorArea(), F = async () => {
|
|
56
|
+
}, Z = async (e, l) => {
|
|
57
|
+
r || (r = new Pe(s)), r.connectTrafficFlow(e, l);
|
|
58
|
+
}, q = () => {
|
|
59
|
+
r == null || r.disconnectTrafficFlow();
|
|
60
|
+
}, K = (e) => {
|
|
61
|
+
n.handleVehicleTraceData(e);
|
|
62
|
+
}, U = () => {
|
|
63
|
+
n.clearHoloTrace();
|
|
64
|
+
}, $ = (e) => {
|
|
65
|
+
n.setInterpolate(e);
|
|
66
|
+
}, G = async (e) => {
|
|
67
|
+
await n.handleSignalData(e);
|
|
68
|
+
}, J = () => {
|
|
69
|
+
n.clearHoloSignal();
|
|
72
70
|
}, R = (e) => {
|
|
73
|
-
|
|
71
|
+
r == null || r.toggleTrafficInfo(e), n.toggleTrafficInfo(e);
|
|
74
72
|
}, W = (e) => {
|
|
75
|
-
n
|
|
73
|
+
n.togglePause(e);
|
|
76
74
|
}, X = (e) => {
|
|
77
|
-
|
|
78
|
-
}, Y =
|
|
79
|
-
|
|
80
|
-
},
|
|
81
|
-
|
|
82
|
-
}, oe = () => {
|
|
75
|
+
r == null || r.toggleTrafficObject(e), n.toggleTrafficObject(e);
|
|
76
|
+
}, Y = (e) => {
|
|
77
|
+
n.updatePanelContent(e);
|
|
78
|
+
}, ee = async (e) => (a || (a = new k(s)), a.addOverlays(e)), te = (e) => (a || (a = new k(s)), a.addMask(e)), ae = () => {
|
|
79
|
+
a == null || a.removeMask();
|
|
80
|
+
}, ne = (e) => a == null ? void 0 : a.removeOverlaysByType(e), re = (e) => a == null ? void 0 : a.removeOverlaysById(e), oe = () => a == null ? void 0 : a.removeAllOverlays(), se = () => {
|
|
81
|
+
a == null || a.showAllOverlays();
|
|
82
|
+
}, ie = (e) => {
|
|
83
|
+
u || (u = new Qe(s)), u.updateQueueLength(e);
|
|
84
|
+
}, ce = () => {
|
|
83
85
|
u == null || u.removeQueueLength();
|
|
84
|
-
},
|
|
86
|
+
}, le = async (e, l) => (t || (t = new C(s)), await t.showOpenDriveFromServer(e, l)), ue = async (e) => (t || (t = new C(s)), await t.clearOpenDrive(), await t.showOpenDriveFromFile(e)), me = async () => await (t == null ? void 0 : t.clearOpenDrive()), pe = async (e) => t ? await (t == null ? void 0 : t.findSumo(e)) : {
|
|
85
87
|
status: -1,
|
|
86
88
|
message: "未加载OpenDrive地图"
|
|
87
|
-
},
|
|
89
|
+
}, ge = async (e) => t ? t.selectSumo(e) : {
|
|
88
90
|
status: -1,
|
|
89
91
|
message: "未加载OpenDrive地图"
|
|
90
|
-
},
|
|
92
|
+
}, fe = async (e) => t ? t.unselectSumo(e) : {
|
|
91
93
|
status: -1,
|
|
92
94
|
message: "未加载OpenDrive地图"
|
|
93
|
-
},
|
|
95
|
+
}, we = async (e) => t ? await t.geometrySearch(e) : {
|
|
94
96
|
status: -1,
|
|
95
97
|
message: "未加载OpenDrive地图"
|
|
96
|
-
},
|
|
98
|
+
}, de = async (e) => t ? await t.getSumoInfo(e) : {
|
|
97
99
|
status: -1,
|
|
98
100
|
message: "未加载OpenDrive地图"
|
|
99
|
-
},
|
|
101
|
+
}, ve = async (e) => t ? await (t == null ? void 0 : t.splitLane(e)) : {
|
|
100
102
|
status: -1,
|
|
101
103
|
message: "未加载OpenDrive地图"
|
|
102
|
-
},
|
|
104
|
+
}, ye = async () => t ? t == null ? void 0 : t.clearSplitLane() : {
|
|
103
105
|
status: -1,
|
|
104
106
|
message: "未加载OpenDrive地图"
|
|
105
|
-
},
|
|
107
|
+
}, he = (e) => (o || (o = new je(s)), o.showSignalControlArea(e)), Se = () => {
|
|
106
108
|
o == null || o.clearSignalControlArea();
|
|
107
|
-
},
|
|
108
|
-
return
|
|
109
|
-
mapViewer:
|
|
110
|
-
setLayerVisibility:
|
|
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
|
+
return L({
|
|
111
|
+
mapViewer: I,
|
|
112
|
+
setLayerVisibility: V,
|
|
111
113
|
setMapCenter: _,
|
|
112
114
|
lookAt: x,
|
|
113
115
|
setMapCamera: H,
|
|
114
|
-
setMapZoomRange:
|
|
115
|
-
requestCoordinateTransform:
|
|
116
|
-
cancelCoordinateTransform:
|
|
117
|
-
addOverlays:
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
116
|
+
setMapZoomRange: N,
|
|
117
|
+
requestCoordinateTransform: B,
|
|
118
|
+
cancelCoordinateTransform: z,
|
|
119
|
+
addOverlays: ee,
|
|
120
|
+
addMask: te,
|
|
121
|
+
removeMask: ae,
|
|
122
|
+
showAllOverlays: se,
|
|
123
|
+
removeOverlaysByType: ne,
|
|
124
|
+
removeOverlaysById: re,
|
|
125
|
+
removeAllOverlays: oe,
|
|
126
|
+
showLaneNumber: Q,
|
|
127
|
+
clearLaneNumber: j,
|
|
128
|
+
initializeAreaTool: P,
|
|
129
|
+
calCrossIndicatorArea: E,
|
|
130
|
+
calRoadIndicatorArea: F,
|
|
131
|
+
connectCarFlow: Z,
|
|
132
|
+
disconnectCarFlow: q,
|
|
133
|
+
handleHoloVehicleTraceData: K,
|
|
134
|
+
clearHoloTrace: U,
|
|
135
|
+
handleHoloSignalData: G,
|
|
136
|
+
clearHoloSignal: J,
|
|
137
|
+
setInterpolate: $,
|
|
138
|
+
toggleTrafficInfo: R,
|
|
139
|
+
toggleTrafficObject: X,
|
|
140
|
+
toggleVehicleInfo: Y,
|
|
141
|
+
togglePause: W,
|
|
142
|
+
updateQueueLength: ie,
|
|
143
|
+
removeQueueLength: ce,
|
|
144
|
+
showOpenDriveFromServer: le,
|
|
145
|
+
showOpenDriveFromFile: ue,
|
|
146
|
+
clearOpenDrive: me,
|
|
147
|
+
geometrySearchInOpenDrive: we,
|
|
148
|
+
findSumoInOpenDrive: pe,
|
|
149
|
+
selectSumoInOpenDrive: ge,
|
|
150
|
+
unselectSumoInOpenDrive: fe,
|
|
151
|
+
getSumoInfo: de,
|
|
152
|
+
splitOpenDriveLane: ve,
|
|
153
|
+
clearSplitOpenDriveLane: ye,
|
|
154
|
+
showSignalControlArea: he,
|
|
155
|
+
clearSignalControlArea: Se,
|
|
156
|
+
locateSignalControlArea: Oe,
|
|
157
|
+
highlightSignalControlArea: Ce,
|
|
158
|
+
resetHighlightSignalControlArea: ke
|
|
159
|
+
}), (e, l) => (_e(), He("div", Ee, [
|
|
156
160
|
p("div", {
|
|
157
161
|
class: "gis-viewer-main",
|
|
158
162
|
ref_key: "mapContainer",
|
|
159
163
|
ref: g
|
|
160
164
|
}, [
|
|
161
|
-
|
|
165
|
+
xe(p("div", Fe, [
|
|
162
166
|
p("button", {
|
|
163
167
|
style: { "margin-right": "10px" },
|
|
164
|
-
onClick:
|
|
168
|
+
onClick: b
|
|
165
169
|
}, " 开始记录 "),
|
|
166
|
-
p("button", { onClick:
|
|
170
|
+
p("button", { onClick: M }, "下载日志")
|
|
167
171
|
], 512), [
|
|
168
|
-
[
|
|
172
|
+
[Ve, f.value]
|
|
169
173
|
])
|
|
170
174
|
], 512)
|
|
171
175
|
]));
|
|
172
176
|
}
|
|
173
177
|
});
|
|
174
178
|
export {
|
|
175
|
-
|
|
179
|
+
et as default
|
|
176
180
|
};
|
|
@@ -52,6 +52,8 @@ export declare const GisMap: import("@easyest/utils/dist/lib/withinstall").SFCWi
|
|
|
52
52
|
toggleTrafficObject: (params: import("../types").IToggleTrafficInfoParams) => void;
|
|
53
53
|
toggleVehicleInfo: (contentType: string) => void;
|
|
54
54
|
addOverlays: (params: import("../types").IOverlayParam) => Promise<import("../types").IResult>;
|
|
55
|
+
addMask: (params: import("../types").IMaskParam) => void;
|
|
56
|
+
removeMask: () => void;
|
|
55
57
|
removeOverlaysByType: (types: string[]) => import("../types").IResult;
|
|
56
58
|
removeOverlaysById: (ids: string[]) => import("../types").IResult;
|
|
57
59
|
removeAllOverlays: () => import("../types").IResult;
|
|
@@ -1,10 +1,9 @@
|
|
|
1
|
-
import View from '@arcgis/core/views/View';
|
|
2
1
|
import { IToggleTrafficInfoParams } from '../../../types';
|
|
3
2
|
export default class Index {
|
|
4
3
|
private readonly view;
|
|
5
4
|
private traceHoloFlow;
|
|
6
5
|
private signalHoloFlow;
|
|
7
|
-
constructor(view:
|
|
6
|
+
constructor(view: __esri.MapView | __esri.SceneView);
|
|
8
7
|
init(): Promise<void>;
|
|
9
8
|
/**
|
|
10
9
|
* 处理全息流轨迹数据
|
|
@@ -1,12 +1,14 @@
|
|
|
1
|
-
import { EVehiclePlateState as
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
|
|
1
|
+
import { EVehiclePlateState as a } from "../../../types/index.mjs";
|
|
2
|
+
import i from "../../stores/index.mjs";
|
|
3
|
+
import r from "./signal-holo-flow.mjs";
|
|
4
|
+
import s from "./signal-holo-flow-lsr.mjs";
|
|
5
|
+
import n from "./trace-holo-flow.mjs";
|
|
6
|
+
class p {
|
|
5
7
|
constructor(e) {
|
|
6
8
|
this.view = e;
|
|
7
9
|
}
|
|
8
10
|
async init() {
|
|
9
|
-
this.traceHoloFlow = new
|
|
11
|
+
this.traceHoloFlow = new n(this.view), await this.traceHoloFlow.init();
|
|
10
12
|
}
|
|
11
13
|
/**
|
|
12
14
|
* 处理全息流轨迹数据
|
|
@@ -37,25 +39,30 @@ class n {
|
|
|
37
39
|
this.traceHoloFlow.togglePause(e);
|
|
38
40
|
}
|
|
39
41
|
updatePanelContent(e) {
|
|
40
|
-
let o =
|
|
42
|
+
let o = a.None;
|
|
41
43
|
switch (e) {
|
|
42
44
|
case "none":
|
|
43
|
-
o =
|
|
45
|
+
o = a.None;
|
|
44
46
|
break;
|
|
45
47
|
case "plateNumber":
|
|
46
|
-
o =
|
|
48
|
+
o = a.PlateNumber;
|
|
47
49
|
break;
|
|
48
50
|
case "vehicleId":
|
|
49
|
-
o =
|
|
51
|
+
o = a.Id;
|
|
50
52
|
break;
|
|
51
53
|
case "mix":
|
|
52
|
-
o =
|
|
54
|
+
o = a.Mix;
|
|
53
55
|
break;
|
|
54
56
|
}
|
|
55
57
|
this.traceHoloFlow.updatePanelContent(o);
|
|
56
58
|
}
|
|
57
59
|
async handleSignalData(e) {
|
|
58
|
-
|
|
60
|
+
var o, l;
|
|
61
|
+
if (!this.signalHoloFlow) {
|
|
62
|
+
const t = i.useAppDataStore;
|
|
63
|
+
((l = (o = JSON.parse(JSON.stringify(t.mapConfig)).holoFlow) == null ? void 0 : o.signal) == null ? void 0 : l.style) === "LSR" ? this.signalHoloFlow = new s(this.view) : this.signalHoloFlow = new r(this.view), await this.signalHoloFlow.initializeLayer();
|
|
64
|
+
}
|
|
65
|
+
await this.signalHoloFlow.handleSignalData(e);
|
|
59
66
|
}
|
|
60
67
|
clearHoloSignal() {
|
|
61
68
|
var e;
|
|
@@ -69,5 +76,5 @@ class n {
|
|
|
69
76
|
}
|
|
70
77
|
}
|
|
71
78
|
export {
|
|
72
|
-
|
|
79
|
+
p as default
|
|
73
80
|
};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import SignalHoloFlow from './signal-holo-flow';
|
|
2
|
+
export default class LSRSignalHoloFlow extends SignalHoloFlow {
|
|
3
|
+
private stopLineLayer;
|
|
4
|
+
constructor(view: __esri.MapView | __esri.SceneView);
|
|
5
|
+
private stopLineMap;
|
|
6
|
+
initializeLayer(): Promise<void>;
|
|
7
|
+
handleSignalData(data: any): Promise<void>;
|
|
8
|
+
clearSignal(): void;
|
|
9
|
+
}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import c from "@arcgis/core/Graphic";
|
|
2
|
+
import h from "@arcgis/core/layers/GraphicsLayer";
|
|
3
|
+
import d from "./signal-holo-flow.mjs";
|
|
4
|
+
class f extends d {
|
|
5
|
+
constructor(e) {
|
|
6
|
+
super(e), this.stopLineLayer = new h(), this.stopLineMap = /* @__PURE__ */ new Map(), this.view.map.add(this.stopLineLayer);
|
|
7
|
+
}
|
|
8
|
+
async initializeLayer() {
|
|
9
|
+
var s, a;
|
|
10
|
+
console.time("初始化停止线图层");
|
|
11
|
+
let e = (a = (s = this.mapConfig.holoFlow) == null ? void 0 : s.signal) == null ? void 0 : a.stopLineLayer;
|
|
12
|
+
if (!e)
|
|
13
|
+
return;
|
|
14
|
+
e = this.mapConfig.assetsRoot + "/" + e;
|
|
15
|
+
const o = await (await fetch(e)).json();
|
|
16
|
+
console.log(o.features.length), o.features.forEach((t) => {
|
|
17
|
+
const { roadId: n, nodeId: r } = t.properties, { coordinates: p } = t.geometry, l = this.stopLineMap.get(r);
|
|
18
|
+
l ? l.set(n, p) : this.stopLineMap.set(r, /* @__PURE__ */ new Map([[n, p]]));
|
|
19
|
+
}), console.timeEnd("初始化停止线图层"), console.log(this.stopLineMap.size);
|
|
20
|
+
}
|
|
21
|
+
async handleSignalData(e) {
|
|
22
|
+
const { crossId: i } = e, o = this.stopLineMap.get(i);
|
|
23
|
+
o && o.forEach((s, a) => {
|
|
24
|
+
const t = new c({
|
|
25
|
+
geometry: {
|
|
26
|
+
type: "polyline",
|
|
27
|
+
paths: [s]
|
|
28
|
+
},
|
|
29
|
+
symbol: {
|
|
30
|
+
type: "simple-line",
|
|
31
|
+
color: [255, 0, 0],
|
|
32
|
+
width: 4
|
|
33
|
+
}
|
|
34
|
+
});
|
|
35
|
+
this.stopLineLayer.add(t);
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
clearSignal() {
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
export {
|
|
42
|
+
f as default
|
|
43
|
+
};
|
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
import View from '@arcgis/core/views/View';
|
|
2
1
|
export default class SignalHoloFlow {
|
|
3
|
-
|
|
4
|
-
|
|
2
|
+
protected view: __esri.MapView | __esri.SceneView;
|
|
3
|
+
protected mapConfig: any;
|
|
5
4
|
/** 显示停止线的图层 */
|
|
6
5
|
private phaseLineLayer;
|
|
7
6
|
/** 每个路口的当前相位 */
|
|
@@ -11,7 +10,7 @@ export default class SignalHoloFlow {
|
|
|
11
10
|
private countdownWatchHandel;
|
|
12
11
|
private plateBackground;
|
|
13
12
|
private lastDataTime;
|
|
14
|
-
constructor(view:
|
|
13
|
+
constructor(view: __esri.MapView | __esri.SceneView);
|
|
15
14
|
/**
|
|
16
15
|
* 初始化相位线图层
|
|
17
16
|
* */
|
|
@@ -3,16 +3,17 @@ import * as j from "@arcgis/core/core/promiseUtils";
|
|
|
3
3
|
import { Polygon as N } from "@arcgis/core/geometry";
|
|
4
4
|
import * as L from "@arcgis/core/geometry/geometryEngine";
|
|
5
5
|
import k from "@arcgis/core/layers/FeatureLayer";
|
|
6
|
-
import
|
|
6
|
+
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
|
|
10
|
+
import { XMLParser as x } from "fast-xml-parser";
|
|
11
|
+
import F from "md5";
|
|
11
12
|
import O from "pako";
|
|
12
|
-
import { watch as
|
|
13
|
+
import { watch as P } from "vue";
|
|
13
14
|
import J from "../../stores/index.mjs";
|
|
14
|
-
import
|
|
15
|
-
class
|
|
15
|
+
import E from "../common-utils.mjs";
|
|
16
|
+
class M {
|
|
16
17
|
constructor(e) {
|
|
17
18
|
this.junctionNames = /* @__PURE__ */ new Map(), this.projectName = "", this.openDriveServer = "", this.currentSectionCode = "", this.selectedSectionIds = [], this.currentJunctionId = "", this.view = e, this.laneLayer = new k({
|
|
18
19
|
id: "OpenDriveLane",
|
|
@@ -287,7 +288,7 @@ class F {
|
|
|
287
288
|
}
|
|
288
289
|
}
|
|
289
290
|
]
|
|
290
|
-
}), this.junctionLayer = new
|
|
291
|
+
}), this.junctionLayer = new I({ id: "OpenDriveJunction" }), this.sectionLayer = new I({ id: "OpenDriveSection" }), this.highlightLayer = new I({ id: "OpenDriveHighlight" }), this.flashLayer = new I({ id: "OpenDriveFlash" }), this.drawLayer = new I({ id: "Draw" }), this.splitLaneLayer = new I({ id: "SplitLane" }), this.borderLayer = new I({ id: "OpenDriveBorder" }), this.view.map.addMany([
|
|
291
292
|
this.laneLayer,
|
|
292
293
|
this.junctionLayer,
|
|
293
294
|
this.sectionLayer,
|
|
@@ -295,18 +296,23 @@ class F {
|
|
|
295
296
|
this.highlightLayer,
|
|
296
297
|
this.flashLayer,
|
|
297
298
|
this.drawLayer,
|
|
298
|
-
this.splitLaneLayer
|
|
299
|
+
this.splitLaneLayer,
|
|
300
|
+
this.borderLayer
|
|
299
301
|
]);
|
|
300
302
|
}
|
|
301
303
|
static getInstance(e) {
|
|
302
|
-
return this.instance || (this.instance = new
|
|
304
|
+
return this.instance || (this.instance = new M(e)), this.instance;
|
|
303
305
|
}
|
|
304
306
|
async makeMd5FromFile(e) {
|
|
307
|
+
var t;
|
|
305
308
|
try {
|
|
306
|
-
const
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
309
|
+
const r = await (await fetch(e)).text(), n = (t = new x({
|
|
310
|
+
ignoreAttributes: !1,
|
|
311
|
+
allowBooleanAttributes: !0
|
|
312
|
+
}).parse(r).OpenDRIVE.userData) == null ? void 0 : t.border;
|
|
313
|
+
return { status: 0, message: "ok", result: { md5: F(r), border: n } };
|
|
314
|
+
} catch (i) {
|
|
315
|
+
return { status: -1, message: i.message };
|
|
310
316
|
}
|
|
311
317
|
}
|
|
312
318
|
/**
|
|
@@ -320,7 +326,7 @@ class F {
|
|
|
320
326
|
const t = await this.makeMd5FromFile(e.file);
|
|
321
327
|
if (t.status !== 0)
|
|
322
328
|
return t;
|
|
323
|
-
this.projectName = t.result, console.timeEnd("md5用时"), this.openDriveServer = e.server
|
|
329
|
+
this.projectName = t.result.md5, console.timeEnd("md5用时"), console.log(t.result.border), this.openDriveServer = e.server;
|
|
324
330
|
const i = `http://${this.openDriveServer}/api/openDrive/uploadXodr`;
|
|
325
331
|
let r;
|
|
326
332
|
try {
|
|
@@ -341,7 +347,7 @@ class F {
|
|
|
341
347
|
return { status: -1, message: r.statusText };
|
|
342
348
|
console.time("渲染用时");
|
|
343
349
|
const s = r.data.result.geoSetting;
|
|
344
|
-
|
|
350
|
+
E.setGeoData(
|
|
345
351
|
s.geoReference,
|
|
346
352
|
s.offsetX,
|
|
347
353
|
s.offsetY
|
|
@@ -357,7 +363,7 @@ class F {
|
|
|
357
363
|
const d = r.data.result.junctions;
|
|
358
364
|
this.showJunction(d), e.options && e.options.centerMap !== !1 && await this.view.goTo(this.allLaneGraphics), this.mouseMoveHandler || this.monitorMouseMove(), this.mouseClickHandler || this.monitorMouseClick();
|
|
359
365
|
const h = J.useAppDataStore;
|
|
360
|
-
return
|
|
366
|
+
return P(
|
|
361
367
|
() => h.isSketching,
|
|
362
368
|
() => {
|
|
363
369
|
var m, f;
|
|
@@ -426,8 +432,8 @@ class F {
|
|
|
426
432
|
const w = Number(u.id);
|
|
427
433
|
if (w === 0)
|
|
428
434
|
continue;
|
|
429
|
-
const
|
|
430
|
-
|
|
435
|
+
const v = u.type, $ = [...u.outerPath], S = u.innerPath.concat(
|
|
436
|
+
$.reverse()
|
|
431
437
|
);
|
|
432
438
|
if (S.length <= 3) {
|
|
433
439
|
console.warn(`lane ${w} has less than 3 points`);
|
|
@@ -450,7 +456,7 @@ class F {
|
|
|
450
456
|
sectionId: String(f),
|
|
451
457
|
sectionIndex: p,
|
|
452
458
|
laneId: w,
|
|
453
|
-
type:
|
|
459
|
+
type: v,
|
|
454
460
|
sumoId: "",
|
|
455
461
|
// 记录左右边线的起始点,用于按长度高亮车道的一部分
|
|
456
462
|
leftLine: u.innerPath,
|
|
@@ -1021,11 +1027,11 @@ class F {
|
|
|
1021
1027
|
const r = Number(i[1]), s = i[0].split("#"), c = s.length === 2 ? Number(s[1]) : 0;
|
|
1022
1028
|
let n = s[0];
|
|
1023
1029
|
n.startsWith("-") && (n = n.slice(1));
|
|
1024
|
-
const a = this.allLaneGraphics.filter((
|
|
1030
|
+
const a = this.allLaneGraphics.filter((v) => v.getAttribute("roadId") === n && v.getAttribute("sectionIndex") === c);
|
|
1025
1031
|
if (a.length === 0)
|
|
1026
1032
|
return { status: -1, message: "未找到路段" };
|
|
1027
1033
|
const o = a.length - r, l = a.find(
|
|
1028
|
-
(
|
|
1034
|
+
(v) => Math.abs(v.getAttribute("laneId")) === o
|
|
1029
1035
|
);
|
|
1030
1036
|
if (!l)
|
|
1031
1037
|
return { status: -1, message: "未找到车道" };
|
|
@@ -1071,5 +1077,5 @@ class F {
|
|
|
1071
1077
|
}
|
|
1072
1078
|
}
|
|
1073
1079
|
export {
|
|
1074
|
-
|
|
1080
|
+
M as default
|
|
1075
1081
|
};
|
|
@@ -2,7 +2,7 @@ import Graphic from '@arcgis/core/Graphic';
|
|
|
2
2
|
import GraphicsLayer from '@arcgis/core/layers/GraphicsLayer';
|
|
3
3
|
import MapView from '@arcgis/core/views/MapView';
|
|
4
4
|
import SceneView from '@arcgis/core/views/SceneView';
|
|
5
|
-
import { IOverlay, IOverlayParam, IPointSymbol, IResult } from '../../types';
|
|
5
|
+
import { IMaskParam, IOverlay, IOverlayParam, IPointSymbol, IResult } from '../../types';
|
|
6
6
|
interface IOverlayOptions {
|
|
7
7
|
id: string;
|
|
8
8
|
}
|
|
@@ -11,6 +11,8 @@ export default class Overlay {
|
|
|
11
11
|
overlayLayer: GraphicsLayer;
|
|
12
12
|
constructor(view: MapView | SceneView, options?: IOverlayOptions);
|
|
13
13
|
private defaultPointSymbol;
|
|
14
|
+
addMask(params: IMaskParam): void;
|
|
15
|
+
removeMask(): void;
|
|
14
16
|
/**
|
|
15
17
|
* 添加覆盖物
|
|
16
18
|
* @param params
|
|
@@ -1,30 +1,62 @@
|
|
|
1
|
-
import
|
|
2
|
-
import l from "@arcgis/core/
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
import { Polygon as n } from "@arcgis/core/geometry";
|
|
2
|
+
import * as l from "@arcgis/core/geometry/geometryEngine";
|
|
3
|
+
import y from "@arcgis/core/Graphic";
|
|
4
|
+
import h from "@arcgis/core/layers/GraphicsLayer";
|
|
5
|
+
class u {
|
|
6
|
+
constructor(e, s) {
|
|
5
7
|
this.defaultPointSymbol = {
|
|
6
8
|
type: "simple-marker",
|
|
7
9
|
style: "circle",
|
|
8
10
|
color: "yellow",
|
|
9
11
|
size: 10
|
|
10
|
-
}, this.view =
|
|
12
|
+
}, this.view = e, this.overlayLayer = new h({
|
|
11
13
|
...s
|
|
12
14
|
}), this.view.map.layers.add(this.overlayLayer);
|
|
13
15
|
}
|
|
16
|
+
addMask(e) {
|
|
17
|
+
this.removeMask();
|
|
18
|
+
const s = e.maskColor || [100, 100, 100, 0.8], i = e.maskSize || 100, r = new n({
|
|
19
|
+
rings: e.geometry.rings
|
|
20
|
+
}), t = r.centroid, a = l.geodesicBuffer(
|
|
21
|
+
t,
|
|
22
|
+
i,
|
|
23
|
+
"kilometers"
|
|
24
|
+
), o = l.difference(
|
|
25
|
+
a,
|
|
26
|
+
r
|
|
27
|
+
), d = new y({
|
|
28
|
+
geometry: o,
|
|
29
|
+
symbol: {
|
|
30
|
+
type: "simple-fill",
|
|
31
|
+
color: s,
|
|
32
|
+
outline: {
|
|
33
|
+
style: "none"
|
|
34
|
+
}
|
|
35
|
+
},
|
|
36
|
+
attributes: { type: "mask" }
|
|
37
|
+
});
|
|
38
|
+
this.overlayLayer.add(d);
|
|
39
|
+
}
|
|
40
|
+
removeMask() {
|
|
41
|
+
const e = this.overlayLayer.graphics.find(
|
|
42
|
+
(s) => s.getAttribute("type") === "mask"
|
|
43
|
+
);
|
|
44
|
+
e && this.overlayLayer.remove(e);
|
|
45
|
+
}
|
|
14
46
|
/**
|
|
15
47
|
* 添加覆盖物
|
|
16
48
|
* @param params
|
|
17
49
|
*/
|
|
18
|
-
addOverlays(
|
|
50
|
+
addOverlays(e) {
|
|
19
51
|
let s = 0, i = 0;
|
|
20
|
-
for (const
|
|
21
|
-
|
|
22
|
-
const t =
|
|
52
|
+
for (const r of e.overlays) {
|
|
53
|
+
r.properties ? (r.properties.type || (r.properties.type = e.type), r.properties.id || (r.properties.id = r.id)) : r.properties = { type: e.type, id: r.id };
|
|
54
|
+
const t = r.symbol || e.defaultSymbol || this.defaultPointSymbol;
|
|
23
55
|
this.addOverlay(
|
|
24
|
-
|
|
56
|
+
r,
|
|
25
57
|
t,
|
|
26
|
-
|
|
27
|
-
|
|
58
|
+
r.properties,
|
|
59
|
+
r.visible
|
|
28
60
|
).message === "add" ? s++ : i++;
|
|
29
61
|
}
|
|
30
62
|
return { status: 0, message: `新增${s}, 更新${i}` };
|
|
@@ -33,10 +65,10 @@ class v {
|
|
|
33
65
|
* 按type移除覆盖物
|
|
34
66
|
* @param types
|
|
35
67
|
*/
|
|
36
|
-
removeOverlaysByType(
|
|
68
|
+
removeOverlaysByType(e) {
|
|
37
69
|
const s = this.overlayLayer.graphics.filter((i) => {
|
|
38
|
-
const
|
|
39
|
-
return
|
|
70
|
+
const r = i.getAttribute("type");
|
|
71
|
+
return e.includes(r);
|
|
40
72
|
});
|
|
41
73
|
return this.overlayLayer.graphics.removeMany(s), { status: 0, message: `删除${s.length}` };
|
|
42
74
|
}
|
|
@@ -44,10 +76,10 @@ class v {
|
|
|
44
76
|
* 按id移除覆盖物
|
|
45
77
|
* @param ids
|
|
46
78
|
*/
|
|
47
|
-
removeOverlaysById(
|
|
79
|
+
removeOverlaysById(e) {
|
|
48
80
|
const s = this.overlayLayer.graphics.filter((i) => {
|
|
49
|
-
const
|
|
50
|
-
return
|
|
81
|
+
const r = i.getAttribute("id");
|
|
82
|
+
return e.includes(r);
|
|
51
83
|
});
|
|
52
84
|
return this.overlayLayer.graphics.removeMany(s), { status: 0, message: `删除${s.length}` };
|
|
53
85
|
}
|
|
@@ -56,10 +88,10 @@ class v {
|
|
|
56
88
|
* @param ids
|
|
57
89
|
* @param isShow
|
|
58
90
|
*/
|
|
59
|
-
isShowOverlaysByIds(
|
|
91
|
+
isShowOverlaysByIds(e, s) {
|
|
60
92
|
this.overlayLayer.graphics.map((i) => {
|
|
61
|
-
const
|
|
62
|
-
|
|
93
|
+
const r = i.getAttribute("id");
|
|
94
|
+
e.includes(r) ? i.visible = s : i.visible = !s;
|
|
63
95
|
});
|
|
64
96
|
}
|
|
65
97
|
/**
|
|
@@ -68,8 +100,8 @@ class v {
|
|
|
68
100
|
* @memberof Overlay
|
|
69
101
|
*/
|
|
70
102
|
showAllOverlays() {
|
|
71
|
-
this.overlayLayer.graphics.forEach((
|
|
72
|
-
|
|
103
|
+
this.overlayLayer.graphics.forEach((e) => {
|
|
104
|
+
e.visible = !0;
|
|
73
105
|
});
|
|
74
106
|
}
|
|
75
107
|
/**
|
|
@@ -77,8 +109,8 @@ class v {
|
|
|
77
109
|
* @returns
|
|
78
110
|
*/
|
|
79
111
|
removeAllOverlays() {
|
|
80
|
-
const
|
|
81
|
-
return this.overlayLayer.removeAll(), { status: 0, message: `删除${
|
|
112
|
+
const e = this.overlayLayer.graphics.length;
|
|
113
|
+
return this.overlayLayer.removeAll(), { status: 0, message: `删除${e}` };
|
|
82
114
|
}
|
|
83
115
|
/**
|
|
84
116
|
* 销毁
|
|
@@ -88,8 +120,8 @@ class v {
|
|
|
88
120
|
destroy() {
|
|
89
121
|
this.view.map.remove(this.overlayLayer), this.overlayLayer.destroy();
|
|
90
122
|
}
|
|
91
|
-
removeGraphics(
|
|
92
|
-
Array.isArray(
|
|
123
|
+
removeGraphics(e) {
|
|
124
|
+
Array.isArray(e) || (e = [e]), this.overlayLayer.graphics.removeMany(e);
|
|
93
125
|
}
|
|
94
126
|
/**
|
|
95
127
|
* 查找当前点击是否有覆盖物在当前图层
|
|
@@ -99,9 +131,9 @@ class v {
|
|
|
99
131
|
* @returns
|
|
100
132
|
* @memberof Overlay
|
|
101
133
|
*/
|
|
102
|
-
async findGraphic(
|
|
103
|
-
var
|
|
104
|
-
return (
|
|
134
|
+
async findGraphic(e) {
|
|
135
|
+
var r;
|
|
136
|
+
return (r = (await this.view.hitTest(e)).results) == null ? void 0 : r.filter(
|
|
105
137
|
(t) => t.type === "graphic" && t.graphic.layer === this.overlayLayer
|
|
106
138
|
);
|
|
107
139
|
}
|
|
@@ -127,23 +159,23 @@ class v {
|
|
|
127
159
|
* @param symbol
|
|
128
160
|
* @param properties
|
|
129
161
|
*/
|
|
130
|
-
addPoint(
|
|
162
|
+
addPoint(e, s, i, r) {
|
|
131
163
|
let t, a = !0;
|
|
132
|
-
return
|
|
133
|
-
(
|
|
134
|
-
)), t ? t.visible =
|
|
135
|
-
visible:
|
|
136
|
-
}), this.overlayLayer.add(t), a = !1), t.geometry =
|
|
164
|
+
return e.id && (t = this.overlayLayer.graphics.find(
|
|
165
|
+
(o) => o.getAttribute("id") === e.id
|
|
166
|
+
)), t ? t.visible = r ?? t.visible : (r = r ?? !0, t = new y({
|
|
167
|
+
visible: r
|
|
168
|
+
}), this.overlayLayer.add(t), a = !1), t.geometry = e.geometry, t.symbol = s, t.attributes = i, { status: 0, message: a ? "add" : "update" };
|
|
137
169
|
}
|
|
138
|
-
addOverlay(
|
|
170
|
+
addOverlay(e, s, i, r) {
|
|
139
171
|
let t, a = !0;
|
|
140
|
-
return
|
|
141
|
-
(
|
|
142
|
-
)), t ? t.visible =
|
|
143
|
-
visible:
|
|
144
|
-
}), this.overlayLayer.add(t), a = !1), t.geometry =
|
|
172
|
+
return e.id && (t = this.overlayLayer.graphics.find(
|
|
173
|
+
(o) => o.getAttribute("id") === e.id
|
|
174
|
+
)), t ? t.visible = r ?? t.visible : (r = r ?? !0, t = new y({
|
|
175
|
+
visible: r
|
|
176
|
+
}), this.overlayLayer.add(t), a = !1), t.geometry = e.geometry, t.symbol = s, t.attributes = i, { status: 0, message: a ? "add" : "update" };
|
|
145
177
|
}
|
|
146
178
|
}
|
|
147
179
|
export {
|
|
148
|
-
|
|
180
|
+
u as default
|
|
149
181
|
};
|
package/es/src/types/index.d.ts
CHANGED
|
@@ -129,6 +129,11 @@ export interface IOverlay {
|
|
|
129
129
|
symbol?: IPointSymbol | ILineSymbol | IPolygonSymbol;
|
|
130
130
|
properties?: any;
|
|
131
131
|
}
|
|
132
|
+
export interface IMaskParam {
|
|
133
|
+
geometry: IPolygon;
|
|
134
|
+
maskColor?: number[];
|
|
135
|
+
maskSize?: number;
|
|
136
|
+
}
|
|
132
137
|
export interface IOverlayParam {
|
|
133
138
|
type?: string;
|
|
134
139
|
defaultSymbol?: IPointSymbol | ILineSymbol | IPolygonSymbol;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import MapView from '@arcgis/core/views/MapView';
|
|
2
2
|
import SceneView from '@arcgis/core/views/SceneView';
|
|
3
|
-
import { IFindSumoParams, ILaneNumberParams, ILayerVisibleParams, ILookAtParams, IOverlayParam, IQueueLengthParams, ISetMapCameraParams, ISetMapCenterParams, IShowOpenDriveFromFileParams, ISplitOpenDriveLaneParams, IStartCrossBufferParam, IToggleTrafficInfoParams, IUnselectSumoParams } from '../types';
|
|
3
|
+
import { IFindSumoParams, ILaneNumberParams, ILayerVisibleParams, ILookAtParams, IMaskParam, IOverlayParam, IQueueLengthParams, ISetMapCameraParams, ISetMapCenterParams, IShowOpenDriveFromFileParams, ISplitOpenDriveLaneParams, IStartCrossBufferParam, IToggleTrafficInfoParams, IUnselectSumoParams } from '../types';
|
|
4
4
|
import HoloFlow from './utils/holo-flow';
|
|
5
5
|
import MapInitializer from './utils/map-initializer';
|
|
6
6
|
import OpenDriveRenderer from './utils/open-drive-renderer';
|
|
@@ -63,6 +63,8 @@ declare const _sfc_main: import("vue").DefineComponent<{
|
|
|
63
63
|
toggleTrafficObject: (params: IToggleTrafficInfoParams) => void;
|
|
64
64
|
toggleVehicleInfo: (contentType: string) => void;
|
|
65
65
|
addOverlays: (params: IOverlayParam) => Promise<import("../types").IResult>;
|
|
66
|
+
addMask: (params: IMaskParam) => void;
|
|
67
|
+
removeMask: () => void;
|
|
66
68
|
removeOverlaysByType: (types: string[]) => import("../types").IResult;
|
|
67
69
|
removeOverlaysById: (ids: string[]) => import("../types").IResult;
|
|
68
70
|
removeAllOverlays: () => import("../types").IResult;
|
|
@@ -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
|
|
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;
|
|
@@ -52,6 +52,8 @@ export declare const GisMap: import("@easyest/utils/dist/lib/withinstall").SFCWi
|
|
|
52
52
|
toggleTrafficObject: (params: import("../types").IToggleTrafficInfoParams) => void;
|
|
53
53
|
toggleVehicleInfo: (contentType: string) => void;
|
|
54
54
|
addOverlays: (params: import("../types").IOverlayParam) => Promise<import("../types").IResult>;
|
|
55
|
+
addMask: (params: import("../types").IMaskParam) => void;
|
|
56
|
+
removeMask: () => void;
|
|
55
57
|
removeOverlaysByType: (types: string[]) => import("../types").IResult;
|
|
56
58
|
removeOverlaysById: (ids: string[]) => import("../types").IResult;
|
|
57
59
|
removeAllOverlays: () => import("../types").IResult;
|
|
@@ -1,10 +1,9 @@
|
|
|
1
|
-
import View from '@arcgis/core/views/View';
|
|
2
1
|
import { IToggleTrafficInfoParams } from '../../../types';
|
|
3
2
|
export default class Index {
|
|
4
3
|
private readonly view;
|
|
5
4
|
private traceHoloFlow;
|
|
6
5
|
private signalHoloFlow;
|
|
7
|
-
constructor(view:
|
|
6
|
+
constructor(view: __esri.MapView | __esri.SceneView);
|
|
8
7
|
init(): Promise<void>;
|
|
9
8
|
/**
|
|
10
9
|
* 处理全息流轨迹数据
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const t=require("../../../types/index.js"),
|
|
1
|
+
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const t=require("../../../types/index.js"),i=require("../../stores/index.js"),s=require("./signal-holo-flow.js"),n=require("./signal-holo-flow-lsr.js"),c=require("./trace-holo-flow.js");class r{constructor(e){this.view=e}async init(){this.traceHoloFlow=new c.default(this.view),await this.traceHoloFlow.init()}handleVehicleTraceData(e){this.traceHoloFlow.handleVehicleTraceData(e)}toggleTrafficObject(e){switch(e.name.toLowerCase()){case"groundVehicle".toLowerCase():this.traceHoloFlow.toggleGroundVehicle(e.visible);break;case"elevatedVehicle".toLowerCase():this.traceHoloFlow.toggleElevatedVehicle(e.visible);break}}clearHoloTrace(){this.traceHoloFlow.clearTrace()}toggleTrafficInfo(e){this.traceHoloFlow.toggleTrafficInfo(e)}togglePause(e){this.traceHoloFlow.togglePause(e)}updatePanelContent(e){let o=t.EVehiclePlateState.None;switch(e){case"none":o=t.EVehiclePlateState.None;break;case"plateNumber":o=t.EVehiclePlateState.PlateNumber;break;case"vehicleId":o=t.EVehiclePlateState.Id;break;case"mix":o=t.EVehiclePlateState.Mix;break}this.traceHoloFlow.updatePanelContent(o)}async handleSignalData(e){var o,l;if(!this.signalHoloFlow){const a=i.default.useAppDataStore;((l=(o=JSON.parse(JSON.stringify(a.mapConfig)).holoFlow)==null?void 0:o.signal)==null?void 0:l.style)==="LSR"?this.signalHoloFlow=new n.default(this.view):this.signalHoloFlow=new s.default(this.view),await this.signalHoloFlow.initializeLayer()}await this.signalHoloFlow.handleSignalData(e)}clearHoloSignal(){var e;(e=this.signalHoloFlow)==null||e.clearSignal()}setInterpolate(e){this.traceHoloFlow.setInterpolate(e)}downloadTrackLog(){this.traceHoloFlow.downloadLog()}}exports.default=r;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import SignalHoloFlow from './signal-holo-flow';
|
|
2
|
+
export default class LSRSignalHoloFlow extends SignalHoloFlow {
|
|
3
|
+
private stopLineLayer;
|
|
4
|
+
constructor(view: __esri.MapView | __esri.SceneView);
|
|
5
|
+
private stopLineMap;
|
|
6
|
+
initializeLayer(): Promise<void>;
|
|
7
|
+
handleSignalData(data: any): Promise<void>;
|
|
8
|
+
clearSignal(): void;
|
|
9
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const c=require("@arcgis/core/Graphic"),d=require("@arcgis/core/layers/GraphicsLayer"),h=require("./signal-holo-flow.js");class y extends h.default{constructor(e){super(e),this.stopLineLayer=new d,this.stopLineMap=new Map,this.view.map.add(this.stopLineLayer)}async initializeLayer(){var s,i;console.time("初始化停止线图层");let e=(i=(s=this.mapConfig.holoFlow)==null?void 0:s.signal)==null?void 0:i.stopLineLayer;if(!e)return;e=this.mapConfig.assetsRoot+"/"+e;const o=await(await fetch(e)).json();console.log(o.features.length),o.features.forEach(t=>{const{roadId:n,nodeId:r}=t.properties,{coordinates:l}=t.geometry,p=this.stopLineMap.get(r);p?p.set(n,l):this.stopLineMap.set(r,new Map([[n,l]]))}),console.timeEnd("初始化停止线图层"),console.log(this.stopLineMap.size)}async handleSignalData(e){const{crossId:a}=e,o=this.stopLineMap.get(a);o&&o.forEach((s,i)=>{const t=new c({geometry:{type:"polyline",paths:[s]},symbol:{type:"simple-line",color:[255,0,0],width:4}});this.stopLineLayer.add(t)})}clearSignal(){}}exports.default=y;
|
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
import View from '@arcgis/core/views/View';
|
|
2
1
|
export default class SignalHoloFlow {
|
|
3
|
-
|
|
4
|
-
|
|
2
|
+
protected view: __esri.MapView | __esri.SceneView;
|
|
3
|
+
protected mapConfig: any;
|
|
5
4
|
/** 显示停止线的图层 */
|
|
6
5
|
private phaseLineLayer;
|
|
7
6
|
/** 每个路口的当前相位 */
|
|
@@ -11,7 +10,7 @@ export default class SignalHoloFlow {
|
|
|
11
10
|
private countdownWatchHandel;
|
|
12
11
|
private plateBackground;
|
|
13
12
|
private lastDataTime;
|
|
14
|
-
constructor(view:
|
|
13
|
+
constructor(view: __esri.MapView | __esri.SceneView);
|
|
15
14
|
/**
|
|
16
15
|
* 初始化相位线图层
|
|
17
16
|
* */
|
|
@@ -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"),A=require("@arcgis/core/geometry"),J=require("@arcgis/core/geometry/geometryEngine"),C=require("@arcgis/core/layers/FeatureLayer"),I=require("@arcgis/core/layers/GraphicsLayer"),q=require("@turf/helpers"),O=require("@turf/line-slice-along"),b=require("axios"),E=require("md5"),M=require("pako"),T=require("vue"),H=require("../../stores/index.js"),R=require("../common-utils.js");function j(L){const e=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(L){for(const t in L)if(t!=="default"){const i=Object.getOwnPropertyDescriptor(L,t);Object.defineProperty(e,t,i.get?i:{enumerable:!0,get:()=>L[t]})}}return e.default=L,Object.freeze(e)}const F=j(P),S=j(J),$=j(q);class D{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 I({id:"OpenDriveJunction"}),this.sectionLayer=new I({id:"OpenDriveSection"}),this.highlightLayer=new I({id:"OpenDriveHighlight"}),this.flashLayer=new I({id:"OpenDriveFlash"}),this.drawLayer=new I({id:"Draw"}),this.splitLaneLayer=new I({id:"SplitLane"}),this.view.map.addMany([this.laneLayer,this.junctionLayer,this.sectionLayer,this.roadNameLayer,this.highlightLayer,this.flashLayer,this.drawLayer,this.splitLaneLayer])}static getInstance(e){return this.instance||(this.instance=new D(e)),this.instance}async makeMd5FromFile(e){try{const i=await(await fetch(e)).text();return{status:0,message:"ok",result:E(i)}}catch(t){return{status:-1,message:t.message}}}async showOpenDriveFromFile(e){var m,p;this.openDriveClickCallback=e.selectedCallback,console.time("md5用时");const t=await this.makeMd5FromFile(e.file);if(t.status!==0)return t;this.projectName=t.result,console.timeEnd("md5用时"),this.openDriveServer=e.server,await this.makeMd5FromFile(e.file);const i=`http://${this.openDriveServer}/api/openDrive/uploadXodr`;let n;try{n=await b.post(i,{},{params:{url:e.file,projectName:this.projectName}})}catch(g){return{status:-1,message:g.message}}if(n.status!==200)return{status:-1,message:n.statusText};console.time("渲染用时");const s=n.data.result.geoSetting;R.default.setGeoData(s.geoReference,s.offsetX,s.offsetY);let c=n.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=n.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`,n=await b.get(i,{headers:{projectName:t},params:{analyze:!1,compressed:!0}});if(n.status!==200)throw new Error(`OpenDriveRenderer: ${n.statusText}`);let s=n.data.result.json;s.startsWith(window.location.protocol)||(s=`${window.location.protocol}//${e}${s}`);const r=await(await fetch(s)).arrayBuffer(),a=M.inflate(r,{to:"string"}),o=JSON.parse(a);return await this.showAllLanes(o,!1,!1),{status:0,message:"ok"}}async showAllLanes(e,t,i){const n=await this.laneLayer.queryFeatures();return n.features.length>0&&this.laneLayer.applyEdits({deleteFeatures:n.features}),this.roadNameLayer.visible=i,new Promise(s=>{let c=0;this.allLaneGraphics=[],this.allRefLineGraphics=[];const r=[];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 v=u.type,x=[...u.outerPath],N=u.innerPath.concat(x.reverse());if(N.length<=3){console.warn(`lane ${w} has less than 3 points`);continue}N.push(u.innerPath[0]);const k=new A.Polygon({rings:[N]});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:v,sumoId:"",leftLine:u.innerPath,rightLine:u.outerPath}});this.allLaneGraphics.push(G),r.push(G)}}}}const a=setInterval(()=>{if(r.length>0||this.allRefLineGraphics.length>0){if(r.length>0){const o=r.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 n=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(n)}this.junctionLayer.addMany(t)}monitorMouseMove(){const e=F.debounce(async t=>{var c;const n=(c=(await this.view.hitTest(t,{include:[this.laneLayer,this.junctionLayer]})).results)==null?void 0:c.filter(r=>r.type==="graphic");if(n.length===0){this.currentSectionCode!==""&&(this.currentSectionCode="",this.highlightLayer.removeAll()),this.currentJunctionId!==""&&(this.currentJunctionId=""),this.view.closePopup();return}const s=n[0];if(this.hitGraphic=s.graphic,s.layer.id==="OpenDriveLane"){const r=`${this.hitGraphic.getAttribute("roadId")}+${this.hitGraphic.getAttribute("sectionId")}`;if(this.currentSectionCode===r||this.selectedSectionIds.includes(r)||this.sectionLayer.graphics.findIndex(u=>u.getAttribute("id")===r)>=0)return;this.currentSectionCode=r;const o=this.allLaneGraphics.filter(u=>`${u.attributes.roadId}+${u.attributes.sectionId}`===r),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:r,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 r=this.hitGraphic.getAttribute("id");if(r===this.currentJunctionId)return;this.currentJunctionId=r,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=F.debounce(async t=>{var a;const n=(a=(await this.view.hitTest(t,{include:[this.highlightLayer,this.junctionLayer,this.sectionLayer]})).results)==null?void 0:a.filter(o=>o.type==="graphic");if(n.length===0)return;const s=n[0].graphic,c=s.getAttribute("type"),r=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:r,projectName:this.projectName}});l.status===200&&l.data.status===0&&(this.openDriveClickCallback&&this.openDriveClickCallback({type:"OpenDriveJunction",id:r,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:r,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(r);const o=`http://${this.openDriveServer}/api/sumo/getSumoEdge`,l=await b.get(o,{params:{id:r,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!==r),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 n=e.symbol,s=n.width;s<t?e.symbol={type:"picture-marker",url:n.url,width:s+1,height:s+1}:clearInterval(i)},20)}decreasePictureMarkerSize(e,t){const i=setInterval(()=>{const n=e.symbol,s=n.width;s>t?e.symbol={type:"picture-marker",url:n.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 n=0;t.length===2&&(n=Number(t[1]));const s=this.allLaneGraphics.find(c=>c.getAttribute("roadId")===i&&c.getAttribute("sectionIndex")===n);if(s){const c=`${i}+${s.getAttribute("sectionId")}`,r=`http://${this.openDriveServer}/api/sumo/getSumoEdge`,a=await b.get(r,{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,n=e.flash===void 0?!0:e.flash;if(t==="junction")return await this.findJunction(i,n);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,r=s[0].split("#");if(r.length>2)return{status:-1,message:"id格式错误"};const a=r[0],o=r.length===2?Number(r[1]):void 0;return await this.findLane({roadsectId:a,segmentId:o,laneId:c,flash:n})}else return{status:-1,message:"未知类型"}}async findJunction(e,t){const i=this.junctionLayer.graphics.find(n=>n.attributes.id===e);if(!i)return{status:-1,message:"未找到。请检查路口编号"};if(t){const n=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(n)}return await this.view.goTo(i.geometry,{duration:1e3}),{status:0,message:"ok"}}async findLane(e){let{roadsectId:t,segmentId:i,laneId:n}=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(n!==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),n>a.length-1)return{status:-1,message:"未找到。请检查车道编号"};n=a[n],s=s.filter(o=>Number(o.attributes.laneId)===n)}const c=s.map(a=>a.geometry),r=S.union(c);if(e.flash){const a=new y({geometry:r,symbol:{type:"simple-fill",color:[255,0,0,.5],style:"solid",outline:{color:"red",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,i=!0;const n=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(n))},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 n=i.getAttribute("id");this.selectedSectionIds=this.selectedSectionIds.filter(s=>s!==n)}),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 n=0;t.length===2&&(n=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")===n)),s.length>0){const c=new Map;return s.forEach(r=>{const a=r.getAttribute("roadId")+"+"+r.getAttribute("sectionId");this.selectedSectionIds.includes(a)||this.selectedSectionIds.push(a);let o=c.get(a);o?o.push(r.geometry):(o=[r.geometry],c.set(a,o))}),c.forEach((r,a)=>{const o=S.union(r),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 A.Polygon({rings:[e]}),i=await this.laneLayer.queryFeatures({geometry:t,outFields:["*"]}),n=[],s=[];for(const a of i.features){const o=a.getAttribute("roadId"),l=a.getAttribute("sectionIndex"),d=`${o}#${l}`;if(n.indexOf(d)===-1){n.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)}),r=[];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&&r.push(d.data.result)}return{status:0,message:"ok",result:{junctions:r,edges:s}}}async splitLane(e){const i=e.id.split("_");if(i.length!==2)return{status:-1,message:"车道编号格式错误"};const n=Number(i[1]),s=i[0].split("#"),c=s.length===2?Number(s[1]):0;let r=s[0];r.startsWith("-")&&(r=r.slice(1));const a=this.allLaneGraphics.filter(v=>v.getAttribute("roadId")===r&&v.getAttribute("sectionIndex")===c);if(a.length===0)return{status:-1,message:"未找到路段"};const o=a.length-n,l=a.find(v=>Math.abs(v.getAttribute("laneId"))===o);if(!l)return{status:-1,message:"未找到车道"};const d=e.start||0,h=e.end||100,m=$.lineString(l.getAttribute("leftLine")),p=O.lineSliceAlong(m,d,h,{units:"meters"}),g=$.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 A.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=D;
|
|
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;
|
|
@@ -2,7 +2,7 @@ import Graphic from '@arcgis/core/Graphic';
|
|
|
2
2
|
import GraphicsLayer from '@arcgis/core/layers/GraphicsLayer';
|
|
3
3
|
import MapView from '@arcgis/core/views/MapView';
|
|
4
4
|
import SceneView from '@arcgis/core/views/SceneView';
|
|
5
|
-
import { IOverlay, IOverlayParam, IPointSymbol, IResult } from '../../types';
|
|
5
|
+
import { IMaskParam, IOverlay, IOverlayParam, IPointSymbol, IResult } from '../../types';
|
|
6
6
|
interface IOverlayOptions {
|
|
7
7
|
id: string;
|
|
8
8
|
}
|
|
@@ -11,6 +11,8 @@ export default class Overlay {
|
|
|
11
11
|
overlayLayer: GraphicsLayer;
|
|
12
12
|
constructor(view: MapView | SceneView, options?: IOverlayOptions);
|
|
13
13
|
private defaultPointSymbol;
|
|
14
|
+
addMask(params: IMaskParam): void;
|
|
15
|
+
removeMask(): void;
|
|
14
16
|
/**
|
|
15
17
|
* 添加覆盖物
|
|
16
18
|
* @param params
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const l=require("@arcgis/core/Graphic"),
|
|
1
|
+
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const d=require("@arcgis/core/geometry"),u=require("@arcgis/core/geometry/geometryEngine"),l=require("@arcgis/core/Graphic"),h=require("@arcgis/core/layers/GraphicsLayer");function p(o){const e=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(o){for(const r in o)if(r!=="default"){const i=Object.getOwnPropertyDescriptor(o,r);Object.defineProperty(e,r,i.get?i:{enumerable:!0,get:()=>o[r]})}}return e.default=o,Object.freeze(e)}const n=p(u);class v{constructor(e,r){this.defaultPointSymbol={type:"simple-marker",style:"circle",color:"yellow",size:10},this.view=e,this.overlayLayer=new h({...r}),this.view.map.layers.add(this.overlayLayer)}addMask(e){this.removeMask();const r=e.maskColor||[100,100,100,.8],i=e.maskSize||100,t=new d.Polygon({rings:e.geometry.rings}),s=t.centroid,a=n.geodesicBuffer(s,i,"kilometers"),y=n.difference(a,t),c=new l({geometry:y,symbol:{type:"simple-fill",color:r,outline:{style:"none"}},attributes:{type:"mask"}});this.overlayLayer.add(c)}removeMask(){const e=this.overlayLayer.graphics.find(r=>r.getAttribute("type")==="mask");e&&this.overlayLayer.remove(e)}addOverlays(e){let r=0,i=0;for(const t of e.overlays){t.properties?(t.properties.type||(t.properties.type=e.type),t.properties.id||(t.properties.id=t.id)):t.properties={type:e.type,id:t.id};const s=t.symbol||e.defaultSymbol||this.defaultPointSymbol;this.addOverlay(t,s,t.properties,t.visible).message==="add"?r++:i++}return{status:0,message:`新增${r}, 更新${i}`}}removeOverlaysByType(e){const r=this.overlayLayer.graphics.filter(i=>{const t=i.getAttribute("type");return e.includes(t)});return this.overlayLayer.graphics.removeMany(r),{status:0,message:`删除${r.length}`}}removeOverlaysById(e){const r=this.overlayLayer.graphics.filter(i=>{const t=i.getAttribute("id");return e.includes(t)});return this.overlayLayer.graphics.removeMany(r),{status:0,message:`删除${r.length}`}}isShowOverlaysByIds(e,r){this.overlayLayer.graphics.map(i=>{const t=i.getAttribute("id");e.includes(t)?i.visible=r:i.visible=!r})}showAllOverlays(){this.overlayLayer.graphics.forEach(e=>{e.visible=!0})}removeAllOverlays(){const e=this.overlayLayer.graphics.length;return this.overlayLayer.removeAll(),{status:0,message:`删除${e}`}}destroy(){this.view.map.remove(this.overlayLayer),this.overlayLayer.destroy()}removeGraphics(e){Array.isArray(e)||(e=[e]),this.overlayLayer.graphics.removeMany(e)}async findGraphic(e){var t;return(t=(await this.view.hitTest(e)).results)==null?void 0:t.filter(s=>s.type==="graphic"&&s.graphic.layer===this.overlayLayer)}hideLayer(){this.overlayLayer.visible=!1}showLayer(){this.overlayLayer.visible=!0}addPoint(e,r,i,t){let s,a=!0;return e.id&&(s=this.overlayLayer.graphics.find(y=>y.getAttribute("id")===e.id)),s?s.visible=t??s.visible:(t=t??!0,s=new l({visible:t}),this.overlayLayer.add(s),a=!1),s.geometry=e.geometry,s.symbol=r,s.attributes=i,{status:0,message:a?"add":"update"}}addOverlay(e,r,i,t){let s,a=!0;return e.id&&(s=this.overlayLayer.graphics.find(y=>y.getAttribute("id")===e.id)),s?s.visible=t??s.visible:(t=t??!0,s=new l({visible:t}),this.overlayLayer.add(s),a=!1),s.geometry=e.geometry,s.symbol=r,s.attributes=i,{status:0,message:a?"add":"update"}}}exports.default=v;
|
package/lib/src/types/index.d.ts
CHANGED
|
@@ -129,6 +129,11 @@ export interface IOverlay {
|
|
|
129
129
|
symbol?: IPointSymbol | ILineSymbol | IPolygonSymbol;
|
|
130
130
|
properties?: any;
|
|
131
131
|
}
|
|
132
|
+
export interface IMaskParam {
|
|
133
|
+
geometry: IPolygon;
|
|
134
|
+
maskColor?: number[];
|
|
135
|
+
maskSize?: number;
|
|
136
|
+
}
|
|
132
137
|
export interface IOverlayParam {
|
|
133
138
|
type?: string;
|
|
134
139
|
defaultSymbol?: IPointSymbol | ILineSymbol | IPolygonSymbol;
|