gisviewer-vue3-arcgis 1.0.121 → 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 +265 -202
- package/es/src/types/index.d.ts +3 -0
- 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 +3 -0
- 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,25 +268,27 @@ 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 =
|
|
283
|
+
async showOpenDriveFromFile(t) {
|
|
284
|
+
var h, d;
|
|
285
|
+
this.openDriveClickCallback = t.selectedCallback, this.projectName = Date.now().toString(), this.openDriveServer = t.server;
|
|
284
286
|
const o = `http://${this.openDriveServer}/api/openDrive/uploadXodr`, i = await f.post(
|
|
285
287
|
o,
|
|
286
288
|
{},
|
|
287
289
|
{
|
|
288
290
|
params: {
|
|
289
|
-
url:
|
|
291
|
+
url: t.file,
|
|
290
292
|
projectName: this.projectName
|
|
291
293
|
}
|
|
292
294
|
}
|
|
@@ -295,23 +297,23 @@ class N {
|
|
|
295
297
|
throw new Error(`OpenDriveRenderer: ${i.statusText}`);
|
|
296
298
|
console.time("渲染用时");
|
|
297
299
|
const s = i.data.result.geoSetting;
|
|
298
|
-
|
|
300
|
+
j.setGeoData(
|
|
299
301
|
s.geoReference,
|
|
300
302
|
s.offsetX,
|
|
301
303
|
s.offsetY
|
|
302
304
|
);
|
|
303
|
-
let
|
|
304
|
-
|
|
305
|
-
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);
|
|
306
308
|
await this.showAllLanes(
|
|
307
|
-
|
|
308
|
-
((
|
|
309
|
-
((
|
|
309
|
+
a,
|
|
310
|
+
((h = t.options) == null ? void 0 : h.showJunctionLane) || !1,
|
|
311
|
+
((d = t.options) == null ? void 0 : d.showRoadName) || !0
|
|
310
312
|
);
|
|
311
|
-
const
|
|
312
|
-
if (this.showJunction(
|
|
313
|
-
const
|
|
314
|
-
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);
|
|
315
317
|
}
|
|
316
318
|
return this.mouseMoveHandler || this.monitorMouseMove(), this.mouseClickHandler || this.monitorMouseClick(), console.timeEnd("渲染用时"), { status: 0, message: "ok" };
|
|
317
319
|
}
|
|
@@ -320,8 +322,8 @@ class N {
|
|
|
320
322
|
* @param server
|
|
321
323
|
* @param projectName
|
|
322
324
|
*/
|
|
323
|
-
async showOpenDriveFromServer(
|
|
324
|
-
const i = `http://${
|
|
325
|
+
async showOpenDriveFromServer(t, o) {
|
|
326
|
+
const i = `http://${t}/api/openDrive/analyzeXodr`, s = await f.get(i, {
|
|
325
327
|
headers: {
|
|
326
328
|
projectName: o
|
|
327
329
|
},
|
|
@@ -332,102 +334,107 @@ class N {
|
|
|
332
334
|
});
|
|
333
335
|
if (s.status !== 200)
|
|
334
336
|
throw new Error(`OpenDriveRenderer: ${s.statusText}`);
|
|
335
|
-
let
|
|
336
|
-
|
|
337
|
-
const
|
|
338
|
-
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" };
|
|
339
341
|
}
|
|
340
|
-
async showAllLanes(
|
|
342
|
+
async showAllLanes(t, o, i) {
|
|
341
343
|
const s = await this.laneLayer.queryFeatures();
|
|
342
344
|
return s.features.length > 0 && this.laneLayer.applyEdits({
|
|
343
345
|
deleteFeatures: s.features
|
|
344
|
-
}), this.roadNameLayer.visible = i, new Promise((
|
|
345
|
-
let
|
|
346
|
+
}), this.roadNameLayer.visible = i, new Promise((e) => {
|
|
347
|
+
let c = 0;
|
|
346
348
|
this.allLaneGraphics = [], this.allRefLineGraphics = [];
|
|
347
|
-
const
|
|
348
|
-
for (const
|
|
349
|
-
if (!o &&
|
|
349
|
+
const r = [];
|
|
350
|
+
for (const a of t) {
|
|
351
|
+
if (!o && a.junction !== "-1")
|
|
350
352
|
continue;
|
|
351
|
-
const { id:
|
|
352
|
-
let
|
|
353
|
-
|
|
354
|
-
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({
|
|
355
357
|
geometry: {
|
|
356
358
|
type: "polyline",
|
|
357
|
-
paths: [
|
|
359
|
+
paths: [h]
|
|
358
360
|
},
|
|
359
361
|
attributes: {
|
|
360
|
-
ObjectID:
|
|
361
|
-
roadId:
|
|
362
|
-
roadName:
|
|
362
|
+
ObjectID: c++,
|
|
363
|
+
roadId: l,
|
|
364
|
+
roadName: d
|
|
363
365
|
}
|
|
364
366
|
});
|
|
365
|
-
this.allRefLineGraphics.push(
|
|
366
|
-
for (const
|
|
367
|
-
const b = Number(
|
|
368
|
-
for (const
|
|
369
|
-
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);
|
|
370
372
|
if (y === 0)
|
|
371
373
|
continue;
|
|
372
|
-
const
|
|
373
|
-
|
|
374
|
+
const O = u.type, w = u.innerPath.concat(
|
|
375
|
+
u.outerPath.reverse()
|
|
374
376
|
);
|
|
375
|
-
if (
|
|
377
|
+
if (w.length <= 3) {
|
|
376
378
|
console.warn(`lane ${y} has less than 3 points`);
|
|
377
379
|
continue;
|
|
378
380
|
}
|
|
379
|
-
|
|
380
|
-
const
|
|
381
|
-
rings: [
|
|
381
|
+
w.push(u.innerPath[0]);
|
|
382
|
+
const L = new N({
|
|
383
|
+
rings: [w]
|
|
382
384
|
});
|
|
383
|
-
if (
|
|
384
|
-
const I = new
|
|
385
|
-
geometry:
|
|
385
|
+
if (L) {
|
|
386
|
+
const I = new p({
|
|
387
|
+
geometry: L,
|
|
386
388
|
attributes: {
|
|
387
|
-
ObjectID:
|
|
388
|
-
id: `${
|
|
389
|
-
roadId:
|
|
390
|
-
roadName:
|
|
389
|
+
ObjectID: c++,
|
|
390
|
+
id: `${l}+${b}+${y}`,
|
|
391
|
+
roadId: l,
|
|
392
|
+
roadName: a.name,
|
|
391
393
|
sectionId: b,
|
|
392
394
|
laneId: y,
|
|
393
|
-
type:
|
|
395
|
+
type: O,
|
|
394
396
|
sumoId: ""
|
|
395
397
|
}
|
|
396
398
|
});
|
|
397
|
-
this.allLaneGraphics.push(I),
|
|
399
|
+
this.allLaneGraphics.push(I), r.push(I);
|
|
398
400
|
}
|
|
399
401
|
}
|
|
400
402
|
}
|
|
401
403
|
}
|
|
402
|
-
const
|
|
403
|
-
if (
|
|
404
|
-
if (
|
|
405
|
-
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);
|
|
406
408
|
this.laneLayer.applyEdits({
|
|
407
|
-
addFeatures:
|
|
409
|
+
addFeatures: a
|
|
408
410
|
});
|
|
409
411
|
}
|
|
410
412
|
if (this.allRefLineGraphics.length > 0) {
|
|
411
|
-
const
|
|
413
|
+
const a = this.allRefLineGraphics.splice(0, 10);
|
|
412
414
|
this.roadNameLayer.applyEdits({
|
|
413
|
-
addFeatures:
|
|
415
|
+
addFeatures: a
|
|
414
416
|
});
|
|
415
417
|
}
|
|
416
418
|
} else
|
|
417
|
-
clearInterval(
|
|
419
|
+
clearInterval(n), e();
|
|
418
420
|
}, 10);
|
|
419
421
|
});
|
|
420
422
|
}
|
|
421
|
-
showJunction(
|
|
423
|
+
showJunction(t) {
|
|
422
424
|
const o = [];
|
|
423
|
-
for (const i of
|
|
424
|
-
|
|
425
|
+
for (const i of t) {
|
|
426
|
+
i.nodeType = i.type;
|
|
427
|
+
const s = new p({
|
|
425
428
|
geometry: {
|
|
426
429
|
type: "point",
|
|
427
430
|
x: i.coordinates[0],
|
|
428
431
|
y: i.coordinates[1]
|
|
429
432
|
},
|
|
430
|
-
attributes: {
|
|
433
|
+
attributes: {
|
|
434
|
+
...i,
|
|
435
|
+
selected: !1,
|
|
436
|
+
type: "OpenDriveJunction"
|
|
437
|
+
},
|
|
431
438
|
symbol: {
|
|
432
439
|
type: "picture-marker",
|
|
433
440
|
url: i.crossId ? "/GisViewerAssets/Images/point_green.png" : "/GisViewerAssets/Images/normal-cross.png",
|
|
@@ -443,30 +450,32 @@ class N {
|
|
|
443
450
|
* 监听鼠标移动事件,高亮显示鼠标所在路段和路口
|
|
444
451
|
*/
|
|
445
452
|
monitorMouseMove() {
|
|
446
|
-
const
|
|
447
|
-
var
|
|
448
|
-
const s = (
|
|
453
|
+
const t = D.debounce(async (o) => {
|
|
454
|
+
var c;
|
|
455
|
+
const s = (c = (await this.view.hitTest(o, {
|
|
449
456
|
include: [this.laneLayer, this.junctionLayer]
|
|
450
|
-
})).results) == null ? void 0 :
|
|
451
|
-
(
|
|
457
|
+
})).results) == null ? void 0 : c.filter(
|
|
458
|
+
(r) => r.type === "graphic"
|
|
452
459
|
);
|
|
453
460
|
if (s.length === 0) {
|
|
454
461
|
this.currentSectionCode !== "" && (this.currentSectionCode = "", this.highlightGraphic = void 0, this.highlightLayer.removeAll()), this.currentJunctionId !== "" && (this.currentJunctionId = "", this.highlightGraphic = void 0, this.highlightLayer.removeAll());
|
|
455
462
|
return;
|
|
456
463
|
}
|
|
457
|
-
const
|
|
458
|
-
if (this.hitGraphic =
|
|
459
|
-
const
|
|
460
|
-
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)
|
|
461
470
|
return;
|
|
462
|
-
this.currentSectionCode =
|
|
471
|
+
this.currentSectionCode = r;
|
|
463
472
|
const a = this.allLaneGraphics.filter(
|
|
464
|
-
(
|
|
465
|
-
),
|
|
466
|
-
a.map((
|
|
473
|
+
(h) => `${h.attributes.roadId}+${h.attributes.sectionId}` === r
|
|
474
|
+
), l = await k.union(
|
|
475
|
+
a.map((h) => h.geometry)
|
|
467
476
|
);
|
|
468
|
-
this.highlightGraphic = new
|
|
469
|
-
geometry:
|
|
477
|
+
this.highlightGraphic = new p({
|
|
478
|
+
geometry: l,
|
|
470
479
|
symbol: {
|
|
471
480
|
type: "simple-fill",
|
|
472
481
|
color: [255, 0, 0, 0.5],
|
|
@@ -478,31 +487,16 @@ class N {
|
|
|
478
487
|
},
|
|
479
488
|
attributes: {
|
|
480
489
|
type: "OpenDriveSection",
|
|
481
|
-
id:
|
|
482
|
-
|
|
490
|
+
id: r,
|
|
491
|
+
selected: !1
|
|
483
492
|
}
|
|
484
493
|
}), this.highlightLayer.removeAll(), this.highlightLayer.add(this.highlightGraphic);
|
|
485
|
-
} else if (
|
|
486
|
-
const
|
|
487
|
-
if (
|
|
494
|
+
} else if (e.layer.id === "OpenDriveJunction") {
|
|
495
|
+
const r = this.hitGraphic.attributes.id;
|
|
496
|
+
if (r === this.currentJunctionId)
|
|
488
497
|
return;
|
|
489
|
-
this.currentJunctionId =
|
|
490
|
-
|
|
491
|
-
symbol: {
|
|
492
|
-
type: "simple-marker",
|
|
493
|
-
style: "circle",
|
|
494
|
-
size: 40,
|
|
495
|
-
color: [0, 0, 0, 0],
|
|
496
|
-
outline: {
|
|
497
|
-
color: [0, 0, 0, 0]
|
|
498
|
-
}
|
|
499
|
-
},
|
|
500
|
-
attributes: {
|
|
501
|
-
type: "OpenDriveJunction",
|
|
502
|
-
id: l
|
|
503
|
-
}
|
|
504
|
-
});
|
|
505
|
-
const a = new d({
|
|
498
|
+
this.currentJunctionId = r;
|
|
499
|
+
const n = new p({
|
|
506
500
|
geometry: this.hitGraphic.geometry,
|
|
507
501
|
symbol: {
|
|
508
502
|
type: "text",
|
|
@@ -516,11 +510,11 @@ ${this.hitGraphic.attributes.id}`,
|
|
|
516
510
|
yoffset: 40
|
|
517
511
|
}
|
|
518
512
|
});
|
|
519
|
-
this.highlightLayer.removeAll(), this.highlightLayer.
|
|
513
|
+
this.highlightLayer.removeAll(), this.highlightLayer.add(n);
|
|
520
514
|
}
|
|
521
515
|
});
|
|
522
516
|
this.mouseMoveHandler = this.view.on("pointer-move", async (o) => {
|
|
523
|
-
|
|
517
|
+
t(o).catch(() => {
|
|
524
518
|
});
|
|
525
519
|
});
|
|
526
520
|
}
|
|
@@ -528,42 +522,81 @@ ${this.hitGraphic.attributes.id}`,
|
|
|
528
522
|
* 监听鼠标点击事件,获取高亮要素的拓扑信息
|
|
529
523
|
*/
|
|
530
524
|
monitorMouseClick() {
|
|
531
|
-
|
|
532
|
-
var
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
}
|
|
544
|
-
|
|
545
|
-
|
|
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
|
+
});
|
|
546
579
|
});
|
|
547
580
|
}
|
|
548
|
-
increasePictureMarkerSize(
|
|
581
|
+
increasePictureMarkerSize(t, o) {
|
|
549
582
|
const i = setInterval(() => {
|
|
550
|
-
const s =
|
|
551
|
-
|
|
583
|
+
const s = t.symbol, e = s.width;
|
|
584
|
+
e < o ? t.symbol = {
|
|
552
585
|
type: "picture-marker",
|
|
553
586
|
url: s.url,
|
|
554
|
-
width:
|
|
555
|
-
height:
|
|
587
|
+
width: e + 1,
|
|
588
|
+
height: e + 1
|
|
556
589
|
} : clearInterval(i);
|
|
557
590
|
}, 20);
|
|
558
591
|
}
|
|
559
|
-
decreasePictureMarkerSize(
|
|
592
|
+
decreasePictureMarkerSize(t, o) {
|
|
560
593
|
const i = setInterval(() => {
|
|
561
|
-
const s =
|
|
562
|
-
|
|
594
|
+
const s = t.symbol, e = s.width;
|
|
595
|
+
e > o ? t.symbol = {
|
|
563
596
|
type: "picture-marker",
|
|
564
597
|
url: s.url,
|
|
565
|
-
width:
|
|
566
|
-
height:
|
|
598
|
+
width: e - 1,
|
|
599
|
+
height: e - 1
|
|
567
600
|
} : clearInterval(i);
|
|
568
601
|
}, 20);
|
|
569
602
|
}
|
|
@@ -572,11 +605,11 @@ ${this.hitGraphic.attributes.id}`,
|
|
|
572
605
|
*/
|
|
573
606
|
async clearOpenDrive() {
|
|
574
607
|
var o, i;
|
|
575
|
-
let
|
|
576
|
-
|
|
577
|
-
deleteFeatures:
|
|
578
|
-
}),
|
|
579
|
-
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
|
|
580
613
|
}), this.highlightLayer.removeAll(), this.junctionLayer.removeAll(), this.wasmLoader.clear(), (o = this.mouseMoveHandler) == null || o.remove(), (i = this.mouseClickHandler) == null || i.remove();
|
|
581
614
|
}
|
|
582
615
|
/**
|
|
@@ -584,82 +617,112 @@ ${this.hitGraphic.attributes.id}`,
|
|
|
584
617
|
* @param params
|
|
585
618
|
* @returns
|
|
586
619
|
*/
|
|
587
|
-
async findSumo(
|
|
588
|
-
const {
|
|
589
|
-
if (
|
|
590
|
-
return
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
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" };
|
|
598
659
|
}
|
|
599
660
|
/**
|
|
600
661
|
* 用sumo的id定位车道、基本段、路段
|
|
601
662
|
* @param params
|
|
602
663
|
* @returns
|
|
603
664
|
*/
|
|
604
|
-
async findLane(
|
|
605
|
-
let {
|
|
606
|
-
|
|
607
|
-
let
|
|
608
|
-
(
|
|
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
|
|
609
670
|
);
|
|
610
|
-
if (
|
|
671
|
+
if (e.length === 0)
|
|
611
672
|
return { status: -1, message: "未找到。请检查路段编号" };
|
|
612
|
-
if (
|
|
613
|
-
const
|
|
614
|
-
if (
|
|
615
|
-
const
|
|
616
|
-
|
|
617
|
-
}),
|
|
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)
|
|
618
679
|
return { status: -1, message: "未找到。请检查基本段编号" };
|
|
619
|
-
|
|
620
|
-
(
|
|
680
|
+
i = n[i], e = e.filter(
|
|
681
|
+
(a) => Number(a.attributes.sectionId) === i
|
|
621
682
|
);
|
|
622
683
|
}
|
|
623
|
-
if (
|
|
624
|
-
const
|
|
625
|
-
if (
|
|
626
|
-
const
|
|
627
|
-
|
|
628
|
-
}),
|
|
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)
|
|
629
690
|
return { status: -1, message: "未找到。请检查车道编号" };
|
|
630
|
-
|
|
631
|
-
(
|
|
691
|
+
s = n[s], e = e.filter(
|
|
692
|
+
(a) => Number(a.attributes.laneId) === s
|
|
632
693
|
);
|
|
633
694
|
}
|
|
634
|
-
const
|
|
635
|
-
(
|
|
636
|
-
),
|
|
637
|
-
if (
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
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,
|
|
641
701
|
symbol: {
|
|
642
702
|
type: "simple-fill",
|
|
643
703
|
color: [255, 0, 0, 0.5],
|
|
644
704
|
style: "solid",
|
|
645
705
|
outline: {
|
|
646
706
|
color: "red",
|
|
647
|
-
width:
|
|
707
|
+
width: 0
|
|
648
708
|
}
|
|
649
709
|
}
|
|
650
710
|
});
|
|
651
|
-
this.
|
|
652
|
-
let r = 0, n = !0;
|
|
653
|
-
const u = setInterval(() => {
|
|
654
|
-
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));
|
|
655
|
-
}, 20);
|
|
711
|
+
this.flashGraphic(n);
|
|
656
712
|
}
|
|
657
|
-
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);
|
|
658
721
|
}
|
|
659
|
-
async splitLane(
|
|
660
|
-
return { status: 0, message: "ok", result:
|
|
722
|
+
async splitLane(t) {
|
|
723
|
+
return { status: 0, message: "ok", result: t };
|
|
661
724
|
}
|
|
662
725
|
}
|
|
663
726
|
export {
|
|
664
|
-
|
|
727
|
+
S as default
|
|
665
728
|
};
|
package/es/src/types/index.d.ts
CHANGED
|
@@ -216,8 +216,10 @@ export interface IShowOpenDriveFromFileParams {
|
|
|
216
216
|
showRoadName: boolean;
|
|
217
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
|
@@ -216,8 +216,10 @@ export interface IShowOpenDriveFromFileParams {
|
|
|
216
216
|
showRoadName: boolean;
|
|
217
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;
|