gisviewer-vue3-arcgis 1.0.120 → 1.0.122
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/open-drive-renderer/index.d.ts +5 -0
- package/es/src/gis-map/utils/open-drive-renderer/index.mjs +273 -206
- package/es/src/types/index.d.ts +4 -1
- package/lib/src/gis-map/utils/open-drive-renderer/index.d.ts +5 -0
- package/lib/src/gis-map/utils/open-drive-renderer/index.js +2 -2
- package/lib/src/types/index.d.ts +4 -1
- package/package.json +1 -1
|
@@ -6,7 +6,9 @@ export default class OpenDriveRenderer {
|
|
|
6
6
|
private laneLayer;
|
|
7
7
|
private roadNameLayer;
|
|
8
8
|
private junctionLayer;
|
|
9
|
+
private sectionLayer;
|
|
9
10
|
private highlightLayer;
|
|
11
|
+
private flashLayer;
|
|
10
12
|
private allLaneGraphics;
|
|
11
13
|
private allRefLineGraphics;
|
|
12
14
|
private mouseMoveHandler;
|
|
@@ -15,6 +17,7 @@ export default class OpenDriveRenderer {
|
|
|
15
17
|
constructor(view: __esri.MapView | __esri.SceneView);
|
|
16
18
|
private projectName;
|
|
17
19
|
private openDriveServer;
|
|
20
|
+
private openDriveClickCallback;
|
|
18
21
|
showOpenDriveFromFile(params: IShowOpenDriveFromFileParams): Promise<IResult>;
|
|
19
22
|
/**
|
|
20
23
|
* 从服务器载入OpenDrive文件解析结果并显示
|
|
@@ -48,11 +51,13 @@ export default class OpenDriveRenderer {
|
|
|
48
51
|
* @returns
|
|
49
52
|
*/
|
|
50
53
|
findSumo(params: IFindSumoParams): Promise<IResult>;
|
|
54
|
+
private findJunction;
|
|
51
55
|
/**
|
|
52
56
|
* 用sumo的id定位车道、基本段、路段
|
|
53
57
|
* @param params
|
|
54
58
|
* @returns
|
|
55
59
|
*/
|
|
56
60
|
private findLane;
|
|
61
|
+
private flashGraphic;
|
|
57
62
|
splitLane(params: ISplitOpenDriveLaneParams): Promise<IResult>;
|
|
58
63
|
}
|
|
@@ -1,16 +1,16 @@
|
|
|
1
|
-
import
|
|
2
|
-
import * as
|
|
3
|
-
import { Polygon as
|
|
4
|
-
import * as
|
|
5
|
-
import
|
|
6
|
-
import
|
|
1
|
+
import p from "@arcgis/core/Graphic";
|
|
2
|
+
import * as D from "@arcgis/core/core/promiseUtils";
|
|
3
|
+
import { Polygon as N } from "@arcgis/core/geometry";
|
|
4
|
+
import * as k from "@arcgis/core/geometry/geometryEngineAsync";
|
|
5
|
+
import C from "@arcgis/core/layers/FeatureLayer";
|
|
6
|
+
import m from "@arcgis/core/layers/GraphicsLayer";
|
|
7
7
|
import f from "axios";
|
|
8
|
-
import
|
|
9
|
-
import
|
|
8
|
+
import G from "pako";
|
|
9
|
+
import j from "../common-utils.mjs";
|
|
10
10
|
import F from "./wasm-loader.mjs";
|
|
11
|
-
class
|
|
12
|
-
constructor(
|
|
13
|
-
this.wasmLoader = F.getInstance(), this.projectName = "", this.openDriveServer = "", this.currentSectionCode = "", this.currentJunctionId = "", this.view =
|
|
11
|
+
class S {
|
|
12
|
+
constructor(t) {
|
|
13
|
+
this.wasmLoader = F.getInstance(), this.projectName = "", this.openDriveServer = "", this.currentSectionCode = "", this.currentJunctionId = "", this.view = t, this.laneLayer = new C({
|
|
14
14
|
id: "OpenDriveLane",
|
|
15
15
|
fields: [
|
|
16
16
|
{
|
|
@@ -218,7 +218,7 @@ class N {
|
|
|
218
218
|
}
|
|
219
219
|
]
|
|
220
220
|
}
|
|
221
|
-
}), this.roadNameLayer = new
|
|
221
|
+
}), this.roadNameLayer = new C({
|
|
222
222
|
id: "OpenDriveRoadName",
|
|
223
223
|
fields: [
|
|
224
224
|
{
|
|
@@ -268,46 +268,52 @@ class N {
|
|
|
268
268
|
}
|
|
269
269
|
}
|
|
270
270
|
]
|
|
271
|
-
}), this.junctionLayer = new
|
|
271
|
+
}), this.junctionLayer = new m({ id: "OpenDriveJunction" }), this.sectionLayer = new m({ id: "OpenDriveSection" }), this.highlightLayer = new m({ id: "OpenDriveHighlight" }), this.flashLayer = new m({ id: "OpenDriveFlash" }), this.view.map.addMany([
|
|
272
272
|
this.laneLayer,
|
|
273
273
|
this.junctionLayer,
|
|
274
|
+
this.sectionLayer,
|
|
274
275
|
this.roadNameLayer,
|
|
275
|
-
this.highlightLayer
|
|
276
|
+
this.highlightLayer,
|
|
277
|
+
this.flashLayer
|
|
276
278
|
]);
|
|
277
279
|
}
|
|
278
|
-
static getInstance(
|
|
279
|
-
return this.instance || (this.instance = new
|
|
280
|
+
static getInstance(t) {
|
|
281
|
+
return this.instance || (this.instance = new S(t)), this.instance;
|
|
280
282
|
}
|
|
281
|
-
async showOpenDriveFromFile(
|
|
282
|
-
var
|
|
283
|
-
this.projectName = Date.now().toString(), this.openDriveServer =
|
|
284
|
-
const o = `http://${this.openDriveServer}/api/openDrive/uploadXodr`, i = await f.post(
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
283
|
+
async showOpenDriveFromFile(t) {
|
|
284
|
+
var h, d;
|
|
285
|
+
this.openDriveClickCallback = t.selectedCallback, this.projectName = Date.now().toString(), this.openDriveServer = t.server;
|
|
286
|
+
const o = `http://${this.openDriveServer}/api/openDrive/uploadXodr`, i = await f.post(
|
|
287
|
+
o,
|
|
288
|
+
{},
|
|
289
|
+
{
|
|
290
|
+
params: {
|
|
291
|
+
url: t.file,
|
|
292
|
+
projectName: this.projectName
|
|
293
|
+
}
|
|
288
294
|
}
|
|
289
|
-
|
|
295
|
+
);
|
|
290
296
|
if (i.status !== 200)
|
|
291
297
|
throw new Error(`OpenDriveRenderer: ${i.statusText}`);
|
|
292
298
|
console.time("渲染用时");
|
|
293
299
|
const s = i.data.result.geoSetting;
|
|
294
|
-
|
|
300
|
+
j.setGeoData(
|
|
295
301
|
s.geoReference,
|
|
296
302
|
s.offsetX,
|
|
297
303
|
s.offsetY
|
|
298
304
|
);
|
|
299
|
-
let
|
|
300
|
-
|
|
301
|
-
const
|
|
305
|
+
let e = i.data.result.json;
|
|
306
|
+
e.startsWith(window.location.protocol) || (e = `${window.location.protocol}//${t.server}${e}`);
|
|
307
|
+
const r = await (await fetch(e)).arrayBuffer(), n = G.inflate(r, { to: "string" }), a = JSON.parse(n);
|
|
302
308
|
await this.showAllLanes(
|
|
303
|
-
|
|
304
|
-
((
|
|
305
|
-
((
|
|
309
|
+
a,
|
|
310
|
+
((h = t.options) == null ? void 0 : h.showJunctionLane) || !1,
|
|
311
|
+
((d = t.options) == null ? void 0 : d.showRoadName) || !0
|
|
306
312
|
);
|
|
307
|
-
const
|
|
308
|
-
if (this.showJunction(
|
|
309
|
-
const
|
|
310
|
-
await this.view.goTo(
|
|
313
|
+
const l = i.data.result.junctions;
|
|
314
|
+
if (this.showJunction(l), t.options && t.options.centerMap !== !1) {
|
|
315
|
+
const g = j.transformPointProjection([0, 0]);
|
|
316
|
+
await this.view.goTo(g);
|
|
311
317
|
}
|
|
312
318
|
return this.mouseMoveHandler || this.monitorMouseMove(), this.mouseClickHandler || this.monitorMouseClick(), console.timeEnd("渲染用时"), { status: 0, message: "ok" };
|
|
313
319
|
}
|
|
@@ -316,8 +322,8 @@ class N {
|
|
|
316
322
|
* @param server
|
|
317
323
|
* @param projectName
|
|
318
324
|
*/
|
|
319
|
-
async showOpenDriveFromServer(
|
|
320
|
-
const i = `http://${
|
|
325
|
+
async showOpenDriveFromServer(t, o) {
|
|
326
|
+
const i = `http://${t}/api/openDrive/analyzeXodr`, s = await f.get(i, {
|
|
321
327
|
headers: {
|
|
322
328
|
projectName: o
|
|
323
329
|
},
|
|
@@ -328,102 +334,107 @@ class N {
|
|
|
328
334
|
});
|
|
329
335
|
if (s.status !== 200)
|
|
330
336
|
throw new Error(`OpenDriveRenderer: ${s.statusText}`);
|
|
331
|
-
let
|
|
332
|
-
|
|
333
|
-
const
|
|
334
|
-
return await this.showAllLanes(
|
|
337
|
+
let e = s.data.result.json;
|
|
338
|
+
e.startsWith(window.location.protocol) || (e = `${window.location.protocol}//${t}${e}`);
|
|
339
|
+
const r = await (await fetch(e)).arrayBuffer(), n = G.inflate(r, { to: "string" }), a = JSON.parse(n);
|
|
340
|
+
return await this.showAllLanes(a, !1, !1), { status: 0, message: "ok" };
|
|
335
341
|
}
|
|
336
|
-
async showAllLanes(
|
|
342
|
+
async showAllLanes(t, o, i) {
|
|
337
343
|
const s = await this.laneLayer.queryFeatures();
|
|
338
344
|
return s.features.length > 0 && this.laneLayer.applyEdits({
|
|
339
345
|
deleteFeatures: s.features
|
|
340
|
-
}), this.roadNameLayer.visible = i, new Promise((
|
|
341
|
-
let
|
|
346
|
+
}), this.roadNameLayer.visible = i, new Promise((e) => {
|
|
347
|
+
let c = 0;
|
|
342
348
|
this.allLaneGraphics = [], this.allRefLineGraphics = [];
|
|
343
|
-
const
|
|
344
|
-
for (const
|
|
345
|
-
if (!o &&
|
|
349
|
+
const r = [];
|
|
350
|
+
for (const a of t) {
|
|
351
|
+
if (!o && a.junction !== "-1")
|
|
346
352
|
continue;
|
|
347
|
-
const { id:
|
|
348
|
-
let
|
|
349
|
-
|
|
350
|
-
const
|
|
353
|
+
const { id: l, refLine: h } = a;
|
|
354
|
+
let d = a.name;
|
|
355
|
+
d.includes("(") && (d = d.slice(0, d.indexOf("("))), d = d.replace(/(.)/g, "$1 ");
|
|
356
|
+
const g = new p({
|
|
351
357
|
geometry: {
|
|
352
358
|
type: "polyline",
|
|
353
|
-
paths: [
|
|
359
|
+
paths: [h]
|
|
354
360
|
},
|
|
355
361
|
attributes: {
|
|
356
|
-
ObjectID:
|
|
357
|
-
roadId:
|
|
358
|
-
roadName:
|
|
362
|
+
ObjectID: c++,
|
|
363
|
+
roadId: l,
|
|
364
|
+
roadName: d
|
|
359
365
|
}
|
|
360
366
|
});
|
|
361
|
-
this.allRefLineGraphics.push(
|
|
362
|
-
for (const
|
|
363
|
-
const b = Number(
|
|
364
|
-
for (const
|
|
365
|
-
const y = Number(
|
|
367
|
+
this.allRefLineGraphics.push(g);
|
|
368
|
+
for (const v of a.laneSections) {
|
|
369
|
+
const b = Number(v.id);
|
|
370
|
+
for (const u of v.lanePaths) {
|
|
371
|
+
const y = Number(u.id);
|
|
366
372
|
if (y === 0)
|
|
367
373
|
continue;
|
|
368
|
-
const
|
|
369
|
-
|
|
374
|
+
const O = u.type, w = u.innerPath.concat(
|
|
375
|
+
u.outerPath.reverse()
|
|
370
376
|
);
|
|
371
|
-
if (
|
|
377
|
+
if (w.length <= 3) {
|
|
372
378
|
console.warn(`lane ${y} has less than 3 points`);
|
|
373
379
|
continue;
|
|
374
380
|
}
|
|
375
|
-
|
|
376
|
-
const
|
|
377
|
-
rings: [
|
|
381
|
+
w.push(u.innerPath[0]);
|
|
382
|
+
const L = new N({
|
|
383
|
+
rings: [w]
|
|
378
384
|
});
|
|
379
|
-
if (
|
|
380
|
-
const I = new
|
|
381
|
-
geometry:
|
|
385
|
+
if (L) {
|
|
386
|
+
const I = new p({
|
|
387
|
+
geometry: L,
|
|
382
388
|
attributes: {
|
|
383
|
-
ObjectID:
|
|
384
|
-
id: `${
|
|
385
|
-
roadId:
|
|
386
|
-
roadName:
|
|
389
|
+
ObjectID: c++,
|
|
390
|
+
id: `${l}+${b}+${y}`,
|
|
391
|
+
roadId: l,
|
|
392
|
+
roadName: a.name,
|
|
387
393
|
sectionId: b,
|
|
388
394
|
laneId: y,
|
|
389
|
-
type:
|
|
395
|
+
type: O,
|
|
390
396
|
sumoId: ""
|
|
391
397
|
}
|
|
392
398
|
});
|
|
393
|
-
this.allLaneGraphics.push(I),
|
|
399
|
+
this.allLaneGraphics.push(I), r.push(I);
|
|
394
400
|
}
|
|
395
401
|
}
|
|
396
402
|
}
|
|
397
403
|
}
|
|
398
|
-
const
|
|
399
|
-
if (
|
|
400
|
-
if (
|
|
401
|
-
const
|
|
404
|
+
const n = setInterval(() => {
|
|
405
|
+
if (r.length > 0 || this.allRefLineGraphics.length > 0) {
|
|
406
|
+
if (r.length > 0) {
|
|
407
|
+
const a = r.splice(0, 100);
|
|
402
408
|
this.laneLayer.applyEdits({
|
|
403
|
-
addFeatures:
|
|
409
|
+
addFeatures: a
|
|
404
410
|
});
|
|
405
411
|
}
|
|
406
412
|
if (this.allRefLineGraphics.length > 0) {
|
|
407
|
-
const
|
|
413
|
+
const a = this.allRefLineGraphics.splice(0, 10);
|
|
408
414
|
this.roadNameLayer.applyEdits({
|
|
409
|
-
addFeatures:
|
|
415
|
+
addFeatures: a
|
|
410
416
|
});
|
|
411
417
|
}
|
|
412
418
|
} else
|
|
413
|
-
clearInterval(
|
|
419
|
+
clearInterval(n), e();
|
|
414
420
|
}, 10);
|
|
415
421
|
});
|
|
416
422
|
}
|
|
417
|
-
showJunction(
|
|
423
|
+
showJunction(t) {
|
|
418
424
|
const o = [];
|
|
419
|
-
for (const i of
|
|
420
|
-
|
|
425
|
+
for (const i of t) {
|
|
426
|
+
i.nodeType = i.type;
|
|
427
|
+
const s = new p({
|
|
421
428
|
geometry: {
|
|
422
429
|
type: "point",
|
|
423
430
|
x: i.coordinates[0],
|
|
424
431
|
y: i.coordinates[1]
|
|
425
432
|
},
|
|
426
|
-
attributes: {
|
|
433
|
+
attributes: {
|
|
434
|
+
...i,
|
|
435
|
+
selected: !1,
|
|
436
|
+
type: "OpenDriveJunction"
|
|
437
|
+
},
|
|
427
438
|
symbol: {
|
|
428
439
|
type: "picture-marker",
|
|
429
440
|
url: i.crossId ? "/GisViewerAssets/Images/point_green.png" : "/GisViewerAssets/Images/normal-cross.png",
|
|
@@ -439,30 +450,32 @@ class N {
|
|
|
439
450
|
* 监听鼠标移动事件,高亮显示鼠标所在路段和路口
|
|
440
451
|
*/
|
|
441
452
|
monitorMouseMove() {
|
|
442
|
-
const
|
|
443
|
-
var
|
|
444
|
-
const s = (
|
|
453
|
+
const t = D.debounce(async (o) => {
|
|
454
|
+
var c;
|
|
455
|
+
const s = (c = (await this.view.hitTest(o, {
|
|
445
456
|
include: [this.laneLayer, this.junctionLayer]
|
|
446
|
-
})).results) == null ? void 0 :
|
|
447
|
-
(
|
|
457
|
+
})).results) == null ? void 0 : c.filter(
|
|
458
|
+
(r) => r.type === "graphic"
|
|
448
459
|
);
|
|
449
460
|
if (s.length === 0) {
|
|
450
461
|
this.currentSectionCode !== "" && (this.currentSectionCode = "", this.highlightGraphic = void 0, this.highlightLayer.removeAll()), this.currentJunctionId !== "" && (this.currentJunctionId = "", this.highlightGraphic = void 0, this.highlightLayer.removeAll());
|
|
451
462
|
return;
|
|
452
463
|
}
|
|
453
|
-
const
|
|
454
|
-
if (this.hitGraphic =
|
|
455
|
-
const
|
|
456
|
-
if (
|
|
464
|
+
const e = s[0];
|
|
465
|
+
if (this.hitGraphic = e.graphic, e.layer.id === "OpenDriveLane") {
|
|
466
|
+
const r = `${this.hitGraphic.attributes.roadId}+${this.hitGraphic.attributes.sectionId}`;
|
|
467
|
+
if (r === this.currentSectionCode || this.sectionLayer.graphics.findIndex(
|
|
468
|
+
(h) => h.getAttribute("id") === r
|
|
469
|
+
) >= 0)
|
|
457
470
|
return;
|
|
458
|
-
this.currentSectionCode =
|
|
471
|
+
this.currentSectionCode = r;
|
|
459
472
|
const a = this.allLaneGraphics.filter(
|
|
460
|
-
(
|
|
461
|
-
),
|
|
462
|
-
a.map((
|
|
473
|
+
(h) => `${h.attributes.roadId}+${h.attributes.sectionId}` === r
|
|
474
|
+
), l = await k.union(
|
|
475
|
+
a.map((h) => h.geometry)
|
|
463
476
|
);
|
|
464
|
-
this.highlightGraphic = new
|
|
465
|
-
geometry:
|
|
477
|
+
this.highlightGraphic = new p({
|
|
478
|
+
geometry: l,
|
|
466
479
|
symbol: {
|
|
467
480
|
type: "simple-fill",
|
|
468
481
|
color: [255, 0, 0, 0.5],
|
|
@@ -474,31 +487,16 @@ class N {
|
|
|
474
487
|
},
|
|
475
488
|
attributes: {
|
|
476
489
|
type: "OpenDriveSection",
|
|
477
|
-
id:
|
|
478
|
-
|
|
490
|
+
id: r,
|
|
491
|
+
selected: !1
|
|
479
492
|
}
|
|
480
493
|
}), this.highlightLayer.removeAll(), this.highlightLayer.add(this.highlightGraphic);
|
|
481
|
-
} else if (
|
|
482
|
-
const
|
|
483
|
-
if (
|
|
494
|
+
} else if (e.layer.id === "OpenDriveJunction") {
|
|
495
|
+
const r = this.hitGraphic.attributes.id;
|
|
496
|
+
if (r === this.currentJunctionId)
|
|
484
497
|
return;
|
|
485
|
-
this.currentJunctionId =
|
|
486
|
-
|
|
487
|
-
symbol: {
|
|
488
|
-
type: "simple-marker",
|
|
489
|
-
style: "circle",
|
|
490
|
-
size: 40,
|
|
491
|
-
color: [0, 0, 0, 0],
|
|
492
|
-
outline: {
|
|
493
|
-
color: [0, 0, 0, 0]
|
|
494
|
-
}
|
|
495
|
-
},
|
|
496
|
-
attributes: {
|
|
497
|
-
type: "OpenDriveJunction",
|
|
498
|
-
id: l
|
|
499
|
-
}
|
|
500
|
-
});
|
|
501
|
-
const a = new d({
|
|
498
|
+
this.currentJunctionId = r;
|
|
499
|
+
const n = new p({
|
|
502
500
|
geometry: this.hitGraphic.geometry,
|
|
503
501
|
symbol: {
|
|
504
502
|
type: "text",
|
|
@@ -512,11 +510,11 @@ ${this.hitGraphic.attributes.id}`,
|
|
|
512
510
|
yoffset: 40
|
|
513
511
|
}
|
|
514
512
|
});
|
|
515
|
-
this.highlightLayer.removeAll(), this.highlightLayer.
|
|
513
|
+
this.highlightLayer.removeAll(), this.highlightLayer.add(n);
|
|
516
514
|
}
|
|
517
515
|
});
|
|
518
516
|
this.mouseMoveHandler = this.view.on("pointer-move", async (o) => {
|
|
519
|
-
|
|
517
|
+
t(o).catch(() => {
|
|
520
518
|
});
|
|
521
519
|
});
|
|
522
520
|
}
|
|
@@ -524,42 +522,81 @@ ${this.hitGraphic.attributes.id}`,
|
|
|
524
522
|
* 监听鼠标点击事件,获取高亮要素的拓扑信息
|
|
525
523
|
*/
|
|
526
524
|
monitorMouseClick() {
|
|
527
|
-
|
|
528
|
-
var
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
}
|
|
540
|
-
|
|
541
|
-
|
|
525
|
+
const t = D.debounce(async (o) => {
|
|
526
|
+
var n;
|
|
527
|
+
const s = (n = (await this.view.hitTest(o, {
|
|
528
|
+
include: [this.highlightLayer, this.junctionLayer, this.sectionLayer]
|
|
529
|
+
})).results) == null ? void 0 : n.filter(
|
|
530
|
+
(a) => a.type === "graphic"
|
|
531
|
+
);
|
|
532
|
+
if (s.length === 0)
|
|
533
|
+
return;
|
|
534
|
+
const e = s[0].graphic, c = e.getAttribute("type"), r = e.getAttribute("id");
|
|
535
|
+
if (c === "OpenDriveJunction")
|
|
536
|
+
if (e.getAttribute("selected") === !1) {
|
|
537
|
+
const a = `http://${this.openDriveServer}/api/sumo/getSumoJunction`, l = await f.get(a, {
|
|
538
|
+
params: {
|
|
539
|
+
id: r,
|
|
540
|
+
projectName: this.projectName
|
|
541
|
+
}
|
|
542
|
+
});
|
|
543
|
+
l.status === 200 && l.data.status === 0 && (this.openDriveClickCallback && this.openDriveClickCallback({
|
|
544
|
+
type: "OpenDriveJunction",
|
|
545
|
+
id: r,
|
|
546
|
+
details: l.data.result
|
|
547
|
+
}), e.setAttribute("selected", !0), e.symbol.url = "/GisViewerAssets/Images/point_red.png", this.increasePictureMarkerSize(e, 50));
|
|
548
|
+
} else
|
|
549
|
+
this.openDriveClickCallback && this.openDriveClickCallback({
|
|
550
|
+
type: "OpenDriveJunction",
|
|
551
|
+
id: r,
|
|
552
|
+
details: void 0
|
|
553
|
+
}), e.setAttribute("selected", !1), e.symbol.url = "/GisViewerAssets/Images/point_green.png", this.decreasePictureMarkerSize(e, 30);
|
|
554
|
+
else if (c === "OpenDriveSection")
|
|
555
|
+
if (e.getAttribute("selected"))
|
|
556
|
+
this.sectionLayer.remove(e), this.openDriveClickCallback && this.openDriveClickCallback({
|
|
557
|
+
type: "OpenDriveSection",
|
|
558
|
+
id: r,
|
|
559
|
+
details: void 0
|
|
560
|
+
});
|
|
561
|
+
else {
|
|
562
|
+
this.highlightLayer.remove(e), this.sectionLayer.add(e), e.setAttribute("selected", !0);
|
|
563
|
+
const a = `http://${this.openDriveServer}/api/sumo/getSumoEdge`, l = await f.get(a, {
|
|
564
|
+
params: {
|
|
565
|
+
id: r,
|
|
566
|
+
projectName: this.projectName
|
|
567
|
+
}
|
|
568
|
+
});
|
|
569
|
+
l.status === 200 && l.data.status === 0 && this.openDriveClickCallback && this.openDriveClickCallback({
|
|
570
|
+
type: "OpenDriveSection",
|
|
571
|
+
id: r,
|
|
572
|
+
details: l.data.result
|
|
573
|
+
});
|
|
574
|
+
}
|
|
575
|
+
});
|
|
576
|
+
this.mouseClickHandler = this.view.on("immediate-click", async (o) => {
|
|
577
|
+
t(o).catch(() => {
|
|
578
|
+
});
|
|
542
579
|
});
|
|
543
580
|
}
|
|
544
|
-
increasePictureMarkerSize(
|
|
581
|
+
increasePictureMarkerSize(t, o) {
|
|
545
582
|
const i = setInterval(() => {
|
|
546
|
-
const s =
|
|
547
|
-
|
|
583
|
+
const s = t.symbol, e = s.width;
|
|
584
|
+
e < o ? t.symbol = {
|
|
548
585
|
type: "picture-marker",
|
|
549
586
|
url: s.url,
|
|
550
|
-
width:
|
|
551
|
-
height:
|
|
587
|
+
width: e + 1,
|
|
588
|
+
height: e + 1
|
|
552
589
|
} : clearInterval(i);
|
|
553
590
|
}, 20);
|
|
554
591
|
}
|
|
555
|
-
decreasePictureMarkerSize(
|
|
592
|
+
decreasePictureMarkerSize(t, o) {
|
|
556
593
|
const i = setInterval(() => {
|
|
557
|
-
const s =
|
|
558
|
-
|
|
594
|
+
const s = t.symbol, e = s.width;
|
|
595
|
+
e > o ? t.symbol = {
|
|
559
596
|
type: "picture-marker",
|
|
560
597
|
url: s.url,
|
|
561
|
-
width:
|
|
562
|
-
height:
|
|
598
|
+
width: e - 1,
|
|
599
|
+
height: e - 1
|
|
563
600
|
} : clearInterval(i);
|
|
564
601
|
}, 20);
|
|
565
602
|
}
|
|
@@ -568,11 +605,11 @@ ${this.hitGraphic.attributes.id}`,
|
|
|
568
605
|
*/
|
|
569
606
|
async clearOpenDrive() {
|
|
570
607
|
var o, i;
|
|
571
|
-
let
|
|
572
|
-
|
|
573
|
-
deleteFeatures:
|
|
574
|
-
}),
|
|
575
|
-
deleteFeatures:
|
|
608
|
+
let t = await this.laneLayer.queryFeatures();
|
|
609
|
+
t.features.length > 0 && await this.laneLayer.applyEdits({
|
|
610
|
+
deleteFeatures: t.features
|
|
611
|
+
}), t = await this.roadNameLayer.queryFeatures(), t.features.length > 0 && await this.roadNameLayer.applyEdits({
|
|
612
|
+
deleteFeatures: t.features
|
|
576
613
|
}), this.highlightLayer.removeAll(), this.junctionLayer.removeAll(), this.wasmLoader.clear(), (o = this.mouseMoveHandler) == null || o.remove(), (i = this.mouseClickHandler) == null || i.remove();
|
|
577
614
|
}
|
|
578
615
|
/**
|
|
@@ -580,82 +617,112 @@ ${this.hitGraphic.attributes.id}`,
|
|
|
580
617
|
* @param params
|
|
581
618
|
* @returns
|
|
582
619
|
*/
|
|
583
|
-
async findSumo(
|
|
584
|
-
const {
|
|
585
|
-
if (
|
|
586
|
-
return
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
620
|
+
async findSumo(t) {
|
|
621
|
+
const { type: o, id: i } = t, s = t.flash === void 0 ? !0 : t.flash;
|
|
622
|
+
if (o === "junction")
|
|
623
|
+
return await this.findJunction(i, s);
|
|
624
|
+
if (o === "edge") {
|
|
625
|
+
const e = i.split("+");
|
|
626
|
+
if (e.length > 2)
|
|
627
|
+
return { status: -1, message: "id格式错误" };
|
|
628
|
+
const c = e.length === 2 ? Number(e[1]) : void 0, r = e[0].split("#");
|
|
629
|
+
if (r.length > 2)
|
|
630
|
+
return { status: -1, message: "id格式错误" };
|
|
631
|
+
const n = r[0], a = r.length === 2 ? Number(r[1]) : void 0;
|
|
632
|
+
return await this.findLane({ roadsectId: n, segmentId: a, laneId: c, flash: s });
|
|
633
|
+
} else
|
|
634
|
+
return { status: -1, message: "未知类型" };
|
|
635
|
+
}
|
|
636
|
+
async findJunction(t, o) {
|
|
637
|
+
const i = this.junctionLayer.graphics.find(
|
|
638
|
+
(s) => s.attributes.id === t
|
|
639
|
+
);
|
|
640
|
+
if (!i)
|
|
641
|
+
return { status: -1, message: "未找到。请检查路口编号" };
|
|
642
|
+
if (o) {
|
|
643
|
+
const s = new p({
|
|
644
|
+
geometry: i.geometry,
|
|
645
|
+
symbol: {
|
|
646
|
+
type: "simple-marker",
|
|
647
|
+
style: "circle",
|
|
648
|
+
size: 30,
|
|
649
|
+
color: [255, 0, 0, 0.6],
|
|
650
|
+
outline: {
|
|
651
|
+
color: "red",
|
|
652
|
+
width: 1
|
|
653
|
+
}
|
|
654
|
+
}
|
|
655
|
+
});
|
|
656
|
+
this.flashGraphic(s);
|
|
657
|
+
}
|
|
658
|
+
return await this.view.goTo(i.geometry, { duration: 1e3 }), { status: 0, message: "ok" };
|
|
594
659
|
}
|
|
595
660
|
/**
|
|
596
661
|
* 用sumo的id定位车道、基本段、路段
|
|
597
662
|
* @param params
|
|
598
663
|
* @returns
|
|
599
664
|
*/
|
|
600
|
-
async findLane(
|
|
601
|
-
let {
|
|
602
|
-
|
|
603
|
-
let
|
|
604
|
-
(
|
|
665
|
+
async findLane(t) {
|
|
666
|
+
let { roadsectId: o, segmentId: i, laneId: s } = t;
|
|
667
|
+
o.startsWith("-") && (o = o.slice(1));
|
|
668
|
+
let e = this.allLaneGraphics.filter(
|
|
669
|
+
(n) => n.attributes.roadId === o
|
|
605
670
|
);
|
|
606
|
-
if (
|
|
671
|
+
if (e.length === 0)
|
|
607
672
|
return { status: -1, message: "未找到。请检查路段编号" };
|
|
608
|
-
if (
|
|
609
|
-
const
|
|
610
|
-
if (
|
|
611
|
-
const
|
|
612
|
-
|
|
613
|
-
}),
|
|
673
|
+
if (i !== void 0) {
|
|
674
|
+
const n = [];
|
|
675
|
+
if (e.forEach((a) => {
|
|
676
|
+
const l = Number(a.attributes.sectionId);
|
|
677
|
+
n.indexOf(l) === -1 && n.push(l);
|
|
678
|
+
}), n.sort((a, l) => a - l), i > n.length - 1)
|
|
614
679
|
return { status: -1, message: "未找到。请检查基本段编号" };
|
|
615
|
-
|
|
616
|
-
(
|
|
680
|
+
i = n[i], e = e.filter(
|
|
681
|
+
(a) => Number(a.attributes.sectionId) === i
|
|
617
682
|
);
|
|
618
683
|
}
|
|
619
|
-
if (
|
|
620
|
-
const
|
|
621
|
-
if (
|
|
622
|
-
const
|
|
623
|
-
|
|
624
|
-
}),
|
|
684
|
+
if (s !== void 0) {
|
|
685
|
+
const n = [];
|
|
686
|
+
if (e.forEach((a) => {
|
|
687
|
+
const l = Number(a.attributes.laneId);
|
|
688
|
+
n.indexOf(l) === -1 && n.push(l);
|
|
689
|
+
}), n.sort((a, l) => a - l), s > n.length - 1)
|
|
625
690
|
return { status: -1, message: "未找到。请检查车道编号" };
|
|
626
|
-
|
|
627
|
-
(
|
|
691
|
+
s = n[s], e = e.filter(
|
|
692
|
+
(a) => Number(a.attributes.laneId) === s
|
|
628
693
|
);
|
|
629
694
|
}
|
|
630
|
-
const
|
|
631
|
-
(
|
|
632
|
-
),
|
|
633
|
-
if (
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
geometry: l,
|
|
695
|
+
const c = e.map(
|
|
696
|
+
(n) => n.geometry
|
|
697
|
+
), r = await k.union(c);
|
|
698
|
+
if (t.flash) {
|
|
699
|
+
const n = new p({
|
|
700
|
+
geometry: r,
|
|
637
701
|
symbol: {
|
|
638
702
|
type: "simple-fill",
|
|
639
703
|
color: [255, 0, 0, 0.5],
|
|
640
704
|
style: "solid",
|
|
641
705
|
outline: {
|
|
642
706
|
color: "red",
|
|
643
|
-
width:
|
|
707
|
+
width: 0
|
|
644
708
|
}
|
|
645
709
|
}
|
|
646
710
|
});
|
|
647
|
-
this.
|
|
648
|
-
let r = 0, n = !0;
|
|
649
|
-
const u = setInterval(() => {
|
|
650
|
-
n ? (this.highlightLayer.opacity -= 0.02, this.highlightLayer.opacity <= 0.1 && (n = !1, r++)) : (this.highlightLayer.opacity += 0.02, this.highlightLayer.opacity >= 1 && (n = !0)), r > 5 && (this.highlightLayer.removeAll(), this.highlightLayer.opacity = 1, clearInterval(u));
|
|
651
|
-
}, 20);
|
|
711
|
+
this.flashGraphic(n);
|
|
652
712
|
}
|
|
653
|
-
return await this.view.goTo(
|
|
713
|
+
return await this.view.goTo(r, { duration: 1e3 }), { status: 0, message: "ok" };
|
|
714
|
+
}
|
|
715
|
+
flashGraphic(t) {
|
|
716
|
+
this.flashLayer.removeAll(), this.flashLayer.add(t);
|
|
717
|
+
let o = 0, i = !0;
|
|
718
|
+
const s = setInterval(() => {
|
|
719
|
+
i ? (this.flashLayer.opacity -= 0.02, this.flashLayer.opacity <= 0.1 && (i = !1, o++)) : (this.flashLayer.opacity += 0.02, this.flashLayer.opacity >= 1 && (i = !0)), o >= 5 && (this.flashLayer.removeAll(), this.flashLayer.opacity = 1, clearInterval(s));
|
|
720
|
+
}, 10);
|
|
654
721
|
}
|
|
655
|
-
async splitLane(
|
|
656
|
-
return { status: 0, message: "ok", result:
|
|
722
|
+
async splitLane(t) {
|
|
723
|
+
return { status: 0, message: "ok", result: t };
|
|
657
724
|
}
|
|
658
725
|
}
|
|
659
726
|
export {
|
|
660
|
-
|
|
727
|
+
S as default
|
|
661
728
|
};
|
package/es/src/types/index.d.ts
CHANGED
|
@@ -214,10 +214,12 @@ export interface IShowOpenDriveFromFileParams {
|
|
|
214
214
|
showJunctionPolygon: boolean;
|
|
215
215
|
showJunctionLane: boolean;
|
|
216
216
|
showRoadName: boolean;
|
|
217
|
-
centerMap
|
|
217
|
+
centerMap?: boolean;
|
|
218
218
|
};
|
|
219
|
+
selectedCallback?: (info: any) => void;
|
|
219
220
|
}
|
|
220
221
|
export interface IFindSumoParams {
|
|
222
|
+
type: string;
|
|
221
223
|
id: string;
|
|
222
224
|
flash?: boolean;
|
|
223
225
|
}
|
|
@@ -229,6 +231,7 @@ export interface ISplitOpenDriveLaneParams {
|
|
|
229
231
|
export interface IJunctionTableData {
|
|
230
232
|
id: string;
|
|
231
233
|
name: string;
|
|
234
|
+
nodeType: string;
|
|
232
235
|
type: string;
|
|
233
236
|
coordinates: number[];
|
|
234
237
|
district: string;
|
|
@@ -6,7 +6,9 @@ export default class OpenDriveRenderer {
|
|
|
6
6
|
private laneLayer;
|
|
7
7
|
private roadNameLayer;
|
|
8
8
|
private junctionLayer;
|
|
9
|
+
private sectionLayer;
|
|
9
10
|
private highlightLayer;
|
|
11
|
+
private flashLayer;
|
|
10
12
|
private allLaneGraphics;
|
|
11
13
|
private allRefLineGraphics;
|
|
12
14
|
private mouseMoveHandler;
|
|
@@ -15,6 +17,7 @@ export default class OpenDriveRenderer {
|
|
|
15
17
|
constructor(view: __esri.MapView | __esri.SceneView);
|
|
16
18
|
private projectName;
|
|
17
19
|
private openDriveServer;
|
|
20
|
+
private openDriveClickCallback;
|
|
18
21
|
showOpenDriveFromFile(params: IShowOpenDriveFromFileParams): Promise<IResult>;
|
|
19
22
|
/**
|
|
20
23
|
* 从服务器载入OpenDrive文件解析结果并显示
|
|
@@ -48,11 +51,13 @@ export default class OpenDriveRenderer {
|
|
|
48
51
|
* @returns
|
|
49
52
|
*/
|
|
50
53
|
findSumo(params: IFindSumoParams): Promise<IResult>;
|
|
54
|
+
private findJunction;
|
|
51
55
|
/**
|
|
52
56
|
* 用sumo的id定位车道、基本段、路段
|
|
53
57
|
* @param params
|
|
54
58
|
* @returns
|
|
55
59
|
*/
|
|
56
60
|
private findLane;
|
|
61
|
+
private flashGraphic;
|
|
57
62
|
splitLane(params: ISplitOpenDriveLaneParams): Promise<IResult>;
|
|
58
63
|
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const
|
|
2
|
-
${this.hitGraphic.attributes.id}`,font:{size:10},yoffset:40}});this.highlightLayer.removeAll(),this.highlightLayer.
|
|
1
|
+
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const d=require("@arcgis/core/Graphic"),F=require("@arcgis/core/core/promiseUtils"),$=require("@arcgis/core/geometry"),J=require("@arcgis/core/geometry/geometryEngineAsync"),j=require("@arcgis/core/layers/FeatureLayer"),m=require("@arcgis/core/layers/GraphicsLayer"),g=require("axios"),G=require("pako"),C=require("../common-utils.js"),M=require("./wasm-loader.js");function N(p){const e=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(p){for(const s in p)if(s!=="default"){const i=Object.getOwnPropertyDescriptor(p,s);Object.defineProperty(e,s,i.get?i:{enumerable:!0,get:()=>p[s]})}}return e.default=p,Object.freeze(e)}const O=N(F),S=N(J);class v{constructor(e){this.wasmLoader=M.default.getInstance(),this.projectName="",this.openDriveServer="",this.currentSectionCode="",this.currentJunctionId="",this.view=e,this.laneLayer=new j({id:"OpenDriveLane",fields:[{name:"ObjectID",alias:"ObjectID",type:"oid"},{name:"id",alias:"编号",type:"string"},{name:"roadId",alias:"道路号",type:"string"},{name:"roadName",alias:"道路名称",type:"string"},{name:"sectionId",alias:"路段号",type:"string"},{name:"laneId",alias:"车道号",type:"string"},{name:"type",alias:"类型",type:"string"},{name:"sumoId",alias:"sumo编号",type:"string"}],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 j({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 m({id:"OpenDriveJunction"}),this.sectionLayer=new m({id:"OpenDriveSection"}),this.highlightLayer=new m({id:"OpenDriveHighlight"}),this.flashLayer=new m({id:"OpenDriveFlash"}),this.view.map.addMany([this.laneLayer,this.junctionLayer,this.sectionLayer,this.roadNameLayer,this.highlightLayer,this.flashLayer])}static getInstance(e){return this.instance||(this.instance=new v(e)),this.instance}async showOpenDriveFromFile(e){var h,u;this.openDriveClickCallback=e.selectedCallback,this.projectName=Date.now().toString(),this.openDriveServer=e.server;const s=`http://${this.openDriveServer}/api/openDrive/uploadXodr`,i=await g.post(s,{},{params:{url:e.file,projectName:this.projectName}});if(i.status!==200)throw new Error(`OpenDriveRenderer: ${i.statusText}`);console.time("渲染用时");const r=i.data.result.geoSetting;C.default.setGeoData(r.geoReference,r.offsetX,r.offsetY);let t=i.data.result.json;t.startsWith(window.location.protocol)||(t=`${window.location.protocol}//${e.server}${t}`);const o=await(await fetch(t)).arrayBuffer(),n=G.inflate(o,{to:"string"}),a=JSON.parse(n);await this.showAllLanes(a,((h=e.options)==null?void 0:h.showJunctionLane)||!1,((u=e.options)==null?void 0:u.showRoadName)||!0);const l=i.data.result.junctions;if(this.showJunction(l),e.options&&e.options.centerMap!==!1){const w=C.default.transformPointProjection([0,0]);await this.view.goTo(w)}return this.mouseMoveHandler||this.monitorMouseMove(),this.mouseClickHandler||this.monitorMouseClick(),console.timeEnd("渲染用时"),{status:0,message:"ok"}}async showOpenDriveFromServer(e,s){const i=`http://${e}/api/openDrive/analyzeXodr`,r=await g.get(i,{headers:{projectName:s},params:{analyze:!1,compressed:!0}});if(r.status!==200)throw new Error(`OpenDriveRenderer: ${r.statusText}`);let t=r.data.result.json;t.startsWith(window.location.protocol)||(t=`${window.location.protocol}//${e}${t}`);const o=await(await fetch(t)).arrayBuffer(),n=G.inflate(o,{to:"string"}),a=JSON.parse(n);return await this.showAllLanes(a,!1,!1),{status:0,message:"ok"}}async showAllLanes(e,s,i){const r=await this.laneLayer.queryFeatures();return r.features.length>0&&this.laneLayer.applyEdits({deleteFeatures:r.features}),this.roadNameLayer.visible=i,new Promise(t=>{let c=0;this.allLaneGraphics=[],this.allRefLineGraphics=[];const o=[];for(const a of e){if(!s&&a.junction!=="-1")continue;const{id:l,refLine:h}=a;let u=a.name;u.includes("(")&&(u=u.slice(0,u.indexOf("("))),u=u.replace(/(.)/g,"$1 ");const w=new d({geometry:{type:"polyline",paths:[h]},attributes:{ObjectID:c++,roadId:l,roadName:u}});this.allRefLineGraphics.push(w);for(const L of a.laneSections){const I=Number(L.id);for(const y of L.lanePaths){const f=Number(y.id);if(f===0)continue;const A=y.type,b=y.innerPath.concat(y.outerPath.reverse());if(b.length<=3){console.warn(`lane ${f} has less than 3 points`);continue}b.push(y.innerPath[0]);const D=new $.Polygon({rings:[b]});if(D){const k=new d({geometry:D,attributes:{ObjectID:c++,id:`${l}+${I}+${f}`,roadId:l,roadName:a.name,sectionId:I,laneId:f,type:A,sumoId:""}});this.allLaneGraphics.push(k),o.push(k)}}}}const n=setInterval(()=>{if(o.length>0||this.allRefLineGraphics.length>0){if(o.length>0){const a=o.splice(0,100);this.laneLayer.applyEdits({addFeatures:a})}if(this.allRefLineGraphics.length>0){const a=this.allRefLineGraphics.splice(0,10);this.roadNameLayer.applyEdits({addFeatures:a})}}else clearInterval(n),t()},10)})}showJunction(e){const s=[];for(const i of e){i.nodeType=i.type;const r=new d({geometry:{type:"point",x:i.coordinates[0],y:i.coordinates[1]},attributes:{...i,selected:!1,type:"OpenDriveJunction"},symbol:{type:"picture-marker",url:i.crossId?"/GisViewerAssets/Images/point_green.png":"/GisViewerAssets/Images/normal-cross.png",width:30,height:30}});s.push(r)}this.junctionLayer.addMany(s)}monitorMouseMove(){const e=O.debounce(async s=>{var c;const r=(c=(await this.view.hitTest(s,{include:[this.laneLayer,this.junctionLayer]})).results)==null?void 0:c.filter(o=>o.type==="graphic");if(r.length===0){this.currentSectionCode!==""&&(this.currentSectionCode="",this.highlightGraphic=void 0,this.highlightLayer.removeAll()),this.currentJunctionId!==""&&(this.currentJunctionId="",this.highlightGraphic=void 0,this.highlightLayer.removeAll());return}const t=r[0];if(this.hitGraphic=t.graphic,t.layer.id==="OpenDriveLane"){const o=`${this.hitGraphic.attributes.roadId}+${this.hitGraphic.attributes.sectionId}`;if(o===this.currentSectionCode||this.sectionLayer.graphics.findIndex(h=>h.getAttribute("id")===o)>=0)return;this.currentSectionCode=o;const a=this.allLaneGraphics.filter(h=>`${h.attributes.roadId}+${h.attributes.sectionId}`===o),l=await S.union(a.map(h=>h.geometry));this.highlightGraphic=new d({geometry:l,symbol:{type:"simple-fill",color:[255,0,0,.5],style:"solid",outline:{color:"red",width:2}},attributes:{type:"OpenDriveSection",id:o,selected:!1}}),this.highlightLayer.removeAll(),this.highlightLayer.add(this.highlightGraphic)}else if(t.layer.id==="OpenDriveJunction"){const o=this.hitGraphic.attributes.id;if(o===this.currentJunctionId)return;this.currentJunctionId=o;const n=new d({geometry:this.hitGraphic.geometry,symbol:{type:"text",color:"black",backgroundColor:"gray",text:`${this.hitGraphic.attributes.name}
|
|
2
|
+
${this.hitGraphic.attributes.id}`,font:{size:10},yoffset:40}});this.highlightLayer.removeAll(),this.highlightLayer.add(n)}});this.mouseMoveHandler=this.view.on("pointer-move",async s=>{e(s).catch(()=>{})})}monitorMouseClick(){const e=O.debounce(async s=>{var n;const r=(n=(await this.view.hitTest(s,{include:[this.highlightLayer,this.junctionLayer,this.sectionLayer]})).results)==null?void 0:n.filter(a=>a.type==="graphic");if(r.length===0)return;const t=r[0].graphic,c=t.getAttribute("type"),o=t.getAttribute("id");if(c==="OpenDriveJunction")if(t.getAttribute("selected")===!1){const a=`http://${this.openDriveServer}/api/sumo/getSumoJunction`,l=await g.get(a,{params:{id:o,projectName:this.projectName}});l.status===200&&l.data.status===0&&(this.openDriveClickCallback&&this.openDriveClickCallback({type:"OpenDriveJunction",id:o,details:l.data.result}),t.setAttribute("selected",!0),t.symbol.url="/GisViewerAssets/Images/point_red.png",this.increasePictureMarkerSize(t,50))}else this.openDriveClickCallback&&this.openDriveClickCallback({type:"OpenDriveJunction",id:o,details:void 0}),t.setAttribute("selected",!1),t.symbol.url="/GisViewerAssets/Images/point_green.png",this.decreasePictureMarkerSize(t,30);else if(c==="OpenDriveSection")if(t.getAttribute("selected"))this.sectionLayer.remove(t),this.openDriveClickCallback&&this.openDriveClickCallback({type:"OpenDriveSection",id:o,details:void 0});else{this.highlightLayer.remove(t),this.sectionLayer.add(t),t.setAttribute("selected",!0);const a=`http://${this.openDriveServer}/api/sumo/getSumoEdge`,l=await g.get(a,{params:{id:o,projectName:this.projectName}});l.status===200&&l.data.status===0&&this.openDriveClickCallback&&this.openDriveClickCallback({type:"OpenDriveSection",id:o,details:l.data.result})}});this.mouseClickHandler=this.view.on("immediate-click",async s=>{e(s).catch(()=>{})})}increasePictureMarkerSize(e,s){const i=setInterval(()=>{const r=e.symbol,t=r.width;t<s?e.symbol={type:"picture-marker",url:r.url,width:t+1,height:t+1}:clearInterval(i)},20)}decreasePictureMarkerSize(e,s){const i=setInterval(()=>{const r=e.symbol,t=r.width;t>s?e.symbol={type:"picture-marker",url:r.url,width:t-1,height:t-1}:clearInterval(i)},20)}async clearOpenDrive(){var s,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.wasmLoader.clear(),(s=this.mouseMoveHandler)==null||s.remove(),(i=this.mouseClickHandler)==null||i.remove()}async findSumo(e){const{type:s,id:i}=e,r=e.flash===void 0?!0:e.flash;if(s==="junction")return await this.findJunction(i,r);if(s==="edge"){const t=i.split("+");if(t.length>2)return{status:-1,message:"id格式错误"};const c=t.length===2?Number(t[1]):void 0,o=t[0].split("#");if(o.length>2)return{status:-1,message:"id格式错误"};const n=o[0],a=o.length===2?Number(o[1]):void 0;return await this.findLane({roadsectId:n,segmentId:a,laneId:c,flash:r})}else return{status:-1,message:"未知类型"}}async findJunction(e,s){const i=this.junctionLayer.graphics.find(r=>r.attributes.id===e);if(!i)return{status:-1,message:"未找到。请检查路口编号"};if(s){const r=new d({geometry:i.geometry,symbol:{type:"simple-marker",style:"circle",size:30,color:[255,0,0,.6],outline:{color:"red",width:1}}});this.flashGraphic(r)}return await this.view.goTo(i.geometry,{duration:1e3}),{status:0,message:"ok"}}async findLane(e){let{roadsectId:s,segmentId:i,laneId:r}=e;s.startsWith("-")&&(s=s.slice(1));let t=this.allLaneGraphics.filter(n=>n.attributes.roadId===s);if(t.length===0)return{status:-1,message:"未找到。请检查路段编号"};if(i!==void 0){const n=[];if(t.forEach(a=>{const l=Number(a.attributes.sectionId);n.indexOf(l)===-1&&n.push(l)}),n.sort((a,l)=>a-l),i>n.length-1)return{status:-1,message:"未找到。请检查基本段编号"};i=n[i],t=t.filter(a=>Number(a.attributes.sectionId)===i)}if(r!==void 0){const n=[];if(t.forEach(a=>{const l=Number(a.attributes.laneId);n.indexOf(l)===-1&&n.push(l)}),n.sort((a,l)=>a-l),r>n.length-1)return{status:-1,message:"未找到。请检查车道编号"};r=n[r],t=t.filter(a=>Number(a.attributes.laneId)===r)}const c=t.map(n=>n.geometry),o=await S.union(c);if(e.flash){const n=new d({geometry:o,symbol:{type:"simple-fill",color:[255,0,0,.5],style:"solid",outline:{color:"red",width:0}}});this.flashGraphic(n)}return await this.view.goTo(o,{duration:1e3}),{status:0,message:"ok"}}flashGraphic(e){this.flashLayer.removeAll(),this.flashLayer.add(e);let s=0,i=!0;const r=setInterval(()=>{i?(this.flashLayer.opacity-=.02,this.flashLayer.opacity<=.1&&(i=!1,s++)):(this.flashLayer.opacity+=.02,this.flashLayer.opacity>=1&&(i=!0)),s>=5&&(this.flashLayer.removeAll(),this.flashLayer.opacity=1,clearInterval(r))},10)}async splitLane(e){return{status:0,message:"ok",result:e}}}exports.default=v;
|
package/lib/src/types/index.d.ts
CHANGED
|
@@ -214,10 +214,12 @@ export interface IShowOpenDriveFromFileParams {
|
|
|
214
214
|
showJunctionPolygon: boolean;
|
|
215
215
|
showJunctionLane: boolean;
|
|
216
216
|
showRoadName: boolean;
|
|
217
|
-
centerMap
|
|
217
|
+
centerMap?: boolean;
|
|
218
218
|
};
|
|
219
|
+
selectedCallback?: (info: any) => void;
|
|
219
220
|
}
|
|
220
221
|
export interface IFindSumoParams {
|
|
222
|
+
type: string;
|
|
221
223
|
id: string;
|
|
222
224
|
flash?: boolean;
|
|
223
225
|
}
|
|
@@ -229,6 +231,7 @@ export interface ISplitOpenDriveLaneParams {
|
|
|
229
231
|
export interface IJunctionTableData {
|
|
230
232
|
id: string;
|
|
231
233
|
name: string;
|
|
234
|
+
nodeType: string;
|
|
232
235
|
type: string;
|
|
233
236
|
coordinates: number[];
|
|
234
237
|
district: string;
|