gisviewer-vue3-arcgis 1.0.150 → 1.0.152
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/common-utils.d.ts +4 -0
- package/es/src/gis-map/utils/common-utils.mjs +16 -13
- package/es/src/gis-map/utils/map-initializer.mjs +43 -35
- package/es/src/gis-map/utils/open-drive-renderer/index.d.ts +1 -1
- package/es/src/gis-map/utils/open-drive-renderer/index.mjs +231 -222
- package/es/src/gis-map/utils/signal-control-area-controller/district-controller.mjs +9 -8
- package/es/src/gis-map/utils/signal-control-area-controller/index.mjs +84 -84
- package/lib/src/gis-map/utils/common-utils.d.ts +4 -0
- package/lib/src/gis-map/utils/common-utils.js +1 -1
- package/lib/src/gis-map/utils/map-initializer.js +1 -1
- package/lib/src/gis-map/utils/open-drive-renderer/index.d.ts +1 -1
- package/lib/src/gis-map/utils/open-drive-renderer/index.js +1 -1
- package/lib/src/gis-map/utils/signal-control-area-controller/district-controller.js +1 -1
- package/lib/src/gis-map/utils/signal-control-area-controller/index.js +1 -1
- package/package.json +1 -1
|
@@ -1,23 +1,20 @@
|
|
|
1
1
|
import y from "@arcgis/core/Graphic";
|
|
2
2
|
import * as j from "@arcgis/core/core/promiseUtils";
|
|
3
|
-
import { Polygon as
|
|
3
|
+
import { Polygon as N } from "@arcgis/core/geometry";
|
|
4
4
|
import * as L from "@arcgis/core/geometry/geometryEngine";
|
|
5
5
|
import k from "@arcgis/core/layers/FeatureLayer";
|
|
6
|
-
import
|
|
6
|
+
import v 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 $ 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
14
|
import P from "../common-utils.mjs";
|
|
15
15
|
class F {
|
|
16
16
|
constructor(e) {
|
|
17
|
-
this.junctionNames = /* @__PURE__ */ new Map(), this.projectName = "", this.openDriveServer = "", this.currentSectionCode = "", this.currentJunctionId = "", this.view = e, this.
|
|
18
|
-
collapseButton: !1,
|
|
19
|
-
actionBar: !1
|
|
20
|
-
}, this.laneLayer = new k({
|
|
17
|
+
this.junctionNames = /* @__PURE__ */ new Map(), this.projectName = "", this.openDriveServer = "", this.currentSectionCode = "", this.selectedSectionIds = [], this.currentJunctionId = "", this.view = e, this.laneLayer = new k({
|
|
21
18
|
id: "OpenDriveLane",
|
|
22
19
|
fields: [
|
|
23
20
|
{
|
|
@@ -45,6 +42,11 @@ class F {
|
|
|
45
42
|
alias: "路段号",
|
|
46
43
|
type: "string"
|
|
47
44
|
},
|
|
45
|
+
{
|
|
46
|
+
name: "sectionIndex",
|
|
47
|
+
alias: "路段序号",
|
|
48
|
+
type: "string"
|
|
49
|
+
},
|
|
48
50
|
{
|
|
49
51
|
name: "laneId",
|
|
50
52
|
alias: "车道号",
|
|
@@ -285,7 +287,7 @@ class F {
|
|
|
285
287
|
}
|
|
286
288
|
}
|
|
287
289
|
]
|
|
288
|
-
}), this.junctionLayer = new
|
|
290
|
+
}), this.junctionLayer = new v({ id: "OpenDriveJunction" }), this.sectionLayer = new v({ id: "OpenDriveSection" }), this.highlightLayer = new v({ id: "OpenDriveHighlight" }), this.flashLayer = new v({ id: "OpenDriveFlash" }), this.drawLayer = new v({ id: "Draw" }), this.splitLaneLayer = new v({ id: "SplitLane" }), this.view.map.addMany([
|
|
289
291
|
this.laneLayer,
|
|
290
292
|
this.junctionLayer,
|
|
291
293
|
this.sectionLayer,
|
|
@@ -302,7 +304,7 @@ class F {
|
|
|
302
304
|
async makeMd5FromFile(e) {
|
|
303
305
|
try {
|
|
304
306
|
const i = await (await fetch(e)).text();
|
|
305
|
-
return { status: 0, message: "ok", result:
|
|
307
|
+
return { status: 0, message: "ok", result: $(i) };
|
|
306
308
|
} catch (t) {
|
|
307
309
|
return { status: -1, message: t.message };
|
|
308
310
|
}
|
|
@@ -320,9 +322,9 @@ class F {
|
|
|
320
322
|
return t;
|
|
321
323
|
this.projectName = t.result, console.timeEnd("md5用时"), this.openDriveServer = e.server, await this.makeMd5FromFile(e.file);
|
|
322
324
|
const i = `http://${this.openDriveServer}/api/openDrive/uploadXodr`;
|
|
323
|
-
let
|
|
325
|
+
let r;
|
|
324
326
|
try {
|
|
325
|
-
|
|
327
|
+
r = await b.post(
|
|
326
328
|
i,
|
|
327
329
|
{},
|
|
328
330
|
{
|
|
@@ -335,31 +337,31 @@ class F {
|
|
|
335
337
|
} catch (m) {
|
|
336
338
|
return { status: -1, message: m.message };
|
|
337
339
|
}
|
|
338
|
-
if (
|
|
339
|
-
return { status: -1, message:
|
|
340
|
+
if (r.status !== 200)
|
|
341
|
+
return { status: -1, message: r.statusText };
|
|
340
342
|
console.time("渲染用时");
|
|
341
|
-
const s =
|
|
343
|
+
const s = r.data.result.geoSetting;
|
|
342
344
|
P.setGeoData(
|
|
343
345
|
s.geoReference,
|
|
344
346
|
s.offsetX,
|
|
345
347
|
s.offsetY
|
|
346
348
|
);
|
|
347
|
-
let c =
|
|
349
|
+
let c = r.data.result.json;
|
|
348
350
|
c.startsWith(window.location.protocol) || (c = `${window.location.protocol}//${e.server}${c}`);
|
|
349
|
-
const a = await (await fetch(c)).arrayBuffer(),
|
|
351
|
+
const a = await (await fetch(c)).arrayBuffer(), o = O.inflate(a, { to: "string" }), l = JSON.parse(o);
|
|
350
352
|
await this.showAllLanes(
|
|
351
|
-
|
|
353
|
+
l,
|
|
352
354
|
((g = e.options) == null ? void 0 : g.showJunctionLane) || !1,
|
|
353
355
|
((p = e.options) == null ? void 0 : p.showRoadName) || !0
|
|
354
356
|
);
|
|
355
|
-
const d =
|
|
357
|
+
const d = r.data.result.junctions;
|
|
356
358
|
this.showJunction(d), e.options && e.options.centerMap !== !1 && await this.view.goTo(this.allLaneGraphics), this.mouseMoveHandler || this.monitorMouseMove(), this.mouseClickHandler || this.monitorMouseClick();
|
|
357
359
|
const h = J.useAppDataStore;
|
|
358
360
|
return x(
|
|
359
361
|
() => h.isSketching,
|
|
360
362
|
() => {
|
|
361
|
-
var m,
|
|
362
|
-
h.isSketching ? ((m = this.mouseMoveHandler) == null || m.remove(), this.mouseMoveHandler = void 0, (
|
|
363
|
+
var m, f;
|
|
364
|
+
h.isSketching ? ((m = this.mouseMoveHandler) == null || m.remove(), this.mouseMoveHandler = void 0, (f = this.mouseClickHandler) == null || f.remove(), this.mouseClickHandler = void 0) : (this.monitorMouseMove(), this.monitorMouseClick());
|
|
363
365
|
}
|
|
364
366
|
), console.timeEnd("渲染用时"), { status: 0, message: "ok" };
|
|
365
367
|
}
|
|
@@ -369,7 +371,7 @@ class F {
|
|
|
369
371
|
* @param projectName
|
|
370
372
|
*/
|
|
371
373
|
async showOpenDriveFromServer(e, t) {
|
|
372
|
-
const i = `http://${e}/api/openDrive/analyzeXodr`,
|
|
374
|
+
const i = `http://${e}/api/openDrive/analyzeXodr`, r = await b.get(i, {
|
|
373
375
|
headers: {
|
|
374
376
|
projectName: t
|
|
375
377
|
},
|
|
@@ -378,12 +380,12 @@ class F {
|
|
|
378
380
|
compressed: !0
|
|
379
381
|
}
|
|
380
382
|
});
|
|
381
|
-
if (
|
|
382
|
-
throw new Error(`OpenDriveRenderer: ${
|
|
383
|
-
let s =
|
|
383
|
+
if (r.status !== 200)
|
|
384
|
+
throw new Error(`OpenDriveRenderer: ${r.statusText}`);
|
|
385
|
+
let s = r.data.result.json;
|
|
384
386
|
s.startsWith(window.location.protocol) || (s = `${window.location.protocol}//${e}${s}`);
|
|
385
|
-
const
|
|
386
|
-
return await this.showAllLanes(
|
|
387
|
+
const n = await (await fetch(s)).arrayBuffer(), a = O.inflate(n, { to: "string" }), o = JSON.parse(a);
|
|
388
|
+
return await this.showAllLanes(o, !1, !1), { status: 0, message: "ok" };
|
|
387
389
|
}
|
|
388
390
|
/**
|
|
389
391
|
* 显示所有车道
|
|
@@ -393,19 +395,18 @@ class F {
|
|
|
393
395
|
* @returns
|
|
394
396
|
*/
|
|
395
397
|
async showAllLanes(e, t, i) {
|
|
396
|
-
const
|
|
397
|
-
return
|
|
398
|
-
deleteFeatures:
|
|
398
|
+
const r = await this.laneLayer.queryFeatures();
|
|
399
|
+
return r.features.length > 0 && this.laneLayer.applyEdits({
|
|
400
|
+
deleteFeatures: r.features
|
|
399
401
|
}), this.roadNameLayer.visible = i, new Promise((s) => {
|
|
400
402
|
let c = 0;
|
|
401
403
|
this.allLaneGraphics = [], this.allRefLineGraphics = [];
|
|
402
|
-
const
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
if (!t && r.junction !== "-1")
|
|
404
|
+
const n = [];
|
|
405
|
+
for (const o of e) {
|
|
406
|
+
if (!t && o.junction !== "-1")
|
|
406
407
|
continue;
|
|
407
|
-
const { id:
|
|
408
|
-
let h =
|
|
408
|
+
const { id: l, refLine: d } = o;
|
|
409
|
+
let h = o.name;
|
|
409
410
|
h.includes("(") && (h = h.slice(0, h.indexOf("("))), h = h.replace(/(.)/g, "$1 ");
|
|
410
411
|
const g = new y({
|
|
411
412
|
geometry: {
|
|
@@ -414,65 +415,65 @@ class F {
|
|
|
414
415
|
},
|
|
415
416
|
attributes: {
|
|
416
417
|
ObjectID: c++,
|
|
417
|
-
roadId:
|
|
418
|
+
roadId: l,
|
|
418
419
|
roadName: h
|
|
419
420
|
}
|
|
420
421
|
});
|
|
421
|
-
this.allRefLineGraphics.push(g),
|
|
422
|
-
for (let p = 0; p <
|
|
423
|
-
const m =
|
|
424
|
-
for (const
|
|
425
|
-
const w = Number(
|
|
422
|
+
this.allRefLineGraphics.push(g), o.laneSections.sort((p, m) => Number(p.id) - Number(m.id));
|
|
423
|
+
for (let p = 0; p < o.laneSections.length; p++) {
|
|
424
|
+
const m = o.laneSections[p], f = Number(m.id);
|
|
425
|
+
for (const u of m.lanePaths) {
|
|
426
|
+
const w = Number(u.id);
|
|
426
427
|
if (w === 0)
|
|
427
428
|
continue;
|
|
428
|
-
const
|
|
429
|
-
|
|
429
|
+
const I = u.type, M = [...u.outerPath], S = u.innerPath.concat(
|
|
430
|
+
M.reverse()
|
|
430
431
|
);
|
|
431
|
-
if (
|
|
432
|
+
if (S.length <= 3) {
|
|
432
433
|
console.warn(`lane ${w} has less than 3 points`);
|
|
433
434
|
continue;
|
|
434
435
|
}
|
|
435
|
-
|
|
436
|
-
const A = new
|
|
437
|
-
rings: [
|
|
436
|
+
S.push(u.innerPath[0]);
|
|
437
|
+
const A = new N({
|
|
438
|
+
rings: [S]
|
|
438
439
|
});
|
|
439
440
|
if (A) {
|
|
440
441
|
const D = new y({
|
|
441
442
|
geometry: A,
|
|
442
443
|
attributes: {
|
|
443
444
|
ObjectID: c++,
|
|
444
|
-
id: `${
|
|
445
|
-
fromNode:
|
|
446
|
-
toNode:
|
|
447
|
-
roadId: String(
|
|
448
|
-
roadName:
|
|
449
|
-
sectionId: String(
|
|
445
|
+
id: `${l}+${f}+${w}`,
|
|
446
|
+
fromNode: o.fromNode,
|
|
447
|
+
toNode: o.toNode,
|
|
448
|
+
roadId: String(l),
|
|
449
|
+
roadName: o.name,
|
|
450
|
+
sectionId: String(f),
|
|
450
451
|
sectionIndex: p,
|
|
451
452
|
laneId: w,
|
|
452
|
-
type:
|
|
453
|
+
type: I,
|
|
453
454
|
sumoId: "",
|
|
454
455
|
// 记录左右边线的起始点,用于按长度高亮车道的一部分
|
|
455
|
-
leftLine:
|
|
456
|
-
rightLine:
|
|
456
|
+
leftLine: u.innerPath,
|
|
457
|
+
rightLine: u.outerPath
|
|
457
458
|
}
|
|
458
459
|
});
|
|
459
|
-
this.allLaneGraphics.push(D),
|
|
460
|
+
this.allLaneGraphics.push(D), n.push(D);
|
|
460
461
|
}
|
|
461
462
|
}
|
|
462
463
|
}
|
|
463
464
|
}
|
|
464
465
|
const a = setInterval(() => {
|
|
465
|
-
if (
|
|
466
|
-
if (
|
|
467
|
-
const
|
|
466
|
+
if (n.length > 0 || this.allRefLineGraphics.length > 0) {
|
|
467
|
+
if (n.length > 0) {
|
|
468
|
+
const o = n.splice(0, 100);
|
|
468
469
|
this.laneLayer.applyEdits({
|
|
469
|
-
addFeatures:
|
|
470
|
+
addFeatures: o
|
|
470
471
|
});
|
|
471
472
|
}
|
|
472
473
|
if (this.allRefLineGraphics.length > 0) {
|
|
473
|
-
const
|
|
474
|
+
const o = this.allRefLineGraphics.splice(0, 10);
|
|
474
475
|
this.roadNameLayer.applyEdits({
|
|
475
|
-
addFeatures:
|
|
476
|
+
addFeatures: o
|
|
476
477
|
});
|
|
477
478
|
}
|
|
478
479
|
} else
|
|
@@ -491,7 +492,7 @@ class F {
|
|
|
491
492
|
if (!i)
|
|
492
493
|
continue;
|
|
493
494
|
this.junctionNames.set(i.id, i.name), i.nodeType = i.type;
|
|
494
|
-
const
|
|
495
|
+
const r = new y({
|
|
495
496
|
geometry: {
|
|
496
497
|
type: "point",
|
|
497
498
|
x: i.coordinates[0],
|
|
@@ -527,7 +528,7 @@ class F {
|
|
|
527
528
|
]
|
|
528
529
|
}
|
|
529
530
|
});
|
|
530
|
-
t.push(
|
|
531
|
+
t.push(r);
|
|
531
532
|
}
|
|
532
533
|
this.junctionLayer.addMany(t);
|
|
533
534
|
}
|
|
@@ -537,32 +538,31 @@ class F {
|
|
|
537
538
|
monitorMouseMove() {
|
|
538
539
|
const e = j.debounce(async (t) => {
|
|
539
540
|
var c;
|
|
540
|
-
const
|
|
541
|
+
const r = (c = (await this.view.hitTest(t, {
|
|
541
542
|
include: [this.laneLayer, this.junctionLayer]
|
|
542
543
|
})).results) == null ? void 0 : c.filter(
|
|
543
|
-
(
|
|
544
|
+
(n) => n.type === "graphic"
|
|
544
545
|
);
|
|
545
|
-
if (
|
|
546
|
-
this.currentSectionCode !== "" && (this.currentSectionCode = "", this.
|
|
546
|
+
if (r.length === 0) {
|
|
547
|
+
this.currentSectionCode !== "" && (this.currentSectionCode = "", this.highlightLayer.removeAll()), this.currentJunctionId !== "" && (this.currentJunctionId = ""), this.view.closePopup();
|
|
547
548
|
return;
|
|
548
549
|
}
|
|
549
|
-
const s =
|
|
550
|
+
const s = r[0];
|
|
550
551
|
if (this.hitGraphic = s.graphic, s.layer.id === "OpenDriveLane") {
|
|
551
|
-
const
|
|
552
|
+
const n = `${this.hitGraphic.getAttribute(
|
|
552
553
|
"roadId"
|
|
553
554
|
)}+${this.hitGraphic.getAttribute("sectionId")}`;
|
|
554
|
-
if (
|
|
555
|
-
(u) => u.getAttribute("id") ===
|
|
555
|
+
if (this.currentSectionCode === n || this.selectedSectionIds.includes(n) || this.sectionLayer.graphics.findIndex(
|
|
556
|
+
(u) => u.getAttribute("id") === n
|
|
556
557
|
) >= 0)
|
|
557
558
|
return;
|
|
558
|
-
this.currentSectionCode =
|
|
559
|
-
const
|
|
560
|
-
(u) => `${u.attributes.roadId}+${u.attributes.sectionId}` ===
|
|
561
|
-
),
|
|
562
|
-
|
|
563
|
-
), d = this.hitGraphic.getAttribute("fromNode"), h = this.hitGraphic.getAttribute("toNode"), g = this.junctionNames.get(d) || d, p = this.junctionNames.get(h) || h
|
|
564
|
-
|
|
565
|
-
geometry: n,
|
|
559
|
+
this.currentSectionCode = n;
|
|
560
|
+
const o = this.allLaneGraphics.filter(
|
|
561
|
+
(u) => `${u.attributes.roadId}+${u.attributes.sectionId}` === n
|
|
562
|
+
), l = L.union(
|
|
563
|
+
o.map((u) => u.geometry)
|
|
564
|
+
), d = this.hitGraphic.getAttribute("fromNode"), h = this.hitGraphic.getAttribute("toNode"), g = this.junctionNames.get(d) || d, p = this.junctionNames.get(h) || h, m = new y({
|
|
565
|
+
geometry: l,
|
|
566
566
|
symbol: {
|
|
567
567
|
type: "simple-fill",
|
|
568
568
|
color: [0, 255, 255, 0.5],
|
|
@@ -574,11 +574,11 @@ class F {
|
|
|
574
574
|
},
|
|
575
575
|
attributes: {
|
|
576
576
|
type: "OpenDriveSection",
|
|
577
|
-
id:
|
|
577
|
+
id: n,
|
|
578
578
|
selected: !1,
|
|
579
579
|
fromNodeName: g,
|
|
580
580
|
toNodeName: p,
|
|
581
|
-
laneCount:
|
|
581
|
+
laneCount: o.length
|
|
582
582
|
},
|
|
583
583
|
popupTemplate: {
|
|
584
584
|
title: this.hitGraphic.getAttribute("roadName"),
|
|
@@ -602,17 +602,18 @@ class F {
|
|
|
602
602
|
}
|
|
603
603
|
]
|
|
604
604
|
}
|
|
605
|
-
})
|
|
606
|
-
|
|
605
|
+
});
|
|
606
|
+
this.highlightLayer.removeAll(), this.highlightLayer.add(m);
|
|
607
|
+
const f = this.view.toMap(t);
|
|
607
608
|
this.view.openPopup({
|
|
608
|
-
features: [
|
|
609
|
-
location:
|
|
609
|
+
features: [m],
|
|
610
|
+
location: f
|
|
610
611
|
});
|
|
611
612
|
} else if (s.layer.id === "OpenDriveJunction") {
|
|
612
|
-
const
|
|
613
|
-
if (
|
|
613
|
+
const n = this.hitGraphic.getAttribute("id");
|
|
614
|
+
if (n === this.currentJunctionId)
|
|
614
615
|
return;
|
|
615
|
-
this.currentJunctionId =
|
|
616
|
+
this.currentJunctionId = n, this.view.openPopup({
|
|
616
617
|
features: [this.hitGraphic],
|
|
617
618
|
location: this.hitGraphic.geometry
|
|
618
619
|
});
|
|
@@ -629,60 +630,61 @@ class F {
|
|
|
629
630
|
monitorMouseClick() {
|
|
630
631
|
const e = j.debounce(async (t) => {
|
|
631
632
|
var a;
|
|
632
|
-
const
|
|
633
|
+
const r = (a = (await this.view.hitTest(t, {
|
|
633
634
|
include: [this.highlightLayer, this.junctionLayer, this.sectionLayer]
|
|
634
635
|
})).results) == null ? void 0 : a.filter(
|
|
635
|
-
(
|
|
636
|
+
(o) => o.type === "graphic"
|
|
636
637
|
);
|
|
637
|
-
if (
|
|
638
|
+
if (r.length === 0)
|
|
638
639
|
return;
|
|
639
|
-
const s =
|
|
640
|
+
const s = r[0].graphic, c = s.getAttribute("type"), n = s.getAttribute("id");
|
|
640
641
|
if (c === "OpenDriveJunction")
|
|
641
642
|
if (s.getAttribute("selected") === !1) {
|
|
642
|
-
const
|
|
643
|
+
const o = `http://${this.openDriveServer}/api/sumo/getSumoJunction`, l = await b.get(o, {
|
|
643
644
|
params: {
|
|
644
|
-
id:
|
|
645
|
+
id: n,
|
|
645
646
|
projectName: this.projectName
|
|
646
647
|
}
|
|
647
648
|
});
|
|
648
|
-
|
|
649
|
+
l.status === 200 && l.data.status === 0 && (this.openDriveClickCallback && this.openDriveClickCallback({
|
|
649
650
|
type: "OpenDriveJunction",
|
|
650
|
-
id:
|
|
651
|
-
details:
|
|
651
|
+
id: n,
|
|
652
|
+
details: l.data.result
|
|
652
653
|
}), s.setAttribute("selected", !0), s.symbol.url = "/GisViewerAssets/Images/point_red.png", this.increasePictureMarkerSize(s, 50));
|
|
653
654
|
} else {
|
|
654
655
|
this.openDriveClickCallback && this.openDriveClickCallback({
|
|
655
656
|
type: "OpenDriveJunction",
|
|
656
|
-
id:
|
|
657
|
+
id: n,
|
|
657
658
|
details: void 0
|
|
658
659
|
}), s.setAttribute("selected", !1);
|
|
659
|
-
const
|
|
660
|
-
s.symbol.url =
|
|
660
|
+
const o = s.getAttribute("crossId");
|
|
661
|
+
s.symbol.url = o ? "/GisViewerAssets/Images/point_green.png" : "/GisViewerAssets/Images/point_yellow.png", this.decreasePictureMarkerSize(s, 30);
|
|
661
662
|
}
|
|
662
663
|
else if (c === "OpenDriveSection")
|
|
663
|
-
if (s.
|
|
664
|
-
this.
|
|
665
|
-
|
|
666
|
-
id: s.getAttribute("edgeId"),
|
|
667
|
-
details: void 0
|
|
668
|
-
});
|
|
669
|
-
else {
|
|
670
|
-
this.highlightLayer.remove(s), this.sectionLayer.add(s), s.setAttribute("selected", !0);
|
|
671
|
-
const r = `http://${this.openDriveServer}/api/sumo/getSumoEdge`, n = await b.get(r, {
|
|
664
|
+
if (s.layer.id === "OpenDriveHighlight") {
|
|
665
|
+
this.highlightLayer.remove(s), this.sectionLayer.add(s), s.setAttribute("selected", !0), this.selectedSectionIds.push(n);
|
|
666
|
+
const o = `http://${this.openDriveServer}/api/sumo/getSumoEdge`, l = await b.get(o, {
|
|
672
667
|
params: {
|
|
673
|
-
id:
|
|
668
|
+
id: n,
|
|
674
669
|
projectName: this.projectName
|
|
675
670
|
}
|
|
676
671
|
});
|
|
677
|
-
if (
|
|
678
|
-
const d =
|
|
672
|
+
if (l.status === 200 && l.data.status === 0 && this.openDriveClickCallback) {
|
|
673
|
+
const d = l.data.result.obj_id;
|
|
679
674
|
s.setAttribute("edgeId", d), this.openDriveClickCallback({
|
|
680
675
|
type: "OpenDriveSection",
|
|
681
676
|
id: d,
|
|
682
|
-
details:
|
|
677
|
+
details: l.data.result
|
|
683
678
|
});
|
|
684
679
|
}
|
|
685
|
-
}
|
|
680
|
+
} else
|
|
681
|
+
this.sectionLayer.remove(s), this.selectedSectionIds = this.selectedSectionIds.filter(
|
|
682
|
+
(o) => o !== n
|
|
683
|
+
), this.openDriveClickCallback && this.openDriveClickCallback({
|
|
684
|
+
type: "OpenDriveSection",
|
|
685
|
+
id: s.getAttribute("edgeId"),
|
|
686
|
+
details: void 0
|
|
687
|
+
});
|
|
686
688
|
});
|
|
687
689
|
this.mouseClickHandler = this.view.on("immediate-click", async (t) => {
|
|
688
690
|
e(t).catch(() => {
|
|
@@ -696,10 +698,10 @@ class F {
|
|
|
696
698
|
*/
|
|
697
699
|
increasePictureMarkerSize(e, t) {
|
|
698
700
|
const i = setInterval(() => {
|
|
699
|
-
const
|
|
701
|
+
const r = e.symbol, s = r.width;
|
|
700
702
|
s < t ? e.symbol = {
|
|
701
703
|
type: "picture-marker",
|
|
702
|
-
url:
|
|
704
|
+
url: r.url,
|
|
703
705
|
width: s + 1,
|
|
704
706
|
height: s + 1
|
|
705
707
|
} : clearInterval(i);
|
|
@@ -712,10 +714,10 @@ class F {
|
|
|
712
714
|
*/
|
|
713
715
|
decreasePictureMarkerSize(e, t) {
|
|
714
716
|
const i = setInterval(() => {
|
|
715
|
-
const
|
|
717
|
+
const r = e.symbol, s = r.width;
|
|
716
718
|
s > t ? e.symbol = {
|
|
717
719
|
type: "picture-marker",
|
|
718
|
-
url:
|
|
720
|
+
url: r.url,
|
|
719
721
|
width: s - 1,
|
|
720
722
|
height: s - 1
|
|
721
723
|
} : clearInterval(i);
|
|
@@ -736,15 +738,15 @@ class F {
|
|
|
736
738
|
const t = e.id.split("#");
|
|
737
739
|
let i = t[0];
|
|
738
740
|
i.startsWith("-") && (i = i.slice(1));
|
|
739
|
-
let
|
|
740
|
-
t.length === 2 && (
|
|
741
|
+
let r = 0;
|
|
742
|
+
t.length === 2 && (r = Number(t[1]));
|
|
741
743
|
const s = this.allLaneGraphics.find(
|
|
742
|
-
(c) => c.getAttribute("roadId") === i && c.getAttribute("sectionIndex") ===
|
|
744
|
+
(c) => c.getAttribute("roadId") === i && c.getAttribute("sectionIndex") === r
|
|
743
745
|
);
|
|
744
746
|
if (s) {
|
|
745
747
|
const c = `${i}+${s.getAttribute(
|
|
746
748
|
"sectionId"
|
|
747
|
-
)}`,
|
|
749
|
+
)}`, n = `http://${this.openDriveServer}/api/sumo/getSumoEdge`, a = await b.get(n, {
|
|
748
750
|
params: {
|
|
749
751
|
id: c,
|
|
750
752
|
projectName: this.projectName
|
|
@@ -776,29 +778,29 @@ class F {
|
|
|
776
778
|
* @returns
|
|
777
779
|
*/
|
|
778
780
|
async findSumo(e) {
|
|
779
|
-
const { type: t, id: i } = e,
|
|
781
|
+
const { type: t, id: i } = e, r = e.flash === void 0 ? !0 : e.flash;
|
|
780
782
|
if (t === "junction")
|
|
781
|
-
return await this.findJunction(i,
|
|
783
|
+
return await this.findJunction(i, r);
|
|
782
784
|
if (t === "edge") {
|
|
783
785
|
const s = i.split("_");
|
|
784
786
|
if (s.length > 2)
|
|
785
787
|
return { status: -1, message: "id格式错误" };
|
|
786
|
-
const c = s.length === 2 ? Number(s[1]) : void 0,
|
|
787
|
-
if (
|
|
788
|
+
const c = s.length === 2 ? Number(s[1]) : void 0, n = s[0].split("#");
|
|
789
|
+
if (n.length > 2)
|
|
788
790
|
return { status: -1, message: "id格式错误" };
|
|
789
|
-
const a =
|
|
790
|
-
return await this.findLane({ roadsectId: a, segmentId:
|
|
791
|
+
const a = n[0], o = n.length === 2 ? Number(n[1]) : void 0;
|
|
792
|
+
return await this.findLane({ roadsectId: a, segmentId: o, laneId: c, flash: r });
|
|
791
793
|
} else
|
|
792
794
|
return { status: -1, message: "未知类型" };
|
|
793
795
|
}
|
|
794
796
|
async findJunction(e, t) {
|
|
795
797
|
const i = this.junctionLayer.graphics.find(
|
|
796
|
-
(
|
|
798
|
+
(r) => r.attributes.id === e
|
|
797
799
|
);
|
|
798
800
|
if (!i)
|
|
799
801
|
return { status: -1, message: "未找到。请检查路口编号" };
|
|
800
802
|
if (t) {
|
|
801
|
-
const
|
|
803
|
+
const r = new y({
|
|
802
804
|
geometry: i.geometry,
|
|
803
805
|
symbol: {
|
|
804
806
|
type: "simple-marker",
|
|
@@ -811,7 +813,7 @@ class F {
|
|
|
811
813
|
}
|
|
812
814
|
}
|
|
813
815
|
});
|
|
814
|
-
this.flashGraphic(
|
|
816
|
+
this.flashGraphic(r);
|
|
815
817
|
}
|
|
816
818
|
return await this.view.goTo(i.geometry, { duration: 1e3 }), { status: 0, message: "ok" };
|
|
817
819
|
}
|
|
@@ -821,7 +823,7 @@ class F {
|
|
|
821
823
|
* @returns
|
|
822
824
|
*/
|
|
823
825
|
async findLane(e) {
|
|
824
|
-
let { roadsectId: t, segmentId: i, laneId:
|
|
826
|
+
let { roadsectId: t, segmentId: i, laneId: r } = e;
|
|
825
827
|
t.startsWith("-") && (t = t.slice(1));
|
|
826
828
|
let s = this.allLaneGraphics.filter(
|
|
827
829
|
(a) => a.attributes.roadId === t
|
|
@@ -830,32 +832,32 @@ class F {
|
|
|
830
832
|
return { status: -1, message: "未找到。请检查路段编号" };
|
|
831
833
|
if (i !== void 0) {
|
|
832
834
|
const a = [];
|
|
833
|
-
if (s.forEach((
|
|
834
|
-
const
|
|
835
|
-
a.indexOf(
|
|
836
|
-
}), a.sort((
|
|
835
|
+
if (s.forEach((o) => {
|
|
836
|
+
const l = Number(o.attributes.sectionId);
|
|
837
|
+
a.indexOf(l) === -1 && a.push(l);
|
|
838
|
+
}), a.sort((o, l) => o - l), i > a.length - 1)
|
|
837
839
|
return { status: -1, message: "未找到。请检查基本段编号" };
|
|
838
840
|
i = a[i], s = s.filter(
|
|
839
|
-
(
|
|
841
|
+
(o) => Number(o.attributes.sectionId) === i
|
|
840
842
|
);
|
|
841
843
|
}
|
|
842
|
-
if (
|
|
844
|
+
if (r !== void 0) {
|
|
843
845
|
const a = [];
|
|
844
|
-
if (s.forEach((
|
|
845
|
-
const
|
|
846
|
-
a.indexOf(
|
|
847
|
-
}), a.sort((
|
|
846
|
+
if (s.forEach((o) => {
|
|
847
|
+
const l = Number(o.attributes.laneId);
|
|
848
|
+
a.indexOf(l) === -1 && a.push(l);
|
|
849
|
+
}), a.sort((o, l) => o - l), r > a.length - 1)
|
|
848
850
|
return { status: -1, message: "未找到。请检查车道编号" };
|
|
849
|
-
|
|
850
|
-
(
|
|
851
|
+
r = a[r], s = s.filter(
|
|
852
|
+
(o) => Number(o.attributes.laneId) === r
|
|
851
853
|
);
|
|
852
854
|
}
|
|
853
855
|
const c = s.map(
|
|
854
856
|
(a) => a.geometry
|
|
855
|
-
),
|
|
857
|
+
), n = L.union(c);
|
|
856
858
|
if (e.flash) {
|
|
857
859
|
const a = new y({
|
|
858
|
-
geometry:
|
|
860
|
+
geometry: n,
|
|
859
861
|
symbol: {
|
|
860
862
|
type: "simple-fill",
|
|
861
863
|
color: [255, 0, 0, 0.5],
|
|
@@ -868,7 +870,7 @@ class F {
|
|
|
868
870
|
});
|
|
869
871
|
this.flashGraphic(a);
|
|
870
872
|
}
|
|
871
|
-
return await this.view.goTo(
|
|
873
|
+
return await this.view.goTo(n, { duration: 1e3 }), { status: 0, message: "ok" };
|
|
872
874
|
}
|
|
873
875
|
/**
|
|
874
876
|
* graphic渐隐渐显闪烁
|
|
@@ -877,8 +879,8 @@ class F {
|
|
|
877
879
|
flashGraphic(e) {
|
|
878
880
|
this.flashLayer.removeAll(), this.flashLayer.add(e);
|
|
879
881
|
let t = 0, i = !0;
|
|
880
|
-
const
|
|
881
|
-
i ? (this.flashLayer.opacity -= 0.02, this.flashLayer.opacity <= 0.1 && (i = !1, t++)) : (this.flashLayer.opacity += 0.02, this.flashLayer.opacity >= 1 && (i = !0)), t >= 5 && (this.flashLayer.removeAll(), this.flashLayer.opacity = 1, clearInterval(
|
|
882
|
+
const r = setInterval(() => {
|
|
883
|
+
i ? (this.flashLayer.opacity -= 0.02, this.flashLayer.opacity <= 0.1 && (i = !1, t++)) : (this.flashLayer.opacity += 0.02, this.flashLayer.opacity >= 1 && (i = !0)), t >= 5 && (this.flashLayer.removeAll(), this.flashLayer.opacity = 1, clearInterval(r));
|
|
882
884
|
}, 10);
|
|
883
885
|
}
|
|
884
886
|
/**
|
|
@@ -893,15 +895,15 @@ class F {
|
|
|
893
895
|
const i = t.getAttribute("crossId");
|
|
894
896
|
t.symbol.url = i ? "/GisViewerAssets/Images/point_green.png" : "/GisViewerAssets/Images/point_yellow.png", this.decreasePictureMarkerSize(t, 30);
|
|
895
897
|
}
|
|
896
|
-
}), !e || e.type === "edge")
|
|
897
|
-
|
|
898
|
-
|
|
899
|
-
|
|
900
|
-
|
|
901
|
-
(
|
|
898
|
+
}), !e || e.type === "edge") {
|
|
899
|
+
let t;
|
|
900
|
+
!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) => {
|
|
901
|
+
const r = i.getAttribute("id");
|
|
902
|
+
this.selectedSectionIds = this.selectedSectionIds.filter(
|
|
903
|
+
(s) => s !== r
|
|
902
904
|
);
|
|
903
|
-
|
|
904
|
-
|
|
905
|
+
}), this.sectionLayer.removeMany(t));
|
|
906
|
+
}
|
|
905
907
|
return { status: 0, message: "ok" };
|
|
906
908
|
}
|
|
907
909
|
/**
|
|
@@ -920,34 +922,41 @@ class F {
|
|
|
920
922
|
const t = e.id.split("#");
|
|
921
923
|
let i = String(t[0]);
|
|
922
924
|
i.startsWith("-") && (i = i.slice(1));
|
|
923
|
-
let
|
|
924
|
-
t.length === 2 && (
|
|
925
|
+
let r = 0;
|
|
926
|
+
t.length === 2 && (r = Number(t[1]));
|
|
925
927
|
let s = [];
|
|
926
928
|
if (t.length === 1 ? s = this.allLaneGraphics.filter(
|
|
927
929
|
(c) => c.getAttribute("roadId") === i
|
|
928
930
|
) : t.length === 2 && (s = this.allLaneGraphics.filter(
|
|
929
|
-
(c) => c.getAttribute("roadId") === i && c.getAttribute("
|
|
931
|
+
(c) => c.getAttribute("roadId") === i && c.getAttribute("sectionIndex") === r
|
|
930
932
|
)), s.length > 0) {
|
|
931
|
-
const c =
|
|
932
|
-
|
|
933
|
-
|
|
934
|
-
|
|
935
|
-
|
|
936
|
-
|
|
937
|
-
|
|
938
|
-
|
|
939
|
-
|
|
940
|
-
|
|
941
|
-
|
|
933
|
+
const c = /* @__PURE__ */ new Map();
|
|
934
|
+
return s.forEach((n) => {
|
|
935
|
+
const a = n.getAttribute("roadId") + "+" + n.getAttribute("sectionId");
|
|
936
|
+
this.selectedSectionIds.includes(a) || this.selectedSectionIds.push(a);
|
|
937
|
+
let o = c.get(a);
|
|
938
|
+
o ? o.push(n.geometry) : (o = [n.geometry], c.set(a, o));
|
|
939
|
+
}), c.forEach((n, a) => {
|
|
940
|
+
const o = L.union(n), l = new y({
|
|
941
|
+
geometry: o,
|
|
942
|
+
symbol: {
|
|
943
|
+
type: "simple-fill",
|
|
944
|
+
color: [0, 255, 255, 0.5],
|
|
945
|
+
style: "solid",
|
|
946
|
+
outline: {
|
|
947
|
+
color: [0, 255, 255],
|
|
948
|
+
width: 1
|
|
949
|
+
}
|
|
950
|
+
},
|
|
951
|
+
attributes: {
|
|
952
|
+
type: "OpenDriveSection",
|
|
953
|
+
id: a,
|
|
954
|
+
edgeId: e.id,
|
|
955
|
+
selected: !0
|
|
942
956
|
}
|
|
943
|
-
}
|
|
944
|
-
|
|
945
|
-
|
|
946
|
-
edgeId: e.id,
|
|
947
|
-
selected: !0
|
|
948
|
-
}
|
|
949
|
-
});
|
|
950
|
-
return this.sectionLayer.add(l), { status: 0, message: "ok" };
|
|
957
|
+
});
|
|
958
|
+
this.sectionLayer.add(l);
|
|
959
|
+
}), { status: 0, message: "ok" };
|
|
951
960
|
} else
|
|
952
961
|
return { status: -1, message: "未找到路段" };
|
|
953
962
|
}
|
|
@@ -956,22 +965,22 @@ class F {
|
|
|
956
965
|
}
|
|
957
966
|
}
|
|
958
967
|
async geometrySearch(e) {
|
|
959
|
-
const t = new
|
|
968
|
+
const t = new N({
|
|
960
969
|
rings: [e]
|
|
961
970
|
}), i = await this.laneLayer.queryFeatures({
|
|
962
971
|
geometry: t,
|
|
963
972
|
outFields: ["*"]
|
|
964
|
-
}),
|
|
973
|
+
}), r = [], s = [];
|
|
965
974
|
for (const a of i.features) {
|
|
966
|
-
const
|
|
967
|
-
if (
|
|
968
|
-
|
|
975
|
+
const o = a.getAttribute("roadId"), l = a.getAttribute("sectionIndex"), d = `${o}#${l}`;
|
|
976
|
+
if (r.indexOf(d) === -1) {
|
|
977
|
+
r.push(d), this.selectSumo({
|
|
969
978
|
type: "edge",
|
|
970
979
|
id: d
|
|
971
980
|
});
|
|
972
981
|
const h = `http://${this.openDriveServer}/api/sumo/getSumoEdge`, g = await b.get(h, {
|
|
973
982
|
params: {
|
|
974
|
-
id: `${
|
|
983
|
+
id: `${o}+${a.getAttribute("sectionId")}`,
|
|
975
984
|
projectName: this.projectName
|
|
976
985
|
}
|
|
977
986
|
});
|
|
@@ -979,28 +988,28 @@ class F {
|
|
|
979
988
|
}
|
|
980
989
|
}
|
|
981
990
|
const c = this.junctionLayer.graphics.filter((a) => {
|
|
982
|
-
const
|
|
983
|
-
return L.contains(t,
|
|
984
|
-
}),
|
|
991
|
+
const o = a.geometry;
|
|
992
|
+
return L.contains(t, o);
|
|
993
|
+
}), n = [];
|
|
985
994
|
for (const a of c) {
|
|
986
|
-
const
|
|
995
|
+
const o = a.getAttribute("id");
|
|
987
996
|
this.selectSumo({
|
|
988
997
|
type: "junction",
|
|
989
|
-
id:
|
|
998
|
+
id: o
|
|
990
999
|
});
|
|
991
|
-
const
|
|
1000
|
+
const l = `http://${this.openDriveServer}/api/sumo/getSumoJunction`, d = await b.get(l, {
|
|
992
1001
|
params: {
|
|
993
|
-
id:
|
|
1002
|
+
id: o,
|
|
994
1003
|
projectName: this.projectName
|
|
995
1004
|
}
|
|
996
1005
|
});
|
|
997
|
-
d.status === 200 && d.data.status === 0 &&
|
|
1006
|
+
d.status === 200 && d.data.status === 0 && n.push(d.data.result);
|
|
998
1007
|
}
|
|
999
1008
|
return {
|
|
1000
1009
|
status: 0,
|
|
1001
1010
|
message: "ok",
|
|
1002
1011
|
result: {
|
|
1003
|
-
junctions:
|
|
1012
|
+
junctions: n,
|
|
1004
1013
|
edges: s
|
|
1005
1014
|
}
|
|
1006
1015
|
};
|
|
@@ -1009,43 +1018,43 @@ class F {
|
|
|
1009
1018
|
const i = e.id.split("_");
|
|
1010
1019
|
if (i.length !== 2)
|
|
1011
1020
|
return { status: -1, message: "车道编号格式错误" };
|
|
1012
|
-
const
|
|
1013
|
-
let
|
|
1014
|
-
|
|
1015
|
-
const a = this.allLaneGraphics.filter((
|
|
1021
|
+
const r = Number(i[1]), s = i[0].split("#"), c = s.length === 2 ? Number(s[1]) : 0;
|
|
1022
|
+
let n = s[0];
|
|
1023
|
+
n.startsWith("-") && (n = n.slice(1));
|
|
1024
|
+
const a = this.allLaneGraphics.filter((I) => I.getAttribute("roadId") === n && I.getAttribute("sectionIndex") === c);
|
|
1016
1025
|
if (a.length === 0)
|
|
1017
1026
|
return { status: -1, message: "未找到路段" };
|
|
1018
|
-
const
|
|
1019
|
-
(
|
|
1027
|
+
const o = a.length - r, l = a.find(
|
|
1028
|
+
(I) => Math.abs(I.getAttribute("laneId")) === o
|
|
1020
1029
|
);
|
|
1021
|
-
if (!
|
|
1030
|
+
if (!l)
|
|
1022
1031
|
return { status: -1, message: "未找到车道" };
|
|
1023
|
-
const d = e.start || 0, h = e.end || 100, g = G.lineString(
|
|
1032
|
+
const d = e.start || 0, h = e.end || 100, g = G.lineString(l.getAttribute("leftLine")), p = C(g, d, h, {
|
|
1024
1033
|
units: "meters"
|
|
1025
|
-
}), m = G.lineString(
|
|
1034
|
+
}), m = G.lineString(l.getAttribute("rightLine")), f = C(m, d, h, {
|
|
1026
1035
|
units: "meters"
|
|
1027
|
-
}),
|
|
1028
|
-
|
|
1036
|
+
}), u = p.geometry.coordinates.concat(
|
|
1037
|
+
f.geometry.coordinates.reverse()
|
|
1029
1038
|
);
|
|
1030
|
-
|
|
1039
|
+
u.push(u[u.length - 1]);
|
|
1031
1040
|
const w = new y({
|
|
1032
|
-
geometry: new
|
|
1033
|
-
rings: [
|
|
1041
|
+
geometry: new N({
|
|
1042
|
+
rings: [u]
|
|
1034
1043
|
}),
|
|
1035
1044
|
attributes: {
|
|
1036
|
-
ObjectID:
|
|
1037
|
-
id:
|
|
1038
|
-
fromNode:
|
|
1039
|
-
toNode:
|
|
1040
|
-
roadId:
|
|
1041
|
-
roadName:
|
|
1042
|
-
sectionId:
|
|
1043
|
-
sectionIndex:
|
|
1044
|
-
laneId:
|
|
1045
|
-
type:
|
|
1046
|
-
sumoId:
|
|
1045
|
+
ObjectID: l.getAttribute("ObjectID"),
|
|
1046
|
+
id: l.getAttribute("id"),
|
|
1047
|
+
fromNode: l.getAttribute("fromNode"),
|
|
1048
|
+
toNode: l.getAttribute("toNode"),
|
|
1049
|
+
roadId: l.getAttribute("roadId"),
|
|
1050
|
+
roadName: l.getAttribute("roadName"),
|
|
1051
|
+
sectionId: l.getAttribute("sectionId"),
|
|
1052
|
+
sectionIndex: l.getAttribute("sectionIndex"),
|
|
1053
|
+
laneId: l.getAttribute("laneId"),
|
|
1054
|
+
type: l.getAttribute("type"),
|
|
1055
|
+
sumoId: l.getAttribute("sumoId"),
|
|
1047
1056
|
leftLine: p.geometry.coordinates,
|
|
1048
|
-
rightLine:
|
|
1057
|
+
rightLine: f.geometry.coordinates
|
|
1049
1058
|
},
|
|
1050
1059
|
symbol: {
|
|
1051
1060
|
type: "simple-fill",
|