gisviewer-vue3-arcgis 1.0.163 → 1.0.165
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.
|
@@ -18,6 +18,8 @@ export default class OpenDriveRenderer {
|
|
|
18
18
|
private mouseClickHandler;
|
|
19
19
|
private junctionNames;
|
|
20
20
|
private readonly junctionScale;
|
|
21
|
+
private scaleWatch;
|
|
22
|
+
private xodrBorder;
|
|
21
23
|
constructor(view: __esri.MapView | __esri.SceneView);
|
|
22
24
|
private projectName;
|
|
23
25
|
private openDriveServer;
|
|
@@ -111,6 +113,11 @@ export default class OpenDriveRenderer {
|
|
|
111
113
|
geometrySearch(coordinate: number[][]): Promise<IResult>;
|
|
112
114
|
splitLane(params: ISplitOpenDriveLaneParams): Promise<IResult>;
|
|
113
115
|
clearSplitLane(): void;
|
|
116
|
+
/**
|
|
117
|
+
* 更新所有路口的symbol
|
|
118
|
+
* @param symbolStyle
|
|
119
|
+
*/
|
|
120
|
+
private updateAllJunctionSymbol;
|
|
114
121
|
/**
|
|
115
122
|
* 生成路口点符号。在不同比例尺下,使用不同的符号
|
|
116
123
|
* @param attributes
|
|
@@ -1,22 +1,22 @@
|
|
|
1
1
|
import g from "@arcgis/core/Graphic";
|
|
2
2
|
import * as C from "@arcgis/core/core/promiseUtils";
|
|
3
3
|
import * as $ from "@arcgis/core/core/reactiveUtils.js";
|
|
4
|
-
import { Polygon as
|
|
5
|
-
import * as
|
|
4
|
+
import { Polygon as L, Point as F } from "@arcgis/core/geometry";
|
|
5
|
+
import * as S from "@arcgis/core/geometry/geometryEngine";
|
|
6
6
|
import k from "@arcgis/core/layers/FeatureLayer";
|
|
7
|
-
import
|
|
7
|
+
import w from "@arcgis/core/layers/GraphicsLayer";
|
|
8
8
|
import * as D from "@turf/helpers";
|
|
9
|
-
import { lineSliceAlong as
|
|
9
|
+
import { lineSliceAlong as x } from "@turf/line-slice-along";
|
|
10
10
|
import b from "axios";
|
|
11
|
-
import { XMLParser as
|
|
12
|
-
import
|
|
13
|
-
import
|
|
11
|
+
import { XMLParser as P } from "fast-xml-parser";
|
|
12
|
+
import J from "md5";
|
|
13
|
+
import G from "pako";
|
|
14
14
|
import { watch as E } from "vue";
|
|
15
15
|
import R from "../../stores/index.mjs";
|
|
16
|
-
import
|
|
17
|
-
class
|
|
16
|
+
import T from "../common-utils.mjs";
|
|
17
|
+
class O {
|
|
18
18
|
constructor(e) {
|
|
19
|
-
this.junctionNames = /* @__PURE__ */ new Map(), this.junctionScale = 5e3, this.projectName = "", this.openDriveServer = "", this.currentSectionCode = "", this.selectedSectionIds = [], this.currentJunctionId = "", this.view = e, this.laneLayer = new k({
|
|
19
|
+
this.junctionNames = /* @__PURE__ */ new Map(), this.junctionScale = 5e3, this.xodrBorder = [], this.projectName = "", this.openDriveServer = "", this.currentSectionCode = "", this.selectedSectionIds = [], this.currentJunctionId = "", this.view = e, this.laneLayer = new k({
|
|
20
20
|
id: "OpenDriveLane",
|
|
21
21
|
fields: [
|
|
22
22
|
{
|
|
@@ -289,7 +289,7 @@ class M {
|
|
|
289
289
|
}
|
|
290
290
|
}
|
|
291
291
|
]
|
|
292
|
-
}), this.junctionLayer = new
|
|
292
|
+
}), this.junctionLayer = new w({ id: "OpenDriveJunction" }), this.sectionLayer = new w({ id: "OpenDriveSection" }), this.highlightLayer = new w({ id: "OpenDriveHighlight" }), this.flashLayer = new w({ id: "OpenDriveFlash" }), this.drawLayer = new w({ id: "Draw" }), this.splitLaneLayer = new w({ id: "SplitLane" }), this.borderLayer = new w({ id: "OpenDriveBorder" }), this.view.map.addMany([
|
|
293
293
|
this.laneLayer,
|
|
294
294
|
this.sectionLayer,
|
|
295
295
|
this.roadNameLayer,
|
|
@@ -302,18 +302,19 @@ class M {
|
|
|
302
302
|
]);
|
|
303
303
|
}
|
|
304
304
|
static getInstance(e) {
|
|
305
|
-
return this.instance || (this.instance = new
|
|
305
|
+
return this.instance || (this.instance = new O(e)), this.instance;
|
|
306
306
|
}
|
|
307
307
|
async makeMd5FromFile(e) {
|
|
308
308
|
var t;
|
|
309
309
|
try {
|
|
310
|
-
const
|
|
310
|
+
const o = await (await fetch(e)).text();
|
|
311
|
+
let r = (t = new P({
|
|
311
312
|
ignoreAttributes: !1,
|
|
312
313
|
allowBooleanAttributes: !0
|
|
313
|
-
}).parse(
|
|
314
|
-
return { status: 0, message: "ok", result: { md5:
|
|
315
|
-
} catch (
|
|
316
|
-
return { status: -1, message:
|
|
314
|
+
}).parse(o).OpenDRIVE.userData) == null ? void 0 : t.border;
|
|
315
|
+
return r ? r = JSON.parse(r) : r = [], { status: 0, message: "ok", result: { md5: J(o), border: r } };
|
|
316
|
+
} catch (s) {
|
|
317
|
+
return { status: -1, message: s.message };
|
|
317
318
|
}
|
|
318
319
|
}
|
|
319
320
|
/**
|
|
@@ -322,32 +323,39 @@ class M {
|
|
|
322
323
|
* @returns
|
|
323
324
|
*/
|
|
324
325
|
async showOpenDriveFromFile(e) {
|
|
325
|
-
var
|
|
326
|
-
this.openDriveClickCallback = e.selectedCallback, $.watch(
|
|
326
|
+
var y, m;
|
|
327
|
+
this.openDriveClickCallback = e.selectedCallback, this.scaleWatch = $.watch(
|
|
327
328
|
() => this.view.scale,
|
|
328
|
-
(
|
|
329
|
-
|
|
330
|
-
m.symbol = this.getCrossGraphicSymbol(
|
|
331
|
-
m.attributes,
|
|
332
|
-
"marker"
|
|
333
|
-
);
|
|
334
|
-
})) : p <= this.junctionScale && h > this.junctionScale && (console.log(p, h), this.junctionLayer.graphics.forEach((m) => {
|
|
335
|
-
m.symbol = this.getCrossGraphicSymbol(
|
|
336
|
-
m.attributes,
|
|
337
|
-
"picture"
|
|
338
|
-
);
|
|
339
|
-
}));
|
|
329
|
+
(h, p) => {
|
|
330
|
+
h > this.junctionScale && p <= this.junctionScale ? this.updateAllJunctionSymbol("marker") : h <= this.junctionScale && p > this.junctionScale && this.updateAllJunctionSymbol("picture");
|
|
340
331
|
}
|
|
341
332
|
), console.time("md5用时");
|
|
342
333
|
const t = await this.makeMd5FromFile(e.file);
|
|
343
334
|
if (t.status !== 0)
|
|
344
335
|
return t;
|
|
345
|
-
this.projectName = t.result.md5, console.timeEnd("md5用时"),
|
|
346
|
-
|
|
347
|
-
|
|
336
|
+
if (this.projectName = t.result.md5, console.timeEnd("md5用时"), this.xodrBorder = t.result.border, this.xodrBorder.length > 0) {
|
|
337
|
+
const h = new g({
|
|
338
|
+
geometry: new L({
|
|
339
|
+
rings: [this.xodrBorder]
|
|
340
|
+
}),
|
|
341
|
+
symbol: {
|
|
342
|
+
type: "simple-fill",
|
|
343
|
+
style: "none",
|
|
344
|
+
outline: {
|
|
345
|
+
style: "dash",
|
|
346
|
+
color: "black",
|
|
347
|
+
width: 2
|
|
348
|
+
}
|
|
349
|
+
}
|
|
350
|
+
});
|
|
351
|
+
console.log(h.toJSON()), this.borderLayer.add(h);
|
|
352
|
+
}
|
|
353
|
+
this.openDriveServer = e.server;
|
|
354
|
+
const s = `http://${this.openDriveServer}/api/openDrive/uploadXodr`;
|
|
355
|
+
let o;
|
|
348
356
|
try {
|
|
349
|
-
|
|
350
|
-
|
|
357
|
+
o = await b.post(
|
|
358
|
+
s,
|
|
351
359
|
{},
|
|
352
360
|
{
|
|
353
361
|
params: {
|
|
@@ -356,34 +364,34 @@ class M {
|
|
|
356
364
|
}
|
|
357
365
|
}
|
|
358
366
|
);
|
|
359
|
-
} catch (
|
|
360
|
-
return { status: -1, message:
|
|
367
|
+
} catch (h) {
|
|
368
|
+
return { status: -1, message: h.message };
|
|
361
369
|
}
|
|
362
|
-
if (
|
|
363
|
-
return { status: -1, message:
|
|
370
|
+
if (o.status !== 200)
|
|
371
|
+
return { status: -1, message: o.statusText };
|
|
364
372
|
console.time("渲染用时");
|
|
365
|
-
const
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
373
|
+
const i = o.data.result.geoSetting;
|
|
374
|
+
T.setGeoData(
|
|
375
|
+
i.geoReference,
|
|
376
|
+
i.offsetX,
|
|
377
|
+
i.offsetY
|
|
370
378
|
);
|
|
371
|
-
let c =
|
|
379
|
+
let c = o.data.result.json;
|
|
372
380
|
c.startsWith(window.location.protocol) || (c = `${window.location.protocol}//${e.server}${c}`);
|
|
373
|
-
const a = await (await fetch(c)).arrayBuffer(),
|
|
381
|
+
const a = await (await fetch(c)).arrayBuffer(), n = G.inflate(a, { to: "string" }), l = JSON.parse(n);
|
|
374
382
|
await this.showAllLanes(
|
|
375
383
|
l,
|
|
376
|
-
((
|
|
377
|
-
((
|
|
384
|
+
((y = e.options) == null ? void 0 : y.showJunctionLane) || !1,
|
|
385
|
+
((m = e.options) == null ? void 0 : m.showRoadName) || !0
|
|
378
386
|
);
|
|
379
|
-
const d =
|
|
387
|
+
const d = o.data.result.junctions;
|
|
380
388
|
this.showJunction(d), e.options && e.options.centerMap !== !1 && await this.view.goTo(this.allLaneGraphics), this.mouseMoveHandler || this.monitorMouseMove(), this.mouseClickHandler || this.monitorMouseClick();
|
|
381
389
|
const u = R.useAppDataStore;
|
|
382
390
|
return E(
|
|
383
391
|
() => u.isSketching,
|
|
384
392
|
() => {
|
|
385
|
-
var
|
|
386
|
-
u.isSketching ? ((
|
|
393
|
+
var h, p;
|
|
394
|
+
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());
|
|
387
395
|
}
|
|
388
396
|
), console.timeEnd("渲染用时"), { status: 0, message: "ok" };
|
|
389
397
|
}
|
|
@@ -393,7 +401,7 @@ class M {
|
|
|
393
401
|
* @param projectName
|
|
394
402
|
*/
|
|
395
403
|
async showOpenDriveFromServer(e, t) {
|
|
396
|
-
const
|
|
404
|
+
const s = `http://${e}/api/openDrive/analyzeXodr`, o = await b.get(s, {
|
|
397
405
|
headers: {
|
|
398
406
|
projectName: t
|
|
399
407
|
},
|
|
@@ -402,12 +410,12 @@ class M {
|
|
|
402
410
|
compressed: !0
|
|
403
411
|
}
|
|
404
412
|
});
|
|
405
|
-
if (
|
|
406
|
-
throw new Error(`OpenDriveRenderer: ${
|
|
407
|
-
let
|
|
408
|
-
|
|
409
|
-
const
|
|
410
|
-
return await this.showAllLanes(
|
|
413
|
+
if (o.status !== 200)
|
|
414
|
+
throw new Error(`OpenDriveRenderer: ${o.statusText}`);
|
|
415
|
+
let i = o.data.result.json;
|
|
416
|
+
i.startsWith(window.location.protocol) || (i = `${window.location.protocol}//${e}${i}`);
|
|
417
|
+
const r = await (await fetch(i)).arrayBuffer(), a = G.inflate(r, { to: "string" }), n = JSON.parse(a);
|
|
418
|
+
return await this.showAllLanes(n, !1, !1), { status: 0, message: "ok" };
|
|
411
419
|
}
|
|
412
420
|
/**
|
|
413
421
|
* 显示所有车道
|
|
@@ -416,21 +424,21 @@ class M {
|
|
|
416
424
|
* @param showRoadName 是否显示道路名称
|
|
417
425
|
* @returns
|
|
418
426
|
*/
|
|
419
|
-
async showAllLanes(e, t,
|
|
420
|
-
const
|
|
421
|
-
return
|
|
422
|
-
deleteFeatures:
|
|
423
|
-
}), this.roadNameLayer.visible =
|
|
427
|
+
async showAllLanes(e, t, s) {
|
|
428
|
+
const o = await this.laneLayer.queryFeatures();
|
|
429
|
+
return o.features.length > 0 && this.laneLayer.applyEdits({
|
|
430
|
+
deleteFeatures: o.features
|
|
431
|
+
}), this.roadNameLayer.visible = s, new Promise((i) => {
|
|
424
432
|
let c = 0;
|
|
425
433
|
this.allLaneGraphics = [], this.allRefLineGraphics = [];
|
|
426
|
-
const
|
|
427
|
-
for (const
|
|
428
|
-
if (!t &&
|
|
434
|
+
const r = [];
|
|
435
|
+
for (const n of e) {
|
|
436
|
+
if (!t && n.junction !== "-1")
|
|
429
437
|
continue;
|
|
430
|
-
const { id: l, refLine: d } =
|
|
431
|
-
let u =
|
|
438
|
+
const { id: l, refLine: d } = n;
|
|
439
|
+
let u = n.name;
|
|
432
440
|
u.includes("(") && (u = u.slice(0, u.indexOf("("))), u = u.replace(/(.)/g, "$1 ");
|
|
433
|
-
const
|
|
441
|
+
const y = new g({
|
|
434
442
|
geometry: {
|
|
435
443
|
type: "polyline",
|
|
436
444
|
paths: [d]
|
|
@@ -441,65 +449,65 @@ class M {
|
|
|
441
449
|
roadName: u
|
|
442
450
|
}
|
|
443
451
|
});
|
|
444
|
-
this.allRefLineGraphics.push(
|
|
445
|
-
for (let
|
|
446
|
-
const
|
|
447
|
-
for (const
|
|
448
|
-
const v = Number(
|
|
452
|
+
this.allRefLineGraphics.push(y), n.laneSections.sort((m, h) => Number(m.id) - Number(h.id));
|
|
453
|
+
for (let m = 0; m < n.laneSections.length; m++) {
|
|
454
|
+
const h = n.laneSections[m], p = Number(h.id);
|
|
455
|
+
for (const f of h.lanePaths) {
|
|
456
|
+
const v = Number(f.id);
|
|
449
457
|
if (v === 0)
|
|
450
458
|
continue;
|
|
451
|
-
const
|
|
452
|
-
|
|
459
|
+
const I = f.type, M = [...f.outerPath], N = f.innerPath.concat(
|
|
460
|
+
M.reverse()
|
|
453
461
|
);
|
|
454
|
-
if (
|
|
462
|
+
if (N.length <= 3) {
|
|
455
463
|
console.warn(`lane ${v} has less than 3 points`);
|
|
456
464
|
continue;
|
|
457
465
|
}
|
|
458
|
-
|
|
459
|
-
const A = new
|
|
460
|
-
rings: [
|
|
466
|
+
N.push(f.innerPath[0]);
|
|
467
|
+
const A = new L({
|
|
468
|
+
rings: [N]
|
|
461
469
|
});
|
|
462
470
|
if (A) {
|
|
463
471
|
const j = new g({
|
|
464
472
|
geometry: A,
|
|
465
473
|
attributes: {
|
|
466
474
|
ObjectID: c++,
|
|
467
|
-
id: `${l}+${
|
|
468
|
-
fromNode:
|
|
469
|
-
toNode:
|
|
475
|
+
id: `${l}+${p}+${v}`,
|
|
476
|
+
fromNode: n.fromNode,
|
|
477
|
+
toNode: n.toNode,
|
|
470
478
|
roadId: String(l),
|
|
471
|
-
roadName:
|
|
472
|
-
sectionId: String(
|
|
473
|
-
sectionIndex:
|
|
479
|
+
roadName: n.name,
|
|
480
|
+
sectionId: String(p),
|
|
481
|
+
sectionIndex: m,
|
|
474
482
|
laneId: v,
|
|
475
|
-
type:
|
|
483
|
+
type: I,
|
|
476
484
|
sumoId: "",
|
|
477
485
|
// 记录左右边线的起始点,用于按长度高亮车道的一部分
|
|
478
|
-
leftLine:
|
|
479
|
-
rightLine:
|
|
486
|
+
leftLine: f.innerPath,
|
|
487
|
+
rightLine: f.outerPath
|
|
480
488
|
}
|
|
481
489
|
});
|
|
482
|
-
this.allLaneGraphics.push(j),
|
|
490
|
+
this.allLaneGraphics.push(j), r.push(j);
|
|
483
491
|
}
|
|
484
492
|
}
|
|
485
493
|
}
|
|
486
494
|
}
|
|
487
495
|
const a = setInterval(() => {
|
|
488
|
-
if (
|
|
489
|
-
if (
|
|
490
|
-
const
|
|
496
|
+
if (r.length > 0 || this.allRefLineGraphics.length > 0) {
|
|
497
|
+
if (r.length > 0) {
|
|
498
|
+
const n = r.splice(0, 100);
|
|
491
499
|
this.laneLayer.applyEdits({
|
|
492
|
-
addFeatures:
|
|
500
|
+
addFeatures: n
|
|
493
501
|
});
|
|
494
502
|
}
|
|
495
503
|
if (this.allRefLineGraphics.length > 0) {
|
|
496
|
-
const
|
|
504
|
+
const n = this.allRefLineGraphics.splice(0, 10);
|
|
497
505
|
this.roadNameLayer.applyEdits({
|
|
498
|
-
addFeatures:
|
|
506
|
+
addFeatures: n
|
|
499
507
|
});
|
|
500
508
|
}
|
|
501
509
|
} else
|
|
502
|
-
clearInterval(a),
|
|
510
|
+
clearInterval(a), i();
|
|
503
511
|
}, 10);
|
|
504
512
|
});
|
|
505
513
|
}
|
|
@@ -510,52 +518,30 @@ class M {
|
|
|
510
518
|
*/
|
|
511
519
|
showJunction(e) {
|
|
512
520
|
const t = [];
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
x:
|
|
521
|
-
y:
|
|
522
|
-
}
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
// } as any,
|
|
538
|
-
// popupTemplate: {
|
|
539
|
-
// title: junctionTableData.name,
|
|
540
|
-
// content: [
|
|
541
|
-
// {
|
|
542
|
-
// type: 'fields',
|
|
543
|
-
// fieldInfos: [
|
|
544
|
-
// {
|
|
545
|
-
// fieldName: 'id',
|
|
546
|
-
// label: '路口编号'
|
|
547
|
-
// },
|
|
548
|
-
// {
|
|
549
|
-
// fieldName: 'crossId',
|
|
550
|
-
// label: '信号机编号'
|
|
551
|
-
// }
|
|
552
|
-
// ]
|
|
553
|
-
// }
|
|
554
|
-
// ]
|
|
555
|
-
// }
|
|
556
|
-
});
|
|
557
|
-
t.push(r);
|
|
558
|
-
}
|
|
521
|
+
let s;
|
|
522
|
+
this.xodrBorder.length > 0 && (s = new L({
|
|
523
|
+
rings: [this.xodrBorder]
|
|
524
|
+
}));
|
|
525
|
+
for (const o of e)
|
|
526
|
+
if (o && (this.junctionNames.set(o.id, o.name), o.nodeType = o.type, o.crossId)) {
|
|
527
|
+
const i = new F({
|
|
528
|
+
x: o.coordinates[0],
|
|
529
|
+
y: o.coordinates[1]
|
|
530
|
+
});
|
|
531
|
+
let c = !0;
|
|
532
|
+
if (s && (c = S.contains(s, i)), c) {
|
|
533
|
+
const r = new g({
|
|
534
|
+
geometry: i,
|
|
535
|
+
attributes: {
|
|
536
|
+
...o,
|
|
537
|
+
selected: !1,
|
|
538
|
+
type: "OpenDriveJunction"
|
|
539
|
+
},
|
|
540
|
+
symbol: this.getCrossGraphicSymbol(o, "marker")
|
|
541
|
+
});
|
|
542
|
+
t.push(r);
|
|
543
|
+
}
|
|
544
|
+
}
|
|
559
545
|
this.junctionLayer.addMany(t);
|
|
560
546
|
}
|
|
561
547
|
/**
|
|
@@ -564,30 +550,30 @@ class M {
|
|
|
564
550
|
monitorMouseMove() {
|
|
565
551
|
const e = C.debounce(async (t) => {
|
|
566
552
|
var c;
|
|
567
|
-
const
|
|
553
|
+
const o = (c = (await this.view.hitTest(t, {
|
|
568
554
|
include: [this.laneLayer, this.junctionLayer]
|
|
569
555
|
})).results) == null ? void 0 : c.filter(
|
|
570
|
-
(
|
|
556
|
+
(r) => r.type === "graphic"
|
|
571
557
|
);
|
|
572
|
-
if (
|
|
558
|
+
if (o.length === 0) {
|
|
573
559
|
this.currentSectionCode !== "" && (this.currentSectionCode = "", this.highlightLayer.removeAll()), this.currentJunctionId !== "" && (this.currentJunctionId = ""), this.view.closePopup();
|
|
574
560
|
return;
|
|
575
561
|
}
|
|
576
|
-
const
|
|
577
|
-
if (this.hitGraphic =
|
|
578
|
-
const
|
|
562
|
+
const i = o[0];
|
|
563
|
+
if (this.hitGraphic = i.graphic, i.layer.id === "OpenDriveLane") {
|
|
564
|
+
const r = `${this.hitGraphic.getAttribute(
|
|
579
565
|
"roadId"
|
|
580
566
|
)}+${this.hitGraphic.getAttribute("sectionId")}`;
|
|
581
|
-
if (this.currentSectionCode ===
|
|
582
|
-
(
|
|
567
|
+
if (this.currentSectionCode === r || this.selectedSectionIds.includes(r) || this.sectionLayer.graphics.findIndex(
|
|
568
|
+
(p) => p.getAttribute("id") === r
|
|
583
569
|
) >= 0)
|
|
584
570
|
return;
|
|
585
|
-
this.currentSectionCode =
|
|
586
|
-
const
|
|
587
|
-
(
|
|
588
|
-
), l =
|
|
589
|
-
|
|
590
|
-
), d = this.hitGraphic.getAttribute("fromNode"), u = this.hitGraphic.getAttribute("toNode"),
|
|
571
|
+
this.currentSectionCode = r;
|
|
572
|
+
const n = this.allLaneGraphics.filter(
|
|
573
|
+
(p) => `${p.attributes.roadId}+${p.attributes.sectionId}` === r
|
|
574
|
+
), l = S.union(
|
|
575
|
+
n.map((p) => p.geometry)
|
|
576
|
+
), d = this.hitGraphic.getAttribute("fromNode"), u = this.hitGraphic.getAttribute("toNode"), y = this.junctionNames.get(d) || d, m = this.junctionNames.get(u) || u, h = new g({
|
|
591
577
|
geometry: l,
|
|
592
578
|
symbol: {
|
|
593
579
|
type: "simple-fill",
|
|
@@ -600,11 +586,11 @@ class M {
|
|
|
600
586
|
},
|
|
601
587
|
attributes: {
|
|
602
588
|
type: "OpenDriveSection",
|
|
603
|
-
id:
|
|
589
|
+
id: r,
|
|
604
590
|
selected: !1,
|
|
605
|
-
fromNodeName:
|
|
606
|
-
toNodeName:
|
|
607
|
-
laneCount:
|
|
591
|
+
fromNodeName: y,
|
|
592
|
+
toNodeName: m,
|
|
593
|
+
laneCount: n.length
|
|
608
594
|
},
|
|
609
595
|
popupTemplate: {
|
|
610
596
|
title: this.hitGraphic.getAttribute("roadName"),
|
|
@@ -629,12 +615,12 @@ class M {
|
|
|
629
615
|
]
|
|
630
616
|
}
|
|
631
617
|
});
|
|
632
|
-
this.highlightLayer.removeAll(), this.highlightLayer.add(
|
|
633
|
-
} else if (
|
|
634
|
-
const
|
|
635
|
-
if (
|
|
618
|
+
this.highlightLayer.removeAll(), this.highlightLayer.add(h);
|
|
619
|
+
} else if (i.layer.id === "OpenDriveJunction") {
|
|
620
|
+
const r = this.hitGraphic.getAttribute("id");
|
|
621
|
+
if (r === this.currentJunctionId)
|
|
636
622
|
return;
|
|
637
|
-
this.currentJunctionId =
|
|
623
|
+
this.currentJunctionId = r;
|
|
638
624
|
}
|
|
639
625
|
});
|
|
640
626
|
this.mouseMoveHandler = this.view.on("pointer-move", async (t) => {
|
|
@@ -648,64 +634,64 @@ class M {
|
|
|
648
634
|
monitorMouseClick() {
|
|
649
635
|
const e = C.debounce(async (t) => {
|
|
650
636
|
var a;
|
|
651
|
-
const
|
|
637
|
+
const o = (a = (await this.view.hitTest(t, {
|
|
652
638
|
include: [this.highlightLayer, this.junctionLayer, this.sectionLayer]
|
|
653
639
|
})).results) == null ? void 0 : a.filter(
|
|
654
|
-
(
|
|
640
|
+
(n) => n.type === "graphic"
|
|
655
641
|
);
|
|
656
|
-
if (
|
|
642
|
+
if (o.length === 0)
|
|
657
643
|
return;
|
|
658
|
-
const
|
|
644
|
+
const i = o[0].graphic, c = i.getAttribute("type"), r = i.getAttribute("id");
|
|
659
645
|
if (c === "OpenDriveJunction")
|
|
660
|
-
if (
|
|
661
|
-
const
|
|
646
|
+
if (i.getAttribute("selected") === !1) {
|
|
647
|
+
const n = `http://${this.openDriveServer}/api/sumo/getSumoJunction`, l = await b.get(n, {
|
|
662
648
|
params: {
|
|
663
|
-
id:
|
|
649
|
+
id: r,
|
|
664
650
|
projectName: this.projectName
|
|
665
651
|
}
|
|
666
652
|
});
|
|
667
653
|
l.status === 200 && l.data.status === 0 && (this.openDriveClickCallback && this.openDriveClickCallback({
|
|
668
654
|
type: "OpenDriveJunction",
|
|
669
|
-
id:
|
|
655
|
+
id: r,
|
|
670
656
|
details: l.data.result
|
|
671
|
-
}),
|
|
657
|
+
}), i.setAttribute("selected", !0), i.symbol = {
|
|
672
658
|
type: "picture-marker",
|
|
673
659
|
url: "/GisViewerAssets/Images/point_red.png",
|
|
674
660
|
width: "20px",
|
|
675
661
|
height: "20px"
|
|
676
|
-
}, this.increasePictureMarkerSize(
|
|
662
|
+
}, this.increasePictureMarkerSize(i, 50));
|
|
677
663
|
} else
|
|
678
664
|
this.openDriveClickCallback && this.openDriveClickCallback({
|
|
679
665
|
type: "OpenDriveJunction",
|
|
680
|
-
id:
|
|
666
|
+
id: r,
|
|
681
667
|
details: void 0
|
|
682
|
-
}),
|
|
683
|
-
|
|
668
|
+
}), i.setAttribute("selected", !1), i.symbol = this.getCrossGraphicSymbol(
|
|
669
|
+
i.attributes,
|
|
684
670
|
this.view.scale < this.junctionScale ? "picture" : "marker"
|
|
685
671
|
);
|
|
686
672
|
else if (c === "OpenDriveSection")
|
|
687
|
-
if (
|
|
688
|
-
this.highlightLayer.remove(
|
|
689
|
-
const
|
|
673
|
+
if (i.layer.id === "OpenDriveHighlight") {
|
|
674
|
+
this.highlightLayer.remove(i), this.sectionLayer.add(i), i.setAttribute("selected", !0), this.selectedSectionIds.push(r);
|
|
675
|
+
const n = `http://${this.openDriveServer}/api/sumo/getSumoEdge`, l = await b.get(n, {
|
|
690
676
|
params: {
|
|
691
|
-
id:
|
|
677
|
+
id: r,
|
|
692
678
|
projectName: this.projectName
|
|
693
679
|
}
|
|
694
680
|
});
|
|
695
681
|
if (l.status === 200 && l.data.status === 0 && this.openDriveClickCallback) {
|
|
696
682
|
const d = l.data.result.obj_id;
|
|
697
|
-
|
|
683
|
+
i.setAttribute("edgeId", d), this.openDriveClickCallback({
|
|
698
684
|
type: "OpenDriveSection",
|
|
699
685
|
id: d,
|
|
700
686
|
details: l.data.result
|
|
701
687
|
});
|
|
702
688
|
}
|
|
703
689
|
} else
|
|
704
|
-
this.sectionLayer.remove(
|
|
705
|
-
(
|
|
690
|
+
this.sectionLayer.remove(i), this.selectedSectionIds = this.selectedSectionIds.filter(
|
|
691
|
+
(n) => n !== r
|
|
706
692
|
), this.openDriveClickCallback && this.openDriveClickCallback({
|
|
707
693
|
type: "OpenDriveSection",
|
|
708
|
-
id:
|
|
694
|
+
id: i.getAttribute("edgeId"),
|
|
709
695
|
details: void 0
|
|
710
696
|
});
|
|
711
697
|
});
|
|
@@ -720,14 +706,14 @@ class M {
|
|
|
720
706
|
* @param targetSize
|
|
721
707
|
*/
|
|
722
708
|
increasePictureMarkerSize(e, t) {
|
|
723
|
-
const
|
|
724
|
-
const
|
|
725
|
-
|
|
709
|
+
const s = setInterval(() => {
|
|
710
|
+
const o = e.symbol, i = o.width;
|
|
711
|
+
i < t ? e.symbol = {
|
|
726
712
|
type: "picture-marker",
|
|
727
|
-
url:
|
|
728
|
-
width:
|
|
729
|
-
height:
|
|
730
|
-
} : clearInterval(
|
|
713
|
+
url: o.url,
|
|
714
|
+
width: i + 1,
|
|
715
|
+
height: i + 1
|
|
716
|
+
} : clearInterval(s);
|
|
731
717
|
}, 20);
|
|
732
718
|
}
|
|
733
719
|
/**
|
|
@@ -736,40 +722,40 @@ class M {
|
|
|
736
722
|
* @param targetSize
|
|
737
723
|
*/
|
|
738
724
|
decreasePictureMarkerSize(e, t) {
|
|
739
|
-
const
|
|
740
|
-
const
|
|
741
|
-
|
|
725
|
+
const s = setInterval(() => {
|
|
726
|
+
const o = e.symbol, i = o.width;
|
|
727
|
+
i > t ? e.symbol = {
|
|
742
728
|
type: "picture-marker",
|
|
743
|
-
url:
|
|
744
|
-
width:
|
|
745
|
-
height:
|
|
746
|
-
} : clearInterval(
|
|
729
|
+
url: o.url,
|
|
730
|
+
width: i - 1,
|
|
731
|
+
height: i - 1
|
|
732
|
+
} : clearInterval(s);
|
|
747
733
|
}, 20);
|
|
748
734
|
}
|
|
749
735
|
async getSumoInfo(e) {
|
|
750
736
|
switch (e.type) {
|
|
751
737
|
case "junction": {
|
|
752
|
-
const t = `http://${this.openDriveServer}/api/sumo/getSumoJunction`,
|
|
738
|
+
const t = `http://${this.openDriveServer}/api/sumo/getSumoJunction`, s = await b.get(t, {
|
|
753
739
|
params: {
|
|
754
740
|
id: e.id,
|
|
755
741
|
projectName: this.projectName
|
|
756
742
|
}
|
|
757
743
|
});
|
|
758
|
-
return
|
|
744
|
+
return s.status === 200 ? s.data : { status: -1, message: `路口信息查询失败: ${e.id}` };
|
|
759
745
|
}
|
|
760
746
|
case "edge": {
|
|
761
747
|
const t = e.id.split("#");
|
|
762
|
-
let
|
|
763
|
-
|
|
764
|
-
let
|
|
765
|
-
t.length === 2 && (
|
|
766
|
-
const
|
|
767
|
-
(c) => c.getAttribute("roadId") ===
|
|
748
|
+
let s = t[0];
|
|
749
|
+
s.startsWith("-") && (s = s.slice(1));
|
|
750
|
+
let o = 0;
|
|
751
|
+
t.length === 2 && (o = Number(t[1]));
|
|
752
|
+
const i = this.allLaneGraphics.find(
|
|
753
|
+
(c) => c.getAttribute("roadId") === s && c.getAttribute("sectionIndex") === o
|
|
768
754
|
);
|
|
769
|
-
if (
|
|
770
|
-
const c = `${
|
|
755
|
+
if (i) {
|
|
756
|
+
const c = `${s}+${i.getAttribute(
|
|
771
757
|
"sectionId"
|
|
772
|
-
)}`,
|
|
758
|
+
)}`, r = `http://${this.openDriveServer}/api/sumo/getSumoEdge`, a = await b.get(r, {
|
|
773
759
|
params: {
|
|
774
760
|
id: c,
|
|
775
761
|
projectName: this.projectName
|
|
@@ -787,13 +773,13 @@ class M {
|
|
|
787
773
|
* 清除OpenDrive内容
|
|
788
774
|
*/
|
|
789
775
|
async clearOpenDrive() {
|
|
790
|
-
var t,
|
|
776
|
+
var t, s, o;
|
|
791
777
|
let e = await this.laneLayer.queryFeatures();
|
|
792
778
|
e.features.length > 0 && await this.laneLayer.applyEdits({
|
|
793
779
|
deleteFeatures: e.features
|
|
794
780
|
}), e = await this.roadNameLayer.queryFeatures(), e.features.length > 0 && await this.roadNameLayer.applyEdits({
|
|
795
781
|
deleteFeatures: e.features
|
|
796
|
-
}), this.highlightLayer.removeAll(), this.junctionLayer.removeAll(), this.sectionLayer.removeAll(), this.flashLayer.removeAll(), (t = this.mouseMoveHandler) == null || t.remove(), this.mouseMoveHandler = void 0, (
|
|
782
|
+
}), this.highlightLayer.removeAll(), this.junctionLayer.removeAll(), this.sectionLayer.removeAll(), this.flashLayer.removeAll(), this.borderLayer.removeAll(), (t = this.mouseMoveHandler) == null || t.remove(), this.mouseMoveHandler = void 0, (s = this.mouseClickHandler) == null || s.remove(), this.mouseClickHandler = void 0, (o = this.scaleWatch) == null || o.remove(), this.scaleWatch = void 0;
|
|
797
783
|
}
|
|
798
784
|
/**
|
|
799
785
|
* 用sumo的id定位车道、基本段、路段
|
|
@@ -801,30 +787,30 @@ class M {
|
|
|
801
787
|
* @returns
|
|
802
788
|
*/
|
|
803
789
|
async findSumo(e) {
|
|
804
|
-
const { type: t, id:
|
|
790
|
+
const { type: t, id: s } = e, o = e.flash === void 0 ? !0 : e.flash;
|
|
805
791
|
if (t === "junction")
|
|
806
|
-
return await this.findJunction(
|
|
792
|
+
return await this.findJunction(s, o);
|
|
807
793
|
if (t === "edge") {
|
|
808
|
-
const
|
|
809
|
-
if (
|
|
794
|
+
const i = s.split("_");
|
|
795
|
+
if (i.length > 2)
|
|
810
796
|
return { status: -1, message: "id格式错误" };
|
|
811
|
-
const c =
|
|
812
|
-
if (
|
|
797
|
+
const c = i.length === 2 ? Number(i[1]) : void 0, r = i[0].split("#");
|
|
798
|
+
if (r.length > 2)
|
|
813
799
|
return { status: -1, message: "id格式错误" };
|
|
814
|
-
const a =
|
|
815
|
-
return await this.findLane({ roadsectId: a, segmentId:
|
|
800
|
+
const a = r[0], n = r.length === 2 ? Number(r[1]) : void 0;
|
|
801
|
+
return await this.findLane({ roadsectId: a, segmentId: n, laneId: c, flash: o });
|
|
816
802
|
} else
|
|
817
803
|
return { status: -1, message: "未知类型" };
|
|
818
804
|
}
|
|
819
805
|
async findJunction(e, t) {
|
|
820
|
-
const
|
|
821
|
-
(
|
|
806
|
+
const s = this.junctionLayer.graphics.find(
|
|
807
|
+
(o) => o.attributes.id === e
|
|
822
808
|
);
|
|
823
|
-
if (!
|
|
809
|
+
if (!s)
|
|
824
810
|
return { status: -1, message: "未找到。请检查路口编号" };
|
|
825
811
|
if (t) {
|
|
826
|
-
const
|
|
827
|
-
geometry:
|
|
812
|
+
const o = new g({
|
|
813
|
+
geometry: s.geometry,
|
|
828
814
|
symbol: {
|
|
829
815
|
type: "simple-marker",
|
|
830
816
|
style: "circle",
|
|
@@ -836,9 +822,9 @@ class M {
|
|
|
836
822
|
}
|
|
837
823
|
}
|
|
838
824
|
});
|
|
839
|
-
this.flashGraphic(
|
|
825
|
+
this.flashGraphic(o);
|
|
840
826
|
}
|
|
841
|
-
return await this.view.goTo(
|
|
827
|
+
return await this.view.goTo(s.geometry, { duration: 1e3 }), { status: 0, message: "ok" };
|
|
842
828
|
}
|
|
843
829
|
/**
|
|
844
830
|
* 用sumo的id定位车道、基本段、路段
|
|
@@ -846,41 +832,41 @@ class M {
|
|
|
846
832
|
* @returns
|
|
847
833
|
*/
|
|
848
834
|
async findLane(e) {
|
|
849
|
-
let { roadsectId: t, segmentId:
|
|
835
|
+
let { roadsectId: t, segmentId: s, laneId: o } = e;
|
|
850
836
|
t.startsWith("-") && (t = t.slice(1));
|
|
851
|
-
let
|
|
837
|
+
let i = this.allLaneGraphics.filter(
|
|
852
838
|
(a) => a.attributes.roadId === t
|
|
853
839
|
);
|
|
854
|
-
if (
|
|
840
|
+
if (i.length === 0)
|
|
855
841
|
return { status: -1, message: "未找到。请检查路段编号" };
|
|
856
|
-
if (
|
|
842
|
+
if (s !== void 0) {
|
|
857
843
|
const a = [];
|
|
858
|
-
if (
|
|
859
|
-
const l = Number(
|
|
844
|
+
if (i.forEach((n) => {
|
|
845
|
+
const l = Number(n.attributes.sectionId);
|
|
860
846
|
a.indexOf(l) === -1 && a.push(l);
|
|
861
|
-
}), a.sort((
|
|
847
|
+
}), a.sort((n, l) => n - l), s > a.length - 1)
|
|
862
848
|
return { status: -1, message: "未找到。请检查基本段编号" };
|
|
863
|
-
|
|
864
|
-
(
|
|
849
|
+
s = a[s], i = i.filter(
|
|
850
|
+
(n) => Number(n.attributes.sectionId) === s
|
|
865
851
|
);
|
|
866
852
|
}
|
|
867
|
-
if (
|
|
853
|
+
if (o !== void 0) {
|
|
868
854
|
const a = [];
|
|
869
|
-
if (
|
|
870
|
-
const l = Number(
|
|
855
|
+
if (i.forEach((n) => {
|
|
856
|
+
const l = Number(n.attributes.laneId);
|
|
871
857
|
a.indexOf(l) === -1 && a.push(l);
|
|
872
|
-
}), a.sort((
|
|
858
|
+
}), a.sort((n, l) => n - l), o > a.length - 1)
|
|
873
859
|
return { status: -1, message: "未找到。请检查车道编号" };
|
|
874
|
-
|
|
875
|
-
(
|
|
860
|
+
o = a[o], i = i.filter(
|
|
861
|
+
(n) => Number(n.attributes.laneId) === o
|
|
876
862
|
);
|
|
877
863
|
}
|
|
878
|
-
const c =
|
|
864
|
+
const c = i.map(
|
|
879
865
|
(a) => a.geometry
|
|
880
|
-
),
|
|
866
|
+
), r = S.union(c);
|
|
881
867
|
if (e.flash) {
|
|
882
868
|
const a = new g({
|
|
883
|
-
geometry:
|
|
869
|
+
geometry: r,
|
|
884
870
|
symbol: {
|
|
885
871
|
type: "simple-fill",
|
|
886
872
|
color: [0, 0, 255, 0.6],
|
|
@@ -892,7 +878,7 @@ class M {
|
|
|
892
878
|
});
|
|
893
879
|
this.flashGraphic(a);
|
|
894
880
|
}
|
|
895
|
-
return await this.view.goTo(
|
|
881
|
+
return await this.view.goTo(r, { duration: 1e3 }), { status: 0, message: "ok" };
|
|
896
882
|
}
|
|
897
883
|
/**
|
|
898
884
|
* graphic渐隐渐显闪烁
|
|
@@ -900,9 +886,9 @@ class M {
|
|
|
900
886
|
*/
|
|
901
887
|
flashGraphic(e) {
|
|
902
888
|
this.flashLayer.removeAll(), this.flashLayer.add(e);
|
|
903
|
-
let t = 0,
|
|
904
|
-
const
|
|
905
|
-
|
|
889
|
+
let t = 0, s = !0;
|
|
890
|
+
const o = setInterval(() => {
|
|
891
|
+
s ? (this.flashLayer.opacity -= 0.02, this.flashLayer.opacity <= 0.1 && (s = !1, t++)) : (this.flashLayer.opacity += 0.02, this.flashLayer.opacity >= 1 && (s = !0)), t >= 5 && (this.flashLayer.removeAll(), this.flashLayer.opacity = 1, clearInterval(o));
|
|
906
892
|
}, 10);
|
|
907
893
|
}
|
|
908
894
|
/**
|
|
@@ -918,10 +904,10 @@ class M {
|
|
|
918
904
|
));
|
|
919
905
|
}), !e || e.type === "edge") {
|
|
920
906
|
let t;
|
|
921
|
-
!e || !e.id || e.id === "" ? t = this.sectionLayer.graphics.toArray() : t = this.sectionLayer.graphics.filter((
|
|
922
|
-
const
|
|
907
|
+
!e || !e.id || e.id === "" ? t = this.sectionLayer.graphics.toArray() : t = this.sectionLayer.graphics.filter((s) => s.getAttribute("edgeId") === e.id).toArray(), t.length > 0 && (t.forEach((s) => {
|
|
908
|
+
const o = s.getAttribute("id");
|
|
923
909
|
this.selectedSectionIds = this.selectedSectionIds.filter(
|
|
924
|
-
(
|
|
910
|
+
(i) => i !== o
|
|
925
911
|
);
|
|
926
912
|
}), this.sectionLayer.removeMany(t));
|
|
927
913
|
}
|
|
@@ -941,25 +927,25 @@ class M {
|
|
|
941
927
|
}), { status: -1, message: "未找到路口" };
|
|
942
928
|
case "edge": {
|
|
943
929
|
const t = e.id.split("#");
|
|
944
|
-
let
|
|
945
|
-
|
|
946
|
-
let
|
|
947
|
-
t.length === 2 && (
|
|
948
|
-
let
|
|
949
|
-
if (t.length === 1 ?
|
|
950
|
-
(c) => c.getAttribute("roadId") ===
|
|
951
|
-
) : t.length === 2 && (
|
|
952
|
-
(c) => c.getAttribute("roadId") ===
|
|
953
|
-
)),
|
|
930
|
+
let s = String(t[0]);
|
|
931
|
+
s.startsWith("-") && (s = s.slice(1));
|
|
932
|
+
let o = 0;
|
|
933
|
+
t.length === 2 && (o = Number(t[1]));
|
|
934
|
+
let i = [];
|
|
935
|
+
if (t.length === 1 ? i = this.allLaneGraphics.filter(
|
|
936
|
+
(c) => c.getAttribute("roadId") === s
|
|
937
|
+
) : t.length === 2 && (i = this.allLaneGraphics.filter(
|
|
938
|
+
(c) => c.getAttribute("roadId") === s && c.getAttribute("sectionIndex") === o
|
|
939
|
+
)), i.length > 0) {
|
|
954
940
|
const c = /* @__PURE__ */ new Map();
|
|
955
|
-
return
|
|
956
|
-
const a =
|
|
941
|
+
return i.forEach((r) => {
|
|
942
|
+
const a = r.getAttribute("roadId") + "+" + r.getAttribute("sectionId");
|
|
957
943
|
this.selectedSectionIds.includes(a) || this.selectedSectionIds.push(a);
|
|
958
|
-
let
|
|
959
|
-
|
|
960
|
-
}), c.forEach((
|
|
961
|
-
const
|
|
962
|
-
geometry:
|
|
944
|
+
let n = c.get(a);
|
|
945
|
+
n ? n.push(r.geometry) : (n = [r.geometry], c.set(a, n));
|
|
946
|
+
}), c.forEach((r, a) => {
|
|
947
|
+
const n = S.union(r), l = new g({
|
|
948
|
+
geometry: n,
|
|
963
949
|
symbol: {
|
|
964
950
|
type: "simple-fill",
|
|
965
951
|
color: [0, 255, 255, 0.5],
|
|
@@ -986,81 +972,81 @@ class M {
|
|
|
986
972
|
}
|
|
987
973
|
}
|
|
988
974
|
async geometrySearch(e) {
|
|
989
|
-
const t = new
|
|
975
|
+
const t = new L({
|
|
990
976
|
rings: [e]
|
|
991
|
-
}),
|
|
977
|
+
}), s = await this.laneLayer.queryFeatures({
|
|
992
978
|
geometry: t,
|
|
993
979
|
outFields: ["*"]
|
|
994
|
-
}),
|
|
995
|
-
for (const a of
|
|
996
|
-
const
|
|
997
|
-
if (
|
|
998
|
-
|
|
980
|
+
}), o = [], i = [];
|
|
981
|
+
for (const a of s.features) {
|
|
982
|
+
const n = a.getAttribute("roadId"), l = a.getAttribute("sectionIndex"), d = `${n}#${l}`;
|
|
983
|
+
if (o.indexOf(d) === -1) {
|
|
984
|
+
o.push(d), this.selectSumo({
|
|
999
985
|
type: "edge",
|
|
1000
986
|
id: d
|
|
1001
987
|
});
|
|
1002
|
-
const u = `http://${this.openDriveServer}/api/sumo/getSumoEdge`,
|
|
988
|
+
const u = `http://${this.openDriveServer}/api/sumo/getSumoEdge`, y = await b.get(u, {
|
|
1003
989
|
params: {
|
|
1004
|
-
id: `${
|
|
990
|
+
id: `${n}+${a.getAttribute("sectionId")}`,
|
|
1005
991
|
projectName: this.projectName
|
|
1006
992
|
}
|
|
1007
993
|
});
|
|
1008
|
-
|
|
994
|
+
y.status === 200 && y.data.status === 0 && i.push(y.data.result);
|
|
1009
995
|
}
|
|
1010
996
|
}
|
|
1011
997
|
const c = this.junctionLayer.graphics.filter((a) => {
|
|
1012
|
-
const
|
|
1013
|
-
return
|
|
1014
|
-
}),
|
|
998
|
+
const n = a.geometry;
|
|
999
|
+
return S.contains(t, n);
|
|
1000
|
+
}), r = [];
|
|
1015
1001
|
for (const a of c) {
|
|
1016
|
-
const
|
|
1002
|
+
const n = a.getAttribute("id");
|
|
1017
1003
|
this.selectSumo({
|
|
1018
1004
|
type: "junction",
|
|
1019
|
-
id:
|
|
1005
|
+
id: n
|
|
1020
1006
|
});
|
|
1021
1007
|
const l = `http://${this.openDriveServer}/api/sumo/getSumoJunction`, d = await b.get(l, {
|
|
1022
1008
|
params: {
|
|
1023
|
-
id:
|
|
1009
|
+
id: n,
|
|
1024
1010
|
projectName: this.projectName
|
|
1025
1011
|
}
|
|
1026
1012
|
});
|
|
1027
|
-
d.status === 200 && d.data.status === 0 &&
|
|
1013
|
+
d.status === 200 && d.data.status === 0 && r.push(d.data.result);
|
|
1028
1014
|
}
|
|
1029
1015
|
return {
|
|
1030
1016
|
status: 0,
|
|
1031
1017
|
message: "ok",
|
|
1032
1018
|
result: {
|
|
1033
|
-
junctions:
|
|
1034
|
-
edges:
|
|
1019
|
+
junctions: r,
|
|
1020
|
+
edges: i
|
|
1035
1021
|
}
|
|
1036
1022
|
};
|
|
1037
1023
|
}
|
|
1038
1024
|
async splitLane(e) {
|
|
1039
|
-
const
|
|
1040
|
-
if (
|
|
1025
|
+
const s = e.id.split("_");
|
|
1026
|
+
if (s.length !== 2)
|
|
1041
1027
|
return { status: -1, message: "车道编号格式错误" };
|
|
1042
|
-
const
|
|
1043
|
-
let
|
|
1044
|
-
|
|
1045
|
-
const a = this.allLaneGraphics.filter((
|
|
1028
|
+
const o = Number(s[1]), i = s[0].split("#"), c = i.length === 2 ? Number(i[1]) : 0;
|
|
1029
|
+
let r = i[0];
|
|
1030
|
+
r.startsWith("-") && (r = r.slice(1));
|
|
1031
|
+
const a = this.allLaneGraphics.filter((I) => I.getAttribute("roadId") === r && I.getAttribute("sectionIndex") === c);
|
|
1046
1032
|
if (a.length === 0)
|
|
1047
1033
|
return { status: -1, message: "未找到路段" };
|
|
1048
|
-
const
|
|
1049
|
-
(
|
|
1034
|
+
const n = a.length - o, l = a.find(
|
|
1035
|
+
(I) => Math.abs(I.getAttribute("laneId")) === n
|
|
1050
1036
|
);
|
|
1051
1037
|
if (!l)
|
|
1052
1038
|
return { status: -1, message: "未找到车道" };
|
|
1053
|
-
const d = e.start || 0, u = e.end || 100,
|
|
1039
|
+
const d = e.start || 0, u = e.end || 100, y = D.lineString(l.getAttribute("leftLine")), m = x(y, d, u, {
|
|
1054
1040
|
units: "meters"
|
|
1055
|
-
}),
|
|
1041
|
+
}), h = D.lineString(l.getAttribute("rightLine")), p = x(h, d, u, {
|
|
1056
1042
|
units: "meters"
|
|
1057
|
-
}),
|
|
1058
|
-
|
|
1043
|
+
}), f = m.geometry.coordinates.concat(
|
|
1044
|
+
p.geometry.coordinates.reverse()
|
|
1059
1045
|
);
|
|
1060
|
-
|
|
1046
|
+
f.push(f[f.length - 1]);
|
|
1061
1047
|
const v = new g({
|
|
1062
|
-
geometry: new
|
|
1063
|
-
rings: [
|
|
1048
|
+
geometry: new L({
|
|
1049
|
+
rings: [f]
|
|
1064
1050
|
}),
|
|
1065
1051
|
attributes: {
|
|
1066
1052
|
ObjectID: l.getAttribute("ObjectID"),
|
|
@@ -1074,8 +1060,8 @@ class M {
|
|
|
1074
1060
|
laneId: l.getAttribute("laneId"),
|
|
1075
1061
|
type: l.getAttribute("type"),
|
|
1076
1062
|
sumoId: l.getAttribute("sumoId"),
|
|
1077
|
-
leftLine:
|
|
1078
|
-
rightLine:
|
|
1063
|
+
leftLine: m.geometry.coordinates,
|
|
1064
|
+
rightLine: p.geometry.coordinates
|
|
1079
1065
|
},
|
|
1080
1066
|
symbol: {
|
|
1081
1067
|
type: "simple-fill",
|
|
@@ -1090,6 +1076,19 @@ class M {
|
|
|
1090
1076
|
clearSplitLane() {
|
|
1091
1077
|
this.splitLaneLayer.removeAll();
|
|
1092
1078
|
}
|
|
1079
|
+
/**
|
|
1080
|
+
* 更新所有路口的symbol
|
|
1081
|
+
* @param symbolStyle
|
|
1082
|
+
*/
|
|
1083
|
+
updateAllJunctionSymbol(e) {
|
|
1084
|
+
const t = this.junctionLayer.graphics.clone();
|
|
1085
|
+
this.junctionLayer.removeAll(), t.forEach((s) => {
|
|
1086
|
+
s.symbol = this.getCrossGraphicSymbol(
|
|
1087
|
+
s.attributes,
|
|
1088
|
+
e
|
|
1089
|
+
);
|
|
1090
|
+
}), this.junctionLayer.addMany(t.toArray());
|
|
1091
|
+
}
|
|
1093
1092
|
/**
|
|
1094
1093
|
* 生成路口点符号。在不同比例尺下,使用不同的符号
|
|
1095
1094
|
* @param attributes
|
|
@@ -1097,17 +1096,17 @@ class M {
|
|
|
1097
1096
|
* @returns
|
|
1098
1097
|
*/
|
|
1099
1098
|
getCrossGraphicSymbol(e, t) {
|
|
1100
|
-
const
|
|
1099
|
+
const s = e.crossId !== "" && e.crossId !== void 0 && e.crossId !== null;
|
|
1101
1100
|
if (t === "marker")
|
|
1102
1101
|
return {
|
|
1103
1102
|
type: "picture-marker",
|
|
1104
|
-
url: `/GisViewerAssets/Images/xhj_${
|
|
1103
|
+
url: `/GisViewerAssets/Images/xhj_${s ? 1 : 2}.png`,
|
|
1105
1104
|
width: "18px",
|
|
1106
1105
|
height: "28px",
|
|
1107
1106
|
yOffset: "12px"
|
|
1108
1107
|
};
|
|
1109
1108
|
if (t === "picture")
|
|
1110
|
-
return
|
|
1109
|
+
return s ? {
|
|
1111
1110
|
type: "cim",
|
|
1112
1111
|
data: {
|
|
1113
1112
|
type: "CIMSymbolReference",
|
|
@@ -1145,7 +1144,7 @@ class M {
|
|
|
1145
1144
|
height: 12,
|
|
1146
1145
|
horizontalAlignment: "Center",
|
|
1147
1146
|
offsetX: 0,
|
|
1148
|
-
offsetY:
|
|
1147
|
+
offsetY: s ? 50 : 40,
|
|
1149
1148
|
haloSize: 2,
|
|
1150
1149
|
haloSymbol: {
|
|
1151
1150
|
type: "CIMPolygonSymbol",
|
|
@@ -1187,8 +1186,8 @@ class M {
|
|
|
1187
1186
|
size: 45,
|
|
1188
1187
|
rotateClockwise: !0,
|
|
1189
1188
|
textureFilter: "Picture",
|
|
1190
|
-
url: "/GisViewerAssets/Images/
|
|
1191
|
-
offsetY:
|
|
1189
|
+
url: "/GisViewerAssets/Images/xhj_1.png",
|
|
1190
|
+
offsetY: s ? 22 : 15
|
|
1192
1191
|
}
|
|
1193
1192
|
]
|
|
1194
1193
|
}
|
|
@@ -1203,5 +1202,5 @@ class M {
|
|
|
1203
1202
|
}
|
|
1204
1203
|
}
|
|
1205
1204
|
export {
|
|
1206
|
-
|
|
1205
|
+
O as default
|
|
1207
1206
|
};
|
|
@@ -18,6 +18,8 @@ export default class OpenDriveRenderer {
|
|
|
18
18
|
private mouseClickHandler;
|
|
19
19
|
private junctionNames;
|
|
20
20
|
private readonly junctionScale;
|
|
21
|
+
private scaleWatch;
|
|
22
|
+
private xodrBorder;
|
|
21
23
|
constructor(view: __esri.MapView | __esri.SceneView);
|
|
22
24
|
private projectName;
|
|
23
25
|
private openDriveServer;
|
|
@@ -111,6 +113,11 @@ export default class OpenDriveRenderer {
|
|
|
111
113
|
geometrySearch(coordinate: number[][]): Promise<IResult>;
|
|
112
114
|
splitLane(params: ISplitOpenDriveLaneParams): Promise<IResult>;
|
|
113
115
|
clearSplitLane(): void;
|
|
116
|
+
/**
|
|
117
|
+
* 更新所有路口的symbol
|
|
118
|
+
* @param symbolStyle
|
|
119
|
+
*/
|
|
120
|
+
private updateAllJunctionSymbol;
|
|
114
121
|
/**
|
|
115
122
|
* 生成路口点符号。在不同比例尺下,使用不同的符号
|
|
116
123
|
* @param attributes
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const f=require("@arcgis/core/Graphic"),F=require("@arcgis/core/core/promiseUtils"),E=require("@arcgis/core/core/reactiveUtils.js"),A=require("@arcgis/core/geometry"),q=require("@arcgis/core/geometry/geometryEngine"),G=require("@arcgis/core/layers/FeatureLayer"),I=require("@arcgis/core/layers/GraphicsLayer"),R=require("@turf/helpers"),x=require("@turf/line-slice-along"),b=require("axios"),J=require("fast-xml-parser"),T=require("md5"),O=require("pako"),H=require("vue"),_=require("../../stores/index.js"),z=require("../common-utils.js");function N(L){const e=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(L){for(const t in L)if(t!=="default"){const i=Object.getOwnPropertyDescriptor(L,t);Object.defineProperty(e,t,i.get?i:{enumerable:!0,get:()=>L[t]})}}return e.default=L,Object.freeze(e)}const M=N(F),U=N(E),S=N(q),P=N(R);class C{constructor(e){this.junctionNames=new Map,this.junctionScale=5e3,this.projectName="",this.openDriveServer="",this.currentSectionCode="",this.selectedSectionIds=[],this.currentJunctionId="",this.view=e,this.laneLayer=new G({id:"OpenDriveLane",fields:[{name:"ObjectID",alias:"ObjectID",type:"oid"},{name:"id",alias:"编号",type:"string"},{name:"roadId",alias:"道路号",type:"string"},{name:"roadName",alias:"道路名称",type:"string"},{name:"sectionId",alias:"路段号",type:"string"},{name:"sectionIndex",alias:"路段序号",type:"string"},{name:"laneId",alias:"车道号",type:"string"},{name:"type",alias:"类型",type:"string"},{name:"sumoId",alias:"sumo编号",type:"string"},{name:"fromNode",alias:"起点路口",type:"string"},{name:"toNode",alias:"终点路口",type:"string"}],objectIdField:"ObjectID",geometryType:"polygon",spatialReference:{wkid:4326},source:[],outFields:["*"],renderer:{type:"unique-value",field:"type",defaultSymbol:{type:"simple-fill",color:[100,100,100],style:"solid",outline:{color:"white",width:1}},uniqueValueInfos:[{value:"shoulder",label:"路肩",symbol:{type:"simple-fill",color:"#008000",style:"solid",outline:{color:"white",width:1}}},{value:"border",label:"路沿",symbol:{type:"simple-fill",color:"#DCDCDC",style:"solid",outline:{color:"white",width:1}}},{value:"driving",label:"机动车道",symbol:{type:"simple-fill",color:[47,79,79,.8],style:"solid",outline:{color:"white",width:1}}},{value:"none",label:"无",symbol:{type:"simple-fill",color:[111,120,135],style:"none",outline:{color:"white",width:1}}},{value:"restricted",label:"禁行区",symbol:{type:"simple-fill",color:"yellow",style:"solid",outline:{color:"yellow",width:2}}},{value:"parking",label:"停车区",symbol:{type:"simple-fill",color:[115,115,115],style:"solid",outline:{color:"white",width:1}}},{value:"median",label:"中央隔离带",symbol:{type:"simple-fill",color:"#008000",style:"solid",outline:{color:"white",width:1}}},{value:"biking",label:"非机动车道",symbol:{type:"simple-fill",color:"#D3D3D3",style:"solid",outline:{color:"white",width:1}}},{value:"sidewalk",label:"人行道",symbol:{type:"simple-fill",color:"#C0C0C0",style:"solid",outline:{color:"white",width:1}}},{value:"junction",label:"路口区域",symbol:{type:"simple-fill",color:"#2F4F4F",style:"solid",outline:{color:"white",width:1}}},{value:"selected",label:"选中车道",symbol:{type:"simple-fill",color:[141,168,211],style:"solid",outline:{color:"white",width:1}}}]}}),this.roadNameLayer=new G({id:"OpenDriveRoadName",fields:[{name:"ObjectID",alias:"ObjectID",type:"oid"},{name:"roadId",alias:"道路号",type:"string"},{name:"roadName",alias:"道路名称",type:"string"}],objectIdField:"ObjectID",geometryType:"polyline",spatialReference:{wkid:4326},source:[],renderer:{type:"simple",symbol:{type:"simple-line",style:"solid",color:[0,0,0,0],width:1}},labelingInfo:[{symbol:{type:"text",color:"black",haloColor:"white",haloSize:1,font:{size:12,family:"sans-serif"}},labelPlacement:this.view.type==="2d"?"center-along":void 0,labelExpressionInfo:{expression:"$feature.roadName"}}]}),this.junctionLayer=new I({id:"OpenDriveJunction"}),this.sectionLayer=new I({id:"OpenDriveSection"}),this.highlightLayer=new I({id:"OpenDriveHighlight"}),this.flashLayer=new I({id:"OpenDriveFlash"}),this.drawLayer=new I({id:"Draw"}),this.splitLaneLayer=new I({id:"SplitLane"}),this.borderLayer=new I({id:"OpenDriveBorder"}),this.view.map.addMany([this.laneLayer,this.sectionLayer,this.roadNameLayer,this.junctionLayer,this.highlightLayer,this.flashLayer,this.drawLayer,this.splitLaneLayer,this.borderLayer])}static getInstance(e){return this.instance||(this.instance=new C(e)),this.instance}async makeMd5FromFile(e){var t;try{const r=await(await fetch(e)).text(),n=(t=new J.XMLParser({ignoreAttributes:!1,allowBooleanAttributes:!0}).parse(r).OpenDRIVE.userData)==null?void 0:t.border;return{status:0,message:"ok",result:{md5:T(r),border:n}}}catch(i){return{status:-1,message:i.message}}}async showOpenDriveFromFile(e){var g,y;this.openDriveClickCallback=e.selectedCallback,U.watch(()=>this.view.scale,(p,d)=>{p>this.junctionScale&&d<=this.junctionScale?(console.log(p,d),this.junctionLayer.graphics.forEach(m=>{m.symbol=this.getCrossGraphicSymbol(m.attributes,"marker")})):p<=this.junctionScale&&d>this.junctionScale&&(console.log(p,d),this.junctionLayer.graphics.forEach(m=>{m.symbol=this.getCrossGraphicSymbol(m.attributes,"picture")}))}),console.time("md5用时");const t=await this.makeMd5FromFile(e.file);if(t.status!==0)return t;this.projectName=t.result.md5,console.timeEnd("md5用时"),console.log(t.result.border),this.openDriveServer=e.server;const i=`http://${this.openDriveServer}/api/openDrive/uploadXodr`;let r;try{r=await b.post(i,{},{params:{url:e.file,projectName:this.projectName}})}catch(p){return{status:-1,message:p.message}}if(r.status!==200)return{status:-1,message:r.statusText};console.time("渲染用时");const s=r.data.result.geoSetting;z.default.setGeoData(s.geoReference,s.offsetX,s.offsetY);let c=r.data.result.json;c.startsWith(window.location.protocol)||(c=`${window.location.protocol}//${e.server}${c}`);const a=await(await fetch(c)).arrayBuffer(),o=O.inflate(a,{to:"string"}),l=JSON.parse(o);await this.showAllLanes(l,((g=e.options)==null?void 0:g.showJunctionLane)||!1,((y=e.options)==null?void 0:y.showRoadName)||!0);const u=r.data.result.junctions;this.showJunction(u),e.options&&e.options.centerMap!==!1&&await this.view.goTo(this.allLaneGraphics),this.mouseMoveHandler||this.monitorMouseMove(),this.mouseClickHandler||this.monitorMouseClick();const h=_.default.useAppDataStore;return H.watch(()=>h.isSketching,()=>{var p,d;h.isSketching?((p=this.mouseMoveHandler)==null||p.remove(),this.mouseMoveHandler=void 0,(d=this.mouseClickHandler)==null||d.remove(),this.mouseClickHandler=void 0):(this.monitorMouseMove(),this.monitorMouseClick())}),console.timeEnd("渲染用时"),{status:0,message:"ok"}}async showOpenDriveFromServer(e,t){const i=`http://${e}/api/openDrive/analyzeXodr`,r=await b.get(i,{headers:{projectName:t},params:{analyze:!1,compressed:!0}});if(r.status!==200)throw new Error(`OpenDriveRenderer: ${r.statusText}`);let s=r.data.result.json;s.startsWith(window.location.protocol)||(s=`${window.location.protocol}//${e}${s}`);const n=await(await fetch(s)).arrayBuffer(),a=O.inflate(n,{to:"string"}),o=JSON.parse(a);return await this.showAllLanes(o,!1,!1),{status:0,message:"ok"}}async showAllLanes(e,t,i){const r=await this.laneLayer.queryFeatures();return r.features.length>0&&this.laneLayer.applyEdits({deleteFeatures:r.features}),this.roadNameLayer.visible=i,new Promise(s=>{let c=0;this.allLaneGraphics=[],this.allRefLineGraphics=[];const n=[];for(const o of e){if(!t&&o.junction!=="-1")continue;const{id:l,refLine:u}=o;let h=o.name;h.includes("(")&&(h=h.slice(0,h.indexOf("("))),h=h.replace(/(.)/g,"$1 ");const g=new f({geometry:{type:"polyline",paths:[u]},attributes:{ObjectID:c++,roadId:l,roadName:h}});this.allRefLineGraphics.push(g),o.laneSections.sort((y,p)=>Number(y.id)-Number(p.id));for(let y=0;y<o.laneSections.length;y++){const p=o.laneSections[y],d=Number(p.id);for(const m of p.lanePaths){const v=Number(m.id);if(v===0)continue;const w=m.type,$=[...m.outerPath],j=m.innerPath.concat($.reverse());if(j.length<=3){console.warn(`lane ${v} has less than 3 points`);continue}j.push(m.innerPath[0]);const D=new A.Polygon({rings:[j]});if(D){const k=new f({geometry:D,attributes:{ObjectID:c++,id:`${l}+${d}+${v}`,fromNode:o.fromNode,toNode:o.toNode,roadId:String(l),roadName:o.name,sectionId:String(d),sectionIndex:y,laneId:v,type:w,sumoId:"",leftLine:m.innerPath,rightLine:m.outerPath}});this.allLaneGraphics.push(k),n.push(k)}}}}const a=setInterval(()=>{if(n.length>0||this.allRefLineGraphics.length>0){if(n.length>0){const o=n.splice(0,100);this.laneLayer.applyEdits({addFeatures:o})}if(this.allRefLineGraphics.length>0){const o=this.allRefLineGraphics.splice(0,10);this.roadNameLayer.applyEdits({addFeatures:o})}}else clearInterval(a),s()},10)})}showJunction(e){const t=[];for(const i of e){if(!i)continue;this.junctionNames.set(i.id,i.name),i.nodeType=i.type;const r=new f({geometry:{type:"point",x:i.coordinates[0],y:i.coordinates[1]},attributes:{...i,selected:!1,type:"OpenDriveJunction"},symbol:this.getCrossGraphicSymbol(i,"marker")});t.push(r)}this.junctionLayer.addMany(t)}monitorMouseMove(){const e=M.debounce(async t=>{var c;const r=(c=(await this.view.hitTest(t,{include:[this.laneLayer,this.junctionLayer]})).results)==null?void 0:c.filter(n=>n.type==="graphic");if(r.length===0){this.currentSectionCode!==""&&(this.currentSectionCode="",this.highlightLayer.removeAll()),this.currentJunctionId!==""&&(this.currentJunctionId=""),this.view.closePopup();return}const s=r[0];if(this.hitGraphic=s.graphic,s.layer.id==="OpenDriveLane"){const n=`${this.hitGraphic.getAttribute("roadId")}+${this.hitGraphic.getAttribute("sectionId")}`;if(this.currentSectionCode===n||this.selectedSectionIds.includes(n)||this.sectionLayer.graphics.findIndex(d=>d.getAttribute("id")===n)>=0)return;this.currentSectionCode=n;const o=this.allLaneGraphics.filter(d=>`${d.attributes.roadId}+${d.attributes.sectionId}`===n),l=S.union(o.map(d=>d.geometry)),u=this.hitGraphic.getAttribute("fromNode"),h=this.hitGraphic.getAttribute("toNode"),g=this.junctionNames.get(u)||u,y=this.junctionNames.get(h)||h,p=new f({geometry:l,symbol:{type:"simple-fill",color:[0,255,255,.5],style:"solid",outline:{color:[0,255,255],width:1}},attributes:{type:"OpenDriveSection",id:n,selected:!1,fromNodeName:g,toNodeName:y,laneCount:o.length},popupTemplate:{title:this.hitGraphic.getAttribute("roadName"),content:[{type:"fields",fieldInfos:[{fieldName:"fromNodeName",label:"起点路口"},{fieldName:"toNodeName",label:"终点路口"},{fieldName:"laneCount",label:"车道数量"}]}]}});this.highlightLayer.removeAll(),this.highlightLayer.add(p)}else if(s.layer.id==="OpenDriveJunction"){const n=this.hitGraphic.getAttribute("id");if(n===this.currentJunctionId)return;this.currentJunctionId=n}});this.mouseMoveHandler=this.view.on("pointer-move",async t=>{e(t).catch(()=>{})})}monitorMouseClick(){const e=M.debounce(async t=>{var a;const r=(a=(await this.view.hitTest(t,{include:[this.highlightLayer,this.junctionLayer,this.sectionLayer]})).results)==null?void 0:a.filter(o=>o.type==="graphic");if(r.length===0)return;const s=r[0].graphic,c=s.getAttribute("type"),n=s.getAttribute("id");if(c==="OpenDriveJunction")if(s.getAttribute("selected")===!1){const o=`http://${this.openDriveServer}/api/sumo/getSumoJunction`,l=await b.get(o,{params:{id:n,projectName:this.projectName}});l.status===200&&l.data.status===0&&(this.openDriveClickCallback&&this.openDriveClickCallback({type:"OpenDriveJunction",id:n,details:l.data.result}),s.setAttribute("selected",!0),s.symbol={type:"picture-marker",url:"/GisViewerAssets/Images/point_red.png",width:"20px",height:"20px"},this.increasePictureMarkerSize(s,50))}else this.openDriveClickCallback&&this.openDriveClickCallback({type:"OpenDriveJunction",id:n,details:void 0}),s.setAttribute("selected",!1),s.symbol=this.getCrossGraphicSymbol(s.attributes,this.view.scale<this.junctionScale?"picture":"marker");else if(c==="OpenDriveSection")if(s.layer.id==="OpenDriveHighlight"){this.highlightLayer.remove(s),this.sectionLayer.add(s),s.setAttribute("selected",!0),this.selectedSectionIds.push(n);const o=`http://${this.openDriveServer}/api/sumo/getSumoEdge`,l=await b.get(o,{params:{id:n,projectName:this.projectName}});if(l.status===200&&l.data.status===0&&this.openDriveClickCallback){const u=l.data.result.obj_id;s.setAttribute("edgeId",u),this.openDriveClickCallback({type:"OpenDriveSection",id:u,details:l.data.result})}}else this.sectionLayer.remove(s),this.selectedSectionIds=this.selectedSectionIds.filter(o=>o!==n),this.openDriveClickCallback&&this.openDriveClickCallback({type:"OpenDriveSection",id:s.getAttribute("edgeId"),details:void 0})});this.mouseClickHandler=this.view.on("immediate-click",async t=>{e(t).catch(()=>{})})}increasePictureMarkerSize(e,t){const i=setInterval(()=>{const r=e.symbol,s=r.width;s<t?e.symbol={type:"picture-marker",url:r.url,width:s+1,height:s+1}:clearInterval(i)},20)}decreasePictureMarkerSize(e,t){const i=setInterval(()=>{const r=e.symbol,s=r.width;s>t?e.symbol={type:"picture-marker",url:r.url,width:s-1,height:s-1}:clearInterval(i)},20)}async getSumoInfo(e){switch(e.type){case"junction":{const t=`http://${this.openDriveServer}/api/sumo/getSumoJunction`,i=await b.get(t,{params:{id:e.id,projectName:this.projectName}});return i.status===200?i.data:{status:-1,message:`路口信息查询失败: ${e.id}`}}case"edge":{const t=e.id.split("#");let i=t[0];i.startsWith("-")&&(i=i.slice(1));let r=0;t.length===2&&(r=Number(t[1]));const s=this.allLaneGraphics.find(c=>c.getAttribute("roadId")===i&&c.getAttribute("sectionIndex")===r);if(s){const c=`${i}+${s.getAttribute("sectionId")}`,n=`http://${this.openDriveServer}/api/sumo/getSumoEdge`,a=await b.get(n,{params:{id:c,projectName:this.projectName}});return a.status===200?a.data:{status:-1,message:`路段信息查询失败: ${c}`}}else return{status:-1,message:"未知类型"}}default:return{status:-1,message:"未知类型"}}}async clearOpenDrive(){var t,i;let e=await this.laneLayer.queryFeatures();e.features.length>0&&await this.laneLayer.applyEdits({deleteFeatures:e.features}),e=await this.roadNameLayer.queryFeatures(),e.features.length>0&&await this.roadNameLayer.applyEdits({deleteFeatures:e.features}),this.highlightLayer.removeAll(),this.junctionLayer.removeAll(),this.sectionLayer.removeAll(),this.flashLayer.removeAll(),(t=this.mouseMoveHandler)==null||t.remove(),this.mouseMoveHandler=void 0,(i=this.mouseClickHandler)==null||i.remove(),this.mouseClickHandler=void 0}async findSumo(e){const{type:t,id:i}=e,r=e.flash===void 0?!0:e.flash;if(t==="junction")return await this.findJunction(i,r);if(t==="edge"){const s=i.split("_");if(s.length>2)return{status:-1,message:"id格式错误"};const c=s.length===2?Number(s[1]):void 0,n=s[0].split("#");if(n.length>2)return{status:-1,message:"id格式错误"};const a=n[0],o=n.length===2?Number(n[1]):void 0;return await this.findLane({roadsectId:a,segmentId:o,laneId:c,flash:r})}else return{status:-1,message:"未知类型"}}async findJunction(e,t){const i=this.junctionLayer.graphics.find(r=>r.attributes.id===e);if(!i)return{status:-1,message:"未找到。请检查路口编号"};if(t){const r=new f({geometry:i.geometry,symbol:{type:"simple-marker",style:"circle",size:30,color:[0,255,255,.8],outline:{color:[0,255,255],width:1}}});this.flashGraphic(r)}return await this.view.goTo(i.geometry,{duration:1e3}),{status:0,message:"ok"}}async findLane(e){let{roadsectId:t,segmentId:i,laneId:r}=e;t.startsWith("-")&&(t=t.slice(1));let s=this.allLaneGraphics.filter(a=>a.attributes.roadId===t);if(s.length===0)return{status:-1,message:"未找到。请检查路段编号"};if(i!==void 0){const a=[];if(s.forEach(o=>{const l=Number(o.attributes.sectionId);a.indexOf(l)===-1&&a.push(l)}),a.sort((o,l)=>o-l),i>a.length-1)return{status:-1,message:"未找到。请检查基本段编号"};i=a[i],s=s.filter(o=>Number(o.attributes.sectionId)===i)}if(r!==void 0){const a=[];if(s.forEach(o=>{const l=Number(o.attributes.laneId);a.indexOf(l)===-1&&a.push(l)}),a.sort((o,l)=>o-l),r>a.length-1)return{status:-1,message:"未找到。请检查车道编号"};r=a[r],s=s.filter(o=>Number(o.attributes.laneId)===r)}const c=s.map(a=>a.geometry),n=S.union(c);if(e.flash){const a=new f({geometry:n,symbol:{type:"simple-fill",color:[0,0,255,.6],style:"solid",outline:{width:0}}});this.flashGraphic(a)}return await this.view.goTo(n,{duration:1e3}),{status:0,message:"ok"}}flashGraphic(e){this.flashLayer.removeAll(),this.flashLayer.add(e);let t=0,i=!0;const r=setInterval(()=>{i?(this.flashLayer.opacity-=.02,this.flashLayer.opacity<=.1&&(i=!1,t++)):(this.flashLayer.opacity+=.02,this.flashLayer.opacity>=1&&(i=!0)),t>=5&&(this.flashLayer.removeAll(),this.flashLayer.opacity=1,clearInterval(r))},10)}unselectSumo(e){if((!e||e.type==="junction")&&this.junctionLayer.graphics.forEach(t=>{(!e||!e.id||e.id===""||e.id===t.getAttribute("id"))&&t.getAttribute("selected")&&(t.setAttribute("selected",!1),t.symbol=this.getCrossGraphicSymbol(t.attributes,this.view.scale<this.junctionScale?"picture":"marker"))}),!e||e.type==="edge"){let t;!e||!e.id||e.id===""?t=this.sectionLayer.graphics.toArray():t=this.sectionLayer.graphics.filter(i=>i.getAttribute("edgeId")===e.id).toArray(),t.length>0&&(t.forEach(i=>{const r=i.getAttribute("id");this.selectedSectionIds=this.selectedSectionIds.filter(s=>s!==r)}),this.sectionLayer.removeMany(t))}return{status:0,message:"ok"}}selectSumo(e){switch(e.type){case"junction":return this.junctionLayer.graphics.forEach(t=>{if(e.id===t.getAttribute("id"))return t.setAttribute("selected",!0),t.symbol.url="/GisViewerAssets/Images/point_red.png",this.increasePictureMarkerSize(t,50),{status:0,message:"ok"}}),{status:-1,message:"未找到路口"};case"edge":{const t=e.id.split("#");let i=String(t[0]);i.startsWith("-")&&(i=i.slice(1));let r=0;t.length===2&&(r=Number(t[1]));let s=[];if(t.length===1?s=this.allLaneGraphics.filter(c=>c.getAttribute("roadId")===i):t.length===2&&(s=this.allLaneGraphics.filter(c=>c.getAttribute("roadId")===i&&c.getAttribute("sectionIndex")===r)),s.length>0){const c=new Map;return s.forEach(n=>{const a=n.getAttribute("roadId")+"+"+n.getAttribute("sectionId");this.selectedSectionIds.includes(a)||this.selectedSectionIds.push(a);let o=c.get(a);o?o.push(n.geometry):(o=[n.geometry],c.set(a,o))}),c.forEach((n,a)=>{const o=S.union(n),l=new f({geometry:o,symbol:{type:"simple-fill",color:[0,255,255,.5],style:"solid",outline:{color:[0,255,255],width:1}},attributes:{type:"OpenDriveSection",id:a,edgeId:e.id,selected:!0}});this.sectionLayer.add(l)}),{status:0,message:"ok"}}else return{status:-1,message:"未找到路段"}}default:return{status:-1,message:"未知类型"}}}async geometrySearch(e){const t=new A.Polygon({rings:[e]}),i=await this.laneLayer.queryFeatures({geometry:t,outFields:["*"]}),r=[],s=[];for(const a of i.features){const o=a.getAttribute("roadId"),l=a.getAttribute("sectionIndex"),u=`${o}#${l}`;if(r.indexOf(u)===-1){r.push(u),this.selectSumo({type:"edge",id:u});const h=`http://${this.openDriveServer}/api/sumo/getSumoEdge`,g=await b.get(h,{params:{id:`${o}+${a.getAttribute("sectionId")}`,projectName:this.projectName}});g.status===200&&g.data.status===0&&s.push(g.data.result)}}const c=this.junctionLayer.graphics.filter(a=>{const o=a.geometry;return S.contains(t,o)}),n=[];for(const a of c){const o=a.getAttribute("id");this.selectSumo({type:"junction",id:o});const l=`http://${this.openDriveServer}/api/sumo/getSumoJunction`,u=await b.get(l,{params:{id:o,projectName:this.projectName}});u.status===200&&u.data.status===0&&n.push(u.data.result)}return{status:0,message:"ok",result:{junctions:n,edges:s}}}async splitLane(e){const i=e.id.split("_");if(i.length!==2)return{status:-1,message:"车道编号格式错误"};const r=Number(i[1]),s=i[0].split("#"),c=s.length===2?Number(s[1]):0;let n=s[0];n.startsWith("-")&&(n=n.slice(1));const a=this.allLaneGraphics.filter(w=>w.getAttribute("roadId")===n&&w.getAttribute("sectionIndex")===c);if(a.length===0)return{status:-1,message:"未找到路段"};const o=a.length-r,l=a.find(w=>Math.abs(w.getAttribute("laneId"))===o);if(!l)return{status:-1,message:"未找到车道"};const u=e.start||0,h=e.end||100,g=P.lineString(l.getAttribute("leftLine")),y=x.lineSliceAlong(g,u,h,{units:"meters"}),p=P.lineString(l.getAttribute("rightLine")),d=x.lineSliceAlong(p,u,h,{units:"meters"}),m=y.geometry.coordinates.concat(d.geometry.coordinates.reverse());m.push(m[m.length-1]);const v=new f({geometry:new A.Polygon({rings:[m]}),attributes:{ObjectID:l.getAttribute("ObjectID"),id:l.getAttribute("id"),fromNode:l.getAttribute("fromNode"),toNode:l.getAttribute("toNode"),roadId:l.getAttribute("roadId"),roadName:l.getAttribute("roadName"),sectionId:l.getAttribute("sectionId"),sectionIndex:l.getAttribute("sectionIndex"),laneId:l.getAttribute("laneId"),type:l.getAttribute("type"),sumoId:l.getAttribute("sumoId"),leftLine:y.geometry.coordinates,rightLine:d.geometry.coordinates},symbol:{type:"simple-fill",color:[255,0,0,.8],outline:{color:"red"}}});return this.splitLaneLayer.add(v),this.view.goTo(v),{status:0,message:"ok",result:e}}clearSplitLane(){this.splitLaneLayer.removeAll()}getCrossGraphicSymbol(e,t){const i=e.crossId!==""&&e.crossId!==void 0&&e.crossId!==null;if(t==="marker")return{type:"picture-marker",url:`/GisViewerAssets/Images/xhj_${i?4:2}.png`,width:"18px",height:"28px",yOffset:"12px"};if(t==="picture")return i?{type:"cim",data:{type:"CIMSymbolReference",primitiveOverrides:[{type:"CIMPrimitiveOverride",primitiveName:"textGraphic",propertyName:"TextString",valueExpressionInfo:{type:"CIMExpressionInfo",title:"Custom",expression:'Replace($feature.name, "与", "/") + " " + $feature.crossId',returnType:"Default"}}],symbol:{type:"CIMPointSymbol",symbolLayers:[{type:"CIMVectorMarker",size:32,colorLocked:!0,anchorPointUnits:"Relative",frame:{xmin:-16,ymin:-16,xmax:16,ymax:16},markerGraphics:[{type:"CIMMarkerGraphic",primitiveName:"textGraphic",geometry:{x:0,y:0},symbol:{type:"CIMTextSymbol",height:12,horizontalAlignment:"Center",offsetX:0,offsetY:i?50:40,haloSize:2,haloSymbol:{type:"CIMPolygonSymbol",symbolLayers:[{type:"CIMSolidFill",enable:!0,color:[255,255,255,255]}]},symbol:{type:"CIMPolygonSymbol",symbolLayers:[{type:"CIMSolidFill",enable:!0,color:[0,0,0,255]}]},verticalAlignment:"Center"},textString:""}],scaleSymbolsProportionally:!0,respectFrame:!0},{type:"CIMPictureMarker",enable:!0,anchorPoint:{x:0,y:0},anchorPointUnits:"Relative",size:45,rotateClockwise:!0,textureFilter:"Picture",url:"/GisViewerAssets/Images/xhj_4.png",offsetY:i?22:15}]}}}:{type:"picture-marker",url:"/GisViewerAssets/Images/xhj_2.png",width:"27px",height:"42px",yOffset:"22px"}}}exports.default=C;
|
|
1
|
+
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const f=require("@arcgis/core/Graphic"),F=require("@arcgis/core/core/promiseUtils"),J=require("@arcgis/core/core/reactiveUtils.js"),L=require("@arcgis/core/geometry"),E=require("@arcgis/core/geometry/geometryEngine"),x=require("@arcgis/core/layers/FeatureLayer"),w=require("@arcgis/core/layers/GraphicsLayer"),q=require("@turf/helpers"),G=require("@turf/line-slice-along"),b=require("axios"),R=require("fast-xml-parser"),T=require("md5"),O=require("pako"),H=require("vue"),_=require("../../stores/index.js"),z=require("../common-utils.js");function N(S){const e=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(S){for(const t in S)if(t!=="default"){const i=Object.getOwnPropertyDescriptor(S,t);Object.defineProperty(e,t,i.get?i:{enumerable:!0,get:()=>S[t]})}}return e.default=S,Object.freeze(e)}const M=N(F),U=N(J),A=N(E),P=N(q);class k{constructor(e){this.junctionNames=new Map,this.junctionScale=5e3,this.xodrBorder=[],this.projectName="",this.openDriveServer="",this.currentSectionCode="",this.selectedSectionIds=[],this.currentJunctionId="",this.view=e,this.laneLayer=new x({id:"OpenDriveLane",fields:[{name:"ObjectID",alias:"ObjectID",type:"oid"},{name:"id",alias:"编号",type:"string"},{name:"roadId",alias:"道路号",type:"string"},{name:"roadName",alias:"道路名称",type:"string"},{name:"sectionId",alias:"路段号",type:"string"},{name:"sectionIndex",alias:"路段序号",type:"string"},{name:"laneId",alias:"车道号",type:"string"},{name:"type",alias:"类型",type:"string"},{name:"sumoId",alias:"sumo编号",type:"string"},{name:"fromNode",alias:"起点路口",type:"string"},{name:"toNode",alias:"终点路口",type:"string"}],objectIdField:"ObjectID",geometryType:"polygon",spatialReference:{wkid:4326},source:[],outFields:["*"],renderer:{type:"unique-value",field:"type",defaultSymbol:{type:"simple-fill",color:[100,100,100],style:"solid",outline:{color:"white",width:1}},uniqueValueInfos:[{value:"shoulder",label:"路肩",symbol:{type:"simple-fill",color:"#008000",style:"solid",outline:{color:"white",width:1}}},{value:"border",label:"路沿",symbol:{type:"simple-fill",color:"#DCDCDC",style:"solid",outline:{color:"white",width:1}}},{value:"driving",label:"机动车道",symbol:{type:"simple-fill",color:[47,79,79,.8],style:"solid",outline:{color:"white",width:1}}},{value:"none",label:"无",symbol:{type:"simple-fill",color:[111,120,135],style:"none",outline:{color:"white",width:1}}},{value:"restricted",label:"禁行区",symbol:{type:"simple-fill",color:"yellow",style:"solid",outline:{color:"yellow",width:2}}},{value:"parking",label:"停车区",symbol:{type:"simple-fill",color:[115,115,115],style:"solid",outline:{color:"white",width:1}}},{value:"median",label:"中央隔离带",symbol:{type:"simple-fill",color:"#008000",style:"solid",outline:{color:"white",width:1}}},{value:"biking",label:"非机动车道",symbol:{type:"simple-fill",color:"#D3D3D3",style:"solid",outline:{color:"white",width:1}}},{value:"sidewalk",label:"人行道",symbol:{type:"simple-fill",color:"#C0C0C0",style:"solid",outline:{color:"white",width:1}}},{value:"junction",label:"路口区域",symbol:{type:"simple-fill",color:"#2F4F4F",style:"solid",outline:{color:"white",width:1}}},{value:"selected",label:"选中车道",symbol:{type:"simple-fill",color:[141,168,211],style:"solid",outline:{color:"white",width:1}}}]}}),this.roadNameLayer=new x({id:"OpenDriveRoadName",fields:[{name:"ObjectID",alias:"ObjectID",type:"oid"},{name:"roadId",alias:"道路号",type:"string"},{name:"roadName",alias:"道路名称",type:"string"}],objectIdField:"ObjectID",geometryType:"polyline",spatialReference:{wkid:4326},source:[],renderer:{type:"simple",symbol:{type:"simple-line",style:"solid",color:[0,0,0,0],width:1}},labelingInfo:[{symbol:{type:"text",color:"black",haloColor:"white",haloSize:1,font:{size:12,family:"sans-serif"}},labelPlacement:this.view.type==="2d"?"center-along":void 0,labelExpressionInfo:{expression:"$feature.roadName"}}]}),this.junctionLayer=new w({id:"OpenDriveJunction"}),this.sectionLayer=new w({id:"OpenDriveSection"}),this.highlightLayer=new w({id:"OpenDriveHighlight"}),this.flashLayer=new w({id:"OpenDriveFlash"}),this.drawLayer=new w({id:"Draw"}),this.splitLaneLayer=new w({id:"SplitLane"}),this.borderLayer=new w({id:"OpenDriveBorder"}),this.view.map.addMany([this.laneLayer,this.sectionLayer,this.roadNameLayer,this.junctionLayer,this.highlightLayer,this.flashLayer,this.drawLayer,this.splitLaneLayer,this.borderLayer])}static getInstance(e){return this.instance||(this.instance=new k(e)),this.instance}async makeMd5FromFile(e){var t;try{const o=await(await fetch(e)).text();let r=(t=new R.XMLParser({ignoreAttributes:!1,allowBooleanAttributes:!0}).parse(o).OpenDRIVE.userData)==null?void 0:t.border;return r?r=JSON.parse(r):r=[],{status:0,message:"ok",result:{md5:T(o),border:r}}}catch(i){return{status:-1,message:i.message}}}async showOpenDriveFromFile(e){var y,m;this.openDriveClickCallback=e.selectedCallback,this.scaleWatch=U.watch(()=>this.view.scale,(u,p)=>{u>this.junctionScale&&p<=this.junctionScale?this.updateAllJunctionSymbol("marker"):u<=this.junctionScale&&p>this.junctionScale&&this.updateAllJunctionSymbol("picture")}),console.time("md5用时");const t=await this.makeMd5FromFile(e.file);if(t.status!==0)return t;if(this.projectName=t.result.md5,console.timeEnd("md5用时"),this.xodrBorder=t.result.border,this.xodrBorder.length>0){const u=new f({geometry:new L.Polygon({rings:[this.xodrBorder]}),symbol:{type:"simple-fill",style:"none",outline:{style:"dash",color:"black",width:2}}});console.log(u.toJSON()),this.borderLayer.add(u)}this.openDriveServer=e.server;const i=`http://${this.openDriveServer}/api/openDrive/uploadXodr`;let o;try{o=await b.post(i,{},{params:{url:e.file,projectName:this.projectName}})}catch(u){return{status:-1,message:u.message}}if(o.status!==200)return{status:-1,message:o.statusText};console.time("渲染用时");const s=o.data.result.geoSetting;z.default.setGeoData(s.geoReference,s.offsetX,s.offsetY);let c=o.data.result.json;c.startsWith(window.location.protocol)||(c=`${window.location.protocol}//${e.server}${c}`);const a=await(await fetch(c)).arrayBuffer(),n=O.inflate(a,{to:"string"}),l=JSON.parse(n);await this.showAllLanes(l,((y=e.options)==null?void 0:y.showJunctionLane)||!1,((m=e.options)==null?void 0:m.showRoadName)||!0);const d=o.data.result.junctions;this.showJunction(d),e.options&&e.options.centerMap!==!1&&await this.view.goTo(this.allLaneGraphics),this.mouseMoveHandler||this.monitorMouseMove(),this.mouseClickHandler||this.monitorMouseClick();const h=_.default.useAppDataStore;return H.watch(()=>h.isSketching,()=>{var u,p;h.isSketching?((u=this.mouseMoveHandler)==null||u.remove(),this.mouseMoveHandler=void 0,(p=this.mouseClickHandler)==null||p.remove(),this.mouseClickHandler=void 0):(this.monitorMouseMove(),this.monitorMouseClick())}),console.timeEnd("渲染用时"),{status:0,message:"ok"}}async showOpenDriveFromServer(e,t){const i=`http://${e}/api/openDrive/analyzeXodr`,o=await b.get(i,{headers:{projectName:t},params:{analyze:!1,compressed:!0}});if(o.status!==200)throw new Error(`OpenDriveRenderer: ${o.statusText}`);let s=o.data.result.json;s.startsWith(window.location.protocol)||(s=`${window.location.protocol}//${e}${s}`);const r=await(await fetch(s)).arrayBuffer(),a=O.inflate(r,{to:"string"}),n=JSON.parse(a);return await this.showAllLanes(n,!1,!1),{status:0,message:"ok"}}async showAllLanes(e,t,i){const o=await this.laneLayer.queryFeatures();return o.features.length>0&&this.laneLayer.applyEdits({deleteFeatures:o.features}),this.roadNameLayer.visible=i,new Promise(s=>{let c=0;this.allLaneGraphics=[],this.allRefLineGraphics=[];const r=[];for(const n of e){if(!t&&n.junction!=="-1")continue;const{id:l,refLine:d}=n;let h=n.name;h.includes("(")&&(h=h.slice(0,h.indexOf("("))),h=h.replace(/(.)/g,"$1 ");const y=new f({geometry:{type:"polyline",paths:[d]},attributes:{ObjectID:c++,roadId:l,roadName:h}});this.allRefLineGraphics.push(y),n.laneSections.sort((m,u)=>Number(m.id)-Number(u.id));for(let m=0;m<n.laneSections.length;m++){const u=n.laneSections[m],p=Number(u.id);for(const g of u.lanePaths){const v=Number(g.id);if(v===0)continue;const I=g.type,$=[...g.outerPath],j=g.innerPath.concat($.reverse());if(j.length<=3){console.warn(`lane ${v} has less than 3 points`);continue}j.push(g.innerPath[0]);const C=new L.Polygon({rings:[j]});if(C){const D=new f({geometry:C,attributes:{ObjectID:c++,id:`${l}+${p}+${v}`,fromNode:n.fromNode,toNode:n.toNode,roadId:String(l),roadName:n.name,sectionId:String(p),sectionIndex:m,laneId:v,type:I,sumoId:"",leftLine:g.innerPath,rightLine:g.outerPath}});this.allLaneGraphics.push(D),r.push(D)}}}}const a=setInterval(()=>{if(r.length>0||this.allRefLineGraphics.length>0){if(r.length>0){const n=r.splice(0,100);this.laneLayer.applyEdits({addFeatures:n})}if(this.allRefLineGraphics.length>0){const n=this.allRefLineGraphics.splice(0,10);this.roadNameLayer.applyEdits({addFeatures:n})}}else clearInterval(a),s()},10)})}showJunction(e){const t=[];let i;this.xodrBorder.length>0&&(i=new L.Polygon({rings:[this.xodrBorder]}));for(const o of e)if(o&&(this.junctionNames.set(o.id,o.name),o.nodeType=o.type,o.crossId)){const s=new L.Point({x:o.coordinates[0],y:o.coordinates[1]});let c=!0;if(i&&(c=A.contains(i,s)),c){const r=new f({geometry:s,attributes:{...o,selected:!1,type:"OpenDriveJunction"},symbol:this.getCrossGraphicSymbol(o,"marker")});t.push(r)}}this.junctionLayer.addMany(t)}monitorMouseMove(){const e=M.debounce(async t=>{var c;const o=(c=(await this.view.hitTest(t,{include:[this.laneLayer,this.junctionLayer]})).results)==null?void 0:c.filter(r=>r.type==="graphic");if(o.length===0){this.currentSectionCode!==""&&(this.currentSectionCode="",this.highlightLayer.removeAll()),this.currentJunctionId!==""&&(this.currentJunctionId=""),this.view.closePopup();return}const s=o[0];if(this.hitGraphic=s.graphic,s.layer.id==="OpenDriveLane"){const r=`${this.hitGraphic.getAttribute("roadId")}+${this.hitGraphic.getAttribute("sectionId")}`;if(this.currentSectionCode===r||this.selectedSectionIds.includes(r)||this.sectionLayer.graphics.findIndex(p=>p.getAttribute("id")===r)>=0)return;this.currentSectionCode=r;const n=this.allLaneGraphics.filter(p=>`${p.attributes.roadId}+${p.attributes.sectionId}`===r),l=A.union(n.map(p=>p.geometry)),d=this.hitGraphic.getAttribute("fromNode"),h=this.hitGraphic.getAttribute("toNode"),y=this.junctionNames.get(d)||d,m=this.junctionNames.get(h)||h,u=new f({geometry:l,symbol:{type:"simple-fill",color:[0,255,255,.5],style:"solid",outline:{color:[0,255,255],width:1}},attributes:{type:"OpenDriveSection",id:r,selected:!1,fromNodeName:y,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(u)}else if(s.layer.id==="OpenDriveJunction"){const r=this.hitGraphic.getAttribute("id");if(r===this.currentJunctionId)return;this.currentJunctionId=r}});this.mouseMoveHandler=this.view.on("pointer-move",async t=>{e(t).catch(()=>{})})}monitorMouseClick(){const e=M.debounce(async t=>{var a;const o=(a=(await this.view.hitTest(t,{include:[this.highlightLayer,this.junctionLayer,this.sectionLayer]})).results)==null?void 0:a.filter(n=>n.type==="graphic");if(o.length===0)return;const s=o[0].graphic,c=s.getAttribute("type"),r=s.getAttribute("id");if(c==="OpenDriveJunction")if(s.getAttribute("selected")===!1){const n=`http://${this.openDriveServer}/api/sumo/getSumoJunction`,l=await b.get(n,{params:{id:r,projectName:this.projectName}});l.status===200&&l.data.status===0&&(this.openDriveClickCallback&&this.openDriveClickCallback({type:"OpenDriveJunction",id:r,details:l.data.result}),s.setAttribute("selected",!0),s.symbol={type:"picture-marker",url:"/GisViewerAssets/Images/point_red.png",width:"20px",height:"20px"},this.increasePictureMarkerSize(s,50))}else this.openDriveClickCallback&&this.openDriveClickCallback({type:"OpenDriveJunction",id:r,details:void 0}),s.setAttribute("selected",!1),s.symbol=this.getCrossGraphicSymbol(s.attributes,this.view.scale<this.junctionScale?"picture":"marker");else if(c==="OpenDriveSection")if(s.layer.id==="OpenDriveHighlight"){this.highlightLayer.remove(s),this.sectionLayer.add(s),s.setAttribute("selected",!0),this.selectedSectionIds.push(r);const n=`http://${this.openDriveServer}/api/sumo/getSumoEdge`,l=await b.get(n,{params:{id:r,projectName:this.projectName}});if(l.status===200&&l.data.status===0&&this.openDriveClickCallback){const d=l.data.result.obj_id;s.setAttribute("edgeId",d),this.openDriveClickCallback({type:"OpenDriveSection",id:d,details:l.data.result})}}else this.sectionLayer.remove(s),this.selectedSectionIds=this.selectedSectionIds.filter(n=>n!==r),this.openDriveClickCallback&&this.openDriveClickCallback({type:"OpenDriveSection",id:s.getAttribute("edgeId"),details:void 0})});this.mouseClickHandler=this.view.on("immediate-click",async t=>{e(t).catch(()=>{})})}increasePictureMarkerSize(e,t){const i=setInterval(()=>{const o=e.symbol,s=o.width;s<t?e.symbol={type:"picture-marker",url:o.url,width:s+1,height:s+1}:clearInterval(i)},20)}decreasePictureMarkerSize(e,t){const i=setInterval(()=>{const o=e.symbol,s=o.width;s>t?e.symbol={type:"picture-marker",url:o.url,width:s-1,height:s-1}:clearInterval(i)},20)}async getSumoInfo(e){switch(e.type){case"junction":{const t=`http://${this.openDriveServer}/api/sumo/getSumoJunction`,i=await b.get(t,{params:{id:e.id,projectName:this.projectName}});return i.status===200?i.data:{status:-1,message:`路口信息查询失败: ${e.id}`}}case"edge":{const t=e.id.split("#");let i=t[0];i.startsWith("-")&&(i=i.slice(1));let o=0;t.length===2&&(o=Number(t[1]));const s=this.allLaneGraphics.find(c=>c.getAttribute("roadId")===i&&c.getAttribute("sectionIndex")===o);if(s){const c=`${i}+${s.getAttribute("sectionId")}`,r=`http://${this.openDriveServer}/api/sumo/getSumoEdge`,a=await b.get(r,{params:{id:c,projectName:this.projectName}});return a.status===200?a.data:{status:-1,message:`路段信息查询失败: ${c}`}}else return{status:-1,message:"未知类型"}}default:return{status:-1,message:"未知类型"}}}async clearOpenDrive(){var t,i,o;let e=await this.laneLayer.queryFeatures();e.features.length>0&&await this.laneLayer.applyEdits({deleteFeatures:e.features}),e=await this.roadNameLayer.queryFeatures(),e.features.length>0&&await this.roadNameLayer.applyEdits({deleteFeatures:e.features}),this.highlightLayer.removeAll(),this.junctionLayer.removeAll(),this.sectionLayer.removeAll(),this.flashLayer.removeAll(),this.borderLayer.removeAll(),(t=this.mouseMoveHandler)==null||t.remove(),this.mouseMoveHandler=void 0,(i=this.mouseClickHandler)==null||i.remove(),this.mouseClickHandler=void 0,(o=this.scaleWatch)==null||o.remove(),this.scaleWatch=void 0}async findSumo(e){const{type:t,id:i}=e,o=e.flash===void 0?!0:e.flash;if(t==="junction")return await this.findJunction(i,o);if(t==="edge"){const s=i.split("_");if(s.length>2)return{status:-1,message:"id格式错误"};const c=s.length===2?Number(s[1]):void 0,r=s[0].split("#");if(r.length>2)return{status:-1,message:"id格式错误"};const a=r[0],n=r.length===2?Number(r[1]):void 0;return await this.findLane({roadsectId:a,segmentId:n,laneId:c,flash:o})}else return{status:-1,message:"未知类型"}}async findJunction(e,t){const i=this.junctionLayer.graphics.find(o=>o.attributes.id===e);if(!i)return{status:-1,message:"未找到。请检查路口编号"};if(t){const o=new f({geometry:i.geometry,symbol:{type:"simple-marker",style:"circle",size:30,color:[0,255,255,.8],outline:{color:[0,255,255],width:1}}});this.flashGraphic(o)}return await this.view.goTo(i.geometry,{duration:1e3}),{status:0,message:"ok"}}async findLane(e){let{roadsectId:t,segmentId:i,laneId:o}=e;t.startsWith("-")&&(t=t.slice(1));let s=this.allLaneGraphics.filter(a=>a.attributes.roadId===t);if(s.length===0)return{status:-1,message:"未找到。请检查路段编号"};if(i!==void 0){const a=[];if(s.forEach(n=>{const l=Number(n.attributes.sectionId);a.indexOf(l)===-1&&a.push(l)}),a.sort((n,l)=>n-l),i>a.length-1)return{status:-1,message:"未找到。请检查基本段编号"};i=a[i],s=s.filter(n=>Number(n.attributes.sectionId)===i)}if(o!==void 0){const a=[];if(s.forEach(n=>{const l=Number(n.attributes.laneId);a.indexOf(l)===-1&&a.push(l)}),a.sort((n,l)=>n-l),o>a.length-1)return{status:-1,message:"未找到。请检查车道编号"};o=a[o],s=s.filter(n=>Number(n.attributes.laneId)===o)}const c=s.map(a=>a.geometry),r=A.union(c);if(e.flash){const a=new f({geometry:r,symbol:{type:"simple-fill",color:[0,0,255,.6],style:"solid",outline:{width:0}}});this.flashGraphic(a)}return await this.view.goTo(r,{duration:1e3}),{status:0,message:"ok"}}flashGraphic(e){this.flashLayer.removeAll(),this.flashLayer.add(e);let t=0,i=!0;const o=setInterval(()=>{i?(this.flashLayer.opacity-=.02,this.flashLayer.opacity<=.1&&(i=!1,t++)):(this.flashLayer.opacity+=.02,this.flashLayer.opacity>=1&&(i=!0)),t>=5&&(this.flashLayer.removeAll(),this.flashLayer.opacity=1,clearInterval(o))},10)}unselectSumo(e){if((!e||e.type==="junction")&&this.junctionLayer.graphics.forEach(t=>{(!e||!e.id||e.id===""||e.id===t.getAttribute("id"))&&t.getAttribute("selected")&&(t.setAttribute("selected",!1),t.symbol=this.getCrossGraphicSymbol(t.attributes,this.view.scale<this.junctionScale?"picture":"marker"))}),!e||e.type==="edge"){let t;!e||!e.id||e.id===""?t=this.sectionLayer.graphics.toArray():t=this.sectionLayer.graphics.filter(i=>i.getAttribute("edgeId")===e.id).toArray(),t.length>0&&(t.forEach(i=>{const o=i.getAttribute("id");this.selectedSectionIds=this.selectedSectionIds.filter(s=>s!==o)}),this.sectionLayer.removeMany(t))}return{status:0,message:"ok"}}selectSumo(e){switch(e.type){case"junction":return this.junctionLayer.graphics.forEach(t=>{if(e.id===t.getAttribute("id"))return t.setAttribute("selected",!0),t.symbol.url="/GisViewerAssets/Images/point_red.png",this.increasePictureMarkerSize(t,50),{status:0,message:"ok"}}),{status:-1,message:"未找到路口"};case"edge":{const t=e.id.split("#");let i=String(t[0]);i.startsWith("-")&&(i=i.slice(1));let o=0;t.length===2&&(o=Number(t[1]));let s=[];if(t.length===1?s=this.allLaneGraphics.filter(c=>c.getAttribute("roadId")===i):t.length===2&&(s=this.allLaneGraphics.filter(c=>c.getAttribute("roadId")===i&&c.getAttribute("sectionIndex")===o)),s.length>0){const c=new Map;return s.forEach(r=>{const a=r.getAttribute("roadId")+"+"+r.getAttribute("sectionId");this.selectedSectionIds.includes(a)||this.selectedSectionIds.push(a);let n=c.get(a);n?n.push(r.geometry):(n=[r.geometry],c.set(a,n))}),c.forEach((r,a)=>{const n=A.union(r),l=new f({geometry:n,symbol:{type:"simple-fill",color:[0,255,255,.5],style:"solid",outline:{color:[0,255,255],width:1}},attributes:{type:"OpenDriveSection",id:a,edgeId:e.id,selected:!0}});this.sectionLayer.add(l)}),{status:0,message:"ok"}}else return{status:-1,message:"未找到路段"}}default:return{status:-1,message:"未知类型"}}}async geometrySearch(e){const t=new L.Polygon({rings:[e]}),i=await this.laneLayer.queryFeatures({geometry:t,outFields:["*"]}),o=[],s=[];for(const a of i.features){const n=a.getAttribute("roadId"),l=a.getAttribute("sectionIndex"),d=`${n}#${l}`;if(o.indexOf(d)===-1){o.push(d),this.selectSumo({type:"edge",id:d});const h=`http://${this.openDriveServer}/api/sumo/getSumoEdge`,y=await b.get(h,{params:{id:`${n}+${a.getAttribute("sectionId")}`,projectName:this.projectName}});y.status===200&&y.data.status===0&&s.push(y.data.result)}}const c=this.junctionLayer.graphics.filter(a=>{const n=a.geometry;return A.contains(t,n)}),r=[];for(const a of c){const n=a.getAttribute("id");this.selectSumo({type:"junction",id:n});const l=`http://${this.openDriveServer}/api/sumo/getSumoJunction`,d=await b.get(l,{params:{id:n,projectName:this.projectName}});d.status===200&&d.data.status===0&&r.push(d.data.result)}return{status:0,message:"ok",result:{junctions:r,edges:s}}}async splitLane(e){const i=e.id.split("_");if(i.length!==2)return{status:-1,message:"车道编号格式错误"};const o=Number(i[1]),s=i[0].split("#"),c=s.length===2?Number(s[1]):0;let r=s[0];r.startsWith("-")&&(r=r.slice(1));const a=this.allLaneGraphics.filter(I=>I.getAttribute("roadId")===r&&I.getAttribute("sectionIndex")===c);if(a.length===0)return{status:-1,message:"未找到路段"};const n=a.length-o,l=a.find(I=>Math.abs(I.getAttribute("laneId"))===n);if(!l)return{status:-1,message:"未找到车道"};const d=e.start||0,h=e.end||100,y=P.lineString(l.getAttribute("leftLine")),m=G.lineSliceAlong(y,d,h,{units:"meters"}),u=P.lineString(l.getAttribute("rightLine")),p=G.lineSliceAlong(u,d,h,{units:"meters"}),g=m.geometry.coordinates.concat(p.geometry.coordinates.reverse());g.push(g[g.length-1]);const v=new f({geometry:new L.Polygon({rings:[g]}),attributes:{ObjectID:l.getAttribute("ObjectID"),id:l.getAttribute("id"),fromNode:l.getAttribute("fromNode"),toNode:l.getAttribute("toNode"),roadId:l.getAttribute("roadId"),roadName:l.getAttribute("roadName"),sectionId:l.getAttribute("sectionId"),sectionIndex:l.getAttribute("sectionIndex"),laneId:l.getAttribute("laneId"),type:l.getAttribute("type"),sumoId:l.getAttribute("sumoId"),leftLine:m.geometry.coordinates,rightLine:p.geometry.coordinates},symbol:{type:"simple-fill",color:[255,0,0,.8],outline:{color:"red"}}});return this.splitLaneLayer.add(v),this.view.goTo(v),{status:0,message:"ok",result:e}}clearSplitLane(){this.splitLaneLayer.removeAll()}updateAllJunctionSymbol(e){const t=this.junctionLayer.graphics.clone();this.junctionLayer.removeAll(),t.forEach(i=>{i.symbol=this.getCrossGraphicSymbol(i.attributes,e)}),this.junctionLayer.addMany(t.toArray())}getCrossGraphicSymbol(e,t){const i=e.crossId!==""&&e.crossId!==void 0&&e.crossId!==null;if(t==="marker")return{type:"picture-marker",url:`/GisViewerAssets/Images/xhj_${i?1:2}.png`,width:"18px",height:"28px",yOffset:"12px"};if(t==="picture")return i?{type:"cim",data:{type:"CIMSymbolReference",primitiveOverrides:[{type:"CIMPrimitiveOverride",primitiveName:"textGraphic",propertyName:"TextString",valueExpressionInfo:{type:"CIMExpressionInfo",title:"Custom",expression:'Replace($feature.name, "与", "/") + " " + $feature.crossId',returnType:"Default"}}],symbol:{type:"CIMPointSymbol",symbolLayers:[{type:"CIMVectorMarker",size:32,colorLocked:!0,anchorPointUnits:"Relative",frame:{xmin:-16,ymin:-16,xmax:16,ymax:16},markerGraphics:[{type:"CIMMarkerGraphic",primitiveName:"textGraphic",geometry:{x:0,y:0},symbol:{type:"CIMTextSymbol",height:12,horizontalAlignment:"Center",offsetX:0,offsetY:i?50:40,haloSize:2,haloSymbol:{type:"CIMPolygonSymbol",symbolLayers:[{type:"CIMSolidFill",enable:!0,color:[255,255,255,255]}]},symbol:{type:"CIMPolygonSymbol",symbolLayers:[{type:"CIMSolidFill",enable:!0,color:[0,0,0,255]}]},verticalAlignment:"Center"},textString:""}],scaleSymbolsProportionally:!0,respectFrame:!0},{type:"CIMPictureMarker",enable:!0,anchorPoint:{x:0,y:0},anchorPointUnits:"Relative",size:45,rotateClockwise:!0,textureFilter:"Picture",url:"/GisViewerAssets/Images/xhj_1.png",offsetY:i?22:15}]}}}:{type:"picture-marker",url:"/GisViewerAssets/Images/xhj_2.png",width:"27px",height:"42px",yOffset:"22px"}}}exports.default=k;
|