gisviewer-vue3-arcgis 1.0.139 → 1.0.140
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 +1 -1
- package/es/src/gis-map/utils/open-drive-renderer/index.mjs +178 -125
- package/es/src/gis-map/utils/signal-control-area-controller/index.d.ts +7 -0
- package/es/src/gis-map/utils/signal-control-area-controller/index.mjs +155 -148
- package/lib/src/gis-map/utils/open-drive-renderer/index.d.ts +1 -1
- package/lib/src/gis-map/utils/open-drive-renderer/index.js +1 -4
- package/lib/src/gis-map/utils/signal-control-area-controller/index.d.ts +7 -0
- package/lib/src/gis-map/utils/signal-control-area-controller/index.js +1 -1
- package/package.json +2 -1
|
@@ -14,6 +14,7 @@ export default class OpenDriveRenderer {
|
|
|
14
14
|
private allRefLineGraphics;
|
|
15
15
|
private mouseMoveHandler;
|
|
16
16
|
private mouseClickHandler;
|
|
17
|
+
private junctionNames;
|
|
17
18
|
constructor(view: __esri.MapView | __esri.SceneView);
|
|
18
19
|
private projectName;
|
|
19
20
|
private openDriveServer;
|
|
@@ -49,7 +50,6 @@ export default class OpenDriveRenderer {
|
|
|
49
50
|
private currentJunctionId;
|
|
50
51
|
private hitGraphic;
|
|
51
52
|
private highlightGraphic;
|
|
52
|
-
private monitorMouseDrag;
|
|
53
53
|
/**
|
|
54
54
|
* 监听鼠标移动事件,高亮显示鼠标所在路段和路口
|
|
55
55
|
*/
|
|
@@ -1,20 +1,19 @@
|
|
|
1
1
|
import p from "@arcgis/core/Graphic";
|
|
2
|
-
import * as
|
|
2
|
+
import * as k from "@arcgis/core/core/promiseUtils";
|
|
3
3
|
import { Polygon as O } from "@arcgis/core/geometry";
|
|
4
|
-
import * as
|
|
5
|
-
import
|
|
6
|
-
import
|
|
7
|
-
import
|
|
4
|
+
import * as L from "@arcgis/core/geometry/geometryEngine";
|
|
5
|
+
import j from "@arcgis/core/layers/FeatureLayer";
|
|
6
|
+
import b from "@arcgis/core/layers/GraphicsLayer";
|
|
7
|
+
import g from "axios";
|
|
8
8
|
import F from "md5";
|
|
9
|
-
import
|
|
9
|
+
import G from "pako";
|
|
10
10
|
import A from "../common-utils.mjs";
|
|
11
|
-
class
|
|
11
|
+
class S {
|
|
12
12
|
constructor(e) {
|
|
13
|
-
this.projectName = "", this.openDriveServer = "", this.currentSectionCode = "", this.currentJunctionId = "", this.view = e, this.view.popup.visibleElements = {
|
|
14
|
-
closeButton: !1,
|
|
13
|
+
this.junctionNames = /* @__PURE__ */ new Map(), this.projectName = "", this.openDriveServer = "", this.currentSectionCode = "", this.currentJunctionId = "", this.view = e, this.view.popup.visibleElements = {
|
|
15
14
|
collapseButton: !1,
|
|
16
15
|
actionBar: !1
|
|
17
|
-
}, this.laneLayer = new
|
|
16
|
+
}, this.laneLayer = new j({
|
|
18
17
|
id: "OpenDriveLane",
|
|
19
18
|
fields: [
|
|
20
19
|
{
|
|
@@ -56,6 +55,16 @@ class C {
|
|
|
56
55
|
name: "sumoId",
|
|
57
56
|
alias: "sumo编号",
|
|
58
57
|
type: "string"
|
|
58
|
+
},
|
|
59
|
+
{
|
|
60
|
+
name: "fromNode",
|
|
61
|
+
alias: "起点路口",
|
|
62
|
+
type: "string"
|
|
63
|
+
},
|
|
64
|
+
{
|
|
65
|
+
name: "toNode",
|
|
66
|
+
alias: "终点路口",
|
|
67
|
+
type: "string"
|
|
59
68
|
}
|
|
60
69
|
],
|
|
61
70
|
objectIdField: "ObjectID",
|
|
@@ -222,7 +231,7 @@ class C {
|
|
|
222
231
|
}
|
|
223
232
|
]
|
|
224
233
|
}
|
|
225
|
-
}), this.roadNameLayer = new
|
|
234
|
+
}), this.roadNameLayer = new j({
|
|
226
235
|
id: "OpenDriveRoadName",
|
|
227
236
|
fields: [
|
|
228
237
|
{
|
|
@@ -272,7 +281,7 @@ class C {
|
|
|
272
281
|
}
|
|
273
282
|
}
|
|
274
283
|
]
|
|
275
|
-
}), this.junctionLayer = new
|
|
284
|
+
}), this.junctionLayer = new b({ id: "OpenDriveJunction" }), this.sectionLayer = new b({ id: "OpenDriveSection" }), this.highlightLayer = new b({ id: "OpenDriveHighlight" }), this.flashLayer = new b({ id: "OpenDriveFlash" }), this.drawLayer = new b({ id: "Draw" }), this.view.map.addMany([
|
|
276
285
|
this.laneLayer,
|
|
277
286
|
this.junctionLayer,
|
|
278
287
|
this.sectionLayer,
|
|
@@ -283,7 +292,7 @@ class C {
|
|
|
283
292
|
]);
|
|
284
293
|
}
|
|
285
294
|
static getInstance(e) {
|
|
286
|
-
return this.instance || (this.instance = new
|
|
295
|
+
return this.instance || (this.instance = new S(e)), this.instance;
|
|
287
296
|
}
|
|
288
297
|
async makeMd5FromFile(e) {
|
|
289
298
|
try {
|
|
@@ -299,7 +308,7 @@ class C {
|
|
|
299
308
|
* @returns
|
|
300
309
|
*/
|
|
301
310
|
async showOpenDriveFromFile(e) {
|
|
302
|
-
var
|
|
311
|
+
var h, f;
|
|
303
312
|
this.openDriveClickCallback = e.selectedCallback, console.time("md5用时");
|
|
304
313
|
const t = await this.makeMd5FromFile(e.file);
|
|
305
314
|
if (t.status !== 0)
|
|
@@ -308,7 +317,7 @@ class C {
|
|
|
308
317
|
const i = `http://${this.openDriveServer}/api/openDrive/uploadXodr`;
|
|
309
318
|
let o;
|
|
310
319
|
try {
|
|
311
|
-
o = await
|
|
320
|
+
o = await g.post(
|
|
312
321
|
i,
|
|
313
322
|
{},
|
|
314
323
|
{
|
|
@@ -318,8 +327,8 @@ class C {
|
|
|
318
327
|
}
|
|
319
328
|
}
|
|
320
329
|
);
|
|
321
|
-
} catch (
|
|
322
|
-
return { status: -1, message:
|
|
330
|
+
} catch (d) {
|
|
331
|
+
return { status: -1, message: d.message };
|
|
323
332
|
}
|
|
324
333
|
if (o.status !== 200)
|
|
325
334
|
return { status: -1, message: o.statusText };
|
|
@@ -332,16 +341,16 @@ class C {
|
|
|
332
341
|
);
|
|
333
342
|
let l = o.data.result.json;
|
|
334
343
|
l.startsWith(window.location.protocol) || (l = `${window.location.protocol}//${e.server}${l}`);
|
|
335
|
-
const
|
|
344
|
+
const n = await (await fetch(l)).arrayBuffer(), r = G.inflate(n, { to: "string" }), c = JSON.parse(r);
|
|
336
345
|
await this.showAllLanes(
|
|
337
346
|
c,
|
|
338
|
-
((
|
|
339
|
-
((
|
|
347
|
+
((h = e.options) == null ? void 0 : h.showJunctionLane) || !1,
|
|
348
|
+
((f = e.options) == null ? void 0 : f.showRoadName) || !0
|
|
340
349
|
);
|
|
341
|
-
const
|
|
342
|
-
if (this.showJunction(
|
|
343
|
-
const
|
|
344
|
-
await this.view.goTo(
|
|
350
|
+
const m = o.data.result.junctions;
|
|
351
|
+
if (this.showJunction(m), e.options && e.options.centerMap !== !1) {
|
|
352
|
+
const d = A.transformPointProjection([0, 0]);
|
|
353
|
+
await this.view.goTo(d);
|
|
345
354
|
}
|
|
346
355
|
return this.mouseMoveHandler || this.monitorMouseMove(), this.mouseClickHandler || this.monitorMouseClick(), console.timeEnd("渲染用时"), { status: 0, message: "ok" };
|
|
347
356
|
}
|
|
@@ -351,7 +360,7 @@ class C {
|
|
|
351
360
|
* @param projectName
|
|
352
361
|
*/
|
|
353
362
|
async showOpenDriveFromServer(e, t) {
|
|
354
|
-
const i = `http://${e}/api/openDrive/analyzeXodr`, o = await
|
|
363
|
+
const i = `http://${e}/api/openDrive/analyzeXodr`, o = await g.get(i, {
|
|
355
364
|
headers: {
|
|
356
365
|
projectName: t
|
|
357
366
|
},
|
|
@@ -364,7 +373,7 @@ class C {
|
|
|
364
373
|
throw new Error(`OpenDriveRenderer: ${o.statusText}`);
|
|
365
374
|
let s = o.data.result.json;
|
|
366
375
|
s.startsWith(window.location.protocol) || (s = `${window.location.protocol}//${e}${s}`);
|
|
367
|
-
const
|
|
376
|
+
const a = await (await fetch(s)).arrayBuffer(), n = G.inflate(a, { to: "string" }), r = JSON.parse(n);
|
|
368
377
|
return await this.showAllLanes(r, !1, !1), { status: 0, message: "ok" };
|
|
369
378
|
}
|
|
370
379
|
/**
|
|
@@ -381,66 +390,68 @@ class C {
|
|
|
381
390
|
}), this.roadNameLayer.visible = i, new Promise((s) => {
|
|
382
391
|
let l = 0;
|
|
383
392
|
this.allLaneGraphics = [], this.allRefLineGraphics = [];
|
|
384
|
-
const
|
|
393
|
+
const a = [];
|
|
385
394
|
for (const r of e) {
|
|
386
395
|
if (!t && r.junction !== "-1")
|
|
387
396
|
continue;
|
|
388
|
-
const { id: c, refLine:
|
|
389
|
-
let
|
|
390
|
-
|
|
391
|
-
const
|
|
397
|
+
const { id: c, refLine: m } = r;
|
|
398
|
+
let h = r.name;
|
|
399
|
+
h.includes("(") && (h = h.slice(0, h.indexOf("("))), h = h.replace(/(.)/g, "$1 ");
|
|
400
|
+
const f = new p({
|
|
392
401
|
geometry: {
|
|
393
402
|
type: "polyline",
|
|
394
|
-
paths: [
|
|
403
|
+
paths: [m]
|
|
395
404
|
},
|
|
396
405
|
attributes: {
|
|
397
406
|
ObjectID: l++,
|
|
398
407
|
roadId: c,
|
|
399
|
-
roadName:
|
|
408
|
+
roadName: h
|
|
400
409
|
}
|
|
401
410
|
});
|
|
402
|
-
this.allRefLineGraphics.push(
|
|
403
|
-
for (let
|
|
404
|
-
const
|
|
405
|
-
for (const
|
|
406
|
-
const
|
|
407
|
-
if (
|
|
411
|
+
this.allRefLineGraphics.push(f), r.laneSections.sort((d, y) => Number(d.id) - Number(y.id));
|
|
412
|
+
for (let d = 0; d < r.laneSections.length; d++) {
|
|
413
|
+
const y = r.laneSections[d], u = Number(y.id);
|
|
414
|
+
for (const w of y.lanePaths) {
|
|
415
|
+
const v = Number(w.id);
|
|
416
|
+
if (v === 0)
|
|
408
417
|
continue;
|
|
409
|
-
const
|
|
410
|
-
|
|
418
|
+
const C = w.type, I = w.innerPath.concat(
|
|
419
|
+
w.outerPath.reverse()
|
|
411
420
|
);
|
|
412
|
-
if (
|
|
413
|
-
console.warn(`lane ${
|
|
421
|
+
if (I.length <= 3) {
|
|
422
|
+
console.warn(`lane ${v} has less than 3 points`);
|
|
414
423
|
continue;
|
|
415
424
|
}
|
|
416
|
-
|
|
417
|
-
const
|
|
418
|
-
rings: [
|
|
425
|
+
I.push(w.innerPath[0]);
|
|
426
|
+
const N = new O({
|
|
427
|
+
rings: [I]
|
|
419
428
|
});
|
|
420
|
-
if (
|
|
421
|
-
const
|
|
422
|
-
geometry:
|
|
429
|
+
if (N) {
|
|
430
|
+
const D = new p({
|
|
431
|
+
geometry: N,
|
|
423
432
|
attributes: {
|
|
424
433
|
ObjectID: l++,
|
|
425
|
-
id: `${c}+${
|
|
434
|
+
id: `${c}+${u}+${v}`,
|
|
435
|
+
fromNode: r.fromNode,
|
|
436
|
+
toNode: r.toNode,
|
|
426
437
|
roadId: c,
|
|
427
438
|
roadName: r.name,
|
|
428
|
-
sectionId:
|
|
429
|
-
sectionIndex:
|
|
430
|
-
laneId:
|
|
431
|
-
type:
|
|
439
|
+
sectionId: u,
|
|
440
|
+
sectionIndex: d,
|
|
441
|
+
laneId: v,
|
|
442
|
+
type: C,
|
|
432
443
|
sumoId: ""
|
|
433
444
|
}
|
|
434
445
|
});
|
|
435
|
-
this.allLaneGraphics.push(
|
|
446
|
+
this.allLaneGraphics.push(D), a.push(D);
|
|
436
447
|
}
|
|
437
448
|
}
|
|
438
449
|
}
|
|
439
450
|
}
|
|
440
|
-
const
|
|
441
|
-
if (
|
|
442
|
-
if (
|
|
443
|
-
const r =
|
|
451
|
+
const n = setInterval(() => {
|
|
452
|
+
if (a.length > 0 || this.allRefLineGraphics.length > 0) {
|
|
453
|
+
if (a.length > 0) {
|
|
454
|
+
const r = a.splice(0, 100);
|
|
444
455
|
this.laneLayer.applyEdits({
|
|
445
456
|
addFeatures: r
|
|
446
457
|
});
|
|
@@ -452,7 +463,7 @@ class C {
|
|
|
452
463
|
});
|
|
453
464
|
}
|
|
454
465
|
} else
|
|
455
|
-
clearInterval(
|
|
466
|
+
clearInterval(n), s();
|
|
456
467
|
}, 10);
|
|
457
468
|
});
|
|
458
469
|
}
|
|
@@ -466,7 +477,7 @@ class C {
|
|
|
466
477
|
for (const i of e) {
|
|
467
478
|
if (!i)
|
|
468
479
|
continue;
|
|
469
|
-
i.nodeType = i.type;
|
|
480
|
+
this.junctionNames.set(i.id, i.name), i.nodeType = i.type;
|
|
470
481
|
const o = new p({
|
|
471
482
|
geometry: {
|
|
472
483
|
type: "point",
|
|
@@ -483,24 +494,40 @@ class C {
|
|
|
483
494
|
url: i.crossId ? "/GisViewerAssets/Images/point_green.png" : "/GisViewerAssets/Images/point_yellow.png",
|
|
484
495
|
width: 30,
|
|
485
496
|
height: 30
|
|
497
|
+
},
|
|
498
|
+
popupTemplate: {
|
|
499
|
+
title: i.name,
|
|
500
|
+
content: [
|
|
501
|
+
{
|
|
502
|
+
type: "fields",
|
|
503
|
+
fieldInfos: [
|
|
504
|
+
{
|
|
505
|
+
fieldName: "id",
|
|
506
|
+
label: "路口编号"
|
|
507
|
+
},
|
|
508
|
+
{
|
|
509
|
+
fieldName: "crossId",
|
|
510
|
+
label: "信号机编号"
|
|
511
|
+
}
|
|
512
|
+
]
|
|
513
|
+
}
|
|
514
|
+
]
|
|
486
515
|
}
|
|
487
516
|
});
|
|
488
517
|
t.push(o);
|
|
489
518
|
}
|
|
490
519
|
this.junctionLayer.addMany(t);
|
|
491
520
|
}
|
|
492
|
-
monitorMouseDrag() {
|
|
493
|
-
}
|
|
494
521
|
/**
|
|
495
522
|
* 监听鼠标移动事件,高亮显示鼠标所在路段和路口
|
|
496
523
|
*/
|
|
497
524
|
monitorMouseMove() {
|
|
498
|
-
const e =
|
|
525
|
+
const e = k.debounce(async (t) => {
|
|
499
526
|
var l;
|
|
500
527
|
const o = (l = (await this.view.hitTest(t, {
|
|
501
528
|
include: [this.laneLayer, this.junctionLayer]
|
|
502
529
|
})).results) == null ? void 0 : l.filter(
|
|
503
|
-
(
|
|
530
|
+
(a) => a.type === "graphic"
|
|
504
531
|
);
|
|
505
532
|
if (o.length === 0) {
|
|
506
533
|
this.currentSectionCode !== "" && (this.currentSectionCode = "", this.highlightGraphic = void 0, this.highlightLayer.removeAll()), this.currentJunctionId !== "" && (this.currentJunctionId = "", this.view.closePopup());
|
|
@@ -508,17 +535,19 @@ class C {
|
|
|
508
535
|
}
|
|
509
536
|
const s = o[0];
|
|
510
537
|
if (this.hitGraphic = s.graphic, s.layer.id === "OpenDriveLane") {
|
|
511
|
-
const
|
|
512
|
-
|
|
513
|
-
|
|
538
|
+
const a = `${this.hitGraphic.getAttribute(
|
|
539
|
+
"roadId"
|
|
540
|
+
)}+${this.hitGraphic.getAttribute("sectionId")}`;
|
|
541
|
+
if (a === this.currentSectionCode || this.sectionLayer.graphics.findIndex(
|
|
542
|
+
(u) => u.getAttribute("id") === a
|
|
514
543
|
) >= 0)
|
|
515
544
|
return;
|
|
516
|
-
this.currentSectionCode =
|
|
545
|
+
this.currentSectionCode = a;
|
|
517
546
|
const r = this.allLaneGraphics.filter(
|
|
518
|
-
(
|
|
519
|
-
), c =
|
|
520
|
-
r.map((
|
|
521
|
-
);
|
|
547
|
+
(u) => `${u.attributes.roadId}+${u.attributes.sectionId}` === a
|
|
548
|
+
), c = L.union(
|
|
549
|
+
r.map((u) => u.geometry)
|
|
550
|
+
), m = this.hitGraphic.getAttribute("fromNode"), h = this.hitGraphic.getAttribute("toNode"), f = this.junctionNames.get(m) || m, d = this.junctionNames.get(h) || h;
|
|
522
551
|
this.highlightGraphic = new p({
|
|
523
552
|
geometry: c,
|
|
524
553
|
symbol: {
|
|
@@ -532,22 +561,46 @@ class C {
|
|
|
532
561
|
},
|
|
533
562
|
attributes: {
|
|
534
563
|
type: "OpenDriveSection",
|
|
535
|
-
id:
|
|
536
|
-
selected: !1
|
|
564
|
+
id: a,
|
|
565
|
+
selected: !1,
|
|
566
|
+
fromNodeName: f,
|
|
567
|
+
toNodeName: d,
|
|
568
|
+
laneCount: r.length
|
|
569
|
+
},
|
|
570
|
+
popupTemplate: {
|
|
571
|
+
title: this.hitGraphic.getAttribute("roadName"),
|
|
572
|
+
content: [
|
|
573
|
+
{
|
|
574
|
+
type: "fields",
|
|
575
|
+
fieldInfos: [
|
|
576
|
+
{
|
|
577
|
+
fieldName: "fromNodeName",
|
|
578
|
+
label: "起点路口"
|
|
579
|
+
},
|
|
580
|
+
{
|
|
581
|
+
fieldName: "toNodeName",
|
|
582
|
+
label: "终点路口"
|
|
583
|
+
},
|
|
584
|
+
{
|
|
585
|
+
fieldName: "laneCount",
|
|
586
|
+
label: "车道数量"
|
|
587
|
+
}
|
|
588
|
+
]
|
|
589
|
+
}
|
|
590
|
+
]
|
|
537
591
|
}
|
|
538
592
|
}), this.highlightLayer.removeAll(), this.highlightLayer.add(this.highlightGraphic);
|
|
593
|
+
const y = this.view.toMap(t);
|
|
594
|
+
this.view.openPopup({
|
|
595
|
+
features: [this.highlightGraphic],
|
|
596
|
+
location: y
|
|
597
|
+
});
|
|
539
598
|
} else if (s.layer.id === "OpenDriveJunction") {
|
|
540
|
-
const
|
|
541
|
-
if (
|
|
599
|
+
const a = this.hitGraphic.getAttribute("id");
|
|
600
|
+
if (a === this.currentJunctionId)
|
|
542
601
|
return;
|
|
543
|
-
this.currentJunctionId =
|
|
544
|
-
|
|
545
|
-
this.view.openPopup({
|
|
546
|
-
title: a,
|
|
547
|
-
content: `<table>
|
|
548
|
-
<tr><td>路口编号</td><td>${n}</td></tr>
|
|
549
|
-
<tr><td>信号机编号</td><td>${r || "无信控"}</td></tr>
|
|
550
|
-
</table>`,
|
|
602
|
+
this.currentJunctionId = a, this.view.openPopup({
|
|
603
|
+
features: [this.hitGraphic],
|
|
551
604
|
location: this.hitGraphic.geometry
|
|
552
605
|
});
|
|
553
606
|
}
|
|
@@ -561,33 +614,33 @@ class C {
|
|
|
561
614
|
* 监听鼠标点击事件,获取高亮要素的拓扑信息
|
|
562
615
|
*/
|
|
563
616
|
monitorMouseClick() {
|
|
564
|
-
const e =
|
|
565
|
-
var
|
|
566
|
-
const o = (
|
|
617
|
+
const e = k.debounce(async (t) => {
|
|
618
|
+
var n;
|
|
619
|
+
const o = (n = (await this.view.hitTest(t, {
|
|
567
620
|
include: [this.highlightLayer, this.junctionLayer, this.sectionLayer]
|
|
568
|
-
})).results) == null ? void 0 :
|
|
621
|
+
})).results) == null ? void 0 : n.filter(
|
|
569
622
|
(r) => r.type === "graphic"
|
|
570
623
|
);
|
|
571
624
|
if (o.length === 0)
|
|
572
625
|
return;
|
|
573
|
-
const s = o[0].graphic, l = s.getAttribute("type"),
|
|
626
|
+
const s = o[0].graphic, l = s.getAttribute("type"), a = s.getAttribute("id");
|
|
574
627
|
if (l === "OpenDriveJunction")
|
|
575
628
|
if (s.getAttribute("selected") === !1) {
|
|
576
|
-
const r = `http://${this.openDriveServer}/api/sumo/getSumoJunction`, c = await
|
|
629
|
+
const r = `http://${this.openDriveServer}/api/sumo/getSumoJunction`, c = await g.get(r, {
|
|
577
630
|
params: {
|
|
578
|
-
id:
|
|
631
|
+
id: a,
|
|
579
632
|
projectName: this.projectName
|
|
580
633
|
}
|
|
581
634
|
});
|
|
582
635
|
c.status === 200 && c.data.status === 0 && (this.openDriveClickCallback && this.openDriveClickCallback({
|
|
583
636
|
type: "OpenDriveJunction",
|
|
584
|
-
id:
|
|
637
|
+
id: a,
|
|
585
638
|
details: c.data.result
|
|
586
639
|
}), s.setAttribute("selected", !0), s.symbol.url = "/GisViewerAssets/Images/point_red.png", this.increasePictureMarkerSize(s, 50));
|
|
587
640
|
} else {
|
|
588
641
|
this.openDriveClickCallback && this.openDriveClickCallback({
|
|
589
642
|
type: "OpenDriveJunction",
|
|
590
|
-
id:
|
|
643
|
+
id: a,
|
|
591
644
|
details: void 0
|
|
592
645
|
}), s.setAttribute("selected", !1);
|
|
593
646
|
const r = s.getAttribute("crossId");
|
|
@@ -597,20 +650,20 @@ class C {
|
|
|
597
650
|
if (s.getAttribute("selected"))
|
|
598
651
|
this.sectionLayer.remove(s), this.openDriveClickCallback && this.openDriveClickCallback({
|
|
599
652
|
type: "OpenDriveSection",
|
|
600
|
-
id:
|
|
653
|
+
id: a,
|
|
601
654
|
details: void 0
|
|
602
655
|
});
|
|
603
656
|
else {
|
|
604
657
|
this.highlightLayer.remove(s), this.sectionLayer.add(s), s.setAttribute("selected", !0);
|
|
605
|
-
const r = `http://${this.openDriveServer}/api/sumo/getSumoEdge`, c = await
|
|
658
|
+
const r = `http://${this.openDriveServer}/api/sumo/getSumoEdge`, c = await g.get(r, {
|
|
606
659
|
params: {
|
|
607
|
-
id:
|
|
660
|
+
id: a,
|
|
608
661
|
projectName: this.projectName
|
|
609
662
|
}
|
|
610
663
|
});
|
|
611
664
|
c.status === 200 && c.data.status === 0 && this.openDriveClickCallback && (s.setAttribute("edgeId", c.data.result.obj_id), this.openDriveClickCallback({
|
|
612
665
|
type: "OpenDriveSection",
|
|
613
|
-
id:
|
|
666
|
+
id: a,
|
|
614
667
|
details: c.data.result
|
|
615
668
|
}));
|
|
616
669
|
}
|
|
@@ -655,7 +708,7 @@ class C {
|
|
|
655
708
|
async getSumoInfo(e) {
|
|
656
709
|
switch (e.type) {
|
|
657
710
|
case "junction": {
|
|
658
|
-
const t = `http://${this.openDriveServer}/api/sumo/getSumoJunction`, i = await
|
|
711
|
+
const t = `http://${this.openDriveServer}/api/sumo/getSumoJunction`, i = await g.get(t, {
|
|
659
712
|
params: {
|
|
660
713
|
id: e.id,
|
|
661
714
|
projectName: this.projectName
|
|
@@ -675,13 +728,13 @@ class C {
|
|
|
675
728
|
if (s) {
|
|
676
729
|
const l = `${i}+${s.getAttribute(
|
|
677
730
|
"sectionId"
|
|
678
|
-
)}`,
|
|
731
|
+
)}`, a = `http://${this.openDriveServer}/api/sumo/getSumoEdge`, n = await g.get(a, {
|
|
679
732
|
params: {
|
|
680
733
|
id: l,
|
|
681
734
|
projectName: this.projectName
|
|
682
735
|
}
|
|
683
736
|
});
|
|
684
|
-
return
|
|
737
|
+
return n.status === 200 ? n.data : { status: -1, message: `路段信息查询失败: ${l}` };
|
|
685
738
|
} else
|
|
686
739
|
return { status: -1, message: "未知类型" };
|
|
687
740
|
}
|
|
@@ -714,11 +767,11 @@ class C {
|
|
|
714
767
|
const s = i.split("+");
|
|
715
768
|
if (s.length > 2)
|
|
716
769
|
return { status: -1, message: "id格式错误" };
|
|
717
|
-
const l = s.length === 2 ? Number(s[1]) : void 0,
|
|
718
|
-
if (
|
|
770
|
+
const l = s.length === 2 ? Number(s[1]) : void 0, a = s[0].split("#");
|
|
771
|
+
if (a.length > 2)
|
|
719
772
|
return { status: -1, message: "id格式错误" };
|
|
720
|
-
const
|
|
721
|
-
return await this.findLane({ roadsectId:
|
|
773
|
+
const n = a[0], r = a.length === 2 ? Number(a[1]) : void 0;
|
|
774
|
+
return await this.findLane({ roadsectId: n, segmentId: r, laneId: l, flash: o });
|
|
722
775
|
} else
|
|
723
776
|
return { status: -1, message: "未知类型" };
|
|
724
777
|
}
|
|
@@ -755,38 +808,38 @@ class C {
|
|
|
755
808
|
let { roadsectId: t, segmentId: i, laneId: o } = e;
|
|
756
809
|
t.startsWith("-") && (t = t.slice(1));
|
|
757
810
|
let s = this.allLaneGraphics.filter(
|
|
758
|
-
(
|
|
811
|
+
(n) => n.attributes.roadId === t
|
|
759
812
|
);
|
|
760
813
|
if (s.length === 0)
|
|
761
814
|
return { status: -1, message: "未找到。请检查路段编号" };
|
|
762
815
|
if (i !== void 0) {
|
|
763
|
-
const
|
|
816
|
+
const n = [];
|
|
764
817
|
if (s.forEach((r) => {
|
|
765
818
|
const c = Number(r.attributes.sectionId);
|
|
766
|
-
|
|
767
|
-
}),
|
|
819
|
+
n.indexOf(c) === -1 && n.push(c);
|
|
820
|
+
}), n.sort((r, c) => r - c), i > n.length - 1)
|
|
768
821
|
return { status: -1, message: "未找到。请检查基本段编号" };
|
|
769
|
-
i =
|
|
822
|
+
i = n[i], s = s.filter(
|
|
770
823
|
(r) => Number(r.attributes.sectionId) === i
|
|
771
824
|
);
|
|
772
825
|
}
|
|
773
826
|
if (o !== void 0) {
|
|
774
|
-
const
|
|
827
|
+
const n = [];
|
|
775
828
|
if (s.forEach((r) => {
|
|
776
829
|
const c = Number(r.attributes.laneId);
|
|
777
|
-
|
|
778
|
-
}),
|
|
830
|
+
n.indexOf(c) === -1 && n.push(c);
|
|
831
|
+
}), n.sort((r, c) => r - c), o > n.length - 1)
|
|
779
832
|
return { status: -1, message: "未找到。请检查车道编号" };
|
|
780
|
-
o =
|
|
833
|
+
o = n[o], s = s.filter(
|
|
781
834
|
(r) => Number(r.attributes.laneId) === o
|
|
782
835
|
);
|
|
783
836
|
}
|
|
784
837
|
const l = s.map(
|
|
785
|
-
(
|
|
786
|
-
),
|
|
838
|
+
(n) => n.geometry
|
|
839
|
+
), a = L.union(l);
|
|
787
840
|
if (e.flash) {
|
|
788
|
-
const
|
|
789
|
-
geometry:
|
|
841
|
+
const n = new p({
|
|
842
|
+
geometry: a,
|
|
790
843
|
symbol: {
|
|
791
844
|
type: "simple-fill",
|
|
792
845
|
color: [255, 0, 0, 0.5],
|
|
@@ -797,9 +850,9 @@ class C {
|
|
|
797
850
|
}
|
|
798
851
|
}
|
|
799
852
|
});
|
|
800
|
-
this.flashGraphic(
|
|
853
|
+
this.flashGraphic(n);
|
|
801
854
|
}
|
|
802
|
-
return await this.view.goTo(
|
|
855
|
+
return await this.view.goTo(a, { duration: 1e3 }), { status: 0, message: "ok" };
|
|
803
856
|
}
|
|
804
857
|
/**
|
|
805
858
|
* graphic渐隐渐显闪烁
|
|
@@ -857,9 +910,9 @@ class C {
|
|
|
857
910
|
(l) => l.getAttribute("roadId") === i && l.getAttribute("sectionIndex") === o
|
|
858
911
|
);
|
|
859
912
|
if (s.length > 0) {
|
|
860
|
-
const l =
|
|
861
|
-
s.map((
|
|
862
|
-
),
|
|
913
|
+
const l = L.union(
|
|
914
|
+
s.map((n) => n.geometry)
|
|
915
|
+
), a = new p({
|
|
863
916
|
geometry: l,
|
|
864
917
|
symbol: {
|
|
865
918
|
type: "simple-fill",
|
|
@@ -876,7 +929,7 @@ class C {
|
|
|
876
929
|
selected: !0
|
|
877
930
|
}
|
|
878
931
|
});
|
|
879
|
-
return this.sectionLayer.add(
|
|
932
|
+
return this.sectionLayer.add(a), { status: 0, message: "ok" };
|
|
880
933
|
} else
|
|
881
934
|
return { status: -1, message: "未找到路段" };
|
|
882
935
|
}
|
|
@@ -889,5 +942,5 @@ class C {
|
|
|
889
942
|
}
|
|
890
943
|
}
|
|
891
944
|
export {
|
|
892
|
-
|
|
945
|
+
S as default
|
|
893
946
|
};
|
|
@@ -9,6 +9,13 @@ export default class SignalControlAreaController {
|
|
|
9
9
|
private readonly crossScale;
|
|
10
10
|
constructor(view: __esri.MapView | __esri.SceneView);
|
|
11
11
|
showSignalControlArea(params: any): IResult;
|
|
12
|
+
/**
|
|
13
|
+
* 生成路口点符号。在不同比例尺下,使用不同的符号
|
|
14
|
+
* @param attributes
|
|
15
|
+
* @param symbolType
|
|
16
|
+
* @returns
|
|
17
|
+
*/
|
|
18
|
+
private getCrossGraphicSymbol;
|
|
12
19
|
clearSignalControlArea(): IResult;
|
|
13
20
|
locateSignalControlArea(params: {
|
|
14
21
|
id: string;
|
|
@@ -1,11 +1,12 @@
|
|
|
1
|
-
import * as
|
|
2
|
-
import
|
|
1
|
+
import * as y from "@arcgis/core/core/reactiveUtils.js";
|
|
2
|
+
import u from "@arcgis/core/Graphic";
|
|
3
3
|
import o from "@arcgis/core/layers/GraphicsLayer";
|
|
4
|
-
import
|
|
5
|
-
import d from "@turf/
|
|
6
|
-
import
|
|
7
|
-
import
|
|
8
|
-
|
|
4
|
+
import p from "@turf/buffer";
|
|
5
|
+
import d from "@turf/concave";
|
|
6
|
+
import f from "@turf/convex";
|
|
7
|
+
import * as h from "@turf/helpers";
|
|
8
|
+
import b from "./district-controller.mjs";
|
|
9
|
+
class G {
|
|
9
10
|
constructor(e) {
|
|
10
11
|
this.crossScale = 3e3, this.view = e, this.view.popup.visibleElements = {
|
|
11
12
|
closeButton: !0,
|
|
@@ -34,84 +35,94 @@ class C {
|
|
|
34
35
|
}
|
|
35
36
|
showSignalControlArea(e) {
|
|
36
37
|
this.districtControllerLayer.removeAll(), this.subDistrictControllerLayer.removeAll(), this.crossLayer.removeAll(), this.highlightLayer.removeAll(), this.districtControllerLayer.visible = !0, this.subDistrictControllerLayer.visible = !0;
|
|
37
|
-
for (const
|
|
38
|
-
const
|
|
39
|
-
this.drawArea(
|
|
38
|
+
for (const t of e) {
|
|
39
|
+
const i = new b(t);
|
|
40
|
+
this.drawArea(i, !0);
|
|
40
41
|
}
|
|
41
|
-
return this.watchHandle =
|
|
42
|
+
return this.watchHandle = y.watch(
|
|
42
43
|
() => this.view.scale,
|
|
43
|
-
(
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
}
|
|
65
|
-
});
|
|
66
|
-
})) : i <= this.crossScale && r > this.crossScale && (this.crossLayer.graphics.forEach((t) => {
|
|
67
|
-
t.symbol = {
|
|
68
|
-
type: "picture-marker",
|
|
69
|
-
url: `/GisViewerAssets/Images/xhj_${t.getAttribute("isKey") ? 4 : 1}.png`,
|
|
70
|
-
width: t.getAttribute("isKey") ? "55px" : "37px",
|
|
71
|
-
height: t.getAttribute("isKey") ? "85px" : "57px",
|
|
72
|
-
yoffset: t.getAttribute("isKey") ? "37px" : "25px"
|
|
73
|
-
};
|
|
74
|
-
}), this.highlightLayer.graphics.forEach((t) => {
|
|
75
|
-
t.getAttribute("type") === "cross" && (t.symbol = {
|
|
76
|
-
type: "picture-marker",
|
|
77
|
-
url: `/GisViewerAssets/Images/xhj_${t.getAttribute("isKey") ? 4 : 1}.png`,
|
|
78
|
-
width: t.getAttribute("isKey") ? "55px" : "37px",
|
|
79
|
-
height: t.getAttribute("isKey") ? "85px" : "57px",
|
|
80
|
-
yoffset: t.getAttribute("isKey") ? "37px" : "25px"
|
|
81
|
-
});
|
|
44
|
+
(t, i) => {
|
|
45
|
+
t > this.crossScale && i <= this.crossScale ? (this.crossLayer.graphics.forEach((r) => {
|
|
46
|
+
r.symbol = this.getCrossGraphicSymbol(
|
|
47
|
+
r.attributes,
|
|
48
|
+
"marker"
|
|
49
|
+
);
|
|
50
|
+
}), this.highlightLayer.graphics.forEach((r) => {
|
|
51
|
+
r.getAttribute("type") === "cross" && (r.symbol = this.getCrossGraphicSymbol(
|
|
52
|
+
r.attributes,
|
|
53
|
+
"marker"
|
|
54
|
+
));
|
|
55
|
+
})) : t <= this.crossScale && i > this.crossScale && (this.crossLayer.graphics.forEach((r) => {
|
|
56
|
+
r.symbol = this.getCrossGraphicSymbol(
|
|
57
|
+
r.attributes,
|
|
58
|
+
"picture"
|
|
59
|
+
);
|
|
60
|
+
}), this.highlightLayer.graphics.forEach((r) => {
|
|
61
|
+
r.getAttribute("type") === "cross" && (r.symbol = this.getCrossGraphicSymbol(
|
|
62
|
+
r.attributes,
|
|
63
|
+
"picture"
|
|
64
|
+
));
|
|
82
65
|
}));
|
|
83
66
|
}
|
|
84
67
|
), { status: 0, message: "ok" };
|
|
85
68
|
}
|
|
69
|
+
/**
|
|
70
|
+
* 生成路口点符号。在不同比例尺下,使用不同的符号
|
|
71
|
+
* @param attributes
|
|
72
|
+
* @param symbolType
|
|
73
|
+
* @returns
|
|
74
|
+
*/
|
|
75
|
+
getCrossGraphicSymbol(e, t) {
|
|
76
|
+
const { isKey: i, color: r } = e;
|
|
77
|
+
if (t === "marker")
|
|
78
|
+
return {
|
|
79
|
+
type: "simple-marker",
|
|
80
|
+
style: i ? "diamond" : "circle",
|
|
81
|
+
color: r,
|
|
82
|
+
size: i ? 16 : 8,
|
|
83
|
+
outline: {
|
|
84
|
+
color: i ? "red" : "white",
|
|
85
|
+
width: i ? 2 : 1
|
|
86
|
+
}
|
|
87
|
+
};
|
|
88
|
+
if (t === "picture")
|
|
89
|
+
return {
|
|
90
|
+
type: "picture-marker",
|
|
91
|
+
url: `/GisViewerAssets/Images/xhj_${i ? 4 : 1}.png`,
|
|
92
|
+
width: i ? "55px" : "37px",
|
|
93
|
+
height: i ? "85px" : "57px",
|
|
94
|
+
yoffset: i ? "37px" : "25px"
|
|
95
|
+
};
|
|
96
|
+
}
|
|
86
97
|
clearSignalControlArea() {
|
|
87
98
|
var e;
|
|
88
99
|
return this.districtControllerLayer.removeAll(), this.subDistrictControllerLayer.removeAll(), this.crossLayer.removeAll(), this.highlightLayer.removeAll(), (e = this.watchHandle) == null || e.remove(), this.view.closePopup(), { status: 0, message: "ok" };
|
|
89
100
|
}
|
|
90
101
|
async locateSignalControlArea(e) {
|
|
91
|
-
const
|
|
92
|
-
return
|
|
93
|
-
target:
|
|
102
|
+
const t = this.findAreaGraphic(e.id);
|
|
103
|
+
return t ? (t.attributes.type === "cross" ? await this.view.goTo({
|
|
104
|
+
target: t.geometry,
|
|
94
105
|
scale: 1500
|
|
95
|
-
}) : await this.view.goTo(
|
|
106
|
+
}) : await this.view.goTo(t.geometry), this.showPopup(t), { status: 0, message: "ok" }) : { status: 1, message: "未找到" };
|
|
96
107
|
}
|
|
97
108
|
showPopup(e) {
|
|
98
|
-
const
|
|
109
|
+
const t = e.geometry.type === "point" ? e.geometry : e.geometry.centroid;
|
|
99
110
|
this.view.openPopup({
|
|
100
111
|
features: [e],
|
|
101
|
-
location:
|
|
112
|
+
location: t
|
|
102
113
|
});
|
|
103
114
|
}
|
|
104
115
|
async highlightSignalControlArea(e) {
|
|
105
116
|
this.highlightLayer.removeAll(), this.districtControllerLayer.visible = !1, this.subDistrictControllerLayer.visible = !1, this.crossLayer.visible = !1;
|
|
106
|
-
const
|
|
117
|
+
const t = this.districtControllerLayer.graphics.filter((s) => s.getAttribute("id") === e.id).toArray().map((s) => s.clone()), i = this.subDistrictControllerLayer.graphics.filter(
|
|
107
118
|
(s) => s.getAttribute("id") === e.id || s.getAttribute("parentId") === e.id
|
|
108
|
-
).toArray().map((s) => s.clone()),
|
|
119
|
+
).toArray().map((s) => s.clone()), r = this.crossLayer.graphics.filter(
|
|
109
120
|
(s) => s.getAttribute("id") === e.id || s.getAttribute("districtId") === e.id || s.getAttribute("subDistrictId") === e.id
|
|
110
121
|
).toArray().map((s) => s.clone());
|
|
111
|
-
return
|
|
112
|
-
target:
|
|
122
|
+
return t.length > 0 && this.highlightLayer.addMany(t), i.length > 0 && (this.highlightLayer.addMany(i), this.showPopup(i[0])), r.length > 0 && this.highlightLayer.addMany(r), this.highlightLayer.graphics.length === 0 ? { status: 1, message: "未找到" } : (t.length > 0 ? (await this.view.goTo(t), this.showPopup(t[0])) : i.length > 0 ? (await this.view.goTo(i), this.showPopup(i[0])) : (r.length > 1 ? await this.view.goTo(r) : await this.view.goTo({
|
|
123
|
+
target: r[0].geometry,
|
|
113
124
|
scale: 1500
|
|
114
|
-
}), this.showPopup(
|
|
125
|
+
}), this.showPopup(r[0])), { status: 0, message: "ok" });
|
|
115
126
|
}
|
|
116
127
|
resetHighlight() {
|
|
117
128
|
return this.highlightLayer.removeAll(), this.districtControllerLayer.visible = !0, this.subDistrictControllerLayer.visible = !0, this.crossLayer.visible = !0, { status: 0, message: "ok" };
|
|
@@ -122,12 +133,12 @@ class C {
|
|
|
122
133
|
* @returns
|
|
123
134
|
*/
|
|
124
135
|
findAreaGraphic(e) {
|
|
125
|
-
let
|
|
126
|
-
(
|
|
136
|
+
let t = this.districtControllerLayer.graphics.find(
|
|
137
|
+
(i) => i.attributes.id === e
|
|
127
138
|
);
|
|
128
|
-
return
|
|
129
|
-
(
|
|
130
|
-
)),
|
|
139
|
+
return t || (t = this.subDistrictControllerLayer.graphics.find(
|
|
140
|
+
(i) => i.attributes.id === e
|
|
141
|
+
)), t || (t = this.crossLayer.graphics.find((i) => i.attributes.id === e)), t;
|
|
131
142
|
}
|
|
132
143
|
/**
|
|
133
144
|
* 绘制区控与子区
|
|
@@ -135,30 +146,32 @@ class C {
|
|
|
135
146
|
* @param isDistrict 是否是区控
|
|
136
147
|
* @returns
|
|
137
148
|
*/
|
|
138
|
-
drawArea(e,
|
|
139
|
-
const
|
|
140
|
-
if (
|
|
149
|
+
drawArea(e, t) {
|
|
150
|
+
const i = e.getAllCrossCoordinates();
|
|
151
|
+
if (i.length >= 2) {
|
|
141
152
|
let s = null;
|
|
142
|
-
if (
|
|
143
|
-
s =
|
|
144
|
-
else if (
|
|
145
|
-
const
|
|
146
|
-
|
|
153
|
+
if (i.length === 2)
|
|
154
|
+
s = h.lineString(i);
|
|
155
|
+
else if (i.length > 2) {
|
|
156
|
+
const c = h.featureCollection(
|
|
157
|
+
i.map((g) => h.point(g))
|
|
147
158
|
);
|
|
148
|
-
s = d(
|
|
159
|
+
s = d(c, { maxEdge: 400, units: "meters" }), s || (s = f(c));
|
|
149
160
|
}
|
|
150
|
-
if (!s)
|
|
161
|
+
if (!s) {
|
|
162
|
+
console.log("生成区控面失败", e);
|
|
151
163
|
return;
|
|
152
|
-
|
|
164
|
+
}
|
|
165
|
+
const a = p(
|
|
153
166
|
s.geometry,
|
|
154
167
|
// 区控面积更大,需要更大的缓冲半径
|
|
155
|
-
|
|
168
|
+
t ? 200 : 30,
|
|
156
169
|
{
|
|
157
170
|
units: "meters"
|
|
158
171
|
}
|
|
159
172
|
);
|
|
160
|
-
let
|
|
161
|
-
|
|
173
|
+
let l;
|
|
174
|
+
t ? l = [
|
|
162
175
|
{
|
|
163
176
|
fieldName: "id",
|
|
164
177
|
label: "区控编号"
|
|
@@ -171,7 +184,7 @@ class C {
|
|
|
171
184
|
fieldName: "subDistrictCount",
|
|
172
185
|
label: "子区数量"
|
|
173
186
|
}
|
|
174
|
-
] :
|
|
187
|
+
] : l = [
|
|
175
188
|
{
|
|
176
189
|
fieldName: "parentName",
|
|
177
190
|
label: "所属区控"
|
|
@@ -181,101 +194,95 @@ class C {
|
|
|
181
194
|
label: "路口数量"
|
|
182
195
|
}
|
|
183
196
|
];
|
|
184
|
-
const
|
|
197
|
+
const m = {
|
|
198
|
+
type: "signalControlArea",
|
|
199
|
+
id: e.id,
|
|
200
|
+
name: e.name,
|
|
201
|
+
parentId: e.parentId,
|
|
202
|
+
parentName: e.parentName,
|
|
203
|
+
crossCount: e.crossCount,
|
|
204
|
+
subDistrictCount: e.subDistrictCount
|
|
205
|
+
}, n = new u({
|
|
185
206
|
geometry: {
|
|
186
207
|
type: "polygon",
|
|
187
|
-
rings:
|
|
208
|
+
rings: a.geometry.coordinates
|
|
188
209
|
},
|
|
189
210
|
symbol: {
|
|
190
211
|
type: "simple-fill",
|
|
191
|
-
color: [...e.areaColor,
|
|
212
|
+
color: [...e.areaColor, t ? 0.6 : 0.8],
|
|
192
213
|
outline: {
|
|
193
214
|
color: e.areaColor,
|
|
194
215
|
width: 2,
|
|
195
|
-
style:
|
|
216
|
+
style: t ? "solid" : "long-dash"
|
|
196
217
|
}
|
|
197
218
|
},
|
|
198
|
-
attributes:
|
|
199
|
-
type: "signalControlArea",
|
|
200
|
-
id: e.id,
|
|
201
|
-
name: e.name,
|
|
202
|
-
parentId: e.parentId,
|
|
203
|
-
parentName: e.parentName,
|
|
204
|
-
crossCount: e.crossCount,
|
|
205
|
-
subDistrictCount: e.subDistrictCount
|
|
206
|
-
},
|
|
219
|
+
attributes: m,
|
|
207
220
|
popupTemplate: {
|
|
208
|
-
title: `${
|
|
221
|
+
title: `${t ? "区控" : "子区"} ${e.name}`,
|
|
209
222
|
content: [
|
|
210
223
|
{
|
|
211
224
|
type: "fields",
|
|
212
|
-
fieldInfos:
|
|
225
|
+
fieldInfos: l
|
|
213
226
|
}
|
|
214
227
|
]
|
|
215
228
|
}
|
|
216
229
|
});
|
|
217
|
-
|
|
230
|
+
t ? this.districtControllerLayer.add(n) : this.subDistrictControllerLayer.add(n);
|
|
218
231
|
}
|
|
219
232
|
for (const s of e.subDistricts)
|
|
220
233
|
this.drawArea(s, !1);
|
|
221
|
-
const
|
|
222
|
-
|
|
223
|
-
type: "point",
|
|
224
|
-
x: s.longitude,
|
|
225
|
-
y: s.latitude
|
|
226
|
-
},
|
|
227
|
-
symbol: {
|
|
228
|
-
type: "simple-marker",
|
|
229
|
-
style: s.isKey ? "diamond" : "circle",
|
|
230
|
-
color: e.areaColor,
|
|
231
|
-
size: s.isKey ? 16 : 8,
|
|
232
|
-
outline: {
|
|
233
|
-
color: s.isKey ? "red" : "white",
|
|
234
|
-
width: s.isKey ? 2 : 1
|
|
235
|
-
}
|
|
236
|
-
},
|
|
237
|
-
attributes: {
|
|
234
|
+
const r = e.crosses.map((s) => {
|
|
235
|
+
const a = {
|
|
238
236
|
type: "cross",
|
|
239
237
|
id: s.id,
|
|
240
238
|
name: s.name,
|
|
241
239
|
color: e.areaColor,
|
|
242
240
|
signalId: s.signalId,
|
|
243
|
-
districtId:
|
|
244
|
-
districtName:
|
|
245
|
-
subDistrictId:
|
|
246
|
-
subDistrictName:
|
|
241
|
+
districtId: t ? e.id : e.parentId,
|
|
242
|
+
districtName: t ? e.name : e.parentName,
|
|
243
|
+
subDistrictId: t ? "" : e.id,
|
|
244
|
+
subDistrictName: t ? "" : e.name,
|
|
247
245
|
isKey: s.isKey
|
|
248
|
-
}
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
246
|
+
};
|
|
247
|
+
return new u({
|
|
248
|
+
geometry: {
|
|
249
|
+
type: "point",
|
|
250
|
+
x: s.longitude,
|
|
251
|
+
y: s.latitude
|
|
252
|
+
},
|
|
253
|
+
symbol: this.getCrossGraphicSymbol(a, "marker"),
|
|
254
|
+
attributes: a,
|
|
255
|
+
popupTemplate: {
|
|
256
|
+
title: s.name,
|
|
257
|
+
content: [
|
|
258
|
+
{
|
|
259
|
+
type: "fields",
|
|
260
|
+
fieldInfos: [
|
|
261
|
+
{
|
|
262
|
+
fieldName: "districtName",
|
|
263
|
+
label: "区控名称"
|
|
264
|
+
},
|
|
265
|
+
{
|
|
266
|
+
fieldName: "subDistrictName",
|
|
267
|
+
label: "子区名称"
|
|
268
|
+
},
|
|
269
|
+
{
|
|
270
|
+
fieldName: "id",
|
|
271
|
+
label: "路口编号"
|
|
272
|
+
},
|
|
273
|
+
{
|
|
274
|
+
fieldName: "signalId",
|
|
275
|
+
label: "信号机编号"
|
|
276
|
+
}
|
|
277
|
+
]
|
|
278
|
+
}
|
|
279
|
+
]
|
|
280
|
+
}
|
|
281
|
+
});
|
|
282
|
+
});
|
|
283
|
+
this.crossLayer.addMany(r);
|
|
277
284
|
}
|
|
278
285
|
}
|
|
279
286
|
export {
|
|
280
|
-
|
|
287
|
+
G as default
|
|
281
288
|
};
|
|
@@ -14,6 +14,7 @@ export default class OpenDriveRenderer {
|
|
|
14
14
|
private allRefLineGraphics;
|
|
15
15
|
private mouseMoveHandler;
|
|
16
16
|
private mouseClickHandler;
|
|
17
|
+
private junctionNames;
|
|
17
18
|
constructor(view: __esri.MapView | __esri.SceneView);
|
|
18
19
|
private projectName;
|
|
19
20
|
private openDriveServer;
|
|
@@ -49,7 +50,6 @@ export default class OpenDriveRenderer {
|
|
|
49
50
|
private currentJunctionId;
|
|
50
51
|
private hitGraphic;
|
|
51
52
|
private highlightGraphic;
|
|
52
|
-
private monitorMouseDrag;
|
|
53
53
|
/**
|
|
54
54
|
* 监听鼠标移动事件,高亮显示鼠标所在路段和路口
|
|
55
55
|
*/
|
|
@@ -1,4 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const p=require("@arcgis/core/Graphic"),$=require("@arcgis/core/core/promiseUtils"),M=require("@arcgis/core/geometry"),P=require("@arcgis/core/geometry/geometryEngine"),G=require("@arcgis/core/layers/FeatureLayer"),g=require("@arcgis/core/layers/GraphicsLayer"),y=require("axios"),J=require("md5"),A=require("pako"),C=require("../common-utils.js");function O(m){const e=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(m){for(const t in m)if(t!=="default"){const i=Object.getOwnPropertyDescriptor(m,t);Object.defineProperty(e,t,i.get?i:{enumerable:!0,get:()=>m[t]})}}return e.default=m,Object.freeze(e)}const N=O($),L=O(P);class D{constructor(e){this.projectName="",this.openDriveServer="",this.currentSectionCode="",this.currentJunctionId="",this.view=e,this.view.popup.visibleElements={closeButton:!1,collapseButton:!1,actionBar:!1},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:"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 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 g({id:"OpenDriveJunction"}),this.sectionLayer=new g({id:"OpenDriveSection"}),this.highlightLayer=new g({id:"OpenDriveHighlight"}),this.flashLayer=new g({id:"OpenDriveFlash"}),this.drawLayer=new g({id:"Draw"}),this.view.map.addMany([this.laneLayer,this.junctionLayer,this.sectionLayer,this.roadNameLayer,this.highlightLayer,this.flashLayer,this.drawLayer])}static getInstance(e){return this.instance||(this.instance=new D(e)),this.instance}async makeMd5FromFile(e){try{const i=await(await fetch(e)).text();return{status:0,message:"ok",result:J(i)}}catch(t){return{status:-1,message:t.message}}}async showOpenDriveFromFile(e){var h,b;this.openDriveClickCallback=e.selectedCallback,console.time("md5用时");const t=await this.makeMd5FromFile(e.file);if(t.status!==0)return t;this.projectName=t.result,console.timeEnd("md5用时"),this.openDriveServer=e.server,await this.makeMd5FromFile(e.file);const i=`http://${this.openDriveServer}/api/openDrive/uploadXodr`;let o;try{o=await y.post(i,{},{params:{url:e.file,projectName:this.projectName}})}catch(d){return{status:-1,message:d.message}}if(o.status!==200)return{status:-1,message:o.statusText};console.time("渲染用时");const s=o.data.result.geoSetting;C.default.setGeoData(s.geoReference,s.offsetX,s.offsetY);let l=o.data.result.json;l.startsWith(window.location.protocol)||(l=`${window.location.protocol}//${e.server}${l}`);const a=await(await fetch(l)).arrayBuffer(),r=A.inflate(a,{to:"string"}),c=JSON.parse(r);await this.showAllLanes(c,((h=e.options)==null?void 0:h.showJunctionLane)||!1,((b=e.options)==null?void 0:b.showRoadName)||!0);const u=o.data.result.junctions;if(this.showJunction(u),e.options&&e.options.centerMap!==!1){const d=C.default.transformPointProjection([0,0]);await this.view.goTo(d)}return this.mouseMoveHandler||this.monitorMouseMove(),this.mouseClickHandler||this.monitorMouseClick(),console.timeEnd("渲染用时"),{status:0,message:"ok"}}async showOpenDriveFromServer(e,t){const i=`http://${e}/api/openDrive/analyzeXodr`,o=await y.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 n=await(await fetch(s)).arrayBuffer(),a=A.inflate(n,{to:"string"}),r=JSON.parse(a);return await this.showAllLanes(r,!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 l=0;this.allLaneGraphics=[],this.allRefLineGraphics=[];const n=[];for(const r of e){if(!t&&r.junction!=="-1")continue;const{id:c,refLine:u}=r;let h=r.name;h.includes("(")&&(h=h.slice(0,h.indexOf("("))),h=h.replace(/(.)/g,"$1 ");const b=new p({geometry:{type:"polyline",paths:[u]},attributes:{ObjectID:l++,roadId:c,roadName:h}});this.allRefLineGraphics.push(b),r.laneSections.sort((d,w)=>Number(d.id)-Number(w.id));for(let d=0;d<r.laneSections.length;d++){const w=r.laneSections[d],k=Number(w.id);for(const f of w.lanePaths){const v=Number(f.id);if(v===0)continue;const F=f.type,I=f.innerPath.concat(f.outerPath.reverse());if(I.length<=3){console.warn(`lane ${v} has less than 3 points`);continue}I.push(f.innerPath[0]);const j=new M.Polygon({rings:[I]});if(j){const S=new p({geometry:j,attributes:{ObjectID:l++,id:`${c}+${k}+${v}`,roadId:c,roadName:r.name,sectionId:k,sectionIndex:d,laneId:v,type:F,sumoId:""}});this.allLaneGraphics.push(S),n.push(S)}}}}const a=setInterval(()=>{if(n.length>0||this.allRefLineGraphics.length>0){if(n.length>0){const r=n.splice(0,100);this.laneLayer.applyEdits({addFeatures:r})}if(this.allRefLineGraphics.length>0){const r=this.allRefLineGraphics.splice(0,10);this.roadNameLayer.applyEdits({addFeatures:r})}}else clearInterval(a),s()},10)})}showJunction(e){const t=[];for(const i of e){if(!i)continue;i.nodeType=i.type;const o=new p({geometry:{type:"point",x:i.coordinates[0],y:i.coordinates[1]},attributes:{...i,selected:!1,type:"OpenDriveJunction"},symbol:{type:"picture-marker",url:i.crossId?"/GisViewerAssets/Images/point_green.png":"/GisViewerAssets/Images/point_yellow.png",width:30,height:30}});t.push(o)}this.junctionLayer.addMany(t)}monitorMouseDrag(){}monitorMouseMove(){const e=N.debounce(async t=>{var l;const o=(l=(await this.view.hitTest(t,{include:[this.laneLayer,this.junctionLayer]})).results)==null?void 0:l.filter(n=>n.type==="graphic");if(o.length===0){this.currentSectionCode!==""&&(this.currentSectionCode="",this.highlightGraphic=void 0,this.highlightLayer.removeAll()),this.currentJunctionId!==""&&(this.currentJunctionId="",this.view.closePopup());return}const s=o[0];if(this.hitGraphic=s.graphic,s.layer.id==="OpenDriveLane"){const n=`${this.hitGraphic.attributes.roadId}+${this.hitGraphic.attributes.sectionId}`;if(n===this.currentSectionCode||this.sectionLayer.graphics.findIndex(u=>u.getAttribute("id")===n)>=0)return;this.currentSectionCode=n;const r=this.allLaneGraphics.filter(u=>`${u.attributes.roadId}+${u.attributes.sectionId}`===n),c=L.union(r.map(u=>u.geometry));this.highlightGraphic=new p({geometry:c,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}}),this.highlightLayer.removeAll(),this.highlightLayer.add(this.highlightGraphic)}else if(s.layer.id==="OpenDriveJunction"){const n=this.hitGraphic.getAttribute("id");if(n===this.currentJunctionId)return;this.currentJunctionId=n;const a=this.hitGraphic.getAttribute("name"),r=this.hitGraphic.getAttribute("crossId");this.view.openPopup({title:a,content:`<table>
|
|
2
|
-
<tr><td>路口编号</td><td>${n}</td></tr>
|
|
3
|
-
<tr><td>信号机编号</td><td>${r||"无信控"}</td></tr>
|
|
4
|
-
</table>`,location:this.hitGraphic.geometry})}});this.mouseMoveHandler=this.view.on("pointer-move",async t=>{e(t).catch(()=>{})})}monitorMouseClick(){const e=N.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(r=>r.type==="graphic");if(o.length===0)return;const s=o[0].graphic,l=s.getAttribute("type"),n=s.getAttribute("id");if(l==="OpenDriveJunction")if(s.getAttribute("selected")===!1){const r=`http://${this.openDriveServer}/api/sumo/getSumoJunction`,c=await y.get(r,{params:{id:n,projectName:this.projectName}});c.status===200&&c.data.status===0&&(this.openDriveClickCallback&&this.openDriveClickCallback({type:"OpenDriveJunction",id:n,details:c.data.result}),s.setAttribute("selected",!0),s.symbol.url="/GisViewerAssets/Images/point_red.png",this.increasePictureMarkerSize(s,50))}else{this.openDriveClickCallback&&this.openDriveClickCallback({type:"OpenDriveJunction",id:n,details:void 0}),s.setAttribute("selected",!1);const r=s.getAttribute("crossId");s.symbol.url=r?"/GisViewerAssets/Images/point_green.png":"/GisViewerAssets/Images/point_yellow.png",this.decreasePictureMarkerSize(s,30)}else if(l==="OpenDriveSection")if(s.getAttribute("selected"))this.sectionLayer.remove(s),this.openDriveClickCallback&&this.openDriveClickCallback({type:"OpenDriveSection",id:n,details:void 0});else{this.highlightLayer.remove(s),this.sectionLayer.add(s),s.setAttribute("selected",!0);const r=`http://${this.openDriveServer}/api/sumo/getSumoEdge`,c=await y.get(r,{params:{id:n,projectName:this.projectName}});c.status===200&&c.data.status===0&&this.openDriveClickCallback&&(s.setAttribute("edgeId",c.data.result.obj_id),this.openDriveClickCallback({type:"OpenDriveSection",id:n,details:c.data.result}))}});this.mouseClickHandler=this.view.on("immediate-click",async t=>{e(t).catch(()=>{})})}increasePictureMarkerSize(e,t){const i=setInterval(()=>{const o=e.symbol,s=o.width;s<t?e.symbol={type:"picture-marker",url:o.url,width:s+1,height:s+1}:clearInterval(i)},20)}decreasePictureMarkerSize(e,t){const i=setInterval(()=>{const o=e.symbol,s=o.width;s>t?e.symbol={type:"picture-marker",url:o.url,width:s-1,height:s-1}:clearInterval(i)},20)}async getSumoInfo(e){switch(e.type){case"junction":{const t=`http://${this.openDriveServer}/api/sumo/getSumoJunction`,i=await y.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(l=>l.getAttribute("roadId")===i&&l.getAttribute("sectionIndex")===o);if(s){const l=`${i}+${s.getAttribute("sectionId")}`,n=`http://${this.openDriveServer}/api/sumo/getSumoEdge`,a=await y.get(n,{params:{id:l,projectName:this.projectName}});return a.status===200?a.data:{status:-1,message:`路段信息查询失败: ${l}`}}else return{status:-1,message:"未知类型"}}default:return{status:-1,message:"未知类型"}}}async clearOpenDrive(){var t,i;let e=await this.laneLayer.queryFeatures();e.features.length>0&&await this.laneLayer.applyEdits({deleteFeatures:e.features}),e=await this.roadNameLayer.queryFeatures(),e.features.length>0&&await this.roadNameLayer.applyEdits({deleteFeatures:e.features}),this.highlightLayer.removeAll(),this.junctionLayer.removeAll(),this.sectionLayer.removeAll(),this.flashLayer.removeAll(),(t=this.mouseMoveHandler)==null||t.remove(),this.mouseMoveHandler=void 0,(i=this.mouseClickHandler)==null||i.remove(),this.mouseClickHandler=void 0}async findSumo(e){const{type:t,id:i}=e,o=e.flash===void 0?!0:e.flash;if(t==="junction")return await this.findJunction(i,o);if(t==="edge"){const s=i.split("+");if(s.length>2)return{status:-1,message:"id格式错误"};const l=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],r=n.length===2?Number(n[1]):void 0;return await this.findLane({roadsectId:a,segmentId:r,laneId:l,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 p({geometry:i.geometry,symbol:{type:"simple-marker",style:"circle",size:30,color:[255,0,0,.6],outline:{color:"red",width:1}}});this.flashGraphic(o)}return await this.view.goTo(i.geometry,{duration:1e3}),{status:0,message:"ok"}}async findLane(e){let{roadsectId:t,segmentId:i,laneId:o}=e;t.startsWith("-")&&(t=t.slice(1));let s=this.allLaneGraphics.filter(a=>a.attributes.roadId===t);if(s.length===0)return{status:-1,message:"未找到。请检查路段编号"};if(i!==void 0){const a=[];if(s.forEach(r=>{const c=Number(r.attributes.sectionId);a.indexOf(c)===-1&&a.push(c)}),a.sort((r,c)=>r-c),i>a.length-1)return{status:-1,message:"未找到。请检查基本段编号"};i=a[i],s=s.filter(r=>Number(r.attributes.sectionId)===i)}if(o!==void 0){const a=[];if(s.forEach(r=>{const c=Number(r.attributes.laneId);a.indexOf(c)===-1&&a.push(c)}),a.sort((r,c)=>r-c),o>a.length-1)return{status:-1,message:"未找到。请检查车道编号"};o=a[o],s=s.filter(r=>Number(r.attributes.laneId)===o)}const l=s.map(a=>a.geometry),n=L.union(l);if(e.flash){const a=new p({geometry:n,symbol:{type:"simple-fill",color:[255,0,0,.5],style:"solid",outline:{color:"red",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 o=setInterval(()=>{i?(this.flashLayer.opacity-=.02,this.flashLayer.opacity<=.1&&(i=!1,t++)):(this.flashLayer.opacity+=.02,this.flashLayer.opacity>=1&&(i=!0)),t>=5&&(this.flashLayer.removeAll(),this.flashLayer.opacity=1,clearInterval(o))},10)}unselectSumo(e){if((!e||e.type==="junction")&&this.junctionLayer.graphics.forEach(t=>{if((!e||!e.id||e.id===""||e.id===t.getAttribute("id"))&&t.getAttribute("selected")){t.setAttribute("selected",!1);const i=t.getAttribute("crossId");t.symbol.url=i?"/GisViewerAssets/Images/point_green.png":"/GisViewerAssets/Images/point_yellow.png",this.decreasePictureMarkerSize(t,30)}}),!e||e.type==="edge")if(!e||!e.id||e.id==="")this.sectionLayer.removeAll();else{const t=this.sectionLayer.graphics.find(i=>i.getAttribute("edgeId")===e.id);t&&this.sectionLayer.remove(t)}return{status:0,message:"ok"}}selectSumo(e){switch(e.type){case"junction":return this.junctionLayer.graphics.forEach(t=>{if(e.id===t.getAttribute("id"))return t.setAttribute("selected",!0),t.symbol.url="/GisViewerAssets/Images/point_red.png",this.increasePictureMarkerSize(t,50),{status:0,message:"ok"}}),{status:-1,message:"未找到路口"};case"edge":{const t=e.id.split("#");let i=t[0];i.startsWith("-")&&(i=i.slice(1));let o=0;t.length===2&&(o=Number(t[1]));const s=this.allLaneGraphics.filter(l=>l.getAttribute("roadId")===i&&l.getAttribute("sectionIndex")===o);if(s.length>0){const l=L.union(s.map(a=>a.geometry)),n=new p({geometry:l,symbol:{type:"simple-fill",color:[0,255,255,.5],style:"solid",outline:{color:[0,255,255],width:1}},attributes:{type:"OpenDriveSection",edgeId:e.id,selected:!0}});return this.sectionLayer.add(n),{status:0,message:"ok"}}else return{status:-1,message:"未找到路段"}}default:return{status:-1,message:"未知类型"}}}async splitLane(e){return{status:0,message:"ok",result:e}}}exports.default=D;
|
|
1
|
+
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const p=require("@arcgis/core/Graphic"),M=require("@arcgis/core/core/promiseUtils"),$=require("@arcgis/core/geometry"),P=require("@arcgis/core/geometry/geometryEngine"),S=require("@arcgis/core/layers/FeatureLayer"),v=require("@arcgis/core/layers/GraphicsLayer"),g=require("axios"),J=require("md5"),G=require("pako"),A=require("../common-utils.js");function O(b){const e=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(b){for(const t in b)if(t!=="default"){const i=Object.getOwnPropertyDescriptor(b,t);Object.defineProperty(e,t,i.get?i:{enumerable:!0,get:()=>b[t]})}}return e.default=b,Object.freeze(e)}const C=O(M),N=O(P);class D{constructor(e){this.junctionNames=new Map,this.projectName="",this.openDriveServer="",this.currentSectionCode="",this.currentJunctionId="",this.view=e,this.view.popup.visibleElements={collapseButton:!1,actionBar:!1},this.laneLayer=new S({id:"OpenDriveLane",fields:[{name:"ObjectID",alias:"ObjectID",type:"oid"},{name:"id",alias:"编号",type:"string"},{name:"roadId",alias:"道路号",type:"string"},{name:"roadName",alias:"道路名称",type:"string"},{name:"sectionId",alias:"路段号",type:"string"},{name:"laneId",alias:"车道号",type:"string"},{name:"type",alias:"类型",type:"string"},{name:"sumoId",alias:"sumo编号",type:"string"},{name:"fromNode",alias:"起点路口",type:"string"},{name:"toNode",alias:"终点路口",type:"string"}],objectIdField:"ObjectID",geometryType:"polygon",spatialReference:{wkid:4326},source:[],outFields:["*"],renderer:{type:"unique-value",field:"type",defaultSymbol:{type:"simple-fill",color:[100,100,100],style:"solid",outline:{color:"white",width:1}},uniqueValueInfos:[{value:"shoulder",label:"路肩",symbol:{type:"simple-fill",color:"#008000",style:"solid",outline:{color:"white",width:1}}},{value:"border",label:"路沿",symbol:{type:"simple-fill",color:"#DCDCDC",style:"solid",outline:{color:"white",width:1}}},{value:"driving",label:"机动车道",symbol:{type:"simple-fill",color:[47,79,79,.8],style:"solid",outline:{color:"white",width:1}}},{value:"none",label:"无",symbol:{type:"simple-fill",color:[111,120,135],style:"none",outline:{color:"white",width:1}}},{value:"restricted",label:"禁行区",symbol:{type:"simple-fill",color:"yellow",style:"solid",outline:{color:"yellow",width:2}}},{value:"parking",label:"停车区",symbol:{type:"simple-fill",color:[115,115,115],style:"solid",outline:{color:"white",width:1}}},{value:"median",label:"中央隔离带",symbol:{type:"simple-fill",color:"#008000",style:"solid",outline:{color:"white",width:1}}},{value:"biking",label:"非机动车道",symbol:{type:"simple-fill",color:"#D3D3D3",style:"solid",outline:{color:"white",width:1}}},{value:"sidewalk",label:"人行道",symbol:{type:"simple-fill",color:"#C0C0C0",style:"solid",outline:{color:"white",width:1}}},{value:"junction",label:"路口区域",symbol:{type:"simple-fill",color:"#2F4F4F",style:"solid",outline:{color:"white",width:1}}},{value:"selected",label:"选中车道",symbol:{type:"simple-fill",color:[141,168,211],style:"solid",outline:{color:"white",width:1}}}]}}),this.roadNameLayer=new S({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 v({id:"OpenDriveJunction"}),this.sectionLayer=new v({id:"OpenDriveSection"}),this.highlightLayer=new v({id:"OpenDriveHighlight"}),this.flashLayer=new v({id:"OpenDriveFlash"}),this.drawLayer=new v({id:"Draw"}),this.view.map.addMany([this.laneLayer,this.junctionLayer,this.sectionLayer,this.roadNameLayer,this.highlightLayer,this.flashLayer,this.drawLayer])}static getInstance(e){return this.instance||(this.instance=new D(e)),this.instance}async makeMd5FromFile(e){try{const i=await(await fetch(e)).text();return{status:0,message:"ok",result:J(i)}}catch(t){return{status:-1,message:t.message}}}async showOpenDriveFromFile(e){var h,y;this.openDriveClickCallback=e.selectedCallback,console.time("md5用时");const t=await this.makeMd5FromFile(e.file);if(t.status!==0)return t;this.projectName=t.result,console.timeEnd("md5用时"),this.openDriveServer=e.server,await this.makeMd5FromFile(e.file);const i=`http://${this.openDriveServer}/api/openDrive/uploadXodr`;let o;try{o=await g.post(i,{},{params:{url:e.file,projectName:this.projectName}})}catch(d){return{status:-1,message:d.message}}if(o.status!==200)return{status:-1,message:o.statusText};console.time("渲染用时");const s=o.data.result.geoSetting;A.default.setGeoData(s.geoReference,s.offsetX,s.offsetY);let l=o.data.result.json;l.startsWith(window.location.protocol)||(l=`${window.location.protocol}//${e.server}${l}`);const a=await(await fetch(l)).arrayBuffer(),r=G.inflate(a,{to:"string"}),c=JSON.parse(r);await this.showAllLanes(c,((h=e.options)==null?void 0:h.showJunctionLane)||!1,((y=e.options)==null?void 0:y.showRoadName)||!0);const m=o.data.result.junctions;if(this.showJunction(m),e.options&&e.options.centerMap!==!1){const d=A.default.transformPointProjection([0,0]);await this.view.goTo(d)}return this.mouseMoveHandler||this.monitorMouseMove(),this.mouseClickHandler||this.monitorMouseClick(),console.timeEnd("渲染用时"),{status:0,message:"ok"}}async showOpenDriveFromServer(e,t){const i=`http://${e}/api/openDrive/analyzeXodr`,o=await g.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 n=await(await fetch(s)).arrayBuffer(),a=G.inflate(n,{to:"string"}),r=JSON.parse(a);return await this.showAllLanes(r,!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 l=0;this.allLaneGraphics=[],this.allRefLineGraphics=[];const n=[];for(const r of e){if(!t&&r.junction!=="-1")continue;const{id:c,refLine:m}=r;let h=r.name;h.includes("(")&&(h=h.slice(0,h.indexOf("("))),h=h.replace(/(.)/g,"$1 ");const y=new p({geometry:{type:"polyline",paths:[m]},attributes:{ObjectID:l++,roadId:c,roadName:h}});this.allRefLineGraphics.push(y),r.laneSections.sort((d,f)=>Number(d.id)-Number(f.id));for(let d=0;d<r.laneSections.length;d++){const f=r.laneSections[d],u=Number(f.id);for(const w of f.lanePaths){const I=Number(w.id);if(I===0)continue;const F=w.type,L=w.innerPath.concat(w.outerPath.reverse());if(L.length<=3){console.warn(`lane ${I} has less than 3 points`);continue}L.push(w.innerPath[0]);const j=new $.Polygon({rings:[L]});if(j){const k=new p({geometry:j,attributes:{ObjectID:l++,id:`${c}+${u}+${I}`,fromNode:r.fromNode,toNode:r.toNode,roadId:c,roadName:r.name,sectionId:u,sectionIndex:d,laneId:I,type:F,sumoId:""}});this.allLaneGraphics.push(k),n.push(k)}}}}const a=setInterval(()=>{if(n.length>0||this.allRefLineGraphics.length>0){if(n.length>0){const r=n.splice(0,100);this.laneLayer.applyEdits({addFeatures:r})}if(this.allRefLineGraphics.length>0){const r=this.allRefLineGraphics.splice(0,10);this.roadNameLayer.applyEdits({addFeatures:r})}}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 o=new p({geometry:{type:"point",x:i.coordinates[0],y:i.coordinates[1]},attributes:{...i,selected:!1,type:"OpenDriveJunction"},symbol:{type:"picture-marker",url:i.crossId?"/GisViewerAssets/Images/point_green.png":"/GisViewerAssets/Images/point_yellow.png",width:30,height:30},popupTemplate:{title:i.name,content:[{type:"fields",fieldInfos:[{fieldName:"id",label:"路口编号"},{fieldName:"crossId",label:"信号机编号"}]}]}});t.push(o)}this.junctionLayer.addMany(t)}monitorMouseMove(){const e=C.debounce(async t=>{var l;const o=(l=(await this.view.hitTest(t,{include:[this.laneLayer,this.junctionLayer]})).results)==null?void 0:l.filter(n=>n.type==="graphic");if(o.length===0){this.currentSectionCode!==""&&(this.currentSectionCode="",this.highlightGraphic=void 0,this.highlightLayer.removeAll()),this.currentJunctionId!==""&&(this.currentJunctionId="",this.view.closePopup());return}const s=o[0];if(this.hitGraphic=s.graphic,s.layer.id==="OpenDriveLane"){const n=`${this.hitGraphic.getAttribute("roadId")}+${this.hitGraphic.getAttribute("sectionId")}`;if(n===this.currentSectionCode||this.sectionLayer.graphics.findIndex(u=>u.getAttribute("id")===n)>=0)return;this.currentSectionCode=n;const r=this.allLaneGraphics.filter(u=>`${u.attributes.roadId}+${u.attributes.sectionId}`===n),c=N.union(r.map(u=>u.geometry)),m=this.hitGraphic.getAttribute("fromNode"),h=this.hitGraphic.getAttribute("toNode"),y=this.junctionNames.get(m)||m,d=this.junctionNames.get(h)||h;this.highlightGraphic=new p({geometry:c,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:y,toNodeName:d,laneCount:r.length},popupTemplate:{title:this.hitGraphic.getAttribute("roadName"),content:[{type:"fields",fieldInfos:[{fieldName:"fromNodeName",label:"起点路口"},{fieldName:"toNodeName",label:"终点路口"},{fieldName:"laneCount",label:"车道数量"}]}]}}),this.highlightLayer.removeAll(),this.highlightLayer.add(this.highlightGraphic);const f=this.view.toMap(t);this.view.openPopup({features:[this.highlightGraphic],location:f})}else if(s.layer.id==="OpenDriveJunction"){const n=this.hitGraphic.getAttribute("id");if(n===this.currentJunctionId)return;this.currentJunctionId=n,this.view.openPopup({features:[this.hitGraphic],location:this.hitGraphic.geometry})}});this.mouseMoveHandler=this.view.on("pointer-move",async t=>{e(t).catch(()=>{})})}monitorMouseClick(){const e=C.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(r=>r.type==="graphic");if(o.length===0)return;const s=o[0].graphic,l=s.getAttribute("type"),n=s.getAttribute("id");if(l==="OpenDriveJunction")if(s.getAttribute("selected")===!1){const r=`http://${this.openDriveServer}/api/sumo/getSumoJunction`,c=await g.get(r,{params:{id:n,projectName:this.projectName}});c.status===200&&c.data.status===0&&(this.openDriveClickCallback&&this.openDriveClickCallback({type:"OpenDriveJunction",id:n,details:c.data.result}),s.setAttribute("selected",!0),s.symbol.url="/GisViewerAssets/Images/point_red.png",this.increasePictureMarkerSize(s,50))}else{this.openDriveClickCallback&&this.openDriveClickCallback({type:"OpenDriveJunction",id:n,details:void 0}),s.setAttribute("selected",!1);const r=s.getAttribute("crossId");s.symbol.url=r?"/GisViewerAssets/Images/point_green.png":"/GisViewerAssets/Images/point_yellow.png",this.decreasePictureMarkerSize(s,30)}else if(l==="OpenDriveSection")if(s.getAttribute("selected"))this.sectionLayer.remove(s),this.openDriveClickCallback&&this.openDriveClickCallback({type:"OpenDriveSection",id:n,details:void 0});else{this.highlightLayer.remove(s),this.sectionLayer.add(s),s.setAttribute("selected",!0);const r=`http://${this.openDriveServer}/api/sumo/getSumoEdge`,c=await g.get(r,{params:{id:n,projectName:this.projectName}});c.status===200&&c.data.status===0&&this.openDriveClickCallback&&(s.setAttribute("edgeId",c.data.result.obj_id),this.openDriveClickCallback({type:"OpenDriveSection",id:n,details:c.data.result}))}});this.mouseClickHandler=this.view.on("immediate-click",async t=>{e(t).catch(()=>{})})}increasePictureMarkerSize(e,t){const i=setInterval(()=>{const o=e.symbol,s=o.width;s<t?e.symbol={type:"picture-marker",url:o.url,width:s+1,height:s+1}:clearInterval(i)},20)}decreasePictureMarkerSize(e,t){const i=setInterval(()=>{const o=e.symbol,s=o.width;s>t?e.symbol={type:"picture-marker",url:o.url,width:s-1,height:s-1}:clearInterval(i)},20)}async getSumoInfo(e){switch(e.type){case"junction":{const t=`http://${this.openDriveServer}/api/sumo/getSumoJunction`,i=await g.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(l=>l.getAttribute("roadId")===i&&l.getAttribute("sectionIndex")===o);if(s){const l=`${i}+${s.getAttribute("sectionId")}`,n=`http://${this.openDriveServer}/api/sumo/getSumoEdge`,a=await g.get(n,{params:{id:l,projectName:this.projectName}});return a.status===200?a.data:{status:-1,message:`路段信息查询失败: ${l}`}}else return{status:-1,message:"未知类型"}}default:return{status:-1,message:"未知类型"}}}async clearOpenDrive(){var t,i;let e=await this.laneLayer.queryFeatures();e.features.length>0&&await this.laneLayer.applyEdits({deleteFeatures:e.features}),e=await this.roadNameLayer.queryFeatures(),e.features.length>0&&await this.roadNameLayer.applyEdits({deleteFeatures:e.features}),this.highlightLayer.removeAll(),this.junctionLayer.removeAll(),this.sectionLayer.removeAll(),this.flashLayer.removeAll(),(t=this.mouseMoveHandler)==null||t.remove(),this.mouseMoveHandler=void 0,(i=this.mouseClickHandler)==null||i.remove(),this.mouseClickHandler=void 0}async findSumo(e){const{type:t,id:i}=e,o=e.flash===void 0?!0:e.flash;if(t==="junction")return await this.findJunction(i,o);if(t==="edge"){const s=i.split("+");if(s.length>2)return{status:-1,message:"id格式错误"};const l=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],r=n.length===2?Number(n[1]):void 0;return await this.findLane({roadsectId:a,segmentId:r,laneId:l,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 p({geometry:i.geometry,symbol:{type:"simple-marker",style:"circle",size:30,color:[255,0,0,.6],outline:{color:"red",width:1}}});this.flashGraphic(o)}return await this.view.goTo(i.geometry,{duration:1e3}),{status:0,message:"ok"}}async findLane(e){let{roadsectId:t,segmentId:i,laneId:o}=e;t.startsWith("-")&&(t=t.slice(1));let s=this.allLaneGraphics.filter(a=>a.attributes.roadId===t);if(s.length===0)return{status:-1,message:"未找到。请检查路段编号"};if(i!==void 0){const a=[];if(s.forEach(r=>{const c=Number(r.attributes.sectionId);a.indexOf(c)===-1&&a.push(c)}),a.sort((r,c)=>r-c),i>a.length-1)return{status:-1,message:"未找到。请检查基本段编号"};i=a[i],s=s.filter(r=>Number(r.attributes.sectionId)===i)}if(o!==void 0){const a=[];if(s.forEach(r=>{const c=Number(r.attributes.laneId);a.indexOf(c)===-1&&a.push(c)}),a.sort((r,c)=>r-c),o>a.length-1)return{status:-1,message:"未找到。请检查车道编号"};o=a[o],s=s.filter(r=>Number(r.attributes.laneId)===o)}const l=s.map(a=>a.geometry),n=N.union(l);if(e.flash){const a=new p({geometry:n,symbol:{type:"simple-fill",color:[255,0,0,.5],style:"solid",outline:{color:"red",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 o=setInterval(()=>{i?(this.flashLayer.opacity-=.02,this.flashLayer.opacity<=.1&&(i=!1,t++)):(this.flashLayer.opacity+=.02,this.flashLayer.opacity>=1&&(i=!0)),t>=5&&(this.flashLayer.removeAll(),this.flashLayer.opacity=1,clearInterval(o))},10)}unselectSumo(e){if((!e||e.type==="junction")&&this.junctionLayer.graphics.forEach(t=>{if((!e||!e.id||e.id===""||e.id===t.getAttribute("id"))&&t.getAttribute("selected")){t.setAttribute("selected",!1);const i=t.getAttribute("crossId");t.symbol.url=i?"/GisViewerAssets/Images/point_green.png":"/GisViewerAssets/Images/point_yellow.png",this.decreasePictureMarkerSize(t,30)}}),!e||e.type==="edge")if(!e||!e.id||e.id==="")this.sectionLayer.removeAll();else{const t=this.sectionLayer.graphics.find(i=>i.getAttribute("edgeId")===e.id);t&&this.sectionLayer.remove(t)}return{status:0,message:"ok"}}selectSumo(e){switch(e.type){case"junction":return this.junctionLayer.graphics.forEach(t=>{if(e.id===t.getAttribute("id"))return t.setAttribute("selected",!0),t.symbol.url="/GisViewerAssets/Images/point_red.png",this.increasePictureMarkerSize(t,50),{status:0,message:"ok"}}),{status:-1,message:"未找到路口"};case"edge":{const t=e.id.split("#");let i=t[0];i.startsWith("-")&&(i=i.slice(1));let o=0;t.length===2&&(o=Number(t[1]));const s=this.allLaneGraphics.filter(l=>l.getAttribute("roadId")===i&&l.getAttribute("sectionIndex")===o);if(s.length>0){const l=N.union(s.map(a=>a.geometry)),n=new p({geometry:l,symbol:{type:"simple-fill",color:[0,255,255,.5],style:"solid",outline:{color:[0,255,255],width:1}},attributes:{type:"OpenDriveSection",edgeId:e.id,selected:!0}});return this.sectionLayer.add(n),{status:0,message:"ok"}}else return{status:-1,message:"未找到路段"}}default:return{status:-1,message:"未知类型"}}}async splitLane(e){return{status:0,message:"ok",result:e}}}exports.default=D;
|
|
@@ -9,6 +9,13 @@ export default class SignalControlAreaController {
|
|
|
9
9
|
private readonly crossScale;
|
|
10
10
|
constructor(view: __esri.MapView | __esri.SceneView);
|
|
11
11
|
showSignalControlArea(params: any): IResult;
|
|
12
|
+
/**
|
|
13
|
+
* 生成路口点符号。在不同比例尺下,使用不同的符号
|
|
14
|
+
* @param attributes
|
|
15
|
+
* @param symbolType
|
|
16
|
+
* @returns
|
|
17
|
+
*/
|
|
18
|
+
private getCrossGraphicSymbol;
|
|
12
19
|
clearSignalControlArea(): IResult;
|
|
13
20
|
locateSignalControlArea(params: {
|
|
14
21
|
id: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const m=require("@arcgis/core/core/reactiveUtils.js"),
|
|
1
|
+
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const m=require("@arcgis/core/core/reactiveUtils.js"),g=require("@arcgis/core/Graphic"),l=require("@arcgis/core/layers/GraphicsLayer"),f=require("@turf/buffer"),b=require("@turf/concave"),L=require("@turf/convex"),w=require("@turf/helpers"),v=require("./district-controller.js");function y(a){const e=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(a){for(const t in a)if(t!=="default"){const i=Object.getOwnPropertyDescriptor(a,t);Object.defineProperty(e,t,i.get?i:{enumerable:!0,get:()=>a[t]})}}return e.default=a,Object.freeze(e)}const A=y(m),h=y(w);class C{constructor(e){this.crossScale=3e3,this.view=e,this.view.popup.visibleElements={closeButton:!0,collapseButton:!1,actionBar:!0},this.districtControllerLayer=new l({id:"districtControllerLayer",maxScale:144447,minScale:1155582}),this.subDistrictControllerLayer=new l({id:"subDistrictControllerLayer",maxScale:0,minScale:144447}),this.crossLayer=new l({id:"crossLayer",maxScale:0,minScale:36112}),this.highlightLayer=new l({id:"highlightLayer"}),this.view.map.addMany([this.districtControllerLayer,this.subDistrictControllerLayer,this.crossLayer,this.highlightLayer])}showSignalControlArea(e){this.districtControllerLayer.removeAll(),this.subDistrictControllerLayer.removeAll(),this.crossLayer.removeAll(),this.highlightLayer.removeAll(),this.districtControllerLayer.visible=!0,this.subDistrictControllerLayer.visible=!0;for(const t of e){const i=new v.default(t);this.drawArea(i,!0)}return this.watchHandle=A.watch(()=>this.view.scale,(t,i)=>{t>this.crossScale&&i<=this.crossScale?(this.crossLayer.graphics.forEach(r=>{r.symbol=this.getCrossGraphicSymbol(r.attributes,"marker")}),this.highlightLayer.graphics.forEach(r=>{r.getAttribute("type")==="cross"&&(r.symbol=this.getCrossGraphicSymbol(r.attributes,"marker"))})):t<=this.crossScale&&i>this.crossScale&&(this.crossLayer.graphics.forEach(r=>{r.symbol=this.getCrossGraphicSymbol(r.attributes,"picture")}),this.highlightLayer.graphics.forEach(r=>{r.getAttribute("type")==="cross"&&(r.symbol=this.getCrossGraphicSymbol(r.attributes,"picture"))}))}),{status:0,message:"ok"}}getCrossGraphicSymbol(e,t){const{isKey:i,color:r}=e;if(t==="marker")return{type:"simple-marker",style:i?"diamond":"circle",color:r,size:i?16:8,outline:{color:i?"red":"white",width:i?2:1}};if(t==="picture")return{type:"picture-marker",url:`/GisViewerAssets/Images/xhj_${i?4:1}.png`,width:i?"55px":"37px",height:i?"85px":"57px",yoffset:i?"37px":"25px"}}clearSignalControlArea(){var e;return this.districtControllerLayer.removeAll(),this.subDistrictControllerLayer.removeAll(),this.crossLayer.removeAll(),this.highlightLayer.removeAll(),(e=this.watchHandle)==null||e.remove(),this.view.closePopup(),{status:0,message:"ok"}}async locateSignalControlArea(e){const t=this.findAreaGraphic(e.id);return t?(t.attributes.type==="cross"?await this.view.goTo({target:t.geometry,scale:1500}):await this.view.goTo(t.geometry),this.showPopup(t),{status:0,message:"ok"}):{status:1,message:"未找到"}}showPopup(e){const t=e.geometry.type==="point"?e.geometry:e.geometry.centroid;this.view.openPopup({features:[e],location:t})}async highlightSignalControlArea(e){this.highlightLayer.removeAll(),this.districtControllerLayer.visible=!1,this.subDistrictControllerLayer.visible=!1,this.crossLayer.visible=!1;const t=this.districtControllerLayer.graphics.filter(s=>s.getAttribute("id")===e.id).toArray().map(s=>s.clone()),i=this.subDistrictControllerLayer.graphics.filter(s=>s.getAttribute("id")===e.id||s.getAttribute("parentId")===e.id).toArray().map(s=>s.clone()),r=this.crossLayer.graphics.filter(s=>s.getAttribute("id")===e.id||s.getAttribute("districtId")===e.id||s.getAttribute("subDistrictId")===e.id).toArray().map(s=>s.clone());return t.length>0&&this.highlightLayer.addMany(t),i.length>0&&(this.highlightLayer.addMany(i),this.showPopup(i[0])),r.length>0&&this.highlightLayer.addMany(r),this.highlightLayer.graphics.length===0?{status:1,message:"未找到"}:(t.length>0?(await this.view.goTo(t),this.showPopup(t[0])):i.length>0?(await this.view.goTo(i),this.showPopup(i[0])):(r.length>1?await this.view.goTo(r):await this.view.goTo({target:r[0].geometry,scale:1500}),this.showPopup(r[0])),{status:0,message:"ok"})}resetHighlight(){return this.highlightLayer.removeAll(),this.districtControllerLayer.visible=!0,this.subDistrictControllerLayer.visible=!0,this.crossLayer.visible=!0,{status:0,message:"ok"}}findAreaGraphic(e){let t=this.districtControllerLayer.graphics.find(i=>i.attributes.id===e);return t||(t=this.subDistrictControllerLayer.graphics.find(i=>i.attributes.id===e)),t||(t=this.crossLayer.graphics.find(i=>i.attributes.id===e)),t}drawArea(e,t){const i=e.getAllCrossCoordinates();if(i.length>=2){let s=null;if(i.length===2)s=h.lineString(i);else if(i.length>2){const u=h.featureCollection(i.map(d=>h.point(d)));s=b(u,{maxEdge:400,units:"meters"}),s||(s=L(u))}if(!s){console.log("生成区控面失败",e);return}const o=f(s.geometry,t?200:30,{units:"meters"});let n;t?n=[{fieldName:"id",label:"区控编号"},{fieldName:"crossCount",label:"路口数量"},{fieldName:"subDistrictCount",label:"子区数量"}]:n=[{fieldName:"parentName",label:"所属区控"},{fieldName:"crossCount",label:"路口数量"}];const p={type:"signalControlArea",id:e.id,name:e.name,parentId:e.parentId,parentName:e.parentName,crossCount:e.crossCount,subDistrictCount:e.subDistrictCount},c=new g({geometry:{type:"polygon",rings:o.geometry.coordinates},symbol:{type:"simple-fill",color:[...e.areaColor,t?.6:.8],outline:{color:e.areaColor,width:2,style:t?"solid":"long-dash"}},attributes:p,popupTemplate:{title:`${t?"区控":"子区"} ${e.name}`,content:[{type:"fields",fieldInfos:n}]}});t?this.districtControllerLayer.add(c):this.subDistrictControllerLayer.add(c)}for(const s of e.subDistricts)this.drawArea(s,!1);const r=e.crosses.map(s=>{const o={type:"cross",id:s.id,name:s.name,color:e.areaColor,signalId:s.signalId,districtId:t?e.id:e.parentId,districtName:t?e.name:e.parentName,subDistrictId:t?"":e.id,subDistrictName:t?"":e.name,isKey:s.isKey};return new g({geometry:{type:"point",x:s.longitude,y:s.latitude},symbol:this.getCrossGraphicSymbol(o,"marker"),attributes:o,popupTemplate:{title:s.name,content:[{type:"fields",fieldInfos:[{fieldName:"districtName",label:"区控名称"},{fieldName:"subDistrictName",label:"子区名称"},{fieldName:"id",label:"路口编号"},{fieldName:"signalId",label:"信号机编号"}]}]}})});this.crossLayer.addMany(r)}}exports.default=C;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "gisviewer-vue3-arcgis",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.140",
|
|
4
4
|
"main": "lib/index.js",
|
|
5
5
|
"module": "es/index.mjs",
|
|
6
6
|
"files": [
|
|
@@ -25,6 +25,7 @@
|
|
|
25
25
|
"@turf/bearing": "^6.5.0",
|
|
26
26
|
"@turf/buffer": "^6.5.0",
|
|
27
27
|
"@turf/destination": "^6.5.0",
|
|
28
|
+
"@turf/concave": "^7.0.0",
|
|
28
29
|
"@turf/convex": "^7.0.0",
|
|
29
30
|
"@turf/helpers": "^6.5.0",
|
|
30
31
|
"@turf/intersect": "^6.5.0",
|