gisviewer-vue3-arcgis 1.0.146 → 1.0.148
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/index.mjs +1 -1
- package/es/src/gis-map/utils/holo-flow/signal-holo-flow.mjs +45 -40
- package/es/src/gis-map/utils/open-drive-renderer/index.mjs +42 -45
- package/lib/src/gis-map/utils/holo-flow/index.js +1 -1
- package/lib/src/gis-map/utils/holo-flow/signal-holo-flow.js +1 -1
- package/lib/src/gis-map/utils/open-drive-renderer/index.js +1 -1
- package/package.json +1 -1
|
@@ -55,7 +55,7 @@ class n {
|
|
|
55
55
|
this.traceHoloFlow.updatePanelContent(o);
|
|
56
56
|
}
|
|
57
57
|
async handleSignalData(e) {
|
|
58
|
-
this.signalHoloFlow || (this.signalHoloFlow = new a(this.view)
|
|
58
|
+
this.signalHoloFlow || (this.signalHoloFlow = new a(this.view), await this.signalHoloFlow.initializeLayer()), await this.signalHoloFlow.handleSignalData(e);
|
|
59
59
|
}
|
|
60
60
|
clearHoloSignal() {
|
|
61
61
|
var e;
|
|
@@ -5,14 +5,19 @@ import u from "../../stores/index.mjs";
|
|
|
5
5
|
class f {
|
|
6
6
|
constructor(e) {
|
|
7
7
|
this.currentPhaseMap = /* @__PURE__ */ new Map(), this.countdownCanvasMap = /* @__PURE__ */ new Map(), this.lastDataTime = 0, this.isDeletingCanvas = !1, this.canvasWidth = 80, this.canvasHeight = 40, this.view = (e.type === "2d", e);
|
|
8
|
-
const
|
|
9
|
-
this.mapConfig = JSON.parse(JSON.stringify(
|
|
8
|
+
const t = u.useAppDataStore;
|
|
9
|
+
this.mapConfig = JSON.parse(JSON.stringify(t.mapConfig));
|
|
10
10
|
}
|
|
11
11
|
/**
|
|
12
12
|
* 初始化相位线图层
|
|
13
13
|
* */
|
|
14
14
|
async initializeLayer() {
|
|
15
|
-
|
|
15
|
+
try {
|
|
16
|
+
await this.initializePlateBackground();
|
|
17
|
+
} catch (e) {
|
|
18
|
+
console.log("倒计时背景图片加载失败", e);
|
|
19
|
+
}
|
|
20
|
+
if (this.mapConfig.phaseLineLayer)
|
|
16
21
|
if (this.phaseLineLayer)
|
|
17
22
|
this.phaseLineLayer.visible || (this.phaseLineLayer.visible = !0);
|
|
18
23
|
else {
|
|
@@ -106,22 +111,22 @@ class f {
|
|
|
106
111
|
}
|
|
107
112
|
}
|
|
108
113
|
async initializePlateBackground() {
|
|
109
|
-
return new Promise((e,
|
|
110
|
-
const
|
|
111
|
-
|
|
112
|
-
this.plateBackground =
|
|
113
|
-
},
|
|
114
|
-
|
|
114
|
+
return new Promise((e, t) => {
|
|
115
|
+
const a = new Image();
|
|
116
|
+
a.src = `${this.mapConfig.assetsRoot}/Images/timeboard/CountdownBG.png`, a.onload = () => {
|
|
117
|
+
this.plateBackground = a, e();
|
|
118
|
+
}, a.onerror = (s) => {
|
|
119
|
+
t(s);
|
|
115
120
|
};
|
|
116
121
|
});
|
|
117
122
|
}
|
|
118
123
|
async handleSignalData(e) {
|
|
119
|
-
const { crossId:
|
|
120
|
-
await this.updateCountdown(
|
|
121
|
-
|
|
124
|
+
const { crossId: t, lat: a, lon: s, rtStage: n, channelsConfig: i } = e;
|
|
125
|
+
await this.updateCountdown(t, a, s, n), !(!this.phaseLineLayer || !i) && ((!this.currentPhaseMap.has(t) || this.currentPhaseMap.get(t) !== n.stagePhase) && await this.updatePhaseLine(
|
|
126
|
+
t,
|
|
122
127
|
n.channelsConfig,
|
|
123
128
|
i
|
|
124
|
-
), this.currentPhaseMap.set(
|
|
129
|
+
), this.currentPhaseMap.set(t, n.stagePhase));
|
|
125
130
|
}
|
|
126
131
|
/**
|
|
127
132
|
* 清除实时信号相关图层
|
|
@@ -134,7 +139,7 @@ class f {
|
|
|
134
139
|
/**
|
|
135
140
|
* 获取显示倒计时的canvas
|
|
136
141
|
* */
|
|
137
|
-
async updateCountdown(e,
|
|
142
|
+
async updateCountdown(e, t, a, s) {
|
|
138
143
|
if (this.isDeletingCanvas)
|
|
139
144
|
return;
|
|
140
145
|
const n = this.countdownCanvasMap.get(e);
|
|
@@ -143,8 +148,8 @@ class f {
|
|
|
143
148
|
else
|
|
144
149
|
try {
|
|
145
150
|
const i = new c({
|
|
146
|
-
longitude:
|
|
147
|
-
latitude:
|
|
151
|
+
longitude: a,
|
|
152
|
+
latitude: t,
|
|
148
153
|
z: 10
|
|
149
154
|
}), o = this.view.toScreen(i), l = this.createCountdownCanvas();
|
|
150
155
|
if (!l)
|
|
@@ -177,19 +182,19 @@ class f {
|
|
|
177
182
|
* @param rtStage.stageAllRedTime 全红时间
|
|
178
183
|
* @param rtStage.stageYellowTime 黄灯时间
|
|
179
184
|
*/
|
|
180
|
-
drawCountdownText(e,
|
|
181
|
-
const
|
|
182
|
-
|
|
183
|
-
`${
|
|
185
|
+
drawCountdownText(e, t) {
|
|
186
|
+
const a = e.getContext("2d");
|
|
187
|
+
a.clearRect(0, 0, e.width, e.height), a.font = "24px Digital", a.textBaseline = "middle", a.textAlign = "center", a.fillStyle = t.stageRemainingTime <= t.stageAllRedTime ? "red" : t.stageRemainingTime <= t.stageAllRedTime + t.stageYellowTime ? "yellow" : "lime", a.fillText(
|
|
188
|
+
`${t.stageID} ${t.stageRemainingTime.toFixed(0)}`,
|
|
184
189
|
e.width / 2,
|
|
185
190
|
e.height / 2
|
|
186
191
|
);
|
|
187
192
|
}
|
|
188
|
-
drawCircle(e,
|
|
189
|
-
console.log(
|
|
190
|
-
const
|
|
191
|
-
|
|
192
|
-
|
|
193
|
+
drawCircle(e, t) {
|
|
194
|
+
console.log(t);
|
|
195
|
+
const a = e.getContext("2d");
|
|
196
|
+
a.clearRect(0, 0, e.width, e.height), this.ctxDraw(
|
|
197
|
+
a,
|
|
193
198
|
"lime",
|
|
194
199
|
e.width / 2,
|
|
195
200
|
e.height / 2,
|
|
@@ -198,16 +203,16 @@ class f {
|
|
|
198
203
|
-Math.PI / 2 + 2 * 0.6 * Math.PI
|
|
199
204
|
);
|
|
200
205
|
}
|
|
201
|
-
ctxDraw(e,
|
|
202
|
-
e.save, e.beginPath(), e.lineWidth = 4, e.strokeStyle =
|
|
206
|
+
ctxDraw(e, t, a, s, n, i, o) {
|
|
207
|
+
e.save, e.beginPath(), e.lineWidth = 4, e.strokeStyle = t, e.arc(a, s, n, i, o), e.stroke(), e.closePath(), e.font = "26px Digital", e.textBaseline = "middle", e.textAlign = "center", e.fillText("A", a, s), e.restore();
|
|
203
208
|
}
|
|
204
|
-
async updatePhaseLine(e,
|
|
209
|
+
async updatePhaseLine(e, t, a) {
|
|
205
210
|
const s = this.phaseLineLayer.source.filter(
|
|
206
211
|
(n) => n.getAttribute("id").includes(e)
|
|
207
212
|
);
|
|
208
213
|
s.forEach((n) => {
|
|
209
214
|
const i = n.getAttribute("id");
|
|
210
|
-
this.isLaneInChannels(i,
|
|
215
|
+
this.isLaneInChannels(i, t) ? n.setAttribute("color", "green") : this.isLaneInChannels(i, a) ? n.setAttribute("color", "red") : n.setAttribute("color", "green");
|
|
211
216
|
}), await this.phaseLineLayer.applyEdits({ updateFeatures: s });
|
|
212
217
|
}
|
|
213
218
|
/**
|
|
@@ -216,29 +221,29 @@ class f {
|
|
|
216
221
|
* @param channels 通道列表
|
|
217
222
|
* @returns
|
|
218
223
|
*/
|
|
219
|
-
isLaneInChannels(e,
|
|
220
|
-
const
|
|
221
|
-
for (let i = 0; i <
|
|
222
|
-
for (let o = 0; o <
|
|
223
|
-
const l =
|
|
224
|
+
isLaneInChannels(e, t) {
|
|
225
|
+
const a = e.split("+"), s = a[1], n = a[2];
|
|
226
|
+
for (let i = 0; i < t.length; i++)
|
|
227
|
+
for (let o = 0; o < t[i].laneSnList.length; o++) {
|
|
228
|
+
const l = t[i].laneSnList[o].toFixed(0);
|
|
224
229
|
if (s === l[0] && n === l[1])
|
|
225
230
|
return !0;
|
|
226
231
|
}
|
|
227
232
|
return !1;
|
|
228
233
|
}
|
|
229
234
|
createCountdownCanvas() {
|
|
230
|
-
if (!this.plateBackground)
|
|
231
|
-
return;
|
|
232
235
|
const e = document.createElement("canvas");
|
|
233
|
-
e.width = this.canvasWidth, e.height = this.canvasHeight, e.style.position = "absolute", e.style.transform = "translate(-50%, -50%)"
|
|
236
|
+
e.width = this.canvasWidth, e.height = this.canvasHeight, e.style.position = "absolute", e.style.transform = "translate(-50%, -50%)";
|
|
237
|
+
const t = e.getContext("2d");
|
|
238
|
+
this.plateBackground ? t.drawImage(
|
|
234
239
|
this.plateBackground,
|
|
235
240
|
0,
|
|
236
241
|
0,
|
|
237
242
|
this.canvasWidth,
|
|
238
243
|
this.canvasHeight
|
|
239
|
-
), this.view.container.appendChild(e);
|
|
240
|
-
const
|
|
241
|
-
return
|
|
244
|
+
) : (t.strokeStyle = "rgba(0, 255, 0, 1)", t.lineWidth = 1, t.strokeRect(0, 0, this.canvasWidth, this.canvasHeight), t.fillStyle = "rgba(0, 0, 0, 1)", t.fillRect(0, 0, this.canvasWidth, this.canvasHeight)), this.view.container.appendChild(e);
|
|
245
|
+
const a = document.createElement("canvas");
|
|
246
|
+
return a.width = this.canvasWidth - 10, a.height = this.canvasHeight - 10, a.style.position = "absolute", a.style.transform = "translate(-50%, -50%)", this.view.container.appendChild(a), [e, a];
|
|
242
247
|
}
|
|
243
248
|
}
|
|
244
249
|
export {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import y from "@arcgis/core/Graphic";
|
|
2
|
-
import * as
|
|
2
|
+
import * as j from "@arcgis/core/core/promiseUtils";
|
|
3
3
|
import { Polygon as S } from "@arcgis/core/geometry";
|
|
4
4
|
import * as L from "@arcgis/core/geometry/geometryEngine";
|
|
5
5
|
import k from "@arcgis/core/layers/FeatureLayer";
|
|
@@ -7,12 +7,12 @@ 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 M from "md5";
|
|
11
11
|
import O from "pako";
|
|
12
12
|
import { watch as x } from "vue";
|
|
13
13
|
import J from "../../stores/index.mjs";
|
|
14
|
-
import
|
|
15
|
-
class
|
|
14
|
+
import P from "../common-utils.mjs";
|
|
15
|
+
class F {
|
|
16
16
|
constructor(e) {
|
|
17
17
|
this.junctionNames = /* @__PURE__ */ new Map(), this.projectName = "", this.openDriveServer = "", this.currentSectionCode = "", this.currentJunctionId = "", this.view = e, this.view.popup.visibleElements = {
|
|
18
18
|
collapseButton: !1,
|
|
@@ -297,12 +297,12 @@ class $ {
|
|
|
297
297
|
]);
|
|
298
298
|
}
|
|
299
299
|
static getInstance(e) {
|
|
300
|
-
return this.instance || (this.instance = new
|
|
300
|
+
return this.instance || (this.instance = new F(e)), this.instance;
|
|
301
301
|
}
|
|
302
302
|
async makeMd5FromFile(e) {
|
|
303
303
|
try {
|
|
304
304
|
const i = await (await fetch(e)).text();
|
|
305
|
-
return { status: 0, message: "ok", result:
|
|
305
|
+
return { status: 0, message: "ok", result: M(i) };
|
|
306
306
|
} catch (t) {
|
|
307
307
|
return { status: -1, message: t.message };
|
|
308
308
|
}
|
|
@@ -313,7 +313,7 @@ class $ {
|
|
|
313
313
|
* @returns
|
|
314
314
|
*/
|
|
315
315
|
async showOpenDriveFromFile(e) {
|
|
316
|
-
var g,
|
|
316
|
+
var g, p;
|
|
317
317
|
this.openDriveClickCallback = e.selectedCallback, console.time("md5用时");
|
|
318
318
|
const t = await this.makeMd5FromFile(e.file);
|
|
319
319
|
if (t.status !== 0)
|
|
@@ -332,14 +332,14 @@ class $ {
|
|
|
332
332
|
}
|
|
333
333
|
}
|
|
334
334
|
);
|
|
335
|
-
} catch (
|
|
336
|
-
return { status: -1, message:
|
|
335
|
+
} catch (m) {
|
|
336
|
+
return { status: -1, message: m.message };
|
|
337
337
|
}
|
|
338
338
|
if (o.status !== 200)
|
|
339
339
|
return { status: -1, message: o.statusText };
|
|
340
340
|
console.time("渲染用时");
|
|
341
341
|
const s = o.data.result.geoSetting;
|
|
342
|
-
|
|
342
|
+
P.setGeoData(
|
|
343
343
|
s.geoReference,
|
|
344
344
|
s.offsetX,
|
|
345
345
|
s.offsetY
|
|
@@ -350,20 +350,16 @@ class $ {
|
|
|
350
350
|
await this.showAllLanes(
|
|
351
351
|
n,
|
|
352
352
|
((g = e.options) == null ? void 0 : g.showJunctionLane) || !1,
|
|
353
|
-
((
|
|
353
|
+
((p = e.options) == null ? void 0 : p.showRoadName) || !0
|
|
354
354
|
);
|
|
355
355
|
const h = o.data.result.junctions;
|
|
356
|
-
|
|
357
|
-
const u = F.transformPointProjection([0, 0]);
|
|
358
|
-
await this.view.goTo(u);
|
|
359
|
-
}
|
|
360
|
-
this.mouseMoveHandler || this.monitorMouseMove(), this.mouseClickHandler || this.monitorMouseClick();
|
|
356
|
+
this.showJunction(h), e.options && e.options.centerMap !== !1 && await this.view.goTo(this.allLaneGraphics), this.mouseMoveHandler || this.monitorMouseMove(), this.mouseClickHandler || this.monitorMouseClick();
|
|
361
357
|
const d = J.useAppDataStore;
|
|
362
358
|
return x(
|
|
363
359
|
() => d.isSketching,
|
|
364
360
|
() => {
|
|
365
|
-
var
|
|
366
|
-
d.isSketching ? ((
|
|
361
|
+
var m, u;
|
|
362
|
+
d.isSketching ? ((m = this.mouseMoveHandler) == null || m.remove(), this.mouseMoveHandler = void 0, (u = this.mouseClickHandler) == null || u.remove(), this.mouseClickHandler = void 0) : (this.monitorMouseMove(), this.monitorMouseClick());
|
|
367
363
|
}
|
|
368
364
|
), console.timeEnd("渲染用时"), { status: 0, message: "ok" };
|
|
369
365
|
}
|
|
@@ -404,6 +400,7 @@ class $ {
|
|
|
404
400
|
let c = 0;
|
|
405
401
|
this.allLaneGraphics = [], this.allRefLineGraphics = [];
|
|
406
402
|
const a = [];
|
|
403
|
+
console.log(e.length);
|
|
407
404
|
for (const r of e) {
|
|
408
405
|
if (!t && r.junction !== "-1")
|
|
409
406
|
continue;
|
|
@@ -421,15 +418,15 @@ class $ {
|
|
|
421
418
|
roadName: d
|
|
422
419
|
}
|
|
423
420
|
});
|
|
424
|
-
this.allRefLineGraphics.push(g), r.laneSections.sort((
|
|
425
|
-
for (let
|
|
426
|
-
const
|
|
427
|
-
for (const f of
|
|
421
|
+
this.allRefLineGraphics.push(g), r.laneSections.sort((p, m) => Number(p.id) - Number(m.id));
|
|
422
|
+
for (let p = 0; p < r.laneSections.length; p++) {
|
|
423
|
+
const m = r.laneSections[p], u = Number(m.id);
|
|
424
|
+
for (const f of m.lanePaths) {
|
|
428
425
|
const w = Number(f.id);
|
|
429
426
|
if (w === 0)
|
|
430
427
|
continue;
|
|
431
|
-
const v = f.type,
|
|
432
|
-
|
|
428
|
+
const v = f.type, $ = [...f.outerPath], N = f.innerPath.concat(
|
|
429
|
+
$.reverse()
|
|
433
430
|
);
|
|
434
431
|
if (N.length <= 3) {
|
|
435
432
|
console.warn(`lane ${w} has less than 3 points`);
|
|
@@ -440,17 +437,17 @@ class $ {
|
|
|
440
437
|
rings: [N]
|
|
441
438
|
});
|
|
442
439
|
if (A) {
|
|
443
|
-
const
|
|
440
|
+
const D = new y({
|
|
444
441
|
geometry: A,
|
|
445
442
|
attributes: {
|
|
446
443
|
ObjectID: c++,
|
|
447
|
-
id: `${n}+${
|
|
444
|
+
id: `${n}+${u}+${w}`,
|
|
448
445
|
fromNode: r.fromNode,
|
|
449
446
|
toNode: r.toNode,
|
|
450
447
|
roadId: String(n),
|
|
451
448
|
roadName: r.name,
|
|
452
|
-
sectionId: String(
|
|
453
|
-
sectionIndex:
|
|
449
|
+
sectionId: String(u),
|
|
450
|
+
sectionIndex: p,
|
|
454
451
|
laneId: w,
|
|
455
452
|
type: v,
|
|
456
453
|
sumoId: "",
|
|
@@ -459,7 +456,7 @@ class $ {
|
|
|
459
456
|
rightLine: f.outerPath
|
|
460
457
|
}
|
|
461
458
|
});
|
|
462
|
-
this.allLaneGraphics.push(
|
|
459
|
+
this.allLaneGraphics.push(D), a.push(D);
|
|
463
460
|
}
|
|
464
461
|
}
|
|
465
462
|
}
|
|
@@ -538,7 +535,7 @@ class $ {
|
|
|
538
535
|
* 监听鼠标移动事件,高亮显示鼠标所在路段和路口
|
|
539
536
|
*/
|
|
540
537
|
monitorMouseMove() {
|
|
541
|
-
const e =
|
|
538
|
+
const e = j.debounce(async (t) => {
|
|
542
539
|
var c;
|
|
543
540
|
const o = (c = (await this.view.hitTest(t, {
|
|
544
541
|
include: [this.laneLayer, this.junctionLayer]
|
|
@@ -555,15 +552,15 @@ class $ {
|
|
|
555
552
|
"roadId"
|
|
556
553
|
)}+${this.hitGraphic.getAttribute("sectionId")}`;
|
|
557
554
|
if (a === this.currentSectionCode || this.sectionLayer.graphics.findIndex(
|
|
558
|
-
(
|
|
555
|
+
(u) => u.getAttribute("id") === a
|
|
559
556
|
) >= 0)
|
|
560
557
|
return;
|
|
561
558
|
this.currentSectionCode = a;
|
|
562
559
|
const r = this.allLaneGraphics.filter(
|
|
563
|
-
(
|
|
560
|
+
(u) => `${u.attributes.roadId}+${u.attributes.sectionId}` === a
|
|
564
561
|
), n = L.union(
|
|
565
|
-
r.map((
|
|
566
|
-
), h = this.hitGraphic.getAttribute("fromNode"), d = this.hitGraphic.getAttribute("toNode"), g = this.junctionNames.get(h) || h,
|
|
562
|
+
r.map((u) => u.geometry)
|
|
563
|
+
), h = this.hitGraphic.getAttribute("fromNode"), d = this.hitGraphic.getAttribute("toNode"), g = this.junctionNames.get(h) || h, p = this.junctionNames.get(d) || d;
|
|
567
564
|
this.highlightGraphic = new y({
|
|
568
565
|
geometry: n,
|
|
569
566
|
symbol: {
|
|
@@ -580,7 +577,7 @@ class $ {
|
|
|
580
577
|
id: a,
|
|
581
578
|
selected: !1,
|
|
582
579
|
fromNodeName: g,
|
|
583
|
-
toNodeName:
|
|
580
|
+
toNodeName: p,
|
|
584
581
|
laneCount: r.length
|
|
585
582
|
},
|
|
586
583
|
popupTemplate: {
|
|
@@ -606,10 +603,10 @@ class $ {
|
|
|
606
603
|
]
|
|
607
604
|
}
|
|
608
605
|
}), this.highlightLayer.removeAll(), this.highlightLayer.add(this.highlightGraphic);
|
|
609
|
-
const
|
|
606
|
+
const m = this.view.toMap(t);
|
|
610
607
|
this.view.openPopup({
|
|
611
608
|
features: [this.highlightGraphic],
|
|
612
|
-
location:
|
|
609
|
+
location: m
|
|
613
610
|
});
|
|
614
611
|
} else if (s.layer.id === "OpenDriveJunction") {
|
|
615
612
|
const a = this.hitGraphic.getAttribute("id");
|
|
@@ -630,7 +627,7 @@ class $ {
|
|
|
630
627
|
* 监听鼠标点击事件,获取高亮要素的拓扑信息
|
|
631
628
|
*/
|
|
632
629
|
monitorMouseClick() {
|
|
633
|
-
const e =
|
|
630
|
+
const e = j.debounce(async (t) => {
|
|
634
631
|
var l;
|
|
635
632
|
const o = (l = (await this.view.hitTest(t, {
|
|
636
633
|
include: [this.highlightLayer, this.junctionLayer, this.sectionLayer]
|
|
@@ -1020,12 +1017,12 @@ class $ {
|
|
|
1020
1017
|
);
|
|
1021
1018
|
if (!n)
|
|
1022
1019
|
return { status: -1, message: "未找到车道" };
|
|
1023
|
-
const h = e.start || 0, d = e.end || 100, g = G.lineString(n.getAttribute("leftLine")),
|
|
1020
|
+
const h = e.start || 0, d = e.end || 100, g = G.lineString(n.getAttribute("leftLine")), p = C(g, h, d, {
|
|
1024
1021
|
units: "meters"
|
|
1025
|
-
}),
|
|
1022
|
+
}), m = G.lineString(n.getAttribute("rightLine")), u = C(m, h, d, {
|
|
1026
1023
|
units: "meters"
|
|
1027
|
-
}), f =
|
|
1028
|
-
|
|
1024
|
+
}), f = p.geometry.coordinates.concat(
|
|
1025
|
+
u.geometry.coordinates.reverse()
|
|
1029
1026
|
);
|
|
1030
1027
|
f.push(f[f.length - 1]);
|
|
1031
1028
|
const w = new y({
|
|
@@ -1044,8 +1041,8 @@ class $ {
|
|
|
1044
1041
|
laneId: n.getAttribute("laneId"),
|
|
1045
1042
|
type: n.getAttribute("type"),
|
|
1046
1043
|
sumoId: n.getAttribute("sumoId"),
|
|
1047
|
-
leftLine:
|
|
1048
|
-
rightLine:
|
|
1044
|
+
leftLine: p.geometry.coordinates,
|
|
1045
|
+
rightLine: u.geometry.coordinates
|
|
1049
1046
|
},
|
|
1050
1047
|
symbol: {
|
|
1051
1048
|
type: "simple-fill",
|
|
@@ -1062,5 +1059,5 @@ class $ {
|
|
|
1062
1059
|
}
|
|
1063
1060
|
}
|
|
1064
1061
|
export {
|
|
1065
|
-
|
|
1062
|
+
F as default
|
|
1066
1063
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const t=require("../../../types/index.js"),a=require("./signal-holo-flow.js"),o=require("./trace-holo-flow.js");class i{constructor(e){this.view=e}async init(){this.traceHoloFlow=new o.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 l=t.EVehiclePlateState.None;switch(e){case"none":l=t.EVehiclePlateState.None;break;case"plateNumber":l=t.EVehiclePlateState.PlateNumber;break;case"vehicleId":l=t.EVehiclePlateState.Id;break;case"mix":l=t.EVehiclePlateState.Mix;break}this.traceHoloFlow.updatePanelContent(l)}async handleSignalData(e){this.signalHoloFlow||(this.signalHoloFlow=new a.default(this.view)
|
|
1
|
+
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const t=require("../../../types/index.js"),a=require("./signal-holo-flow.js"),o=require("./trace-holo-flow.js");class i{constructor(e){this.view=e}async init(){this.traceHoloFlow=new o.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 l=t.EVehiclePlateState.None;switch(e){case"none":l=t.EVehiclePlateState.None;break;case"plateNumber":l=t.EVehiclePlateState.PlateNumber;break;case"vehicleId":l=t.EVehiclePlateState.Id;break;case"mix":l=t.EVehiclePlateState.Mix;break}this.traceHoloFlow.updatePanelContent(l)}async handleSignalData(e){this.signalHoloFlow||(this.signalHoloFlow=new a.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=i;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const d=require("@arcgis/core/core/reactiveUtils"),u=require("@arcgis/core/geometry"),p=require("@arcgis/core/layers/FeatureLayer"),g=require("../../stores/index.js");function y(
|
|
1
|
+
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const d=require("@arcgis/core/core/reactiveUtils"),u=require("@arcgis/core/geometry"),p=require("@arcgis/core/layers/FeatureLayer"),g=require("../../stores/index.js");function y(l){const e=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(l){for(const t in l)if(t!=="default"){const a=Object.getOwnPropertyDescriptor(l,t);Object.defineProperty(e,t,a.get?a:{enumerable:!0,get:()=>l[t]})}}return e.default=l,Object.freeze(e)}const w=y(d);class f{constructor(e){this.currentPhaseMap=new Map,this.countdownCanvasMap=new Map,this.lastDataTime=0,this.isDeletingCanvas=!1,this.canvasWidth=80,this.canvasHeight=40,this.view=(e.type==="2d",e);const t=g.default.useAppDataStore;this.mapConfig=JSON.parse(JSON.stringify(t.mapConfig))}async initializeLayer(){try{await this.initializePlateBackground()}catch(e){console.log("倒计时背景图片加载失败",e)}if(this.mapConfig.phaseLineLayer)if(this.phaseLineLayer)this.phaseLineLayer.visible||(this.phaseLineLayer.visible=!0);else{const e=`${this.mapConfig.assetsRoot}/${this.mapConfig.phaseLineLayer}`,s=(await(await fetch(e)).json()).features.map((n,i)=>({geometry:{type:"polyline",paths:[n.geometry.coordinates]},attributes:{ObjectID:i+1,id:n.properties.id,color:"hide"}}));this.phaseLineLayer=new p({source:s,geometryType:"polyline",objectIdField:"ObjectID",outFields:["*"],fields:[{name:"ObjectID",alias:"ObjectID",type:"oid"},{name:"color",alias:"color",type:"string"}],renderer:{type:"unique-value",field:"color",defaultSymbol:{type:"simple-line",color:"lightblue",width:"2px",style:"none"},uniqueValueInfos:[{value:"green",symbol:{type:"line-3d",symbolLayers:[{type:"path",profile:"quad",material:{color:[19,255,69,.8]},width:1,height:.5}]}},{value:"red",symbol:{type:"line-3d",symbolLayers:[{type:"path",profile:"quad",material:{color:[254,5,9,.8]},width:1,height:.5}]}},{value:"yellow",symbol:{type:"line-3d",symbolLayers:[{type:"path",profile:"quad",material:{color:[255,215,0,.8]},width:1,height:.5}]}}]}}),this.view.map.add(this.phaseLineLayer)}}async initializePlateBackground(){return new Promise((e,t)=>{const a=new Image;a.src=`${this.mapConfig.assetsRoot}/Images/timeboard/CountdownBG.png`,a.onload=()=>{this.plateBackground=a,e()},a.onerror=s=>{t(s)}})}async handleSignalData(e){const{crossId:t,lat:a,lon:s,rtStage:n,channelsConfig:i}=e;await this.updateCountdown(t,a,s,n),!(!this.phaseLineLayer||!i)&&((!this.currentPhaseMap.has(t)||this.currentPhaseMap.get(t)!==n.stagePhase)&&await this.updatePhaseLine(t,n.channelsConfig,i),this.currentPhaseMap.set(t,n.stagePhase))}clearSignal(){this.phaseLineLayer&&(this.phaseLineLayer.visible=!1),this.countdownWatchHandel&&(this.countdownWatchHandel.remove(),this.countdownWatchHandel=void 0),this.countdownCanvasMap.forEach(e=>{this.view.container.removeChild(e.backgroundCanvas),this.view.container.removeChild(e.countdownCanvas)}),this.countdownCanvasMap.clear()}async updateCountdown(e,t,a,s){if(this.isDeletingCanvas)return;const n=this.countdownCanvasMap.get(e);if(n)this.drawCountdownText(n.countdownCanvas,s);else try{const i=new u.Point({longitude:a,latitude:t,z:10}),o=this.view.toScreen(i),r=this.createCountdownCanvas();if(!r)return;const c=r[0],h=r[1];c.style.left=o.x+"px",c.style.top=o.y+"px",h.style.left=o.x+"px",h.style.top=o.y+"px",this.countdownCanvasMap.set(e,{backgroundCanvas:c,countdownCanvas:h,mapPoint:i}),this.drawCountdownText(h,s)}catch(i){console.log("倒计时canvas创建失败",e,i)}this.countdownWatchHandel||(this.countdownWatchHandel=w.watch(()=>this.view.extent,()=>{this.countdownCanvasMap.forEach(i=>{const o=this.view.toScreen(i.mapPoint);i.backgroundCanvas.style.left=o.x+"px",i.backgroundCanvas.style.top=o.y+"px",i.countdownCanvas.style.left=o.x+"px",i.countdownCanvas.style.top=o.y+"px"})}))}drawCountdownText(e,t){const a=e.getContext("2d");a.clearRect(0,0,e.width,e.height),a.font="24px Digital",a.textBaseline="middle",a.textAlign="center",a.fillStyle=t.stageRemainingTime<=t.stageAllRedTime?"red":t.stageRemainingTime<=t.stageAllRedTime+t.stageYellowTime?"yellow":"lime",a.fillText(`${t.stageID} ${t.stageRemainingTime.toFixed(0)}`,e.width/2,e.height/2)}drawCircle(e,t){console.log(t);const a=e.getContext("2d");a.clearRect(0,0,e.width,e.height),this.ctxDraw(a,"lime",e.width/2,e.height/2,20,-Math.PI/2,-Math.PI/2+2*.6*Math.PI)}ctxDraw(e,t,a,s,n,i,o){e.save,e.beginPath(),e.lineWidth=4,e.strokeStyle=t,e.arc(a,s,n,i,o),e.stroke(),e.closePath(),e.font="26px Digital",e.textBaseline="middle",e.textAlign="center",e.fillText("A",a,s),e.restore()}async updatePhaseLine(e,t,a){const s=this.phaseLineLayer.source.filter(n=>n.getAttribute("id").includes(e));s.forEach(n=>{const i=n.getAttribute("id");this.isLaneInChannels(i,t)?n.setAttribute("color","green"):this.isLaneInChannels(i,a)?n.setAttribute("color","red"):n.setAttribute("color","green")}),await this.phaseLineLayer.applyEdits({updateFeatures:s})}isLaneInChannels(e,t){const a=e.split("+"),s=a[1],n=a[2];for(let i=0;i<t.length;i++)for(let o=0;o<t[i].laneSnList.length;o++){const r=t[i].laneSnList[o].toFixed(0);if(s===r[0]&&n===r[1])return!0}return!1}createCountdownCanvas(){const e=document.createElement("canvas");e.width=this.canvasWidth,e.height=this.canvasHeight,e.style.position="absolute",e.style.transform="translate(-50%, -50%)";const t=e.getContext("2d");this.plateBackground?t.drawImage(this.plateBackground,0,0,this.canvasWidth,this.canvasHeight):(t.strokeStyle="rgba(0, 255, 0, 1)",t.lineWidth=1,t.strokeRect(0,0,this.canvasWidth,this.canvasHeight),t.fillStyle="rgba(0, 0, 0, 1)",t.fillRect(0,0,this.canvasWidth,this.canvasHeight)),this.view.container.appendChild(e);const a=document.createElement("canvas");return a.width=this.canvasWidth-10,a.height=this.canvasHeight-10,a.style.position="absolute",a.style.transform="translate(-50%, -50%)",this.view.container.appendChild(a),[e,a]}}exports.default=f;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const y=require("@arcgis/core/Graphic"),J=require("@arcgis/core/core/promiseUtils"),A=require("@arcgis/core/geometry"),q=require("@arcgis/core/geometry/geometryEngine"),C=require("@arcgis/core/layers/FeatureLayer"),I=require("@arcgis/core/layers/GraphicsLayer"),T=require("@turf/helpers"),O=require("@turf/line-slice-along"),b=require("axios"),E=require("md5"),F=require("pako"),R=require("vue"),_=require("../../stores/index.js"),M=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 $=j(J),S=j(q),P=j(T);class D{constructor(e){this.junctionNames=new Map,this.projectName="",this.openDriveServer="",this.currentSectionCode="",this.currentJunctionId="",this.view=e,this.view.popup.visibleElements={collapseButton:!1,actionBar:!1},this.laneLayer=new C({id:"OpenDriveLane",fields:[{name:"ObjectID",alias:"ObjectID",type:"oid"},{name:"id",alias:"编号",type:"string"},{name:"roadId",alias:"道路号",type:"string"},{name:"roadName",alias:"道路名称",type:"string"},{name:"sectionId",alias:"路段号",type:"string"},{name:"laneId",alias:"车道号",type:"string"},{name:"type",alias:"类型",type:"string"},{name:"sumoId",alias:"sumo编号",type:"string"},{name:"fromNode",alias:"起点路口",type:"string"},{name:"toNode",alias:"终点路口",type:"string"}],objectIdField:"ObjectID",geometryType:"polygon",spatialReference:{wkid:4326},source:[],outFields:["*"],renderer:{type:"unique-value",field:"type",defaultSymbol:{type:"simple-fill",color:[100,100,100],style:"solid",outline:{color:"white",width:1}},uniqueValueInfos:[{value:"shoulder",label:"路肩",symbol:{type:"simple-fill",color:"#008000",style:"solid",outline:{color:"white",width:1}}},{value:"border",label:"路沿",symbol:{type:"simple-fill",color:"#DCDCDC",style:"solid",outline:{color:"white",width:1}}},{value:"driving",label:"机动车道",symbol:{type:"simple-fill",color:[47,79,79,.8],style:"solid",outline:{color:"white",width:1}}},{value:"none",label:"无",symbol:{type:"simple-fill",color:[111,120,135],style:"none",outline:{color:"white",width:1}}},{value:"restricted",label:"禁行区",symbol:{type:"simple-fill",color:"yellow",style:"solid",outline:{color:"yellow",width:2}}},{value:"parking",label:"停车区",symbol:{type:"simple-fill",color:[115,115,115],style:"solid",outline:{color:"white",width:1}}},{value:"median",label:"中央隔离带",symbol:{type:"simple-fill",color:"#008000",style:"solid",outline:{color:"white",width:1}}},{value:"biking",label:"非机动车道",symbol:{type:"simple-fill",color:"#D3D3D3",style:"solid",outline:{color:"white",width:1}}},{value:"sidewalk",label:"人行道",symbol:{type:"simple-fill",color:"#C0C0C0",style:"solid",outline:{color:"white",width:1}}},{value:"junction",label:"路口区域",symbol:{type:"simple-fill",color:"#2F4F4F",style:"solid",outline:{color:"white",width:1}}},{value:"selected",label:"选中车道",symbol:{type:"simple-fill",color:[141,168,211],style:"solid",outline:{color:"white",width:1}}}]}}),this.roadNameLayer=new C({id:"OpenDriveRoadName",fields:[{name:"ObjectID",alias:"ObjectID",type:"oid"},{name:"roadId",alias:"道路号",type:"string"},{name:"roadName",alias:"道路名称",type:"string"}],objectIdField:"ObjectID",geometryType:"polyline",spatialReference:{wkid:4326},source:[],renderer:{type:"simple",symbol:{type:"simple-line",style:"solid",color:[0,0,0,0],width:1}},labelingInfo:[{symbol:{type:"text",color:"black",haloColor:"white",haloSize:1,font:{size:12,family:"sans-serif"}},labelPlacement:this.view.type==="2d"?"center-along":void 0,labelExpressionInfo:{expression:"$feature.roadName"}}]}),this.junctionLayer=new I({id:"OpenDriveJunction"}),this.sectionLayer=new I({id:"OpenDriveSection"}),this.highlightLayer=new I({id:"OpenDriveHighlight"}),this.flashLayer=new I({id:"OpenDriveFlash"}),this.drawLayer=new I({id:"Draw"}),this.splitLaneLayer=new I({id:"SplitLane"}),this.view.map.addMany([this.laneLayer,this.junctionLayer,this.sectionLayer,this.roadNameLayer,this.highlightLayer,this.flashLayer,this.drawLayer,this.splitLaneLayer])}static getInstance(e){return this.instance||(this.instance=new D(e)),this.instance}async makeMd5FromFile(e){try{const i=await(await fetch(e)).text();return{status:0,message:"ok",result:E(i)}}catch(t){return{status:-1,message:t.message}}}async showOpenDriveFromFile(e){var g,m;this.openDriveClickCallback=e.selectedCallback,console.time("md5用时");const t=await this.makeMd5FromFile(e.file);if(t.status!==0)return t;this.projectName=t.result,console.timeEnd("md5用时"),this.openDriveServer=e.server,await this.makeMd5FromFile(e.file);const i=`http://${this.openDriveServer}/api/openDrive/uploadXodr`;let o;try{o=await b.post(i,{},{params:{url:e.file,projectName:this.projectName}})}catch(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;M.default.setGeoData(s.geoReference,s.offsetX,s.offsetY);let c=o.data.result.json;c.startsWith(window.location.protocol)||(c=`${window.location.protocol}//${e.server}${c}`);const l=await(await fetch(c)).arrayBuffer(),n=F.inflate(l,{to:"string"}),r=JSON.parse(n);await this.showAllLanes(r,((g=e.options)==null?void 0:g.showJunctionLane)||!1,((m=e.options)==null?void 0:m.showRoadName)||!0);const d=o.data.result.junctions;if(this.showJunction(d),e.options&&e.options.centerMap!==!1){const h=M.default.transformPointProjection([0,0]);await this.view.goTo(h)}this.mouseMoveHandler||this.monitorMouseMove(),this.mouseClickHandler||this.monitorMouseClick();const u=_.default.useAppDataStore;return R.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 a=await(await fetch(s)).arrayBuffer(),l=F.inflate(a,{to:"string"}),n=JSON.parse(l);return await this.showAllLanes(n,!1,!1),{status:0,message:"ok"}}async showAllLanes(e,t,i){const o=await this.laneLayer.queryFeatures();return o.features.length>0&&this.laneLayer.applyEdits({deleteFeatures:o.features}),this.roadNameLayer.visible=i,new Promise(s=>{let c=0;this.allLaneGraphics=[],this.allRefLineGraphics=[];const a=[];for(const n of e){if(!t&&n.junction!=="-1")continue;const{id:r,refLine:d}=n;let u=n.name;u.includes("(")&&(u=u.slice(0,u.indexOf("("))),u=u.replace(/(.)/g,"$1 ");const g=new y({geometry:{type:"polyline",paths:[d]},attributes:{ObjectID:c++,roadId:r,roadName:u}});this.allRefLineGraphics.push(g),n.laneSections.sort((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 f of h.lanePaths){const w=Number(f.id);if(w===0)continue;const v=f.type,x=[...f.outerPath],N=f.innerPath.concat(x.reverse());if(N.length<=3){console.warn(`lane ${w} has less than 3 points`);continue}N.push(f.innerPath[0]);const k=new A.Polygon({rings:[N]});if(k){const G=new y({geometry:k,attributes:{ObjectID:c++,id:`${r}+${p}+${w}`,fromNode:n.fromNode,toNode:n.toNode,roadId:String(r),roadName:n.name,sectionId:String(p),sectionIndex:m,laneId:w,type:v,sumoId:"",leftLine:f.innerPath,rightLine:f.outerPath}});this.allLaneGraphics.push(G),a.push(G)}}}}const l=setInterval(()=>{if(a.length>0||this.allRefLineGraphics.length>0){if(a.length>0){const n=a.splice(0,100);this.laneLayer.applyEdits({addFeatures:n})}if(this.allRefLineGraphics.length>0){const n=this.allRefLineGraphics.splice(0,10);this.roadNameLayer.applyEdits({addFeatures:n})}}else clearInterval(l),s()},10)})}showJunction(e){const t=[];for(const i of e){if(!i)continue;this.junctionNames.set(i.id,i.name),i.nodeType=i.type;const o=new y({geometry:{type:"point",x:i.coordinates[0],y:i.coordinates[1]},attributes:{...i,selected:!1,type:"OpenDriveJunction"},symbol:{type:"picture-marker",url:i.crossId?"/GisViewerAssets/Images/point_green.png":"/GisViewerAssets/Images/point_yellow.png",width:30,height:30},popupTemplate:{title:i.name,content:[{type:"fields",fieldInfos:[{fieldName:"id",label:"路口编号"},{fieldName:"crossId",label:"信号机编号"}]}]}});t.push(o)}this.junctionLayer.addMany(t)}monitorMouseMove(){const e=$.debounce(async t=>{var c;const o=(c=(await this.view.hitTest(t,{include:[this.laneLayer,this.junctionLayer]})).results)==null?void 0:c.filter(a=>a.type==="graphic");if(o.length===0){this.currentSectionCode!==""&&(this.currentSectionCode="",this.highlightGraphic=void 0,this.highlightLayer.removeAll()),this.currentJunctionId!==""&&(this.currentJunctionId="",this.view.closePopup());return}const s=o[0];if(this.hitGraphic=s.graphic,s.layer.id==="OpenDriveLane"){const a=`${this.hitGraphic.getAttribute("roadId")}+${this.hitGraphic.getAttribute("sectionId")}`;if(a===this.currentSectionCode||this.sectionLayer.graphics.findIndex(p=>p.getAttribute("id")===a)>=0)return;this.currentSectionCode=a;const n=this.allLaneGraphics.filter(p=>`${p.attributes.roadId}+${p.attributes.sectionId}`===a),r=S.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;this.highlightGraphic=new y({geometry:r,symbol:{type:"simple-fill",color:[0,255,255,.5],style:"solid",outline:{color:[0,255,255],width:1}},attributes:{type:"OpenDriveSection",id:a,selected:!1,fromNodeName:g,toNodeName: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(this.highlightGraphic);const h=this.view.toMap(t);this.view.openPopup({features:[this.highlightGraphic],location:h})}else if(s.layer.id==="OpenDriveJunction"){const a=this.hitGraphic.getAttribute("id");if(a===this.currentJunctionId)return;this.currentJunctionId=a,this.view.openPopup({features:[this.hitGraphic],location:this.hitGraphic.geometry})}});this.mouseMoveHandler=this.view.on("pointer-move",async t=>{e(t).catch(()=>{})})}monitorMouseClick(){const e=$.debounce(async t=>{var l;const o=(l=(await this.view.hitTest(t,{include:[this.highlightLayer,this.junctionLayer,this.sectionLayer]})).results)==null?void 0:l.filter(n=>n.type==="graphic");if(o.length===0)return;const s=o[0].graphic,c=s.getAttribute("type"),a=s.getAttribute("id");if(c==="OpenDriveJunction")if(s.getAttribute("selected")===!1){const n=`http://${this.openDriveServer}/api/sumo/getSumoJunction`,r=await b.get(n,{params:{id:a,projectName:this.projectName}});r.status===200&&r.data.status===0&&(this.openDriveClickCallback&&this.openDriveClickCallback({type:"OpenDriveJunction",id:a,details:r.data.result}),s.setAttribute("selected",!0),s.symbol.url="/GisViewerAssets/Images/point_red.png",this.increasePictureMarkerSize(s,50))}else{this.openDriveClickCallback&&this.openDriveClickCallback({type:"OpenDriveJunction",id:a,details:void 0}),s.setAttribute("selected",!1);const n=s.getAttribute("crossId");s.symbol.url=n?"/GisViewerAssets/Images/point_green.png":"/GisViewerAssets/Images/point_yellow.png",this.decreasePictureMarkerSize(s,30)}else if(c==="OpenDriveSection")if(s.getAttribute("selected"))this.sectionLayer.remove(s),this.openDriveClickCallback&&this.openDriveClickCallback({type:"OpenDriveSection",id:a,details:void 0});else{this.highlightLayer.remove(s),this.sectionLayer.add(s),s.setAttribute("selected",!0);const n=`http://${this.openDriveServer}/api/sumo/getSumoEdge`,r=await b.get(n,{params:{id:a,projectName:this.projectName}});r.status===200&&r.data.status===0&&this.openDriveClickCallback&&(s.setAttribute("edgeId",r.data.result.obj_id),this.openDriveClickCallback({type:"OpenDriveSection",id:a,details:r.data.result}))}});this.mouseClickHandler=this.view.on("immediate-click",async t=>{e(t).catch(()=>{})})}increasePictureMarkerSize(e,t){const i=setInterval(()=>{const o=e.symbol,s=o.width;s<t?e.symbol={type:"picture-marker",url:o.url,width:s+1,height:s+1}:clearInterval(i)},20)}decreasePictureMarkerSize(e,t){const i=setInterval(()=>{const o=e.symbol,s=o.width;s>t?e.symbol={type:"picture-marker",url:o.url,width:s-1,height:s-1}:clearInterval(i)},20)}async getSumoInfo(e){switch(e.type){case"junction":{const t=`http://${this.openDriveServer}/api/sumo/getSumoJunction`,i=await b.get(t,{params:{id:e.id,projectName:this.projectName}});return i.status===200?i.data:{status:-1,message:`路口信息查询失败: ${e.id}`}}case"edge":{const t=e.id.split("#");let i=t[0];i.startsWith("-")&&(i=i.slice(1));let o=0;t.length===2&&(o=Number(t[1]));const s=this.allLaneGraphics.find(c=>c.getAttribute("roadId")===i&&c.getAttribute("sectionIndex")===o);if(s){const c=`${i}+${s.getAttribute("sectionId")}`,a=`http://${this.openDriveServer}/api/sumo/getSumoEdge`,l=await b.get(a,{params:{id:c,projectName:this.projectName}});return l.status===200?l.data:{status:-1,message:`路段信息查询失败: ${c}`}}else return{status:-1,message:"未知类型"}}default:return{status:-1,message:"未知类型"}}}async clearOpenDrive(){var t,i;let e=await this.laneLayer.queryFeatures();e.features.length>0&&await this.laneLayer.applyEdits({deleteFeatures:e.features}),e=await this.roadNameLayer.queryFeatures(),e.features.length>0&&await this.roadNameLayer.applyEdits({deleteFeatures:e.features}),this.highlightLayer.removeAll(),this.junctionLayer.removeAll(),this.sectionLayer.removeAll(),this.flashLayer.removeAll(),(t=this.mouseMoveHandler)==null||t.remove(),this.mouseMoveHandler=void 0,(i=this.mouseClickHandler)==null||i.remove(),this.mouseClickHandler=void 0}async findSumo(e){const{type:t,id:i}=e,o=e.flash===void 0?!0:e.flash;if(t==="junction")return await this.findJunction(i,o);if(t==="edge"){const s=i.split("_");if(s.length>2)return{status:-1,message:"id格式错误"};const c=s.length===2?Number(s[1]):void 0,a=s[0].split("#");if(a.length>2)return{status:-1,message:"id格式错误"};const l=a[0],n=a.length===2?Number(a[1]):void 0;return await this.findLane({roadsectId:l,segmentId:n,laneId:c,flash:o})}else return{status:-1,message:"未知类型"}}async findJunction(e,t){const i=this.junctionLayer.graphics.find(o=>o.attributes.id===e);if(!i)return{status:-1,message:"未找到。请检查路口编号"};if(t){const o=new y({geometry:i.geometry,symbol:{type:"simple-marker",style:"circle",size:30,color:[255,0,0,.6],outline:{color:"red",width:1}}});this.flashGraphic(o)}return await this.view.goTo(i.geometry,{duration:1e3}),{status:0,message:"ok"}}async findLane(e){let{roadsectId:t,segmentId:i,laneId:o}=e;t.startsWith("-")&&(t=t.slice(1));let s=this.allLaneGraphics.filter(l=>l.attributes.roadId===t);if(s.length===0)return{status:-1,message:"未找到。请检查路段编号"};if(i!==void 0){const l=[];if(s.forEach(n=>{const r=Number(n.attributes.sectionId);l.indexOf(r)===-1&&l.push(r)}),l.sort((n,r)=>n-r),i>l.length-1)return{status:-1,message:"未找到。请检查基本段编号"};i=l[i],s=s.filter(n=>Number(n.attributes.sectionId)===i)}if(o!==void 0){const l=[];if(s.forEach(n=>{const r=Number(n.attributes.laneId);l.indexOf(r)===-1&&l.push(r)}),l.sort((n,r)=>n-r),o>l.length-1)return{status:-1,message:"未找到。请检查车道编号"};o=l[o],s=s.filter(n=>Number(n.attributes.laneId)===o)}const c=s.map(l=>l.geometry),a=S.union(c);if(e.flash){const l=new y({geometry:a,symbol:{type:"simple-fill",color:[255,0,0,.5],style:"solid",outline:{color:"red",width:0}}});this.flashGraphic(l)}return await this.view.goTo(a,{duration:1e3}),{status:0,message:"ok"}}flashGraphic(e){this.flashLayer.removeAll(),this.flashLayer.add(e);let t=0,i=!0;const o=setInterval(()=>{i?(this.flashLayer.opacity-=.02,this.flashLayer.opacity<=.1&&(i=!1,t++)):(this.flashLayer.opacity+=.02,this.flashLayer.opacity>=1&&(i=!0)),t>=5&&(this.flashLayer.removeAll(),this.flashLayer.opacity=1,clearInterval(o))},10)}unselectSumo(e){if((!e||e.type==="junction")&&this.junctionLayer.graphics.forEach(t=>{if((!e||!e.id||e.id===""||e.id===t.getAttribute("id"))&&t.getAttribute("selected")){t.setAttribute("selected",!1);const i=t.getAttribute("crossId");t.symbol.url=i?"/GisViewerAssets/Images/point_green.png":"/GisViewerAssets/Images/point_yellow.png",this.decreasePictureMarkerSize(t,30)}}),!e||e.type==="edge")if(!e||!e.id||e.id==="")this.sectionLayer.removeAll();else{const t=this.sectionLayer.graphics.find(i=>i.getAttribute("edgeId")===e.id);t&&this.sectionLayer.remove(t)}return{status:0,message:"ok"}}selectSumo(e){switch(e.type){case"junction":return this.junctionLayer.graphics.forEach(t=>{if(e.id===t.getAttribute("id"))return t.setAttribute("selected",!0),t.symbol.url="/GisViewerAssets/Images/point_red.png",this.increasePictureMarkerSize(t,50),{status:0,message:"ok"}}),{status:-1,message:"未找到路口"};case"edge":{const t=e.id.split("#");let i=String(t[0]);i.startsWith("-")&&(i=i.slice(1));let o="0";t.length===2&&(o=String(t[1]));let s=[];if(t.length===1?s=this.allLaneGraphics.filter(c=>c.getAttribute("roadId")===i):t.length===2&&(s=this.allLaneGraphics.filter(c=>c.getAttribute("roadId")===i&&c.getAttribute("sectionId")===o)),s.length>0){const c=S.union(s.map(l=>l.geometry)),a=new y({geometry:c,symbol:{type:"simple-fill",color:[0,255,255,.5],style:"solid",outline:{color:[0,255,255],width:1}},attributes:{type:"OpenDriveSection",edgeId:e.id,selected:!0}});return this.sectionLayer.add(a),{status:0,message:"ok"}}else return{status:-1,message:"未找到路段"}}default:return{status:-1,message:"未知类型"}}}async geometrySearch(e){const t=new A.Polygon({rings:[e]}),i=await this.laneLayer.queryFeatures({geometry:t,outFields:["*"]}),o=[],s=[];for(const l of i.features){const n=l.getAttribute("roadId"),r=l.getAttribute("sectionId"),d=`${n}#${r}`;if(o.indexOf(d)===-1){o.push(d),this.selectSumo({type:"edge",id:d});const u=`http://${this.openDriveServer}/api/sumo/getSumoEdge`,g=await b.get(u,{params:{id:`${n}+${r}`,projectName:this.projectName}});g.status===200&&g.data.status===0&&s.push(g.data.result)}}const c=this.junctionLayer.graphics.filter(l=>{const n=l.geometry;return S.contains(t,n)}),a=[];for(const l of c){const n=l.getAttribute("id");this.selectSumo({type:"junction",id:n});const r=`http://${this.openDriveServer}/api/sumo/getSumoJunction`,d=await b.get(r,{params:{id:n,projectName:this.projectName}});d.status===200&&d.data.status===0&&a.push(d.data.result)}return{status:0,message:"ok",result:{junctions:a,edges:s}}}async splitLane(e){const i=e.id.split("_");if(i.length!==2)return{status:-1,message:"车道编号格式错误"};const o=Number(i[1]),s=i[0].split("#"),c=s.length===2?Number(s[1]):0;let a=s[0];a.startsWith("-")&&(a=a.slice(1));const l=this.allLaneGraphics.filter(v=>v.getAttribute("roadId")===a&&v.getAttribute("sectionIndex")===c);if(l.length===0)return{status:-1,message:"未找到路段"};const n=l.length-o,r=l.find(v=>Math.abs(v.getAttribute("laneId"))===n);if(!r)return{status:-1,message:"未找到车道"};const d=e.start||0,u=e.end||100,g=P.lineString(r.getAttribute("leftLine")),m=O.lineSliceAlong(g,d,u,{units:"meters"}),h=P.lineString(r.getAttribute("rightLine")),p=O.lineSliceAlong(h,d,u,{units:"meters"}),f=m.geometry.coordinates.concat(p.geometry.coordinates.reverse());f.push(f[f.length-1]);const w=new y({geometry:new A.Polygon({rings:[f]}),attributes:{ObjectID:r.getAttribute("ObjectID"),id:r.getAttribute("id"),fromNode:r.getAttribute("fromNode"),toNode:r.getAttribute("toNode"),roadId:r.getAttribute("roadId"),roadName:r.getAttribute("roadName"),sectionId:r.getAttribute("sectionId"),sectionIndex:r.getAttribute("sectionIndex"),laneId:r.getAttribute("laneId"),type:r.getAttribute("type"),sumoId:r.getAttribute("sumoId"),leftLine:m.geometry.coordinates,rightLine:p.geometry.coordinates},symbol:{type:"simple-fill",color:[255,0,0,.8],outline:{color:"red"}}});return this.splitLaneLayer.add(w),this.view.goTo(w),{status:0,message:"ok",result:e}}clearSplitLane(){this.splitLaneLayer.removeAll()}}exports.default=D;
|
|
1
|
+
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const y=require("@arcgis/core/Graphic"),x=require("@arcgis/core/core/promiseUtils"),A=require("@arcgis/core/geometry"),J=require("@arcgis/core/geometry/geometryEngine"),C=require("@arcgis/core/layers/FeatureLayer"),I=require("@arcgis/core/layers/GraphicsLayer"),q=require("@turf/helpers"),O=require("@turf/line-slice-along"),b=require("axios"),T=require("md5"),F=require("pako"),E=require("vue"),R=require("../../stores/index.js"),_=require("../common-utils.js");function j(L){const e=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(L){for(const t in L)if(t!=="default"){const i=Object.getOwnPropertyDescriptor(L,t);Object.defineProperty(e,t,i.get?i:{enumerable:!0,get:()=>L[t]})}}return e.default=L,Object.freeze(e)}const M=j(x),S=j(J),$=j(q);class D{constructor(e){this.junctionNames=new Map,this.projectName="",this.openDriveServer="",this.currentSectionCode="",this.currentJunctionId="",this.view=e,this.view.popup.visibleElements={collapseButton:!1,actionBar:!1},this.laneLayer=new C({id:"OpenDriveLane",fields:[{name:"ObjectID",alias:"ObjectID",type:"oid"},{name:"id",alias:"编号",type:"string"},{name:"roadId",alias:"道路号",type:"string"},{name:"roadName",alias:"道路名称",type:"string"},{name:"sectionId",alias:"路段号",type:"string"},{name:"laneId",alias:"车道号",type:"string"},{name:"type",alias:"类型",type:"string"},{name:"sumoId",alias:"sumo编号",type:"string"},{name:"fromNode",alias:"起点路口",type:"string"},{name:"toNode",alias:"终点路口",type:"string"}],objectIdField:"ObjectID",geometryType:"polygon",spatialReference:{wkid:4326},source:[],outFields:["*"],renderer:{type:"unique-value",field:"type",defaultSymbol:{type:"simple-fill",color:[100,100,100],style:"solid",outline:{color:"white",width:1}},uniqueValueInfos:[{value:"shoulder",label:"路肩",symbol:{type:"simple-fill",color:"#008000",style:"solid",outline:{color:"white",width:1}}},{value:"border",label:"路沿",symbol:{type:"simple-fill",color:"#DCDCDC",style:"solid",outline:{color:"white",width:1}}},{value:"driving",label:"机动车道",symbol:{type:"simple-fill",color:[47,79,79,.8],style:"solid",outline:{color:"white",width:1}}},{value:"none",label:"无",symbol:{type:"simple-fill",color:[111,120,135],style:"none",outline:{color:"white",width:1}}},{value:"restricted",label:"禁行区",symbol:{type:"simple-fill",color:"yellow",style:"solid",outline:{color:"yellow",width:2}}},{value:"parking",label:"停车区",symbol:{type:"simple-fill",color:[115,115,115],style:"solid",outline:{color:"white",width:1}}},{value:"median",label:"中央隔离带",symbol:{type:"simple-fill",color:"#008000",style:"solid",outline:{color:"white",width:1}}},{value:"biking",label:"非机动车道",symbol:{type:"simple-fill",color:"#D3D3D3",style:"solid",outline:{color:"white",width:1}}},{value:"sidewalk",label:"人行道",symbol:{type:"simple-fill",color:"#C0C0C0",style:"solid",outline:{color:"white",width:1}}},{value:"junction",label:"路口区域",symbol:{type:"simple-fill",color:"#2F4F4F",style:"solid",outline:{color:"white",width:1}}},{value:"selected",label:"选中车道",symbol:{type:"simple-fill",color:[141,168,211],style:"solid",outline:{color:"white",width:1}}}]}}),this.roadNameLayer=new C({id:"OpenDriveRoadName",fields:[{name:"ObjectID",alias:"ObjectID",type:"oid"},{name:"roadId",alias:"道路号",type:"string"},{name:"roadName",alias:"道路名称",type:"string"}],objectIdField:"ObjectID",geometryType:"polyline",spatialReference:{wkid:4326},source:[],renderer:{type:"simple",symbol:{type:"simple-line",style:"solid",color:[0,0,0,0],width:1}},labelingInfo:[{symbol:{type:"text",color:"black",haloColor:"white",haloSize:1,font:{size:12,family:"sans-serif"}},labelPlacement:this.view.type==="2d"?"center-along":void 0,labelExpressionInfo:{expression:"$feature.roadName"}}]}),this.junctionLayer=new I({id:"OpenDriveJunction"}),this.sectionLayer=new I({id:"OpenDriveSection"}),this.highlightLayer=new I({id:"OpenDriveHighlight"}),this.flashLayer=new I({id:"OpenDriveFlash"}),this.drawLayer=new I({id:"Draw"}),this.splitLaneLayer=new I({id:"SplitLane"}),this.view.map.addMany([this.laneLayer,this.junctionLayer,this.sectionLayer,this.roadNameLayer,this.highlightLayer,this.flashLayer,this.drawLayer,this.splitLaneLayer])}static getInstance(e){return this.instance||(this.instance=new D(e)),this.instance}async makeMd5FromFile(e){try{const i=await(await fetch(e)).text();return{status:0,message:"ok",result:T(i)}}catch(t){return{status:-1,message:t.message}}}async showOpenDriveFromFile(e){var g,p;this.openDriveClickCallback=e.selectedCallback,console.time("md5用时");const t=await this.makeMd5FromFile(e.file);if(t.status!==0)return t;this.projectName=t.result,console.timeEnd("md5用时"),this.openDriveServer=e.server,await this.makeMd5FromFile(e.file);const i=`http://${this.openDriveServer}/api/openDrive/uploadXodr`;let o;try{o=await b.post(i,{},{params:{url:e.file,projectName:this.projectName}})}catch(m){return{status:-1,message:m.message}}if(o.status!==200)return{status:-1,message:o.statusText};console.time("渲染用时");const s=o.data.result.geoSetting;_.default.setGeoData(s.geoReference,s.offsetX,s.offsetY);let c=o.data.result.json;c.startsWith(window.location.protocol)||(c=`${window.location.protocol}//${e.server}${c}`);const l=await(await fetch(c)).arrayBuffer(),n=F.inflate(l,{to:"string"}),r=JSON.parse(n);await this.showAllLanes(r,((g=e.options)==null?void 0:g.showJunctionLane)||!1,((p=e.options)==null?void 0:p.showRoadName)||!0);const d=o.data.result.junctions;this.showJunction(d),e.options&&e.options.centerMap!==!1&&await this.view.goTo(this.allLaneGraphics),this.mouseMoveHandler||this.monitorMouseMove(),this.mouseClickHandler||this.monitorMouseClick();const u=R.default.useAppDataStore;return E.watch(()=>u.isSketching,()=>{var m,h;u.isSketching?((m=this.mouseMoveHandler)==null||m.remove(),this.mouseMoveHandler=void 0,(h=this.mouseClickHandler)==null||h.remove(),this.mouseClickHandler=void 0):(this.monitorMouseMove(),this.monitorMouseClick())}),console.timeEnd("渲染用时"),{status:0,message:"ok"}}async showOpenDriveFromServer(e,t){const i=`http://${e}/api/openDrive/analyzeXodr`,o=await b.get(i,{headers:{projectName:t},params:{analyze:!1,compressed:!0}});if(o.status!==200)throw new Error(`OpenDriveRenderer: ${o.statusText}`);let s=o.data.result.json;s.startsWith(window.location.protocol)||(s=`${window.location.protocol}//${e}${s}`);const a=await(await fetch(s)).arrayBuffer(),l=F.inflate(a,{to:"string"}),n=JSON.parse(l);return await this.showAllLanes(n,!1,!1),{status:0,message:"ok"}}async showAllLanes(e,t,i){const o=await this.laneLayer.queryFeatures();return o.features.length>0&&this.laneLayer.applyEdits({deleteFeatures:o.features}),this.roadNameLayer.visible=i,new Promise(s=>{let c=0;this.allLaneGraphics=[],this.allRefLineGraphics=[];const a=[];console.log(e.length);for(const n of e){if(!t&&n.junction!=="-1")continue;const{id:r,refLine:d}=n;let u=n.name;u.includes("(")&&(u=u.slice(0,u.indexOf("("))),u=u.replace(/(.)/g,"$1 ");const g=new y({geometry:{type:"polyline",paths:[d]},attributes:{ObjectID:c++,roadId:r,roadName:u}});this.allRefLineGraphics.push(g),n.laneSections.sort((p,m)=>Number(p.id)-Number(m.id));for(let p=0;p<n.laneSections.length;p++){const m=n.laneSections[p],h=Number(m.id);for(const f of m.lanePaths){const w=Number(f.id);if(w===0)continue;const v=f.type,P=[...f.outerPath],N=f.innerPath.concat(P.reverse());if(N.length<=3){console.warn(`lane ${w} has less than 3 points`);continue}N.push(f.innerPath[0]);const k=new A.Polygon({rings:[N]});if(k){const G=new y({geometry:k,attributes:{ObjectID:c++,id:`${r}+${h}+${w}`,fromNode:n.fromNode,toNode:n.toNode,roadId:String(r),roadName:n.name,sectionId:String(h),sectionIndex:p,laneId:w,type:v,sumoId:"",leftLine:f.innerPath,rightLine:f.outerPath}});this.allLaneGraphics.push(G),a.push(G)}}}}const l=setInterval(()=>{if(a.length>0||this.allRefLineGraphics.length>0){if(a.length>0){const n=a.splice(0,100);this.laneLayer.applyEdits({addFeatures:n})}if(this.allRefLineGraphics.length>0){const n=this.allRefLineGraphics.splice(0,10);this.roadNameLayer.applyEdits({addFeatures:n})}}else clearInterval(l),s()},10)})}showJunction(e){const t=[];for(const i of e){if(!i)continue;this.junctionNames.set(i.id,i.name),i.nodeType=i.type;const o=new y({geometry:{type:"point",x:i.coordinates[0],y:i.coordinates[1]},attributes:{...i,selected:!1,type:"OpenDriveJunction"},symbol:{type:"picture-marker",url:i.crossId?"/GisViewerAssets/Images/point_green.png":"/GisViewerAssets/Images/point_yellow.png",width:30,height:30},popupTemplate:{title:i.name,content:[{type:"fields",fieldInfos:[{fieldName:"id",label:"路口编号"},{fieldName:"crossId",label:"信号机编号"}]}]}});t.push(o)}this.junctionLayer.addMany(t)}monitorMouseMove(){const e=M.debounce(async t=>{var c;const o=(c=(await this.view.hitTest(t,{include:[this.laneLayer,this.junctionLayer]})).results)==null?void 0:c.filter(a=>a.type==="graphic");if(o.length===0){this.currentSectionCode!==""&&(this.currentSectionCode="",this.highlightGraphic=void 0,this.highlightLayer.removeAll()),this.currentJunctionId!==""&&(this.currentJunctionId="",this.view.closePopup());return}const s=o[0];if(this.hitGraphic=s.graphic,s.layer.id==="OpenDriveLane"){const a=`${this.hitGraphic.getAttribute("roadId")}+${this.hitGraphic.getAttribute("sectionId")}`;if(a===this.currentSectionCode||this.sectionLayer.graphics.findIndex(h=>h.getAttribute("id")===a)>=0)return;this.currentSectionCode=a;const n=this.allLaneGraphics.filter(h=>`${h.attributes.roadId}+${h.attributes.sectionId}`===a),r=S.union(n.map(h=>h.geometry)),d=this.hitGraphic.getAttribute("fromNode"),u=this.hitGraphic.getAttribute("toNode"),g=this.junctionNames.get(d)||d,p=this.junctionNames.get(u)||u;this.highlightGraphic=new y({geometry:r,symbol:{type:"simple-fill",color:[0,255,255,.5],style:"solid",outline:{color:[0,255,255],width:1}},attributes:{type:"OpenDriveSection",id:a,selected:!1,fromNodeName:g,toNodeName:p,laneCount:n.length},popupTemplate:{title:this.hitGraphic.getAttribute("roadName"),content:[{type:"fields",fieldInfos:[{fieldName:"fromNodeName",label:"起点路口"},{fieldName:"toNodeName",label:"终点路口"},{fieldName:"laneCount",label:"车道数量"}]}]}}),this.highlightLayer.removeAll(),this.highlightLayer.add(this.highlightGraphic);const m=this.view.toMap(t);this.view.openPopup({features:[this.highlightGraphic],location:m})}else if(s.layer.id==="OpenDriveJunction"){const a=this.hitGraphic.getAttribute("id");if(a===this.currentJunctionId)return;this.currentJunctionId=a,this.view.openPopup({features:[this.hitGraphic],location:this.hitGraphic.geometry})}});this.mouseMoveHandler=this.view.on("pointer-move",async t=>{e(t).catch(()=>{})})}monitorMouseClick(){const e=M.debounce(async t=>{var l;const o=(l=(await this.view.hitTest(t,{include:[this.highlightLayer,this.junctionLayer,this.sectionLayer]})).results)==null?void 0:l.filter(n=>n.type==="graphic");if(o.length===0)return;const s=o[0].graphic,c=s.getAttribute("type"),a=s.getAttribute("id");if(c==="OpenDriveJunction")if(s.getAttribute("selected")===!1){const n=`http://${this.openDriveServer}/api/sumo/getSumoJunction`,r=await b.get(n,{params:{id:a,projectName:this.projectName}});r.status===200&&r.data.status===0&&(this.openDriveClickCallback&&this.openDriveClickCallback({type:"OpenDriveJunction",id:a,details:r.data.result}),s.setAttribute("selected",!0),s.symbol.url="/GisViewerAssets/Images/point_red.png",this.increasePictureMarkerSize(s,50))}else{this.openDriveClickCallback&&this.openDriveClickCallback({type:"OpenDriveJunction",id:a,details:void 0}),s.setAttribute("selected",!1);const n=s.getAttribute("crossId");s.symbol.url=n?"/GisViewerAssets/Images/point_green.png":"/GisViewerAssets/Images/point_yellow.png",this.decreasePictureMarkerSize(s,30)}else if(c==="OpenDriveSection")if(s.getAttribute("selected"))this.sectionLayer.remove(s),this.openDriveClickCallback&&this.openDriveClickCallback({type:"OpenDriveSection",id:a,details:void 0});else{this.highlightLayer.remove(s),this.sectionLayer.add(s),s.setAttribute("selected",!0);const n=`http://${this.openDriveServer}/api/sumo/getSumoEdge`,r=await b.get(n,{params:{id:a,projectName:this.projectName}});r.status===200&&r.data.status===0&&this.openDriveClickCallback&&(s.setAttribute("edgeId",r.data.result.obj_id),this.openDriveClickCallback({type:"OpenDriveSection",id:a,details:r.data.result}))}});this.mouseClickHandler=this.view.on("immediate-click",async t=>{e(t).catch(()=>{})})}increasePictureMarkerSize(e,t){const i=setInterval(()=>{const o=e.symbol,s=o.width;s<t?e.symbol={type:"picture-marker",url:o.url,width:s+1,height:s+1}:clearInterval(i)},20)}decreasePictureMarkerSize(e,t){const i=setInterval(()=>{const o=e.symbol,s=o.width;s>t?e.symbol={type:"picture-marker",url:o.url,width:s-1,height:s-1}:clearInterval(i)},20)}async getSumoInfo(e){switch(e.type){case"junction":{const t=`http://${this.openDriveServer}/api/sumo/getSumoJunction`,i=await b.get(t,{params:{id:e.id,projectName:this.projectName}});return i.status===200?i.data:{status:-1,message:`路口信息查询失败: ${e.id}`}}case"edge":{const t=e.id.split("#");let i=t[0];i.startsWith("-")&&(i=i.slice(1));let o=0;t.length===2&&(o=Number(t[1]));const s=this.allLaneGraphics.find(c=>c.getAttribute("roadId")===i&&c.getAttribute("sectionIndex")===o);if(s){const c=`${i}+${s.getAttribute("sectionId")}`,a=`http://${this.openDriveServer}/api/sumo/getSumoEdge`,l=await b.get(a,{params:{id:c,projectName:this.projectName}});return l.status===200?l.data:{status:-1,message:`路段信息查询失败: ${c}`}}else return{status:-1,message:"未知类型"}}default:return{status:-1,message:"未知类型"}}}async clearOpenDrive(){var t,i;let e=await this.laneLayer.queryFeatures();e.features.length>0&&await this.laneLayer.applyEdits({deleteFeatures:e.features}),e=await this.roadNameLayer.queryFeatures(),e.features.length>0&&await this.roadNameLayer.applyEdits({deleteFeatures:e.features}),this.highlightLayer.removeAll(),this.junctionLayer.removeAll(),this.sectionLayer.removeAll(),this.flashLayer.removeAll(),(t=this.mouseMoveHandler)==null||t.remove(),this.mouseMoveHandler=void 0,(i=this.mouseClickHandler)==null||i.remove(),this.mouseClickHandler=void 0}async findSumo(e){const{type:t,id:i}=e,o=e.flash===void 0?!0:e.flash;if(t==="junction")return await this.findJunction(i,o);if(t==="edge"){const s=i.split("_");if(s.length>2)return{status:-1,message:"id格式错误"};const c=s.length===2?Number(s[1]):void 0,a=s[0].split("#");if(a.length>2)return{status:-1,message:"id格式错误"};const l=a[0],n=a.length===2?Number(a[1]):void 0;return await this.findLane({roadsectId:l,segmentId:n,laneId:c,flash:o})}else return{status:-1,message:"未知类型"}}async findJunction(e,t){const i=this.junctionLayer.graphics.find(o=>o.attributes.id===e);if(!i)return{status:-1,message:"未找到。请检查路口编号"};if(t){const o=new y({geometry:i.geometry,symbol:{type:"simple-marker",style:"circle",size:30,color:[255,0,0,.6],outline:{color:"red",width:1}}});this.flashGraphic(o)}return await this.view.goTo(i.geometry,{duration:1e3}),{status:0,message:"ok"}}async findLane(e){let{roadsectId:t,segmentId:i,laneId:o}=e;t.startsWith("-")&&(t=t.slice(1));let s=this.allLaneGraphics.filter(l=>l.attributes.roadId===t);if(s.length===0)return{status:-1,message:"未找到。请检查路段编号"};if(i!==void 0){const l=[];if(s.forEach(n=>{const r=Number(n.attributes.sectionId);l.indexOf(r)===-1&&l.push(r)}),l.sort((n,r)=>n-r),i>l.length-1)return{status:-1,message:"未找到。请检查基本段编号"};i=l[i],s=s.filter(n=>Number(n.attributes.sectionId)===i)}if(o!==void 0){const l=[];if(s.forEach(n=>{const r=Number(n.attributes.laneId);l.indexOf(r)===-1&&l.push(r)}),l.sort((n,r)=>n-r),o>l.length-1)return{status:-1,message:"未找到。请检查车道编号"};o=l[o],s=s.filter(n=>Number(n.attributes.laneId)===o)}const c=s.map(l=>l.geometry),a=S.union(c);if(e.flash){const l=new y({geometry:a,symbol:{type:"simple-fill",color:[255,0,0,.5],style:"solid",outline:{color:"red",width:0}}});this.flashGraphic(l)}return await this.view.goTo(a,{duration:1e3}),{status:0,message:"ok"}}flashGraphic(e){this.flashLayer.removeAll(),this.flashLayer.add(e);let t=0,i=!0;const o=setInterval(()=>{i?(this.flashLayer.opacity-=.02,this.flashLayer.opacity<=.1&&(i=!1,t++)):(this.flashLayer.opacity+=.02,this.flashLayer.opacity>=1&&(i=!0)),t>=5&&(this.flashLayer.removeAll(),this.flashLayer.opacity=1,clearInterval(o))},10)}unselectSumo(e){if((!e||e.type==="junction")&&this.junctionLayer.graphics.forEach(t=>{if((!e||!e.id||e.id===""||e.id===t.getAttribute("id"))&&t.getAttribute("selected")){t.setAttribute("selected",!1);const i=t.getAttribute("crossId");t.symbol.url=i?"/GisViewerAssets/Images/point_green.png":"/GisViewerAssets/Images/point_yellow.png",this.decreasePictureMarkerSize(t,30)}}),!e||e.type==="edge")if(!e||!e.id||e.id==="")this.sectionLayer.removeAll();else{const t=this.sectionLayer.graphics.find(i=>i.getAttribute("edgeId")===e.id);t&&this.sectionLayer.remove(t)}return{status:0,message:"ok"}}selectSumo(e){switch(e.type){case"junction":return this.junctionLayer.graphics.forEach(t=>{if(e.id===t.getAttribute("id"))return t.setAttribute("selected",!0),t.symbol.url="/GisViewerAssets/Images/point_red.png",this.increasePictureMarkerSize(t,50),{status:0,message:"ok"}}),{status:-1,message:"未找到路口"};case"edge":{const t=e.id.split("#");let i=String(t[0]);i.startsWith("-")&&(i=i.slice(1));let o="0";t.length===2&&(o=String(t[1]));let s=[];if(t.length===1?s=this.allLaneGraphics.filter(c=>c.getAttribute("roadId")===i):t.length===2&&(s=this.allLaneGraphics.filter(c=>c.getAttribute("roadId")===i&&c.getAttribute("sectionId")===o)),s.length>0){const c=S.union(s.map(l=>l.geometry)),a=new y({geometry:c,symbol:{type:"simple-fill",color:[0,255,255,.5],style:"solid",outline:{color:[0,255,255],width:1}},attributes:{type:"OpenDriveSection",edgeId:e.id,selected:!0}});return this.sectionLayer.add(a),{status:0,message:"ok"}}else return{status:-1,message:"未找到路段"}}default:return{status:-1,message:"未知类型"}}}async geometrySearch(e){const t=new A.Polygon({rings:[e]}),i=await this.laneLayer.queryFeatures({geometry:t,outFields:["*"]}),o=[],s=[];for(const l of i.features){const n=l.getAttribute("roadId"),r=l.getAttribute("sectionId"),d=`${n}#${r}`;if(o.indexOf(d)===-1){o.push(d),this.selectSumo({type:"edge",id:d});const u=`http://${this.openDriveServer}/api/sumo/getSumoEdge`,g=await b.get(u,{params:{id:`${n}+${r}`,projectName:this.projectName}});g.status===200&&g.data.status===0&&s.push(g.data.result)}}const c=this.junctionLayer.graphics.filter(l=>{const n=l.geometry;return S.contains(t,n)}),a=[];for(const l of c){const n=l.getAttribute("id");this.selectSumo({type:"junction",id:n});const r=`http://${this.openDriveServer}/api/sumo/getSumoJunction`,d=await b.get(r,{params:{id:n,projectName:this.projectName}});d.status===200&&d.data.status===0&&a.push(d.data.result)}return{status:0,message:"ok",result:{junctions:a,edges:s}}}async splitLane(e){const i=e.id.split("_");if(i.length!==2)return{status:-1,message:"车道编号格式错误"};const o=Number(i[1]),s=i[0].split("#"),c=s.length===2?Number(s[1]):0;let a=s[0];a.startsWith("-")&&(a=a.slice(1));const l=this.allLaneGraphics.filter(v=>v.getAttribute("roadId")===a&&v.getAttribute("sectionIndex")===c);if(l.length===0)return{status:-1,message:"未找到路段"};const n=l.length-o,r=l.find(v=>Math.abs(v.getAttribute("laneId"))===n);if(!r)return{status:-1,message:"未找到车道"};const d=e.start||0,u=e.end||100,g=$.lineString(r.getAttribute("leftLine")),p=O.lineSliceAlong(g,d,u,{units:"meters"}),m=$.lineString(r.getAttribute("rightLine")),h=O.lineSliceAlong(m,d,u,{units:"meters"}),f=p.geometry.coordinates.concat(h.geometry.coordinates.reverse());f.push(f[f.length-1]);const w=new y({geometry:new A.Polygon({rings:[f]}),attributes:{ObjectID:r.getAttribute("ObjectID"),id:r.getAttribute("id"),fromNode:r.getAttribute("fromNode"),toNode:r.getAttribute("toNode"),roadId:r.getAttribute("roadId"),roadName:r.getAttribute("roadName"),sectionId:r.getAttribute("sectionId"),sectionIndex:r.getAttribute("sectionIndex"),laneId:r.getAttribute("laneId"),type:r.getAttribute("type"),sumoId:r.getAttribute("sumoId"),leftLine:p.geometry.coordinates,rightLine:h.geometry.coordinates},symbol:{type:"simple-fill",color:[255,0,0,.8],outline:{color:"red"}}});return this.splitLaneLayer.add(w),this.view.goTo(w),{status:0,message:"ok",result:e}}clearSplitLane(){this.splitLaneLayer.removeAll()}}exports.default=D;
|