gisviewer-vue3-arcgis 1.0.242 → 1.0.244
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/es/src/gis-map/utils/holo-flow/signal-holo-flow-lsr.mjs +135 -135
- package/es/src/gis-map/utils/open-drive-renderer/index.mjs +56 -75
- package/lib/src/gis-map/utils/holo-flow/signal-holo-flow-lsr.js +1 -1
- package/lib/src/gis-map/utils/open-drive-renderer/index.js +1 -1
- package/package.json +1 -1
|
@@ -1,54 +1,54 @@
|
|
|
1
|
-
import * as
|
|
1
|
+
import * as m from "@arcgis/core/core/reactiveUtils";
|
|
2
2
|
import { Point as u } from "@arcgis/core/geometry";
|
|
3
3
|
import * as g from "@arcgis/core/geometry/support/webMercatorUtils.js";
|
|
4
4
|
import L from "@arcgis/core/Graphic";
|
|
5
5
|
import b from "@arcgis/core/layers/GraphicsLayer";
|
|
6
6
|
import M from "./signal-holo-flow.mjs";
|
|
7
7
|
class v extends M {
|
|
8
|
-
constructor(e,
|
|
9
|
-
var
|
|
10
|
-
super(e), this.waitingAreaLayer = new b(), this.watchHandle = null, this.trajectoryDelayTime = 2, this.stopLineMap = /* @__PURE__ */ new Map(), this.waitingAreaMap = /* @__PURE__ */ new Map(), this.lampGroupMap = /* @__PURE__ */ new Map(), this.countdownPanelProps =
|
|
8
|
+
constructor(e, o) {
|
|
9
|
+
var s, n;
|
|
10
|
+
super(e), this.waitingAreaLayer = new b(), this.watchHandle = null, this.trajectoryDelayTime = 2, this.stopLineMap = /* @__PURE__ */ new Map(), this.waitingAreaMap = /* @__PURE__ */ new Map(), this.lampGroupMap = /* @__PURE__ */ new Map(), this.countdownPanelProps = o, this.view.map.add(this.waitingAreaLayer), this.trajectoryDelayTime = (n = (s = this.mapConfig.holoFlow) == null ? void 0 : s.signal) == null ? void 0 : n.delay, this.trajectoryDelayTime === void 0 && (this.trajectoryDelayTime = 2);
|
|
11
11
|
}
|
|
12
12
|
/**
|
|
13
13
|
* 读取停止线图层,将灯组面板沿着停止线放置
|
|
14
14
|
* @returns
|
|
15
15
|
*/
|
|
16
16
|
async initializeLayer() {
|
|
17
|
-
var
|
|
17
|
+
var n, a, i, r, t;
|
|
18
18
|
if (this.stopLineMap.size > 0)
|
|
19
19
|
return;
|
|
20
20
|
console.time("初始化停止线图层");
|
|
21
|
-
let e = (
|
|
21
|
+
let e = (a = (n = this.mapConfig.holoFlow) == null ? void 0 : n.signal) == null ? void 0 : a.stopLineLayer;
|
|
22
22
|
if (!e)
|
|
23
23
|
return;
|
|
24
24
|
e = this.mapConfig.assetsRoot + "/" + e;
|
|
25
|
-
let
|
|
26
|
-
for (const l of
|
|
27
|
-
const { roadId: c, nodeId:
|
|
25
|
+
let o = await fetch(e), s = await o.json();
|
|
26
|
+
for (const l of s.features) {
|
|
27
|
+
const { roadId: c, nodeId: h } = l.properties;
|
|
28
28
|
let { destinationPoint: p } = l.properties;
|
|
29
|
-
const { coordinates:
|
|
29
|
+
const { coordinates: f } = l.geometry;
|
|
30
30
|
if (p) {
|
|
31
31
|
if (typeof p == "string")
|
|
32
32
|
try {
|
|
33
33
|
p = JSON.parse(p);
|
|
34
|
-
} catch (
|
|
35
|
-
console.error("解析面板基准点失败",
|
|
34
|
+
} catch (d) {
|
|
35
|
+
console.error("解析面板基准点失败", d);
|
|
36
36
|
continue;
|
|
37
37
|
}
|
|
38
38
|
} else {
|
|
39
|
-
const
|
|
39
|
+
const d = f[0], w = f[f.length - 1], y = (d[0] + w[0]) / 2, P = (d[1] + w[1]) / 2;
|
|
40
40
|
p = [y, P];
|
|
41
41
|
}
|
|
42
|
-
this.stopLineMap.set(`${
|
|
43
|
-
coord:
|
|
42
|
+
this.stopLineMap.set(`${h}_${c}`, {
|
|
43
|
+
coord: f,
|
|
44
44
|
panelPoint: p
|
|
45
45
|
});
|
|
46
46
|
}
|
|
47
|
-
if (console.timeEnd("初始化停止线图层"), console.time("初始化待行区图层"), e = (
|
|
48
|
-
e = this.mapConfig.assetsRoot + "/" + e,
|
|
49
|
-
for (const l of
|
|
50
|
-
const { roadId: c, direction:
|
|
51
|
-
this.waitingAreaMap.has(
|
|
47
|
+
if (console.timeEnd("初始化停止线图层"), console.time("初始化待行区图层"), e = (r = (i = this.mapConfig.holoFlow) == null ? void 0 : i.signal) == null ? void 0 : r.waitingAreaLayer, !!e) {
|
|
48
|
+
e = this.mapConfig.assetsRoot + "/" + e, o = await fetch(e), s = await o.json();
|
|
49
|
+
for (const l of s.features) {
|
|
50
|
+
const { roadId: c, direction: h, nodeId: p } = l.properties, { coordinates: f } = l.geometry, d = `${p}_${c}`;
|
|
51
|
+
this.waitingAreaMap.has(d) || this.waitingAreaMap.set(d, []), (t = this.waitingAreaMap.get(d)) == null || t.push({ coord: f, direction: h });
|
|
52
52
|
}
|
|
53
53
|
console.timeEnd("初始化待行区图层");
|
|
54
54
|
}
|
|
@@ -57,14 +57,14 @@ class v extends M {
|
|
|
57
57
|
* 初始化灯组与进口道的关联关系
|
|
58
58
|
*/
|
|
59
59
|
initializeLampGroup(e) {
|
|
60
|
-
const { sigId:
|
|
61
|
-
|
|
62
|
-
const { lampGroupNo:
|
|
63
|
-
if (
|
|
64
|
-
for (const c of
|
|
65
|
-
if (
|
|
60
|
+
const { sigId: o, lampGroupList: s } = e, n = [];
|
|
61
|
+
s.forEach((a) => {
|
|
62
|
+
const { lampGroupNo: i, lampGroupType: r, crossFlowList: t, pedList: l } = a;
|
|
63
|
+
if (t.length > 0)
|
|
64
|
+
for (const c of t) {
|
|
65
|
+
if (r === 81)
|
|
66
66
|
continue;
|
|
67
|
-
const
|
|
67
|
+
const h = c.upSectionId;
|
|
68
68
|
let p = "s";
|
|
69
69
|
switch (c.turn) {
|
|
70
70
|
case 1:
|
|
@@ -80,35 +80,35 @@ class v extends M {
|
|
|
80
80
|
p = "u";
|
|
81
81
|
break;
|
|
82
82
|
}
|
|
83
|
-
|
|
84
|
-
lampGroupId:
|
|
85
|
-
roadId:
|
|
83
|
+
n.push({
|
|
84
|
+
lampGroupId: i,
|
|
85
|
+
roadId: h,
|
|
86
86
|
dir: p
|
|
87
87
|
});
|
|
88
88
|
}
|
|
89
89
|
l.length > 0;
|
|
90
|
-
}), this.lampGroupMap.set(
|
|
90
|
+
}), this.lampGroupMap.set(o, n);
|
|
91
91
|
}
|
|
92
92
|
/**
|
|
93
93
|
* 处理统一信控平台信号灯数据
|
|
94
94
|
* @param data
|
|
95
95
|
*/
|
|
96
96
|
handleUniSignalData(e) {
|
|
97
|
-
this.watchHandle || (this.watchHandle =
|
|
97
|
+
this.watchHandle || (this.watchHandle = m.watch(
|
|
98
98
|
() => this.view.extent,
|
|
99
99
|
() => this.updatePanelPosition()
|
|
100
100
|
));
|
|
101
|
-
const { sigId:
|
|
102
|
-
if (!
|
|
101
|
+
const { sigId: o, runningStatus: s } = e.data.basicInfo, n = this.lampGroupMap.get(o);
|
|
102
|
+
if (!n)
|
|
103
103
|
return { status: -1, message: "灯组未初始化" };
|
|
104
|
-
const
|
|
105
|
-
let
|
|
106
|
-
switch (String(
|
|
104
|
+
const a = /* @__PURE__ */ new Map();
|
|
105
|
+
let i = !1;
|
|
106
|
+
switch (String(s)) {
|
|
107
107
|
case "4": {
|
|
108
|
-
|
|
109
|
-
const { roadId:
|
|
110
|
-
|
|
111
|
-
...
|
|
108
|
+
i = !0, n.forEach((r) => {
|
|
109
|
+
const { roadId: t, dir: l } = r;
|
|
110
|
+
a.set(t, {
|
|
111
|
+
...a.get(t) || {},
|
|
112
112
|
[`${l}Number`]: "",
|
|
113
113
|
[`${l}Color`]: "yellow"
|
|
114
114
|
});
|
|
@@ -116,10 +116,10 @@ class v extends M {
|
|
|
116
116
|
break;
|
|
117
117
|
}
|
|
118
118
|
case "5": {
|
|
119
|
-
|
|
120
|
-
const { roadId:
|
|
121
|
-
|
|
122
|
-
...
|
|
119
|
+
n.forEach((r) => {
|
|
120
|
+
const { roadId: t, dir: l } = r;
|
|
121
|
+
a.set(t, {
|
|
122
|
+
...a.get(t) || {},
|
|
123
123
|
[`${l}Number`]: "",
|
|
124
124
|
[`${l}Color`]: "red"
|
|
125
125
|
});
|
|
@@ -128,10 +128,10 @@ class v extends M {
|
|
|
128
128
|
}
|
|
129
129
|
case "6":
|
|
130
130
|
case "9": {
|
|
131
|
-
|
|
132
|
-
const { roadId:
|
|
133
|
-
|
|
134
|
-
...
|
|
131
|
+
n.forEach((r) => {
|
|
132
|
+
const { roadId: t, dir: l } = r;
|
|
133
|
+
a.set(t, {
|
|
134
|
+
...a.get(t) || {},
|
|
135
135
|
[`${l}Number`]: "",
|
|
136
136
|
[`${l}Color`]: "off"
|
|
137
137
|
});
|
|
@@ -139,108 +139,108 @@ class v extends M {
|
|
|
139
139
|
break;
|
|
140
140
|
}
|
|
141
141
|
default: {
|
|
142
|
-
const { curSigColorInfo:
|
|
143
|
-
|
|
144
|
-
const l = String(
|
|
145
|
-
(
|
|
142
|
+
const { curSigColorInfo: r } = e.data;
|
|
143
|
+
r.forEach((t) => {
|
|
144
|
+
const l = String(t.lamgroupId), { color: c, leftTime: h } = t, p = n.find(
|
|
145
|
+
(f) => f.lampGroupId === l
|
|
146
146
|
);
|
|
147
147
|
if (p) {
|
|
148
|
-
const { roadId:
|
|
149
|
-
|
|
150
|
-
...
|
|
151
|
-
[`${
|
|
152
|
-
[`${
|
|
148
|
+
const { roadId: f, dir: d } = p;
|
|
149
|
+
a.set(f, {
|
|
150
|
+
...a.get(f) || {},
|
|
151
|
+
[`${d}Number`]: h,
|
|
152
|
+
[`${d}Color`]: c === 1 ? "red" : c === 2 ? "yellow" : "green"
|
|
153
153
|
});
|
|
154
154
|
}
|
|
155
155
|
});
|
|
156
156
|
}
|
|
157
157
|
}
|
|
158
|
-
return this.updateLampGroupPanelStatus(
|
|
158
|
+
return this.updateLampGroupPanelStatus(o, a, i), { status: 0, message: "ok" };
|
|
159
159
|
}
|
|
160
160
|
/**
|
|
161
161
|
* 根据地图比例尺计算灯组面板缩放比例
|
|
162
162
|
*/
|
|
163
163
|
getPanelScale() {
|
|
164
164
|
const e = this.view.scale;
|
|
165
|
-
let
|
|
166
|
-
return e < 500 ?
|
|
165
|
+
let o = 1;
|
|
166
|
+
return e < 500 ? o = 1.2 : e < 1e3 ? o = 1 : e < 2e3 ? o = 0.8 : e < 4e3 ? o = 0.4 : o = 0, o;
|
|
167
167
|
}
|
|
168
168
|
/**
|
|
169
169
|
* 地图移动时更新灯组面板位置
|
|
170
170
|
*/
|
|
171
171
|
updatePanelPosition() {
|
|
172
172
|
const e = this.getPanelScale();
|
|
173
|
-
for (const
|
|
174
|
-
e !== this.currentPanelScale && (
|
|
175
|
-
const { mapPoint:
|
|
176
|
-
let
|
|
177
|
-
x:
|
|
178
|
-
y:
|
|
173
|
+
for (const o of this.countdownPanelProps) {
|
|
174
|
+
e !== this.currentPanelScale && (o.scale = e);
|
|
175
|
+
const { mapPoint: s } = o;
|
|
176
|
+
let n = new u({
|
|
177
|
+
x: s[0],
|
|
178
|
+
y: s[1]
|
|
179
179
|
});
|
|
180
|
-
this.view.spatialReference.isWebMercator && (
|
|
181
|
-
|
|
180
|
+
this.view.spatialReference.isWebMercator && (n = g.geographicToWebMercator(
|
|
181
|
+
n
|
|
182
182
|
));
|
|
183
|
-
const
|
|
184
|
-
if (
|
|
185
|
-
const
|
|
186
|
-
|
|
183
|
+
const a = this.view.toScreen(n);
|
|
184
|
+
if (o.position.left = a.x, o.position.top = a.y, this.view.type === "3d") {
|
|
185
|
+
const i = this.getPanelRotation(o.stopLine);
|
|
186
|
+
o.rotation = i;
|
|
187
187
|
}
|
|
188
188
|
}
|
|
189
189
|
this.currentPanelScale = e;
|
|
190
190
|
}
|
|
191
191
|
doHoloSignalData(e) {
|
|
192
|
-
const
|
|
193
|
-
for (const
|
|
194
|
-
let
|
|
195
|
-
for (let
|
|
196
|
-
if (
|
|
197
|
-
|
|
192
|
+
const o = e.crossId, s = e.showWaitingArea === !0, n = e.phaseCountDownList, a = /* @__PURE__ */ new Map();
|
|
193
|
+
for (const i of n) {
|
|
194
|
+
let r = "";
|
|
195
|
+
for (let h of i.roadIdList)
|
|
196
|
+
if (h.startsWith("-") && (h = h.slice(1)), this.stopLineMap.has(`${o}_${h}`)) {
|
|
197
|
+
r = `${o}_${h}`;
|
|
198
198
|
break;
|
|
199
199
|
}
|
|
200
|
-
if (!
|
|
201
|
-
console.log(`没有找到对应的进口道${
|
|
200
|
+
if (!r) {
|
|
201
|
+
console.log(`没有找到对应的进口道${o}--${r}`);
|
|
202
202
|
continue;
|
|
203
203
|
}
|
|
204
|
-
let
|
|
205
|
-
if (
|
|
204
|
+
let t = a.get(r);
|
|
205
|
+
if (t || (t = {}, a.set(r, t)), !i.direction)
|
|
206
206
|
continue;
|
|
207
|
-
const
|
|
208
|
-
|
|
207
|
+
const l = i.direction.toLowerCase(), c = i.color === 1 ? "red" : i.color === 2 ? "yellow" : "green";
|
|
208
|
+
l === "u" ? (t.uNumber = i.leftTime, t.uColor = c) : l === "l" ? (t.lNumber = i.leftTime, t.lColor = c) : l === "s" ? (t.sNumber = i.leftTime, t.sColor = c) : l === "r" && (t.rNumber = i.leftTime, t.rColor = c);
|
|
209
209
|
}
|
|
210
|
-
this.updateLampGroupPanelStatus(
|
|
210
|
+
this.updateLampGroupPanelStatus(o, a), s && this.updateWaitingArea(o, a);
|
|
211
211
|
}
|
|
212
|
-
updateWaitingArea(e,
|
|
213
|
-
|
|
214
|
-
var
|
|
215
|
-
if (
|
|
216
|
-
let
|
|
217
|
-
(
|
|
212
|
+
updateWaitingArea(e, o) {
|
|
213
|
+
o.forEach((s, n) => {
|
|
214
|
+
var a;
|
|
215
|
+
if (s.lColor) {
|
|
216
|
+
let i = this.waitingAreaLayer.graphics.find(
|
|
217
|
+
(r) => r.attributes.roadId === n && r.attributes.direction === "l"
|
|
218
218
|
);
|
|
219
|
-
if (
|
|
220
|
-
|
|
219
|
+
if (i)
|
|
220
|
+
i.attributes.color !== s.lColor && (i.attributes.color = s.lColor, i.symbol = {
|
|
221
221
|
type: "simple-fill",
|
|
222
|
-
color: this.getColor(
|
|
222
|
+
color: this.getColor(s.lColor),
|
|
223
223
|
outline: {
|
|
224
|
-
color: this.getColor(
|
|
224
|
+
color: this.getColor(s.lColor)
|
|
225
225
|
}
|
|
226
226
|
});
|
|
227
227
|
else {
|
|
228
|
-
const
|
|
229
|
-
|
|
230
|
-
geometry: { type: "polygon", rings:
|
|
228
|
+
const r = (a = this.waitingAreaMap.get(n)) == null ? void 0 : a.find((t) => t.direction === "l");
|
|
229
|
+
r && (i = new L({
|
|
230
|
+
geometry: { type: "polygon", rings: r.coord },
|
|
231
231
|
attributes: {
|
|
232
|
-
roadId:
|
|
232
|
+
roadId: n,
|
|
233
233
|
direction: "l",
|
|
234
|
-
color:
|
|
234
|
+
color: s.lColor
|
|
235
235
|
},
|
|
236
236
|
symbol: {
|
|
237
237
|
type: "simple-fill",
|
|
238
|
-
color: this.getColor(
|
|
238
|
+
color: this.getColor(s.lColor),
|
|
239
239
|
outline: {
|
|
240
|
-
color: this.getColor(
|
|
240
|
+
color: this.getColor(s.lColor)
|
|
241
241
|
}
|
|
242
242
|
}
|
|
243
|
-
}), this.waitingAreaLayer.add(
|
|
243
|
+
}), this.waitingAreaLayer.add(i));
|
|
244
244
|
}
|
|
245
245
|
}
|
|
246
246
|
});
|
|
@@ -248,40 +248,40 @@ class v extends M {
|
|
|
248
248
|
getColor(e) {
|
|
249
249
|
return e === "green" ? [0, 255, 0, 0.8] : e === "yellow" ? [255, 192, 2, 0.8] : [255, 0, 0, 0.8];
|
|
250
250
|
}
|
|
251
|
-
updateLampGroupPanelStatus(e,
|
|
252
|
-
|
|
253
|
-
const
|
|
254
|
-
if (!
|
|
251
|
+
updateLampGroupPanelStatus(e, o, s = !1) {
|
|
252
|
+
o.forEach((n, a) => {
|
|
253
|
+
const i = this.stopLineMap.get(a);
|
|
254
|
+
if (!i)
|
|
255
255
|
return;
|
|
256
|
-
const
|
|
257
|
-
(
|
|
256
|
+
const r = this.countdownPanelProps.find(
|
|
257
|
+
(t) => t.roadId === a
|
|
258
258
|
);
|
|
259
|
-
if (
|
|
260
|
-
|
|
259
|
+
if (r)
|
|
260
|
+
r.lampStatus = n, r.flash = s;
|
|
261
261
|
else {
|
|
262
|
-
let
|
|
263
|
-
x:
|
|
264
|
-
y:
|
|
262
|
+
let t = new u({
|
|
263
|
+
x: i.panelPoint[0],
|
|
264
|
+
y: i.panelPoint[1]
|
|
265
265
|
});
|
|
266
|
-
this.view.spatialReference.isWebMercator && (
|
|
267
|
-
|
|
266
|
+
this.view.spatialReference.isWebMercator && (t = g.geographicToWebMercator(
|
|
267
|
+
t
|
|
268
268
|
));
|
|
269
|
-
const l = this.view.toScreen(
|
|
269
|
+
const l = this.view.toScreen(t), c = this.getPanelRotation(i.coord);
|
|
270
270
|
this.countdownPanelProps.push({
|
|
271
271
|
displayMode: "complex",
|
|
272
|
-
flash:
|
|
272
|
+
flash: s,
|
|
273
273
|
crossId: e,
|
|
274
|
-
roadId:
|
|
275
|
-
mapPoint:
|
|
274
|
+
roadId: a,
|
|
275
|
+
mapPoint: i.panelPoint,
|
|
276
276
|
// 定位点地理坐标
|
|
277
|
-
stopLine:
|
|
277
|
+
stopLine: i.coord,
|
|
278
278
|
// 关联的停止线坐标
|
|
279
279
|
position: { left: l.x, top: l.y },
|
|
280
280
|
// 定位点屏幕坐标
|
|
281
281
|
rotation: c,
|
|
282
282
|
// 面板旋转角度
|
|
283
283
|
scale: this.getPanelScale(),
|
|
284
|
-
lampStatus:
|
|
284
|
+
lampStatus: n
|
|
285
285
|
// 灯组状态
|
|
286
286
|
});
|
|
287
287
|
}
|
|
@@ -293,7 +293,7 @@ class v extends M {
|
|
|
293
293
|
* @returns
|
|
294
294
|
*/
|
|
295
295
|
async handleHoloSignalData(e) {
|
|
296
|
-
this.watchHandle || (this.watchHandle =
|
|
296
|
+
this.watchHandle || (this.watchHandle = m.watch(
|
|
297
297
|
() => this.view.extent,
|
|
298
298
|
() => this.updatePanelPosition()
|
|
299
299
|
)), this.trajectoryDelayTime === 0 ? this.doHoloSignalData(e) : setTimeout(
|
|
@@ -311,15 +311,7 @@ class v extends M {
|
|
|
311
311
|
* @returns
|
|
312
312
|
*/
|
|
313
313
|
getPanelRotation(e) {
|
|
314
|
-
const
|
|
315
|
-
let n = new u({
|
|
316
|
-
x: t[0],
|
|
317
|
-
y: t[1]
|
|
318
|
-
});
|
|
319
|
-
this.view.spatialReference.isWebMercator && (n = g.geographicToWebMercator(
|
|
320
|
-
n
|
|
321
|
-
));
|
|
322
|
-
const a = this.view.toScreen(n), o = e[e.length - 1];
|
|
314
|
+
const o = e[0];
|
|
323
315
|
let s = new u({
|
|
324
316
|
x: o[0],
|
|
325
317
|
y: o[1]
|
|
@@ -327,8 +319,16 @@ class v extends M {
|
|
|
327
319
|
this.view.spatialReference.isWebMercator && (s = g.geographicToWebMercator(
|
|
328
320
|
s
|
|
329
321
|
));
|
|
330
|
-
const
|
|
331
|
-
|
|
322
|
+
const n = this.view.toScreen(s), a = e[e.length - 1];
|
|
323
|
+
let i = new u({
|
|
324
|
+
x: a[0],
|
|
325
|
+
y: a[1]
|
|
326
|
+
});
|
|
327
|
+
this.view.spatialReference.isWebMercator && (i = g.geographicToWebMercator(
|
|
328
|
+
i
|
|
329
|
+
));
|
|
330
|
+
const r = this.view.toScreen(i), t = r.x - n.x, l = r.y - n.y;
|
|
331
|
+
return Math.atan2(l, t) * (180 / Math.PI);
|
|
332
332
|
}
|
|
333
333
|
}
|
|
334
334
|
export {
|
|
@@ -1,22 +1,22 @@
|
|
|
1
1
|
import g from "@arcgis/core/Graphic";
|
|
2
|
-
import * as
|
|
2
|
+
import * as C from "@arcgis/core/core/promiseUtils";
|
|
3
3
|
import * as $ from "@arcgis/core/core/reactiveUtils.js";
|
|
4
|
-
import { Polygon as
|
|
5
|
-
import * as
|
|
6
|
-
import
|
|
7
|
-
import
|
|
8
|
-
import * as
|
|
4
|
+
import { Polygon as S, Point as F } from "@arcgis/core/geometry";
|
|
5
|
+
import * as L from "@arcgis/core/geometry/geometryEngine";
|
|
6
|
+
import D from "@arcgis/core/layers/FeatureLayer";
|
|
7
|
+
import I from "@arcgis/core/layers/GraphicsLayer";
|
|
8
|
+
import * as k from "@turf/helpers";
|
|
9
9
|
import { lineSliceAlong as x } from "@turf/line-slice-along";
|
|
10
10
|
import b from "axios";
|
|
11
11
|
import { XMLParser as P } from "fast-xml-parser";
|
|
12
12
|
import J from "md5";
|
|
13
13
|
import G from "pako";
|
|
14
|
-
import { watch as
|
|
15
|
-
import
|
|
14
|
+
import { watch as R } from "vue";
|
|
15
|
+
import E from "../../stores/index.mjs";
|
|
16
16
|
import T from "../common-utils.mjs";
|
|
17
|
-
class
|
|
17
|
+
class O {
|
|
18
18
|
constructor(e) {
|
|
19
|
-
this.junctionNames = /* @__PURE__ */ new Map(), this.junctionScale = 5e3, this.xodrBorder = [], this.projectName = "", this.openDriveServer = "", this.currentSectionCode = "", this.selectedSectionIds = [], this.currentJunctionId = "", this.view = e, this.laneLayer = new
|
|
19
|
+
this.junctionNames = /* @__PURE__ */ new Map(), this.junctionScale = 5e3, this.xodrBorder = [], this.projectName = "", this.openDriveServer = "", this.currentSectionCode = "", this.selectedSectionIds = [], this.currentJunctionId = "", this.view = e, this.laneLayer = new D({
|
|
20
20
|
id: "OpenDriveLane",
|
|
21
21
|
fields: [
|
|
22
22
|
{
|
|
@@ -239,7 +239,7 @@ class M {
|
|
|
239
239
|
}
|
|
240
240
|
]
|
|
241
241
|
}
|
|
242
|
-
}), this.roadNameLayer = new
|
|
242
|
+
}), this.roadNameLayer = new D({
|
|
243
243
|
id: "OpenDriveRoadName",
|
|
244
244
|
fields: [
|
|
245
245
|
{
|
|
@@ -289,7 +289,7 @@ class M {
|
|
|
289
289
|
}
|
|
290
290
|
}
|
|
291
291
|
]
|
|
292
|
-
}), this.junctionLayer = new
|
|
292
|
+
}), 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([
|
|
293
293
|
this.laneLayer,
|
|
294
294
|
this.sectionLayer,
|
|
295
295
|
this.roadNameLayer,
|
|
@@ -302,7 +302,7 @@ class M {
|
|
|
302
302
|
]);
|
|
303
303
|
}
|
|
304
304
|
static getInstance(e) {
|
|
305
|
-
return this.instance || (this.instance = new
|
|
305
|
+
return this.instance || (this.instance = new O(e)), this.instance;
|
|
306
306
|
}
|
|
307
307
|
async makeMd5FromFile(e) {
|
|
308
308
|
var t;
|
|
@@ -326,31 +326,12 @@ class M {
|
|
|
326
326
|
var f, m;
|
|
327
327
|
this.openDriveClickCallback = e.selectedCallback, this.scaleWatch = $.watch(
|
|
328
328
|
() => this.view.scale,
|
|
329
|
-
(
|
|
330
|
-
|
|
329
|
+
(p, u) => {
|
|
330
|
+
p > this.junctionScale && u <= this.junctionScale ? this.updateAllJunctionSymbol("marker") : p <= this.junctionScale && u > this.junctionScale && this.updateAllJunctionSymbol("picture");
|
|
331
331
|
}
|
|
332
|
-
)
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
return t;
|
|
336
|
-
if (this.projectName = t.result.md5, console.timeEnd("md5用时"), this.xodrBorder = t.result.border, this.xodrBorder.length > 0) {
|
|
337
|
-
const u = new g({
|
|
338
|
-
geometry: new L({
|
|
339
|
-
rings: [this.xodrBorder]
|
|
340
|
-
}),
|
|
341
|
-
symbol: {
|
|
342
|
-
type: "simple-fill",
|
|
343
|
-
style: "none",
|
|
344
|
-
outline: {
|
|
345
|
-
style: "dash",
|
|
346
|
-
color: "black",
|
|
347
|
-
width: 2
|
|
348
|
-
}
|
|
349
|
-
}
|
|
350
|
-
});
|
|
351
|
-
this.borderLayer.add(u);
|
|
352
|
-
}
|
|
353
|
-
this.openDriveServer = e.server;
|
|
332
|
+
);
|
|
333
|
+
let t = e.file.split("/").pop() || "";
|
|
334
|
+
t = t.split(".").slice(0, -1).join("."), console.log(`OpenDriveRenderer: 显示OpenDrive文件 ${t}`), this.openDriveServer = e.server;
|
|
354
335
|
const s = `http://${this.openDriveServer}/api/openDrive/uploadXodr`;
|
|
355
336
|
let o;
|
|
356
337
|
try {
|
|
@@ -360,12 +341,12 @@ class M {
|
|
|
360
341
|
{
|
|
361
342
|
params: {
|
|
362
343
|
url: e.file,
|
|
363
|
-
projectName:
|
|
344
|
+
projectName: t
|
|
364
345
|
}
|
|
365
346
|
}
|
|
366
347
|
);
|
|
367
|
-
} catch (
|
|
368
|
-
return { status: -1, message:
|
|
348
|
+
} catch (p) {
|
|
349
|
+
return { status: -1, message: p.message };
|
|
369
350
|
}
|
|
370
351
|
if (o.status !== 200)
|
|
371
352
|
return { status: -1, message: o.statusText };
|
|
@@ -386,12 +367,12 @@ class M {
|
|
|
386
367
|
);
|
|
387
368
|
const d = o.data.result.junctions;
|
|
388
369
|
this.showJunction(d), e.options && e.options.centerMap !== !1 && await this.view.goTo(this.allLaneGraphics), this.mouseMoveHandler || this.monitorMouseMove(), this.mouseClickHandler || this.monitorMouseClick();
|
|
389
|
-
const h =
|
|
390
|
-
return
|
|
370
|
+
const h = E.useAppDataStore;
|
|
371
|
+
return R(
|
|
391
372
|
() => h.isSketching,
|
|
392
373
|
() => {
|
|
393
|
-
var
|
|
394
|
-
h.isSketching ? ((
|
|
374
|
+
var p, u;
|
|
375
|
+
h.isSketching ? ((p = this.mouseMoveHandler) == null || p.remove(), this.mouseMoveHandler = void 0, (u = this.mouseClickHandler) == null || u.remove(), this.mouseClickHandler = void 0) : (this.monitorMouseMove(), this.monitorMouseClick());
|
|
395
376
|
}
|
|
396
377
|
), console.timeEnd("渲染用时"), { status: 0, message: "ok" };
|
|
397
378
|
}
|
|
@@ -449,22 +430,22 @@ class M {
|
|
|
449
430
|
roadName: h
|
|
450
431
|
}
|
|
451
432
|
});
|
|
452
|
-
this.allRefLineGraphics.push(f), n.laneSections.sort((m,
|
|
433
|
+
this.allRefLineGraphics.push(f), n.laneSections.sort((m, p) => Number(m.id) - Number(p.id));
|
|
453
434
|
for (let m = 0; m < n.laneSections.length; m++) {
|
|
454
|
-
const
|
|
455
|
-
for (const y of
|
|
435
|
+
const p = n.laneSections[m], u = Number(p.id);
|
|
436
|
+
for (const y of p.lanePaths) {
|
|
456
437
|
const v = Number(y.id);
|
|
457
438
|
if (v === 0)
|
|
458
439
|
continue;
|
|
459
|
-
const
|
|
460
|
-
|
|
440
|
+
const w = y.type, M = [...y.outerPath], A = y.innerPath.concat(
|
|
441
|
+
M.reverse()
|
|
461
442
|
);
|
|
462
443
|
if (A.length <= 3) {
|
|
463
444
|
console.warn(`lane ${v} has less than 3 points`);
|
|
464
445
|
continue;
|
|
465
446
|
}
|
|
466
447
|
A.push(y.innerPath[0]);
|
|
467
|
-
const N = new
|
|
448
|
+
const N = new S({
|
|
468
449
|
rings: [A]
|
|
469
450
|
});
|
|
470
451
|
if (N) {
|
|
@@ -472,15 +453,15 @@ class M {
|
|
|
472
453
|
geometry: N,
|
|
473
454
|
attributes: {
|
|
474
455
|
ObjectID: c++,
|
|
475
|
-
id: `${l}+${
|
|
456
|
+
id: `${l}+${u}+${v}`,
|
|
476
457
|
fromNode: n.fromNode,
|
|
477
458
|
toNode: n.toNode,
|
|
478
459
|
roadId: String(l),
|
|
479
460
|
roadName: n.name,
|
|
480
|
-
sectionId: String(
|
|
461
|
+
sectionId: String(u),
|
|
481
462
|
sectionIndex: m,
|
|
482
463
|
laneId: v,
|
|
483
|
-
type:
|
|
464
|
+
type: w,
|
|
484
465
|
sumoId: "",
|
|
485
466
|
// 记录左右边线的起始点,用于按长度高亮车道的一部分
|
|
486
467
|
leftLine: y.innerPath,
|
|
@@ -519,7 +500,7 @@ class M {
|
|
|
519
500
|
showJunction(e) {
|
|
520
501
|
const t = [];
|
|
521
502
|
let s;
|
|
522
|
-
this.xodrBorder.length > 0 && (s = new
|
|
503
|
+
this.xodrBorder.length > 0 && (s = new S({
|
|
523
504
|
rings: [this.xodrBorder]
|
|
524
505
|
}));
|
|
525
506
|
for (const o of e)
|
|
@@ -529,7 +510,7 @@ class M {
|
|
|
529
510
|
y: o.coordinates[1]
|
|
530
511
|
});
|
|
531
512
|
let c = !0;
|
|
532
|
-
if (s && (c =
|
|
513
|
+
if (s && (c = L.contains(s, i)), c) {
|
|
533
514
|
const r = new g({
|
|
534
515
|
geometry: i,
|
|
535
516
|
attributes: {
|
|
@@ -548,7 +529,7 @@ class M {
|
|
|
548
529
|
* 监听鼠标移动事件,高亮显示鼠标所在路段和路口
|
|
549
530
|
*/
|
|
550
531
|
monitorMouseMove() {
|
|
551
|
-
const e =
|
|
532
|
+
const e = C.debounce(async (t) => {
|
|
552
533
|
var c;
|
|
553
534
|
const o = (c = (await this.view.hitTest(t, {
|
|
554
535
|
include: [this.laneLayer, this.junctionLayer]
|
|
@@ -565,15 +546,15 @@ class M {
|
|
|
565
546
|
"roadId"
|
|
566
547
|
)}+${this.hitGraphic.getAttribute("sectionId")}`;
|
|
567
548
|
if (this.currentSectionCode === r || this.selectedSectionIds.includes(r) || this.sectionLayer.graphics.findIndex(
|
|
568
|
-
(
|
|
549
|
+
(u) => u.getAttribute("id") === r
|
|
569
550
|
) >= 0)
|
|
570
551
|
return;
|
|
571
552
|
this.currentSectionCode = r;
|
|
572
553
|
const n = this.allLaneGraphics.filter(
|
|
573
|
-
(
|
|
574
|
-
), l =
|
|
575
|
-
n.map((
|
|
576
|
-
), d = this.hitGraphic.getAttribute("fromNode"), h = this.hitGraphic.getAttribute("toNode"), f = this.junctionNames.get(d) || d, m = this.junctionNames.get(h) || h,
|
|
554
|
+
(u) => `${u.attributes.roadId}+${u.attributes.sectionId}` === r
|
|
555
|
+
), l = L.union(
|
|
556
|
+
n.map((u) => u.geometry)
|
|
557
|
+
), d = this.hitGraphic.getAttribute("fromNode"), h = this.hitGraphic.getAttribute("toNode"), f = this.junctionNames.get(d) || d, m = this.junctionNames.get(h) || h, p = new g({
|
|
577
558
|
geometry: l,
|
|
578
559
|
symbol: {
|
|
579
560
|
type: "simple-fill",
|
|
@@ -615,7 +596,7 @@ class M {
|
|
|
615
596
|
]
|
|
616
597
|
}
|
|
617
598
|
});
|
|
618
|
-
this.highlightLayer.removeAll(), this.highlightLayer.add(
|
|
599
|
+
this.highlightLayer.removeAll(), this.highlightLayer.add(p);
|
|
619
600
|
} else if (i.layer.id === "OpenDriveJunction") {
|
|
620
601
|
const r = this.hitGraphic.getAttribute("id");
|
|
621
602
|
if (r === this.currentJunctionId)
|
|
@@ -632,7 +613,7 @@ class M {
|
|
|
632
613
|
* 监听鼠标点击事件,获取高亮要素的拓扑信息
|
|
633
614
|
*/
|
|
634
615
|
monitorMouseClick() {
|
|
635
|
-
const e =
|
|
616
|
+
const e = C.debounce(async (t) => {
|
|
636
617
|
var a;
|
|
637
618
|
const o = (a = (await this.view.hitTest(t, {
|
|
638
619
|
include: [this.highlightLayer, this.junctionLayer, this.sectionLayer]
|
|
@@ -866,7 +847,7 @@ class M {
|
|
|
866
847
|
}
|
|
867
848
|
const c = i.map(
|
|
868
849
|
(a) => a.geometry
|
|
869
|
-
), r =
|
|
850
|
+
), r = L.union(c);
|
|
870
851
|
if (e.flash) {
|
|
871
852
|
const a = new g({
|
|
872
853
|
geometry: r,
|
|
@@ -947,7 +928,7 @@ class M {
|
|
|
947
928
|
let n = c.get(a);
|
|
948
929
|
n ? n.push(r.geometry) : (n = [r.geometry], c.set(a, n));
|
|
949
930
|
}), c.forEach((r, a) => {
|
|
950
|
-
const n =
|
|
931
|
+
const n = L.union(r), l = new g({
|
|
951
932
|
geometry: n,
|
|
952
933
|
symbol: {
|
|
953
934
|
type: "simple-fill",
|
|
@@ -975,7 +956,7 @@ class M {
|
|
|
975
956
|
}
|
|
976
957
|
}
|
|
977
958
|
async geometrySearch(e) {
|
|
978
|
-
const t = new
|
|
959
|
+
const t = new S({
|
|
979
960
|
rings: [e]
|
|
980
961
|
}), s = await this.laneLayer.queryFeatures({
|
|
981
962
|
geometry: t,
|
|
@@ -999,7 +980,7 @@ class M {
|
|
|
999
980
|
}
|
|
1000
981
|
const c = this.junctionLayer.graphics.filter((a) => {
|
|
1001
982
|
const n = a.geometry;
|
|
1002
|
-
return
|
|
983
|
+
return L.contains(t, n);
|
|
1003
984
|
}), r = [];
|
|
1004
985
|
for (const a of c) {
|
|
1005
986
|
const n = a.getAttribute("id");
|
|
@@ -1031,24 +1012,24 @@ class M {
|
|
|
1031
1012
|
const o = Number(s[1]), i = s[0].split("#"), c = i.length === 2 ? Number(i[1]) : 0;
|
|
1032
1013
|
let r = i[0];
|
|
1033
1014
|
r.startsWith("-") && (r = r.slice(1));
|
|
1034
|
-
const a = this.allLaneGraphics.filter((
|
|
1015
|
+
const a = this.allLaneGraphics.filter((w) => w.getAttribute("roadId") === r && w.getAttribute("sectionIndex") === c);
|
|
1035
1016
|
if (a.length === 0)
|
|
1036
1017
|
return { status: -1, message: "未找到路段" };
|
|
1037
1018
|
const n = a.length - o, l = a.find(
|
|
1038
|
-
(
|
|
1019
|
+
(w) => Math.abs(w.getAttribute("laneId")) === n
|
|
1039
1020
|
);
|
|
1040
1021
|
if (!l)
|
|
1041
1022
|
return { status: -1, message: "未找到车道" };
|
|
1042
|
-
const d = e.start || 0, h = e.end || 100, f =
|
|
1023
|
+
const d = e.start || 0, h = e.end || 100, f = k.lineString(l.getAttribute("leftLine")), m = x(f, d, h, {
|
|
1043
1024
|
units: "meters"
|
|
1044
|
-
}),
|
|
1025
|
+
}), p = k.lineString(l.getAttribute("rightLine")), u = x(p, d, h, {
|
|
1045
1026
|
units: "meters"
|
|
1046
1027
|
}), y = m.geometry.coordinates.concat(
|
|
1047
|
-
|
|
1028
|
+
u.geometry.coordinates.reverse()
|
|
1048
1029
|
);
|
|
1049
1030
|
y.push(y[y.length - 1]);
|
|
1050
1031
|
const v = new g({
|
|
1051
|
-
geometry: new
|
|
1032
|
+
geometry: new S({
|
|
1052
1033
|
rings: [y]
|
|
1053
1034
|
}),
|
|
1054
1035
|
attributes: {
|
|
@@ -1064,7 +1045,7 @@ class M {
|
|
|
1064
1045
|
type: l.getAttribute("type"),
|
|
1065
1046
|
sumoId: l.getAttribute("sumoId"),
|
|
1066
1047
|
leftLine: m.geometry.coordinates,
|
|
1067
|
-
rightLine:
|
|
1048
|
+
rightLine: u.geometry.coordinates
|
|
1068
1049
|
},
|
|
1069
1050
|
symbol: {
|
|
1070
1051
|
type: "simple-fill",
|
|
@@ -1202,5 +1183,5 @@ class M {
|
|
|
1202
1183
|
}
|
|
1203
1184
|
}
|
|
1204
1185
|
export {
|
|
1205
|
-
|
|
1186
|
+
O as default
|
|
1206
1187
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const M=require("@arcgis/core/core/reactiveUtils"),g=require("@arcgis/core/geometry"),S=require("@arcgis/core/geometry/support/webMercatorUtils.js"),C=require("@arcgis/core/Graphic"),I=require("@arcgis/core/layers/GraphicsLayer"),v=require("./signal-holo-flow.js");function P(d){const e=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(d){for(const t in d)if(t!=="default"){const a=Object.getOwnPropertyDescriptor(d,t);Object.defineProperty(e,t,a.get?a:{enumerable:!0,get:()=>d[t]})}}return e.default=d,Object.freeze(e)}const y=P(M),w=P(S);class G extends v.default{constructor(e,t){var a,
|
|
1
|
+
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const M=require("@arcgis/core/core/reactiveUtils"),g=require("@arcgis/core/geometry"),S=require("@arcgis/core/geometry/support/webMercatorUtils.js"),C=require("@arcgis/core/Graphic"),I=require("@arcgis/core/layers/GraphicsLayer"),v=require("./signal-holo-flow.js");function P(d){const e=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(d){for(const t in d)if(t!=="default"){const a=Object.getOwnPropertyDescriptor(d,t);Object.defineProperty(e,t,a.get?a:{enumerable:!0,get:()=>d[t]})}}return e.default=d,Object.freeze(e)}const y=P(M),w=P(S);class G extends v.default{constructor(e,t){var a,r;super(e),this.waitingAreaLayer=new I,this.watchHandle=null,this.trajectoryDelayTime=2,this.stopLineMap=new Map,this.waitingAreaMap=new Map,this.lampGroupMap=new Map,this.countdownPanelProps=t,this.view.map.add(this.waitingAreaLayer),this.trajectoryDelayTime=(r=(a=this.mapConfig.holoFlow)==null?void 0:a.signal)==null?void 0:r.delay,this.trajectoryDelayTime===void 0&&(this.trajectoryDelayTime=2)}async initializeLayer(){var r,s,i,n,o;if(this.stopLineMap.size>0)return;console.time("初始化停止线图层");let e=(s=(r=this.mapConfig.holoFlow)==null?void 0:r.signal)==null?void 0:s.stopLineLayer;if(!e)return;e=this.mapConfig.assetsRoot+"/"+e;let t=await fetch(e),a=await t.json();for(const l of a.features){const{roadId:c,nodeId:h}=l.properties;let{destinationPoint:p}=l.properties;const{coordinates:f}=l.geometry;if(p){if(typeof p=="string")try{p=JSON.parse(p)}catch(u){console.error("解析面板基准点失败",u);continue}}else{const u=f[0],m=f[f.length-1],b=(u[0]+m[0])/2,L=(u[1]+m[1])/2;p=[b,L]}this.stopLineMap.set(`${h}_${c}`,{coord:f,panelPoint:p})}if(console.timeEnd("初始化停止线图层"),console.time("初始化待行区图层"),e=(n=(i=this.mapConfig.holoFlow)==null?void 0:i.signal)==null?void 0:n.waitingAreaLayer,!!e){e=this.mapConfig.assetsRoot+"/"+e,t=await fetch(e),a=await t.json();for(const l of a.features){const{roadId:c,direction:h,nodeId:p}=l.properties,{coordinates:f}=l.geometry,u=`${p}_${c}`;this.waitingAreaMap.has(u)||this.waitingAreaMap.set(u,[]),(o=this.waitingAreaMap.get(u))==null||o.push({coord:f,direction:h})}console.timeEnd("初始化待行区图层")}}initializeLampGroup(e){const{sigId:t,lampGroupList:a}=e,r=[];a.forEach(s=>{const{lampGroupNo:i,lampGroupType:n,crossFlowList:o,pedList:l}=s;if(o.length>0)for(const c of o){if(n===81)continue;const h=c.upSectionId;let p="s";switch(c.turn){case 1:p="s";break;case 2:p="l";break;case 4:p="r";break;case 8:p="u";break}r.push({lampGroupId:i,roadId:h,dir:p})}l.length>0}),this.lampGroupMap.set(t,r)}handleUniSignalData(e){this.watchHandle||(this.watchHandle=y.watch(()=>this.view.extent,()=>this.updatePanelPosition()));const{sigId:t,runningStatus:a}=e.data.basicInfo,r=this.lampGroupMap.get(t);if(!r)return{status:-1,message:"灯组未初始化"};const s=new Map;let i=!1;switch(String(a)){case"4":{i=!0,r.forEach(n=>{const{roadId:o,dir:l}=n;s.set(o,{...s.get(o)||{},[`${l}Number`]:"",[`${l}Color`]:"yellow"})});break}case"5":{r.forEach(n=>{const{roadId:o,dir:l}=n;s.set(o,{...s.get(o)||{},[`${l}Number`]:"",[`${l}Color`]:"red"})});break}case"6":case"9":{r.forEach(n=>{const{roadId:o,dir:l}=n;s.set(o,{...s.get(o)||{},[`${l}Number`]:"",[`${l}Color`]:"off"})});break}default:{const{curSigColorInfo:n}=e.data;n.forEach(o=>{const l=String(o.lamgroupId),{color:c,leftTime:h}=o,p=r.find(f=>f.lampGroupId===l);if(p){const{roadId:f,dir:u}=p;s.set(f,{...s.get(f)||{},[`${u}Number`]:h,[`${u}Color`]:c===1?"red":c===2?"yellow":"green"})}})}}return this.updateLampGroupPanelStatus(t,s,i),{status:0,message:"ok"}}getPanelScale(){const e=this.view.scale;let t=1;return e<500?t=1.2:e<1e3?t=1:e<2e3?t=.8:e<4e3?t=.4:t=0,t}updatePanelPosition(){const e=this.getPanelScale();for(const t of this.countdownPanelProps){e!==this.currentPanelScale&&(t.scale=e);const{mapPoint:a}=t;let r=new g.Point({x:a[0],y:a[1]});this.view.spatialReference.isWebMercator&&(r=w.geographicToWebMercator(r));const s=this.view.toScreen(r);if(t.position.left=s.x,t.position.top=s.y,this.view.type==="3d"){const i=this.getPanelRotation(t.stopLine);t.rotation=i}}this.currentPanelScale=e}doHoloSignalData(e){const t=e.crossId,a=e.showWaitingArea===!0,r=e.phaseCountDownList,s=new Map;for(const i of r){let n="";for(let h of i.roadIdList)if(h.startsWith("-")&&(h=h.slice(1)),this.stopLineMap.has(`${t}_${h}`)){n=`${t}_${h}`;break}if(!n){console.log(`没有找到对应的进口道${t}--${n}`);continue}let o=s.get(n);if(o||(o={},s.set(n,o)),!i.direction)continue;const l=i.direction.toLowerCase(),c=i.color===1?"red":i.color===2?"yellow":"green";l==="u"?(o.uNumber=i.leftTime,o.uColor=c):l==="l"?(o.lNumber=i.leftTime,o.lColor=c):l==="s"?(o.sNumber=i.leftTime,o.sColor=c):l==="r"&&(o.rNumber=i.leftTime,o.rColor=c)}this.updateLampGroupPanelStatus(t,s),a&&this.updateWaitingArea(t,s)}updateWaitingArea(e,t){t.forEach((a,r)=>{var s;if(a.lColor){let i=this.waitingAreaLayer.graphics.find(n=>n.attributes.roadId===r&&n.attributes.direction==="l");if(i)i.attributes.color!==a.lColor&&(i.attributes.color=a.lColor,i.symbol={type:"simple-fill",color:this.getColor(a.lColor),outline:{color:this.getColor(a.lColor)}});else{const n=(s=this.waitingAreaMap.get(r))==null?void 0:s.find(o=>o.direction==="l");n&&(i=new C({geometry:{type:"polygon",rings:n.coord},attributes:{roadId:r,direction:"l",color:a.lColor},symbol:{type:"simple-fill",color:this.getColor(a.lColor),outline:{color:this.getColor(a.lColor)}}}),this.waitingAreaLayer.add(i))}}})}getColor(e){return e==="green"?[0,255,0,.8]:e==="yellow"?[255,192,2,.8]:[255,0,0,.8]}updateLampGroupPanelStatus(e,t,a=!1){t.forEach((r,s)=>{const i=this.stopLineMap.get(s);if(!i)return;const n=this.countdownPanelProps.find(o=>o.roadId===s);if(n)n.lampStatus=r,n.flash=a;else{let o=new g.Point({x:i.panelPoint[0],y:i.panelPoint[1]});this.view.spatialReference.isWebMercator&&(o=w.geographicToWebMercator(o));const l=this.view.toScreen(o),c=this.getPanelRotation(i.coord);this.countdownPanelProps.push({displayMode:"complex",flash:a,crossId:e,roadId:s,mapPoint:i.panelPoint,stopLine:i.coord,position:{left:l.x,top:l.y},rotation:c,scale:this.getPanelScale(),lampStatus:r})}})}async handleHoloSignalData(e){this.watchHandle||(this.watchHandle=y.watch(()=>this.view.extent,()=>this.updatePanelPosition())),this.trajectoryDelayTime===0?this.doHoloSignalData(e):setTimeout(()=>this.doHoloSignalData(e),this.trajectoryDelayTime*1e3)}clearSignal(){var e;this.waitingAreaLayer.removeAll(),this.countdownPanelProps.length=0,(e=this.watchHandle)==null||e.remove(),this.watchHandle=null}getPanelRotation(e){const t=e[0];let a=new g.Point({x:t[0],y:t[1]});this.view.spatialReference.isWebMercator&&(a=w.geographicToWebMercator(a));const r=this.view.toScreen(a),s=e[e.length-1];let i=new g.Point({x:s[0],y:s[1]});this.view.spatialReference.isWebMercator&&(i=w.geographicToWebMercator(i));const n=this.view.toScreen(i),o=n.x-r.x,l=n.y-r.y;return Math.atan2(l,o)*(180/Math.PI)}}exports.default=G;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const f=require("@arcgis/core/Graphic"),F=require("@arcgis/core/core/promiseUtils"),J=require("@arcgis/core/core/reactiveUtils.js"),L=require("@arcgis/core/geometry"),E=require("@arcgis/core/geometry/geometryEngine"),x=require("@arcgis/core/layers/FeatureLayer"),w=require("@arcgis/core/layers/GraphicsLayer"),q=require("@turf/helpers"),G=require("@turf/line-slice-along"),b=require("axios"),R=require("fast-xml-parser"),_=require("md5"),O=require("pako"),T=require("vue"),z=require("../../stores/index.js"),H=require("../common-utils.js");function N(S){const e=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(S){for(const t in S)if(t!=="default"){const i=Object.getOwnPropertyDescriptor(S,t);Object.defineProperty(e,t,i.get?i:{enumerable:!0,get:()=>S[t]})}}return e.default=S,Object.freeze(e)}const M=N(F),U=N(J),A=N(E),P=N(q);class k{constructor(e){this.junctionNames=new Map,this.junctionScale=5e3,this.xodrBorder=[],this.projectName="",this.openDriveServer="",this.currentSectionCode="",this.selectedSectionIds=[],this.currentJunctionId="",this.view=e,this.laneLayer=new x({id:"OpenDriveLane",fields:[{name:"ObjectID",alias:"ObjectID",type:"oid"},{name:"id",alias:"编号",type:"string"},{name:"roadId",alias:"道路号",type:"string"},{name:"roadName",alias:"道路名称",type:"string"},{name:"sectionId",alias:"路段号",type:"string"},{name:"sectionIndex",alias:"路段序号",type:"string"},{name:"laneId",alias:"车道号",type:"string"},{name:"type",alias:"类型",type:"string"},{name:"sumoId",alias:"sumo编号",type:"string"},{name:"fromNode",alias:"起点路口",type:"string"},{name:"toNode",alias:"终点路口",type:"string"}],objectIdField:"ObjectID",geometryType:"polygon",spatialReference:{wkid:4326},source:[],outFields:["*"],renderer:{type:"unique-value",field:"type",defaultSymbol:{type:"simple-fill",color:[100,100,100],style:"solid",outline:{color:"white",width:1}},uniqueValueInfos:[{value:"shoulder",label:"路肩",symbol:{type:"simple-fill",color:"#008000",style:"solid",outline:{color:"white",width:1}}},{value:"border",label:"路沿",symbol:{type:"simple-fill",color:"#DCDCDC",style:"solid",outline:{color:"white",width:1}}},{value:"driving",label:"机动车道",symbol:{type:"simple-fill",color:[47,79,79,.8],style:"solid",outline:{color:"white",width:1}}},{value:"none",label:"无",symbol:{type:"simple-fill",color:[111,120,135],style:"none",outline:{color:"white",width:1}}},{value:"restricted",label:"禁行区",symbol:{type:"simple-fill",color:"yellow",style:"solid",outline:{color:"yellow",width:2}}},{value:"parking",label:"停车区",symbol:{type:"simple-fill",color:[115,115,115],style:"solid",outline:{color:"white",width:1}}},{value:"median",label:"中央隔离带",symbol:{type:"simple-fill",color:"#008000",style:"solid",outline:{color:"white",width:1}}},{value:"biking",label:"非机动车道",symbol:{type:"simple-fill",color:"#D3D3D3",style:"solid",outline:{color:"white",width:1}}},{value:"sidewalk",label:"人行道",symbol:{type:"simple-fill",color:"#C0C0C0",style:"solid",outline:{color:"white",width:1}}},{value:"junction",label:"路口区域",symbol:{type:"simple-fill",color:"#2F4F4F",style:"solid",outline:{color:"white",width:1}}},{value:"selected",label:"选中车道",symbol:{type:"simple-fill",color:[141,168,211],style:"solid",outline:{color:"white",width:1}}}]}}),this.roadNameLayer=new x({id:"OpenDriveRoadName",fields:[{name:"ObjectID",alias:"ObjectID",type:"oid"},{name:"roadId",alias:"道路号",type:"string"},{name:"roadName",alias:"道路名称",type:"string"}],objectIdField:"ObjectID",geometryType:"polyline",spatialReference:{wkid:4326},source:[],renderer:{type:"simple",symbol:{type:"simple-line",style:"solid",color:[0,0,0,0],width:1}},labelingInfo:[{symbol:{type:"text",color:"black",haloColor:"white",haloSize:1,font:{size:12,family:"sans-serif"}},labelPlacement:this.view.type==="2d"?"center-along":void 0,labelExpressionInfo:{expression:"$feature.roadName"}}]}),this.junctionLayer=new w({id:"OpenDriveJunction"}),this.sectionLayer=new w({id:"OpenDriveSection"}),this.highlightLayer=new w({id:"OpenDriveHighlight"}),this.flashLayer=new w({id:"OpenDriveFlash"}),this.drawLayer=new w({id:"Draw"}),this.splitLaneLayer=new w({id:"SplitLane"}),this.borderLayer=new w({id:"OpenDriveBorder"}),this.view.map.addMany([this.laneLayer,this.sectionLayer,this.roadNameLayer,this.junctionLayer,this.highlightLayer,this.flashLayer,this.drawLayer,this.splitLaneLayer,this.borderLayer])}static getInstance(e){return this.instance||(this.instance=new k(e)),this.instance}async makeMd5FromFile(e){var t;try{const o=await(await fetch(e)).text();let r=(t=new R.XMLParser({ignoreAttributes:!1,allowBooleanAttributes:!0}).parse(o).OpenDRIVE.userData)==null?void 0:t.border;return r?r=JSON.parse(r):r=[],{status:0,message:"ok",result:{md5:_(o),border:r}}}catch(i){return{status:-1,message:i.message}}}async showOpenDriveFromFile(e){var g,m;this.openDriveClickCallback=e.selectedCallback,this.scaleWatch=U.watch(()=>this.view.scale,(h,p)=>{h>this.junctionScale&&p<=this.junctionScale?this.updateAllJunctionSymbol("marker"):h<=this.junctionScale&&p>this.junctionScale&&this.updateAllJunctionSymbol("picture")}),console.time("md5用时");const t=await this.makeMd5FromFile(e.file);if(t.status!==0)return t;if(this.projectName=t.result.md5,console.timeEnd("md5用时"),this.xodrBorder=t.result.border,this.xodrBorder.length>0){const h=new f({geometry:new L.Polygon({rings:[this.xodrBorder]}),symbol:{type:"simple-fill",style:"none",outline:{style:"dash",color:"black",width:2}}});this.borderLayer.add(h)}this.openDriveServer=e.server;const i=`http://${this.openDriveServer}/api/openDrive/uploadXodr`;let o;try{o=await b.post(i,{},{params:{url:e.file,projectName:this.projectName}})}catch(h){return{status:-1,message:h.message}}if(o.status!==200)return{status:-1,message:o.statusText};console.time("渲染用时");const s=o.data.result.geoSetting;H.default.setGeoData(s.geoReference,s.offsetX,s.offsetY);let c=o.data.result.json;c.startsWith(window.location.protocol)||(c=`${window.location.protocol}//${e.server}${c}`);const a=await(await fetch(c)).arrayBuffer(),n=O.inflate(a,{to:"string"}),l=JSON.parse(n);await this.showAllLanes(l,((g=e.options)==null?void 0:g.showJunctionLane)||!1,((m=e.options)==null?void 0:m.showRoadName)||!0);const d=o.data.result.junctions;this.showJunction(d),e.options&&e.options.centerMap!==!1&&await this.view.goTo(this.allLaneGraphics),this.mouseMoveHandler||this.monitorMouseMove(),this.mouseClickHandler||this.monitorMouseClick();const u=z.default.useAppDataStore;return T.watch(()=>u.isSketching,()=>{var h,p;u.isSketching?((h=this.mouseMoveHandler)==null||h.remove(),this.mouseMoveHandler=void 0,(p=this.mouseClickHandler)==null||p.remove(),this.mouseClickHandler=void 0):(this.monitorMouseMove(),this.monitorMouseClick())}),console.timeEnd("渲染用时"),{status:0,message:"ok"}}async showOpenDriveFromServer(e,t){const i=`http://${e}/api/openDrive/analyzeXodr`,o=await b.get(i,{headers:{projectName:t},params:{analyze:!1,compressed:!0}});if(o.status!==200)throw new Error(`OpenDriveRenderer: ${o.statusText}`);let s=o.data.result.json;s.startsWith(window.location.protocol)||(s=`${window.location.protocol}//${e}${s}`);const r=await(await fetch(s)).arrayBuffer(),a=O.inflate(r,{to:"string"}),n=JSON.parse(a);return await this.showAllLanes(n,!1,!1),{status:0,message:"ok"}}async showAllLanes(e,t,i){const o=await this.laneLayer.queryFeatures();return o.features.length>0&&this.laneLayer.applyEdits({deleteFeatures:o.features}),this.roadNameLayer.visible=i,new Promise(s=>{let c=0;this.allLaneGraphics=[],this.allRefLineGraphics=[];const r=[];for(const n of e){if(!t&&n.junction!=="-1")continue;const{id:l,refLine:d}=n;let u=n.name;u.includes("(")&&(u=u.slice(0,u.indexOf("("))),u=u.replace(/(.)/g,"$1 ");const g=new f({geometry:{type:"polyline",paths:[d]},attributes:{ObjectID:c++,roadId:l,roadName:u}});this.allRefLineGraphics.push(g),n.laneSections.sort((m,h)=>Number(m.id)-Number(h.id));for(let m=0;m<n.laneSections.length;m++){const h=n.laneSections[m],p=Number(h.id);for(const y of h.lanePaths){const v=Number(y.id);if(v===0)continue;const I=y.type,$=[...y.outerPath],j=y.innerPath.concat($.reverse());if(j.length<=3){console.warn(`lane ${v} has less than 3 points`);continue}j.push(y.innerPath[0]);const C=new L.Polygon({rings:[j]});if(C){const D=new f({geometry:C,attributes:{ObjectID:c++,id:`${l}+${p}+${v}`,fromNode:n.fromNode,toNode:n.toNode,roadId:String(l),roadName:n.name,sectionId:String(p),sectionIndex:m,laneId:v,type:I,sumoId:"",leftLine:y.innerPath,rightLine:y.outerPath}});this.allLaneGraphics.push(D),r.push(D)}}}}const a=setInterval(()=>{if(r.length>0||this.allRefLineGraphics.length>0){if(r.length>0){const n=r.splice(0,100);this.laneLayer.applyEdits({addFeatures:n})}if(this.allRefLineGraphics.length>0){const n=this.allRefLineGraphics.splice(0,10);this.roadNameLayer.applyEdits({addFeatures:n})}}else clearInterval(a),s()},10)})}showJunction(e){const t=[];let i;this.xodrBorder.length>0&&(i=new L.Polygon({rings:[this.xodrBorder]}));for(const o of e)if(o&&(this.junctionNames.set(o.id,o.name),o.nodeType=o.type,o.crossId)){const s=new L.Point({x:o.coordinates[0],y:o.coordinates[1]});let c=!0;if(i&&(c=A.contains(i,s)),c){const r=new f({geometry:s,attributes:{...o,selected:!1,type:"OpenDriveJunction"},symbol:this.getCrossGraphicSymbol(o,"marker")});t.push(r)}}this.junctionLayer.addMany(t)}monitorMouseMove(){const e=M.debounce(async t=>{var c;const o=(c=(await this.view.hitTest(t,{include:[this.laneLayer,this.junctionLayer]})).results)==null?void 0:c.filter(r=>r.type==="graphic");if(o.length===0){this.currentSectionCode!==""&&(this.currentSectionCode="",this.highlightLayer.removeAll()),this.currentJunctionId!==""&&(this.currentJunctionId=""),this.view.closePopup();return}const s=o[0];if(this.hitGraphic=s.graphic,s.layer.id==="OpenDriveLane"){const r=`${this.hitGraphic.getAttribute("roadId")}+${this.hitGraphic.getAttribute("sectionId")}`;if(this.currentSectionCode===r||this.selectedSectionIds.includes(r)||this.sectionLayer.graphics.findIndex(p=>p.getAttribute("id")===r)>=0)return;this.currentSectionCode=r;const n=this.allLaneGraphics.filter(p=>`${p.attributes.roadId}+${p.attributes.sectionId}`===r),l=A.union(n.map(p=>p.geometry)),d=this.hitGraphic.getAttribute("fromNode"),u=this.hitGraphic.getAttribute("toNode"),g=this.junctionNames.get(d)||d,m=this.junctionNames.get(u)||u,h=new f({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:g,toNodeName:m,laneCount:n.length},popupTemplate:{title:this.hitGraphic.getAttribute("roadName"),content:[{type:"fields",fieldInfos:[{fieldName:"fromNodeName",label:"起点路口"},{fieldName:"toNodeName",label:"终点路口"},{fieldName:"laneCount",label:"车道数量"}]}]}});this.highlightLayer.removeAll(),this.highlightLayer.add(h)}else if(s.layer.id==="OpenDriveJunction"){const r=this.hitGraphic.getAttribute("id");if(r===this.currentJunctionId)return;this.currentJunctionId=r}});this.mouseMoveHandler=this.view.on("pointer-move",async t=>{e(t).catch(()=>{})})}monitorMouseClick(){const e=M.debounce(async t=>{var a;const o=(a=(await this.view.hitTest(t,{include:[this.highlightLayer,this.junctionLayer,this.sectionLayer]})).results)==null?void 0:a.filter(n=>n.type==="graphic");if(o.length===0)return;const s=o[0].graphic,c=s.getAttribute("type"),r=s.getAttribute("id");if(c==="OpenDriveJunction")if(s.getAttribute("selected")===!1){const n=`http://${this.openDriveServer}/api/sumo/getSumoJunction`,l=await b.get(n,{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={type:"picture-marker",url:"/GisViewerAssets/Images/point_red.png",width:"20px",height:"20px"},this.increasePictureMarkerSize(s,50))}else this.openDriveClickCallback&&this.openDriveClickCallback({type:"OpenDriveJunction",id:r,details:void 0}),s.setAttribute("selected",!1),s.symbol=this.getCrossGraphicSymbol(s.attributes,this.view.scale<this.junctionScale?"picture":"marker");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 n=`http://${this.openDriveServer}/api/sumo/getSumoEdge`,l=await b.get(n,{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(n=>n!==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 o=e.symbol,s=o.width;s<t?e.symbol={type:"picture-marker",url:o.url,width:s+1,height:s+1}:clearInterval(i)},20)}decreasePictureMarkerSize(e,t){const i=setInterval(()=>{const o=e.symbol,s=o.width;s>t?e.symbol={type:"picture-marker",url:o.url,width:s-1,height:s-1}:clearInterval(i)},20)}async getSumoInfo(e){switch(e.type){case"junction":{const t=`http://${this.openDriveServer}/api/sumo/getSumoJunction`,i=await b.get(t,{params:{id:e.id,projectName:this.projectName}});return i.status===200?i.data:{status:-1,message:`路口信息查询失败: ${e.id}`}}case"edge":{const t=e.id.split("#");let i=t[0];i.startsWith("-")&&(i=i.slice(1));let o=0;t.length===2&&(o=Number(t[1]));const s=this.allLaneGraphics.find(c=>c.getAttribute("roadId")===i&&c.getAttribute("sectionIndex")===o);if(s){const c=`${i}+${s.getAttribute("sectionId")}`,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:"未知类型"}}}setOpendriveVisibility(e){this.laneLayer.visible=e}async clearOpenDrive(){var t,i,o;let e=await this.laneLayer.queryFeatures();e.features.length>0&&await this.laneLayer.applyEdits({deleteFeatures:e.features}),e=await this.roadNameLayer.queryFeatures(),e.features.length>0&&await this.roadNameLayer.applyEdits({deleteFeatures:e.features}),this.highlightLayer.removeAll(),this.junctionLayer.removeAll(),this.sectionLayer.removeAll(),this.flashLayer.removeAll(),this.borderLayer.removeAll(),(t=this.mouseMoveHandler)==null||t.remove(),this.mouseMoveHandler=void 0,(i=this.mouseClickHandler)==null||i.remove(),this.mouseClickHandler=void 0,(o=this.scaleWatch)==null||o.remove(),this.scaleWatch=void 0}async findSumo(e){const{type:t,id:i}=e,o=e.flash===void 0?!0:e.flash;if(t==="junction")return await this.findJunction(i,o);if(t==="edge"){const s=i.split("_");if(s.length>2)return{status:-1,message:"id格式错误"};const c=s.length===2?Number(s[1]):void 0,r=s[0].split("#");if(r.length>2)return{status:-1,message:"id格式错误"};const a=r[0],n=r.length===2?Number(r[1]):void 0;return await this.findLane({roadsectId:a,segmentId:n,laneId:c,flash:o})}else return{status:-1,message:"未知类型"}}async findJunction(e,t){const i=this.junctionLayer.graphics.find(o=>o.attributes.id===e);if(!i)return{status:-1,message:"未找到。请检查路口编号"};if(t){const o=new f({geometry:i.geometry,symbol:{type:"simple-marker",style:"circle",size:30,color:[0,255,255,.8],outline:{color:[0,255,255],width:1}}});this.flashGraphic(o)}return await this.view.goTo(i.geometry,{duration:1e3}),{status:0,message:"ok"}}async findLane(e){let{roadsectId:t,segmentId:i,laneId:o}=e;t.startsWith("-")&&(t=t.slice(1));let s=this.allLaneGraphics.filter(a=>a.attributes.roadId===t);if(s.length===0)return{status:-1,message:"未找到。请检查路段编号"};if(i!==void 0){const a=[];if(s.forEach(n=>{const l=Number(n.attributes.sectionId);a.indexOf(l)===-1&&a.push(l)}),a.sort((n,l)=>n-l),i>a.length-1)return{status:-1,message:"未找到。请检查基本段编号"};i=a[i],s=s.filter(n=>Number(n.attributes.sectionId)===i)}if(o!==void 0){const a=[];if(s.forEach(n=>{const l=Number(n.attributes.laneId);a.indexOf(l)===-1&&a.push(l)}),a.sort((n,l)=>n-l),o>a.length-1)return{status:-1,message:"未找到。请检查车道编号"};o=a[o],s=s.filter(n=>Number(n.attributes.laneId)===o)}const c=s.map(a=>a.geometry),r=A.union(c);if(e.flash){const a=new f({geometry:r,symbol:{type:"simple-fill",color:[0,255,255,.6],style:"solid",outline:{width:0}}});this.flashGraphic(a)}return await this.view.goTo(r,{duration:1e3}),{status:0,message:"ok"}}flashGraphic(e){this.flashLayer.removeAll(),this.flashLayer.add(e);let t=0,i=!0;const o=setInterval(()=>{i?(this.flashLayer.opacity-=.02,this.flashLayer.opacity<=.1&&(i=!1,t++)):(this.flashLayer.opacity+=.02,this.flashLayer.opacity>=1&&(i=!0)),t>=5&&(this.flashLayer.removeAll(),this.flashLayer.opacity=1,clearInterval(o))},10)}unselectSumo(e){if((!e||e.type==="junction")&&this.junctionLayer.graphics.forEach(t=>{(!e||!e.id||e.id===""||e.id===t.getAttribute("id"))&&t.getAttribute("selected")&&(t.setAttribute("selected",!1),t.symbol=this.getCrossGraphicSymbol(t.attributes,this.view.scale<this.junctionScale?"picture":"marker"))}),!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 o=i.getAttribute("id");this.selectedSectionIds=this.selectedSectionIds.filter(s=>s!==o)}),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 o=0;t.length===2&&(o=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")===o)),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 n=c.get(a);n?n.push(r.geometry):(n=[r.geometry],c.set(a,n))}),c.forEach((r,a)=>{const n=A.union(r),l=new f({geometry:n,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 L.Polygon({rings:[e]}),i=await this.laneLayer.queryFeatures({geometry:t,outFields:["*"]}),o=[],s=[];for(const a of i.features){const n=a.getAttribute("roadId"),l=a.getAttribute("sectionIndex"),d=`${n}#${l}`;if(o.indexOf(d)===-1){o.push(d),this.selectSumo({type:"edge",id:d});const u=`http://${this.openDriveServer}/api/sumo/getSumoEdge`,g=await b.get(u,{params:{id:`${n}+${a.getAttribute("sectionId")}`,projectName:this.projectName}});g.status===200&&g.data.status===0&&s.push(g.data.result)}}const c=this.junctionLayer.graphics.filter(a=>{const n=a.geometry;return A.contains(t,n)}),r=[];for(const a of c){const n=a.getAttribute("id");this.selectSumo({type:"junction",id:n});const l=`http://${this.openDriveServer}/api/sumo/getSumoJunction`,d=await b.get(l,{params:{id:n,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 o=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(I=>I.getAttribute("roadId")===r&&I.getAttribute("sectionIndex")===c);if(a.length===0)return{status:-1,message:"未找到路段"};const n=a.length-o,l=a.find(I=>Math.abs(I.getAttribute("laneId"))===n);if(!l)return{status:-1,message:"未找到车道"};const d=e.start||0,u=e.end||100,g=P.lineString(l.getAttribute("leftLine")),m=G.lineSliceAlong(g,d,u,{units:"meters"}),h=P.lineString(l.getAttribute("rightLine")),p=G.lineSliceAlong(h,d,u,{units:"meters"}),y=m.geometry.coordinates.concat(p.geometry.coordinates.reverse());y.push(y[y.length-1]);const v=new f({geometry:new L.Polygon({rings:[y]}),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:m.geometry.coordinates,rightLine:p.geometry.coordinates},symbol:{type:"simple-fill",color:[255,0,0,.8],outline:{color:"red"}}});return this.splitLaneLayer.add(v),this.view.goTo(v),{status:0,message:"ok",result:{coordinates:y}}}clearSplitLane(){this.splitLaneLayer.removeAll()}updateAllJunctionSymbol(e){const t=this.junctionLayer.graphics.clone();this.junctionLayer.removeAll(),t.forEach(i=>{i.getAttribute("selected")||(i.symbol=this.getCrossGraphicSymbol(i.attributes,e))}),this.junctionLayer.addMany(t.toArray())}getCrossGraphicSymbol(e,t){const i=e.crossId!==""&&e.crossId!==void 0&&e.crossId!==null;if(t==="marker")return{type:"picture-marker",url:`/GisViewerAssets/Images/cross/${i?"gis_xhj_blue":"gis_lkcz_xz"}.png`,width:"32px",height:"32px"};if(t==="picture")return i?{type:"cim",data:{type:"CIMSymbolReference",primitiveOverrides:[{type:"CIMPrimitiveOverride",primitiveName:"textGraphic",propertyName:"TextString",valueExpressionInfo:{type:"CIMExpressionInfo",title:"Custom",expression:'Replace($feature.name, "与", "/") + " " + $feature.crossId',returnType:"Default"}}],symbol:{type:"CIMPointSymbol",symbolLayers:[{type:"CIMVectorMarker",size:32,colorLocked:!0,anchorPointUnits:"Relative",frame:{xmin:-16,ymin:-16,xmax:16,ymax:16},markerGraphics:[{type:"CIMMarkerGraphic",primitiveName:"textGraphic",geometry:{x:0,y:0},symbol:{type:"CIMTextSymbol",height:12,horizontalAlignment:"Center",offsetX:0,offsetY:i?25:15,haloSize:2,haloSymbol:{type:"CIMPolygonSymbol",symbolLayers:[{type:"CIMSolidFill",enable:!0,color:[255,255,255,255]}]},symbol:{type:"CIMPolygonSymbol",symbolLayers:[{type:"CIMSolidFill",enable:!0,color:[0,0,0,255]}]},verticalAlignment:"Center"},textString:""}],scaleSymbolsProportionally:!0,respectFrame:!0},{type:"CIMPictureMarker",enable:!0,anchorPoint:{x:0,y:0},anchorPointUnits:"Relative",size:32,rotateClockwise:!0,textureFilter:"Picture",url:"/GisViewerAssets/Images/cross/gis_xhj_blue.png"}]}}}:{type:"picture-marker",url:"/GisViewerAssets/Images/cross/gis_lkcz_xz.png",width:"32px",height:"32px"}}}exports.default=k;
|
|
1
|
+
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const f=require("@arcgis/core/Graphic"),F=require("@arcgis/core/core/promiseUtils"),J=require("@arcgis/core/core/reactiveUtils.js"),S=require("@arcgis/core/geometry"),q=require("@arcgis/core/geometry/geometryEngine"),x=require("@arcgis/core/layers/FeatureLayer"),I=require("@arcgis/core/layers/GraphicsLayer"),E=require("@turf/helpers"),G=require("@turf/line-slice-along"),b=require("axios"),R=require("fast-xml-parser"),_=require("md5"),O=require("pako"),T=require("vue"),z=require("../../stores/index.js"),H=require("../common-utils.js");function N(L){const e=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(L){for(const t in L)if(t!=="default"){const i=Object.getOwnPropertyDescriptor(L,t);Object.defineProperty(e,t,i.get?i:{enumerable:!0,get:()=>L[t]})}}return e.default=L,Object.freeze(e)}const M=N(F),U=N(J),A=N(q),P=N(E);class D{constructor(e){this.junctionNames=new Map,this.junctionScale=5e3,this.xodrBorder=[],this.projectName="",this.openDriveServer="",this.currentSectionCode="",this.selectedSectionIds=[],this.currentJunctionId="",this.view=e,this.laneLayer=new x({id:"OpenDriveLane",fields:[{name:"ObjectID",alias:"ObjectID",type:"oid"},{name:"id",alias:"编号",type:"string"},{name:"roadId",alias:"道路号",type:"string"},{name:"roadName",alias:"道路名称",type:"string"},{name:"sectionId",alias:"路段号",type:"string"},{name:"sectionIndex",alias:"路段序号",type:"string"},{name:"laneId",alias:"车道号",type:"string"},{name:"type",alias:"类型",type:"string"},{name:"sumoId",alias:"sumo编号",type:"string"},{name:"fromNode",alias:"起点路口",type:"string"},{name:"toNode",alias:"终点路口",type:"string"}],objectIdField:"ObjectID",geometryType:"polygon",spatialReference:{wkid:4326},source:[],outFields:["*"],renderer:{type:"unique-value",field:"type",defaultSymbol:{type:"simple-fill",color:[100,100,100],style:"solid",outline:{color:"white",width:1}},uniqueValueInfos:[{value:"shoulder",label:"路肩",symbol:{type:"simple-fill",color:"#008000",style:"solid",outline:{color:"white",width:1}}},{value:"border",label:"路沿",symbol:{type:"simple-fill",color:"#DCDCDC",style:"solid",outline:{color:"white",width:1}}},{value:"driving",label:"机动车道",symbol:{type:"simple-fill",color:[47,79,79,.8],style:"solid",outline:{color:"white",width:1}}},{value:"none",label:"无",symbol:{type:"simple-fill",color:[111,120,135],style:"none",outline:{color:"white",width:1}}},{value:"restricted",label:"禁行区",symbol:{type:"simple-fill",color:"yellow",style:"solid",outline:{color:"yellow",width:2}}},{value:"parking",label:"停车区",symbol:{type:"simple-fill",color:[115,115,115],style:"solid",outline:{color:"white",width:1}}},{value:"median",label:"中央隔离带",symbol:{type:"simple-fill",color:"#008000",style:"solid",outline:{color:"white",width:1}}},{value:"biking",label:"非机动车道",symbol:{type:"simple-fill",color:"#D3D3D3",style:"solid",outline:{color:"white",width:1}}},{value:"sidewalk",label:"人行道",symbol:{type:"simple-fill",color:"#C0C0C0",style:"solid",outline:{color:"white",width:1}}},{value:"junction",label:"路口区域",symbol:{type:"simple-fill",color:"#2F4F4F",style:"solid",outline:{color:"white",width:1}}},{value:"selected",label:"选中车道",symbol:{type:"simple-fill",color:[141,168,211],style:"solid",outline:{color:"white",width:1}}}]}}),this.roadNameLayer=new x({id:"OpenDriveRoadName",fields:[{name:"ObjectID",alias:"ObjectID",type:"oid"},{name:"roadId",alias:"道路号",type:"string"},{name:"roadName",alias:"道路名称",type:"string"}],objectIdField:"ObjectID",geometryType:"polyline",spatialReference:{wkid:4326},source:[],renderer:{type:"simple",symbol:{type:"simple-line",style:"solid",color:[0,0,0,0],width:1}},labelingInfo:[{symbol:{type:"text",color:"black",haloColor:"white",haloSize:1,font:{size:12,family:"sans-serif"}},labelPlacement:this.view.type==="2d"?"center-along":void 0,labelExpressionInfo:{expression:"$feature.roadName"}}]}),this.junctionLayer=new 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([this.laneLayer,this.sectionLayer,this.roadNameLayer,this.junctionLayer,this.highlightLayer,this.flashLayer,this.drawLayer,this.splitLaneLayer,this.borderLayer])}static getInstance(e){return this.instance||(this.instance=new D(e)),this.instance}async makeMd5FromFile(e){var t;try{const o=await(await fetch(e)).text();let r=(t=new R.XMLParser({ignoreAttributes:!1,allowBooleanAttributes:!0}).parse(o).OpenDRIVE.userData)==null?void 0:t.border;return r?r=JSON.parse(r):r=[],{status:0,message:"ok",result:{md5:_(o),border:r}}}catch(i){return{status:-1,message:i.message}}}async showOpenDriveFromFile(e){var g,m;this.openDriveClickCallback=e.selectedCallback,this.scaleWatch=U.watch(()=>this.view.scale,(p,h)=>{p>this.junctionScale&&h<=this.junctionScale?this.updateAllJunctionSymbol("marker"):p<=this.junctionScale&&h>this.junctionScale&&this.updateAllJunctionSymbol("picture")});let t=e.file.split("/").pop()||"";t=t.split(".").slice(0,-1).join("."),console.log(`OpenDriveRenderer: 显示OpenDrive文件 ${t}`),this.openDriveServer=e.server;const i=`http://${this.openDriveServer}/api/openDrive/uploadXodr`;let o;try{o=await b.post(i,{},{params:{url:e.file,projectName:t}})}catch(p){return{status:-1,message:p.message}}if(o.status!==200)return{status:-1,message:o.statusText};console.time("渲染用时");const s=o.data.result.geoSetting;H.default.setGeoData(s.geoReference,s.offsetX,s.offsetY);let c=o.data.result.json;c.startsWith(window.location.protocol)||(c=`${window.location.protocol}//${e.server}${c}`);const a=await(await fetch(c)).arrayBuffer(),n=O.inflate(a,{to:"string"}),l=JSON.parse(n);await this.showAllLanes(l,((g=e.options)==null?void 0:g.showJunctionLane)||!1,((m=e.options)==null?void 0:m.showRoadName)||!0);const u=o.data.result.junctions;this.showJunction(u),e.options&&e.options.centerMap!==!1&&await this.view.goTo(this.allLaneGraphics),this.mouseMoveHandler||this.monitorMouseMove(),this.mouseClickHandler||this.monitorMouseClick();const d=z.default.useAppDataStore;return T.watch(()=>d.isSketching,()=>{var p,h;d.isSketching?((p=this.mouseMoveHandler)==null||p.remove(),this.mouseMoveHandler=void 0,(h=this.mouseClickHandler)==null||h.remove(),this.mouseClickHandler=void 0):(this.monitorMouseMove(),this.monitorMouseClick())}),console.timeEnd("渲染用时"),{status:0,message:"ok"}}async showOpenDriveFromServer(e,t){const i=`http://${e}/api/openDrive/analyzeXodr`,o=await b.get(i,{headers:{projectName:t},params:{analyze:!1,compressed:!0}});if(o.status!==200)throw new Error(`OpenDriveRenderer: ${o.statusText}`);let s=o.data.result.json;s.startsWith(window.location.protocol)||(s=`${window.location.protocol}//${e}${s}`);const r=await(await fetch(s)).arrayBuffer(),a=O.inflate(r,{to:"string"}),n=JSON.parse(a);return await this.showAllLanes(n,!1,!1),{status:0,message:"ok"}}async showAllLanes(e,t,i){const o=await this.laneLayer.queryFeatures();return o.features.length>0&&this.laneLayer.applyEdits({deleteFeatures:o.features}),this.roadNameLayer.visible=i,new Promise(s=>{let c=0;this.allLaneGraphics=[],this.allRefLineGraphics=[];const r=[];for(const n of e){if(!t&&n.junction!=="-1")continue;const{id:l,refLine:u}=n;let d=n.name;d.includes("(")&&(d=d.slice(0,d.indexOf("("))),d=d.replace(/(.)/g,"$1 ");const g=new f({geometry:{type:"polyline",paths:[u]},attributes:{ObjectID:c++,roadId:l,roadName:d}});this.allRefLineGraphics.push(g),n.laneSections.sort((m,p)=>Number(m.id)-Number(p.id));for(let m=0;m<n.laneSections.length;m++){const p=n.laneSections[m],h=Number(p.id);for(const y of p.lanePaths){const v=Number(y.id);if(v===0)continue;const w=y.type,$=[...y.outerPath],j=y.innerPath.concat($.reverse());if(j.length<=3){console.warn(`lane ${v} has less than 3 points`);continue}j.push(y.innerPath[0]);const k=new S.Polygon({rings:[j]});if(k){const C=new f({geometry:k,attributes:{ObjectID:c++,id:`${l}+${h}+${v}`,fromNode:n.fromNode,toNode:n.toNode,roadId:String(l),roadName:n.name,sectionId:String(h),sectionIndex:m,laneId:v,type:w,sumoId:"",leftLine:y.innerPath,rightLine:y.outerPath}});this.allLaneGraphics.push(C),r.push(C)}}}}const a=setInterval(()=>{if(r.length>0||this.allRefLineGraphics.length>0){if(r.length>0){const n=r.splice(0,100);this.laneLayer.applyEdits({addFeatures:n})}if(this.allRefLineGraphics.length>0){const n=this.allRefLineGraphics.splice(0,10);this.roadNameLayer.applyEdits({addFeatures:n})}}else clearInterval(a),s()},10)})}showJunction(e){const t=[];let i;this.xodrBorder.length>0&&(i=new S.Polygon({rings:[this.xodrBorder]}));for(const o of e)if(o&&(this.junctionNames.set(o.id,o.name),o.nodeType=o.type,o.crossId)){const s=new S.Point({x:o.coordinates[0],y:o.coordinates[1]});let c=!0;if(i&&(c=A.contains(i,s)),c){const r=new f({geometry:s,attributes:{...o,selected:!1,type:"OpenDriveJunction"},symbol:this.getCrossGraphicSymbol(o,"marker")});t.push(r)}}this.junctionLayer.addMany(t)}monitorMouseMove(){const e=M.debounce(async t=>{var c;const o=(c=(await this.view.hitTest(t,{include:[this.laneLayer,this.junctionLayer]})).results)==null?void 0:c.filter(r=>r.type==="graphic");if(o.length===0){this.currentSectionCode!==""&&(this.currentSectionCode="",this.highlightLayer.removeAll()),this.currentJunctionId!==""&&(this.currentJunctionId=""),this.view.closePopup();return}const s=o[0];if(this.hitGraphic=s.graphic,s.layer.id==="OpenDriveLane"){const r=`${this.hitGraphic.getAttribute("roadId")}+${this.hitGraphic.getAttribute("sectionId")}`;if(this.currentSectionCode===r||this.selectedSectionIds.includes(r)||this.sectionLayer.graphics.findIndex(h=>h.getAttribute("id")===r)>=0)return;this.currentSectionCode=r;const n=this.allLaneGraphics.filter(h=>`${h.attributes.roadId}+${h.attributes.sectionId}`===r),l=A.union(n.map(h=>h.geometry)),u=this.hitGraphic.getAttribute("fromNode"),d=this.hitGraphic.getAttribute("toNode"),g=this.junctionNames.get(u)||u,m=this.junctionNames.get(d)||d,p=new f({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:g,toNodeName:m,laneCount:n.length},popupTemplate:{title:this.hitGraphic.getAttribute("roadName"),content:[{type:"fields",fieldInfos:[{fieldName:"fromNodeName",label:"起点路口"},{fieldName:"toNodeName",label:"终点路口"},{fieldName:"laneCount",label:"车道数量"}]}]}});this.highlightLayer.removeAll(),this.highlightLayer.add(p)}else if(s.layer.id==="OpenDriveJunction"){const r=this.hitGraphic.getAttribute("id");if(r===this.currentJunctionId)return;this.currentJunctionId=r}});this.mouseMoveHandler=this.view.on("pointer-move",async t=>{e(t).catch(()=>{})})}monitorMouseClick(){const e=M.debounce(async t=>{var a;const o=(a=(await this.view.hitTest(t,{include:[this.highlightLayer,this.junctionLayer,this.sectionLayer]})).results)==null?void 0:a.filter(n=>n.type==="graphic");if(o.length===0)return;const s=o[0].graphic,c=s.getAttribute("type"),r=s.getAttribute("id");if(c==="OpenDriveJunction")if(s.getAttribute("selected")===!1){const n=`http://${this.openDriveServer}/api/sumo/getSumoJunction`,l=await b.get(n,{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={type:"picture-marker",url:"/GisViewerAssets/Images/point_red.png",width:"20px",height:"20px"},this.increasePictureMarkerSize(s,50))}else this.openDriveClickCallback&&this.openDriveClickCallback({type:"OpenDriveJunction",id:r,details:void 0}),s.setAttribute("selected",!1),s.symbol=this.getCrossGraphicSymbol(s.attributes,this.view.scale<this.junctionScale?"picture":"marker");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 n=`http://${this.openDriveServer}/api/sumo/getSumoEdge`,l=await b.get(n,{params:{id:r,projectName:this.projectName}});if(l.status===200&&l.data.status===0&&this.openDriveClickCallback){const u=l.data.result.obj_id;s.setAttribute("edgeId",u),this.openDriveClickCallback({type:"OpenDriveSection",id:u,details:l.data.result})}}else this.sectionLayer.remove(s),this.selectedSectionIds=this.selectedSectionIds.filter(n=>n!==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 o=e.symbol,s=o.width;s<t?e.symbol={type:"picture-marker",url:o.url,width:s+1,height:s+1}:clearInterval(i)},20)}decreasePictureMarkerSize(e,t){const i=setInterval(()=>{const o=e.symbol,s=o.width;s>t?e.symbol={type:"picture-marker",url:o.url,width:s-1,height:s-1}:clearInterval(i)},20)}async getSumoInfo(e){switch(e.type){case"junction":{const t=`http://${this.openDriveServer}/api/sumo/getSumoJunction`,i=await b.get(t,{params:{id:e.id,projectName:this.projectName}});return i.status===200?i.data:{status:-1,message:`路口信息查询失败: ${e.id}`}}case"edge":{const t=e.id.split("#");let i=t[0];i.startsWith("-")&&(i=i.slice(1));let o=0;t.length===2&&(o=Number(t[1]));const s=this.allLaneGraphics.find(c=>c.getAttribute("roadId")===i&&c.getAttribute("sectionIndex")===o);if(s){const c=`${i}+${s.getAttribute("sectionId")}`,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:"未知类型"}}}setOpendriveVisibility(e){this.laneLayer.visible=e}async clearOpenDrive(){var t,i,o;let e=await this.laneLayer.queryFeatures();e.features.length>0&&await this.laneLayer.applyEdits({deleteFeatures:e.features}),e=await this.roadNameLayer.queryFeatures(),e.features.length>0&&await this.roadNameLayer.applyEdits({deleteFeatures:e.features}),this.highlightLayer.removeAll(),this.junctionLayer.removeAll(),this.sectionLayer.removeAll(),this.flashLayer.removeAll(),this.borderLayer.removeAll(),(t=this.mouseMoveHandler)==null||t.remove(),this.mouseMoveHandler=void 0,(i=this.mouseClickHandler)==null||i.remove(),this.mouseClickHandler=void 0,(o=this.scaleWatch)==null||o.remove(),this.scaleWatch=void 0}async findSumo(e){const{type:t,id:i}=e,o=e.flash===void 0?!0:e.flash;if(t==="junction")return await this.findJunction(i,o);if(t==="edge"){const s=i.split("_");if(s.length>2)return{status:-1,message:"id格式错误"};const c=s.length===2?Number(s[1]):void 0,r=s[0].split("#");if(r.length>2)return{status:-1,message:"id格式错误"};const a=r[0],n=r.length===2?Number(r[1]):void 0;return await this.findLane({roadsectId:a,segmentId:n,laneId:c,flash:o})}else return{status:-1,message:"未知类型"}}async findJunction(e,t){const i=this.junctionLayer.graphics.find(o=>o.attributes.id===e);if(!i)return{status:-1,message:"未找到。请检查路口编号"};if(t){const o=new f({geometry:i.geometry,symbol:{type:"simple-marker",style:"circle",size:30,color:[0,255,255,.8],outline:{color:[0,255,255],width:1}}});this.flashGraphic(o)}return await this.view.goTo(i.geometry,{duration:1e3}),{status:0,message:"ok"}}async findLane(e){let{roadsectId:t,segmentId:i,laneId:o}=e;t.startsWith("-")&&(t=t.slice(1));let s=this.allLaneGraphics.filter(a=>a.attributes.roadId===t);if(s.length===0)return{status:-1,message:"未找到。请检查路段编号"};if(i!==void 0){const a=[];if(s.forEach(n=>{const l=Number(n.attributes.sectionId);a.indexOf(l)===-1&&a.push(l)}),a.sort((n,l)=>n-l),i>a.length-1)return{status:-1,message:"未找到。请检查基本段编号"};i=a[i],s=s.filter(n=>Number(n.attributes.sectionId)===i)}if(o!==void 0){const a=[];if(s.forEach(n=>{const l=Number(n.attributes.laneId);a.indexOf(l)===-1&&a.push(l)}),a.sort((n,l)=>n-l),o>a.length-1)return{status:-1,message:"未找到。请检查车道编号"};o=a[o],s=s.filter(n=>Number(n.attributes.laneId)===o)}const c=s.map(a=>a.geometry),r=A.union(c);if(e.flash){const a=new f({geometry:r,symbol:{type:"simple-fill",color:[0,255,255,.6],style:"solid",outline:{width:0}}});this.flashGraphic(a)}return await this.view.goTo(r,{duration:1e3}),{status:0,message:"ok"}}flashGraphic(e){this.flashLayer.removeAll(),this.flashLayer.add(e);let t=0,i=!0;const o=setInterval(()=>{i?(this.flashLayer.opacity-=.02,this.flashLayer.opacity<=.1&&(i=!1,t++)):(this.flashLayer.opacity+=.02,this.flashLayer.opacity>=1&&(i=!0)),t>=5&&(this.flashLayer.removeAll(),this.flashLayer.opacity=1,clearInterval(o))},10)}unselectSumo(e){if((!e||e.type==="junction")&&this.junctionLayer.graphics.forEach(t=>{(!e||!e.id||e.id===""||e.id===t.getAttribute("id"))&&t.getAttribute("selected")&&(t.setAttribute("selected",!1),t.symbol=this.getCrossGraphicSymbol(t.attributes,this.view.scale<this.junctionScale?"picture":"marker"))}),!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 o=i.getAttribute("id");this.selectedSectionIds=this.selectedSectionIds.filter(s=>s!==o)}),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 o=0;t.length===2&&(o=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")===o)),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 n=c.get(a);n?n.push(r.geometry):(n=[r.geometry],c.set(a,n))}),c.forEach((r,a)=>{const n=A.union(r),l=new f({geometry:n,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 S.Polygon({rings:[e]}),i=await this.laneLayer.queryFeatures({geometry:t,outFields:["*"]}),o=[],s=[];for(const a of i.features){const n=a.getAttribute("roadId"),l=a.getAttribute("sectionIndex"),u=`${n}#${l}`;if(o.indexOf(u)===-1){o.push(u),this.selectSumo({type:"edge",id:u});const d=`http://${this.openDriveServer}/api/sumo/getSumoEdge`,g=await b.get(d,{params:{id:`${n}+${a.getAttribute("sectionId")}`,projectName:this.projectName}});g.status===200&&g.data.status===0&&s.push(g.data.result)}}const c=this.junctionLayer.graphics.filter(a=>{const n=a.geometry;return A.contains(t,n)}),r=[];for(const a of c){const n=a.getAttribute("id");this.selectSumo({type:"junction",id:n});const l=`http://${this.openDriveServer}/api/sumo/getSumoJunction`,u=await b.get(l,{params:{id:n,projectName:this.projectName}});u.status===200&&u.data.status===0&&r.push(u.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 o=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(w=>w.getAttribute("roadId")===r&&w.getAttribute("sectionIndex")===c);if(a.length===0)return{status:-1,message:"未找到路段"};const n=a.length-o,l=a.find(w=>Math.abs(w.getAttribute("laneId"))===n);if(!l)return{status:-1,message:"未找到车道"};const u=e.start||0,d=e.end||100,g=P.lineString(l.getAttribute("leftLine")),m=G.lineSliceAlong(g,u,d,{units:"meters"}),p=P.lineString(l.getAttribute("rightLine")),h=G.lineSliceAlong(p,u,d,{units:"meters"}),y=m.geometry.coordinates.concat(h.geometry.coordinates.reverse());y.push(y[y.length-1]);const v=new f({geometry:new S.Polygon({rings:[y]}),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:m.geometry.coordinates,rightLine:h.geometry.coordinates},symbol:{type:"simple-fill",color:[255,0,0,.8],outline:{color:"red"}}});return this.splitLaneLayer.add(v),this.view.goTo(v),{status:0,message:"ok",result:{coordinates:y}}}clearSplitLane(){this.splitLaneLayer.removeAll()}updateAllJunctionSymbol(e){const t=this.junctionLayer.graphics.clone();this.junctionLayer.removeAll(),t.forEach(i=>{i.getAttribute("selected")||(i.symbol=this.getCrossGraphicSymbol(i.attributes,e))}),this.junctionLayer.addMany(t.toArray())}getCrossGraphicSymbol(e,t){const i=e.crossId!==""&&e.crossId!==void 0&&e.crossId!==null;if(t==="marker")return{type:"picture-marker",url:`/GisViewerAssets/Images/cross/${i?"gis_xhj_blue":"gis_lkcz_xz"}.png`,width:"32px",height:"32px"};if(t==="picture")return i?{type:"cim",data:{type:"CIMSymbolReference",primitiveOverrides:[{type:"CIMPrimitiveOverride",primitiveName:"textGraphic",propertyName:"TextString",valueExpressionInfo:{type:"CIMExpressionInfo",title:"Custom",expression:'Replace($feature.name, "与", "/") + " " + $feature.crossId',returnType:"Default"}}],symbol:{type:"CIMPointSymbol",symbolLayers:[{type:"CIMVectorMarker",size:32,colorLocked:!0,anchorPointUnits:"Relative",frame:{xmin:-16,ymin:-16,xmax:16,ymax:16},markerGraphics:[{type:"CIMMarkerGraphic",primitiveName:"textGraphic",geometry:{x:0,y:0},symbol:{type:"CIMTextSymbol",height:12,horizontalAlignment:"Center",offsetX:0,offsetY:i?25:15,haloSize:2,haloSymbol:{type:"CIMPolygonSymbol",symbolLayers:[{type:"CIMSolidFill",enable:!0,color:[255,255,255,255]}]},symbol:{type:"CIMPolygonSymbol",symbolLayers:[{type:"CIMSolidFill",enable:!0,color:[0,0,0,255]}]},verticalAlignment:"Center"},textString:""}],scaleSymbolsProportionally:!0,respectFrame:!0},{type:"CIMPictureMarker",enable:!0,anchorPoint:{x:0,y:0},anchorPointUnits:"Relative",size:32,rotateClockwise:!0,textureFilter:"Picture",url:"/GisViewerAssets/Images/cross/gis_xhj_blue.png"}]}}}:{type:"picture-marker",url:"/GisViewerAssets/Images/cross/gis_lkcz_xz.png",width:"32px",height:"32px"}}}exports.default=D;
|