gisviewer-vue3-arcgis 1.0.138 → 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.
@@ -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 j from "@arcgis/core/core/promiseUtils";
2
+ import * as k from "@arcgis/core/core/promiseUtils";
3
3
  import { Polygon as O } from "@arcgis/core/geometry";
4
- import * as I from "@arcgis/core/geometry/geometryEngine";
5
- import G from "@arcgis/core/layers/FeatureLayer";
6
- import f from "@arcgis/core/layers/GraphicsLayer";
7
- import m from "axios";
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 S from "pako";
9
+ import G from "pako";
10
10
  import A from "../common-utils.mjs";
11
- class C {
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 G({
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 G({
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 f({ id: "OpenDriveJunction" }), this.sectionLayer = new f({ id: "OpenDriveSection" }), this.highlightLayer = new f({ id: "OpenDriveHighlight" }), this.flashLayer = new f({ id: "OpenDriveFlash" }), this.drawLayer = new f({ id: "Draw" }), this.view.map.addMany([
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 C(e)), this.instance;
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 d, g;
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 m.post(
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 (u) {
322
- return { status: -1, message: u.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 a = await (await fetch(l)).arrayBuffer(), r = S.inflate(a, { to: "string" }), c = JSON.parse(r);
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
- ((d = e.options) == null ? void 0 : d.showJunctionLane) || !1,
339
- ((g = e.options) == null ? void 0 : g.showRoadName) || !0
347
+ ((h = e.options) == null ? void 0 : h.showJunctionLane) || !1,
348
+ ((f = e.options) == null ? void 0 : f.showRoadName) || !0
340
349
  );
341
- const h = o.data.result.junctions;
342
- if (this.showJunction(h), e.options && e.options.centerMap !== !1) {
343
- const u = A.transformPointProjection([0, 0]);
344
- await this.view.goTo(u);
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 m.get(i, {
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 n = await (await fetch(s)).arrayBuffer(), a = S.inflate(n, { to: "string" }), r = JSON.parse(a);
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 n = [];
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: h } = r;
389
- let d = r.name;
390
- d.includes("(") && (d = d.slice(0, d.indexOf("("))), d = d.replace(/(.)/g, "$1 ");
391
- const g = new p({
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: [h]
403
+ paths: [m]
395
404
  },
396
405
  attributes: {
397
406
  ObjectID: l++,
398
407
  roadId: c,
399
- roadName: d
408
+ roadName: h
400
409
  }
401
410
  });
402
- this.allRefLineGraphics.push(g), r.laneSections.sort((u, w) => Number(u.id) - Number(w.id));
403
- for (let u = 0; u < r.laneSections.length; u++) {
404
- const w = r.laneSections[u], L = Number(w.id);
405
- for (const y of w.lanePaths) {
406
- const b = Number(y.id);
407
- if (b === 0)
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 N = y.type, v = y.innerPath.concat(
410
- y.outerPath.reverse()
418
+ const C = w.type, I = w.innerPath.concat(
419
+ w.outerPath.reverse()
411
420
  );
412
- if (v.length <= 3) {
413
- console.warn(`lane ${b} has less than 3 points`);
421
+ if (I.length <= 3) {
422
+ console.warn(`lane ${v} has less than 3 points`);
414
423
  continue;
415
424
  }
416
- v.push(y.innerPath[0]);
417
- const D = new O({
418
- rings: [v]
425
+ I.push(w.innerPath[0]);
426
+ const N = new O({
427
+ rings: [I]
419
428
  });
420
- if (D) {
421
- const k = new p({
422
- geometry: D,
429
+ if (N) {
430
+ const D = new p({
431
+ geometry: N,
423
432
  attributes: {
424
433
  ObjectID: l++,
425
- id: `${c}+${L}+${b}`,
434
+ id: `${c}+${u}+${v}`,
435
+ fromNode: r.fromNode,
436
+ toNode: r.toNode,
426
437
  roadId: c,
427
438
  roadName: r.name,
428
- sectionId: L,
429
- sectionIndex: u,
430
- laneId: b,
431
- type: N,
439
+ sectionId: u,
440
+ sectionIndex: d,
441
+ laneId: v,
442
+ type: C,
432
443
  sumoId: ""
433
444
  }
434
445
  });
435
- this.allLaneGraphics.push(k), n.push(k);
446
+ this.allLaneGraphics.push(D), a.push(D);
436
447
  }
437
448
  }
438
449
  }
439
450
  }
440
- const a = setInterval(() => {
441
- if (n.length > 0 || this.allRefLineGraphics.length > 0) {
442
- if (n.length > 0) {
443
- const r = n.splice(0, 100);
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(a), s();
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 = j.debounce(async (t) => {
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
- (n) => n.type === "graphic"
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 n = `${this.hitGraphic.attributes.roadId}+${this.hitGraphic.attributes.sectionId}`;
512
- if (n === this.currentSectionCode || this.sectionLayer.graphics.findIndex(
513
- (h) => h.getAttribute("id") === n
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 = n;
545
+ this.currentSectionCode = a;
517
546
  const r = this.allLaneGraphics.filter(
518
- (h) => `${h.attributes.roadId}+${h.attributes.sectionId}` === n
519
- ), c = I.union(
520
- r.map((h) => h.geometry)
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: n,
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 n = this.hitGraphic.getAttribute("id");
541
- if (n === this.currentJunctionId)
599
+ const a = this.hitGraphic.getAttribute("id");
600
+ if (a === this.currentJunctionId)
542
601
  return;
543
- this.currentJunctionId = n;
544
- const a = this.hitGraphic.getAttribute("name"), r = this.hitGraphic.getAttribute("crossId");
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 = j.debounce(async (t) => {
565
- var a;
566
- const o = (a = (await this.view.hitTest(t, {
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 : a.filter(
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"), n = s.getAttribute("id");
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 m.get(r, {
629
+ const r = `http://${this.openDriveServer}/api/sumo/getSumoJunction`, c = await g.get(r, {
577
630
  params: {
578
- id: n,
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: n,
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: n,
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: n,
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 m.get(r, {
658
+ const r = `http://${this.openDriveServer}/api/sumo/getSumoEdge`, c = await g.get(r, {
606
659
  params: {
607
- id: n,
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: n,
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 m.get(t, {
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
- )}`, n = `http://${this.openDriveServer}/api/sumo/getSumoEdge`, a = await m.get(n, {
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 a.status === 200 ? a.data : { status: -1, message: `路段信息查询失败: ${l}` };
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, n = s[0].split("#");
718
- if (n.length > 2)
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 a = n[0], r = n.length === 2 ? Number(n[1]) : void 0;
721
- return await this.findLane({ roadsectId: a, segmentId: r, laneId: l, flash: o });
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
- (a) => a.attributes.roadId === t
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 a = [];
816
+ const n = [];
764
817
  if (s.forEach((r) => {
765
818
  const c = Number(r.attributes.sectionId);
766
- a.indexOf(c) === -1 && a.push(c);
767
- }), a.sort((r, c) => r - c), i > a.length - 1)
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 = a[i], s = s.filter(
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 a = [];
827
+ const n = [];
775
828
  if (s.forEach((r) => {
776
829
  const c = Number(r.attributes.laneId);
777
- a.indexOf(c) === -1 && a.push(c);
778
- }), a.sort((r, c) => r - c), o > a.length - 1)
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 = a[o], s = s.filter(
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
- (a) => a.geometry
786
- ), n = I.union(l);
838
+ (n) => n.geometry
839
+ ), a = L.union(l);
787
840
  if (e.flash) {
788
- const a = new p({
789
- geometry: n,
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(a);
853
+ this.flashGraphic(n);
801
854
  }
802
- return await this.view.goTo(n, { duration: 1e3 }), { status: 0, message: "ok" };
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 = I.union(
861
- s.map((a) => a.geometry)
862
- ), n = new p({
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(n), { status: 0, message: "ok" };
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
- C as default
945
+ S as default
893
946
  };
@@ -9,10 +9,18 @@ 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;
15
22
  }): Promise<IResult>;
23
+ private showPopup;
16
24
  highlightSignalControlArea(params: {
17
25
  id: string;
18
26
  }): Promise<IResult>;
@@ -1,29 +1,30 @@
1
- import * as g from "@arcgis/core/core/reactiveUtils.js";
2
- import h from "@arcgis/core/Graphic";
3
- import a from "@arcgis/core/layers/GraphicsLayer";
4
- import m from "@turf/buffer";
5
- import d from "@turf/convex";
6
- import * as l from "@turf/helpers";
1
+ import * as y from "@arcgis/core/core/reactiveUtils.js";
2
+ import u from "@arcgis/core/Graphic";
3
+ import o from "@arcgis/core/layers/GraphicsLayer";
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";
7
8
  import b from "./district-controller.mjs";
8
- class C {
9
+ class G {
9
10
  constructor(e) {
10
11
  this.crossScale = 3e3, this.view = e, this.view.popup.visibleElements = {
11
12
  closeButton: !0,
12
13
  collapseButton: !1,
13
14
  actionBar: !0
14
- }, this.districtControllerLayer = new a({
15
+ }, this.districtControllerLayer = new o({
15
16
  id: "districtControllerLayer",
16
17
  maxScale: 144447,
17
18
  minScale: 1155582
18
- }), this.subDistrictControllerLayer = new a({
19
+ }), this.subDistrictControllerLayer = new o({
19
20
  id: "subDistrictControllerLayer",
20
21
  maxScale: 0,
21
22
  minScale: 144447
22
- }), this.crossLayer = new a({
23
+ }), this.crossLayer = new o({
23
24
  id: "crossLayer",
24
25
  maxScale: 0,
25
26
  minScale: 36112
26
- }), this.highlightLayer = new a({
27
+ }), this.highlightLayer = new o({
27
28
  id: "highlightLayer"
28
29
  }), this.view.map.addMany([
29
30
  this.districtControllerLayer,
@@ -35,84 +36,93 @@ class C {
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
38
  for (const t of e) {
38
- const r = new b(t);
39
- this.drawArea(r, !0);
39
+ const i = new b(t);
40
+ this.drawArea(i, !0);
40
41
  }
41
- return this.watchHandle = g.watch(
42
+ return this.watchHandle = y.watch(
42
43
  () => this.view.scale,
43
- (t, r) => {
44
- t > this.crossScale && r <= this.crossScale ? (this.crossLayer.graphics.forEach((i) => {
45
- i.symbol = {
46
- type: "simple-marker",
47
- style: i.getAttribute("isKey") ? "diamond" : "circle",
48
- color: i.getAttribute("color"),
49
- size: i.getAttribute("isKey") ? 16 : 8,
50
- outline: {
51
- color: i.getAttribute("isKey") ? "red" : "white",
52
- width: i.getAttribute("isKey") ? 2 : 1
53
- }
54
- };
55
- }), this.highlightLayer.graphics.forEach((i) => {
56
- i.getAttribute("type") === "cross" && (i.symbol = {
57
- type: "simple-marker",
58
- style: i.getAttribute("isKey") ? "diamond" : "circle",
59
- color: i.getAttribute("color"),
60
- size: i.getAttribute("isKey") ? 16 : 8,
61
- outline: {
62
- color: i.getAttribute("isKey") ? "red" : "white",
63
- width: i.getAttribute("isKey") ? 2 : 1
64
- }
65
- });
66
- })) : t <= this.crossScale && r > this.crossScale && (this.crossLayer.graphics.forEach((i) => {
67
- i.symbol = {
68
- type: "picture-marker",
69
- url: `/GisViewerAssets/Images/xhj_${i.getAttribute("isKey") ? 4 : 1}.png`,
70
- width: i.getAttribute("isKey") ? "55px" : "37px",
71
- height: i.getAttribute("isKey") ? "85px" : "57px",
72
- yoffset: i.getAttribute("isKey") ? "37px" : "25px"
73
- };
74
- }), this.highlightLayer.graphics.forEach((i) => {
75
- i.getAttribute("type") === "cross" && (i.symbol = {
76
- type: "picture-marker",
77
- url: `/GisViewerAssets/Images/xhj_${i.getAttribute("isKey") ? 4 : 1}.png`,
78
- width: i.getAttribute("isKey") ? "55px" : "37px",
79
- height: i.getAttribute("isKey") ? "85px" : "57px",
80
- yoffset: i.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
102
  const t = this.findAreaGraphic(e.id);
92
- if (t) {
93
- t.attributes.type === "cross" ? await this.view.goTo({
94
- target: t.geometry,
95
- scale: 1500
96
- }) : await this.view.goTo(t.geometry);
97
- const r = t.geometry.type === "point" ? t.geometry : t.geometry.centroid;
98
- return this.view.openPopup({
99
- features: [t],
100
- location: r
101
- }), { status: 0, message: "ok" };
102
- } else
103
- return { status: 1, message: "未找到" };
103
+ return t ? (t.attributes.type === "cross" ? await this.view.goTo({
104
+ target: t.geometry,
105
+ scale: 1500
106
+ }) : await this.view.goTo(t.geometry), this.showPopup(t), { status: 0, message: "ok" }) : { status: 1, message: "未找到" };
107
+ }
108
+ showPopup(e) {
109
+ const t = e.geometry.type === "point" ? e.geometry : e.geometry.centroid;
110
+ this.view.openPopup({
111
+ features: [e],
112
+ location: t
113
+ });
104
114
  }
105
115
  async highlightSignalControlArea(e) {
106
116
  this.highlightLayer.removeAll(), this.districtControllerLayer.visible = !1, this.subDistrictControllerLayer.visible = !1, this.crossLayer.visible = !1;
107
- const t = this.districtControllerLayer.graphics.filter((s) => s.getAttribute("id") === e.id).toArray().map((s) => s.clone()), r = this.subDistrictControllerLayer.graphics.filter(
117
+ const t = this.districtControllerLayer.graphics.filter((s) => s.getAttribute("id") === e.id).toArray().map((s) => s.clone()), i = this.subDistrictControllerLayer.graphics.filter(
108
118
  (s) => s.getAttribute("id") === e.id || s.getAttribute("parentId") === e.id
109
- ).toArray().map((s) => s.clone()), i = this.crossLayer.graphics.filter(
119
+ ).toArray().map((s) => s.clone()), r = this.crossLayer.graphics.filter(
110
120
  (s) => s.getAttribute("id") === e.id || s.getAttribute("districtId") === e.id || s.getAttribute("subDistrictId") === e.id
111
121
  ).toArray().map((s) => s.clone());
112
- return t.length > 0 && this.highlightLayer.addMany(t), r.length > 0 && this.highlightLayer.addMany(r), i.length > 0 && this.highlightLayer.addMany(i), this.highlightLayer.graphics.length === 0 ? { status: 1, message: "未找到" } : (t.length > 0 ? await this.view.goTo(t) : r.length > 0 ? await this.view.goTo(r) : i.length > 1 ? await this.view.goTo(i) : await this.view.goTo({
113
- target: i[0].geometry,
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,
114
124
  scale: 1500
115
- }), { status: 0, message: "ok" });
125
+ }), this.showPopup(r[0])), { status: 0, message: "ok" });
116
126
  }
117
127
  resetHighlight() {
118
128
  return this.highlightLayer.removeAll(), this.districtControllerLayer.visible = !0, this.subDistrictControllerLayer.visible = !0, this.crossLayer.visible = !0, { status: 0, message: "ok" };
@@ -124,11 +134,11 @@ class C {
124
134
  */
125
135
  findAreaGraphic(e) {
126
136
  let t = this.districtControllerLayer.graphics.find(
127
- (r) => r.attributes.id === e
137
+ (i) => i.attributes.id === e
128
138
  );
129
139
  return t || (t = this.subDistrictControllerLayer.graphics.find(
130
- (r) => r.attributes.id === e
131
- )), t || (t = this.crossLayer.graphics.find((r) => r.attributes.id === e)), t;
140
+ (i) => i.attributes.id === e
141
+ )), t || (t = this.crossLayer.graphics.find((i) => i.attributes.id === e)), t;
132
142
  }
133
143
  /**
134
144
  * 绘制区控与子区
@@ -137,20 +147,22 @@ class C {
137
147
  * @returns
138
148
  */
139
149
  drawArea(e, t) {
140
- const r = e.getAllCrossCoordinates();
141
- if (r.length >= 2) {
150
+ const i = e.getAllCrossCoordinates();
151
+ if (i.length >= 2) {
142
152
  let s = null;
143
- if (r.length === 2)
144
- s = l.lineString(r);
145
- else if (r.length > 2) {
146
- const u = l.featureCollection(
147
- r.map((c) => l.point(c))
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))
148
158
  );
149
- s = d(u);
159
+ s = d(c, { maxEdge: 400, units: "meters" }), s || (s = f(c));
150
160
  }
151
- if (!s)
161
+ if (!s) {
162
+ console.log("生成区控面失败", e);
152
163
  return;
153
- const y = m(
164
+ }
165
+ const a = p(
154
166
  s.geometry,
155
167
  // 区控面积更大,需要更大的缓冲半径
156
168
  t ? 200 : 30,
@@ -158,8 +170,8 @@ class C {
158
170
  units: "meters"
159
171
  }
160
172
  );
161
- let o;
162
- t ? o = [
173
+ let l;
174
+ t ? l = [
163
175
  {
164
176
  fieldName: "id",
165
177
  label: "区控编号"
@@ -172,7 +184,7 @@ class C {
172
184
  fieldName: "subDistrictCount",
173
185
  label: "子区数量"
174
186
  }
175
- ] : o = [
187
+ ] : l = [
176
188
  {
177
189
  fieldName: "parentName",
178
190
  label: "所属区控"
@@ -182,10 +194,18 @@ class C {
182
194
  label: "路口数量"
183
195
  }
184
196
  ];
185
- const n = new h({
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({
186
206
  geometry: {
187
207
  type: "polygon",
188
- rings: y.geometry.coordinates
208
+ rings: a.geometry.coordinates
189
209
  },
190
210
  symbol: {
191
211
  type: "simple-fill",
@@ -196,21 +216,13 @@ class C {
196
216
  style: t ? "solid" : "long-dash"
197
217
  }
198
218
  },
199
- attributes: {
200
- type: "signalControlArea",
201
- id: e.id,
202
- name: e.name,
203
- parentId: e.parentId,
204
- parentName: e.parentName,
205
- crossCount: e.crossCount,
206
- subDistrictCount: e.subDistrictCount
207
- },
219
+ attributes: m,
208
220
  popupTemplate: {
209
221
  title: `${t ? "区控" : "子区"} ${e.name}`,
210
222
  content: [
211
223
  {
212
224
  type: "fields",
213
- fieldInfos: o
225
+ fieldInfos: l
214
226
  }
215
227
  ]
216
228
  }
@@ -219,23 +231,8 @@ class C {
219
231
  }
220
232
  for (const s of e.subDistricts)
221
233
  this.drawArea(s, !1);
222
- const i = e.crosses.map((s) => new h({
223
- geometry: {
224
- type: "point",
225
- x: s.longitude,
226
- y: s.latitude
227
- },
228
- symbol: {
229
- type: "simple-marker",
230
- style: s.isKey ? "diamond" : "circle",
231
- color: e.areaColor,
232
- size: s.isKey ? 16 : 8,
233
- outline: {
234
- color: s.isKey ? "red" : "white",
235
- width: s.isKey ? 2 : 1
236
- }
237
- },
238
- attributes: {
234
+ const r = e.crosses.map((s) => {
235
+ const a = {
239
236
  type: "cross",
240
237
  id: s.id,
241
238
  name: s.name,
@@ -246,37 +243,46 @@ class C {
246
243
  subDistrictId: t ? "" : e.id,
247
244
  subDistrictName: t ? "" : e.name,
248
245
  isKey: s.isKey
249
- },
250
- popupTemplate: {
251
- title: s.name,
252
- content: [
253
- {
254
- type: "fields",
255
- fieldInfos: [
256
- {
257
- fieldName: "districtName",
258
- label: "区控名称"
259
- },
260
- {
261
- fieldName: "subDistrictName",
262
- label: "子区名称"
263
- },
264
- {
265
- fieldName: "id",
266
- label: "路口编号"
267
- },
268
- {
269
- fieldName: "signalId",
270
- label: "信号机编号"
271
- }
272
- ]
273
- }
274
- ]
275
- }
276
- }));
277
- this.crossLayer.addMany(i);
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);
278
284
  }
279
285
  }
280
286
  export {
281
- C as default
287
+ G as default
282
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,10 +9,18 @@ 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;
15
22
  }): Promise<IResult>;
23
+ private showPopup;
16
24
  highlightSignalControlArea(params: {
17
25
  id: string;
18
26
  }): Promise<IResult>;
@@ -1 +1 @@
1
- "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const m=require("@arcgis/core/core/reactiveUtils.js"),u=require("@arcgis/core/Graphic"),l=require("@arcgis/core/layers/GraphicsLayer"),b=require("@turf/buffer"),f=require("@turf/convex"),p=require("@turf/helpers"),A=require("./district-controller.js");function c(a){const e=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(a){for(const t in a)if(t!=="default"){const r=Object.getOwnPropertyDescriptor(a,t);Object.defineProperty(e,t,r.get?r:{enumerable:!0,get:()=>a[t]})}}return e.default=a,Object.freeze(e)}const L=c(m),n=c(p);class w{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 r=new A.default(t);this.drawArea(r,!0)}return this.watchHandle=L.watch(()=>this.view.scale,(t,r)=>{t>this.crossScale&&r<=this.crossScale?(this.crossLayer.graphics.forEach(i=>{i.symbol={type:"simple-marker",style:i.getAttribute("isKey")?"diamond":"circle",color:i.getAttribute("color"),size:i.getAttribute("isKey")?16:8,outline:{color:i.getAttribute("isKey")?"red":"white",width:i.getAttribute("isKey")?2:1}}}),this.highlightLayer.graphics.forEach(i=>{i.getAttribute("type")==="cross"&&(i.symbol={type:"simple-marker",style:i.getAttribute("isKey")?"diamond":"circle",color:i.getAttribute("color"),size:i.getAttribute("isKey")?16:8,outline:{color:i.getAttribute("isKey")?"red":"white",width:i.getAttribute("isKey")?2:1}})})):t<=this.crossScale&&r>this.crossScale&&(this.crossLayer.graphics.forEach(i=>{i.symbol={type:"picture-marker",url:`/GisViewerAssets/Images/xhj_${i.getAttribute("isKey")?4:1}.png`,width:i.getAttribute("isKey")?"55px":"37px",height:i.getAttribute("isKey")?"85px":"57px",yoffset:i.getAttribute("isKey")?"37px":"25px"}}),this.highlightLayer.graphics.forEach(i=>{i.getAttribute("type")==="cross"&&(i.symbol={type:"picture-marker",url:`/GisViewerAssets/Images/xhj_${i.getAttribute("isKey")?4:1}.png`,width:i.getAttribute("isKey")?"55px":"37px",height:i.getAttribute("isKey")?"85px":"57px",yoffset:i.getAttribute("isKey")?"37px":"25px"})}))}),{status:0,message:"ok"}}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);if(t){t.attributes.type==="cross"?await this.view.goTo({target:t.geometry,scale:1500}):await this.view.goTo(t.geometry);const r=t.geometry.type==="point"?t.geometry:t.geometry.centroid;return this.view.openPopup({features:[t],location:r}),{status:0,message:"ok"}}else return{status:1,message:"未找到"}}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()),r=this.subDistrictControllerLayer.graphics.filter(s=>s.getAttribute("id")===e.id||s.getAttribute("parentId")===e.id).toArray().map(s=>s.clone()),i=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),r.length>0&&this.highlightLayer.addMany(r),i.length>0&&this.highlightLayer.addMany(i),this.highlightLayer.graphics.length===0?{status:1,message:"未找到"}:(t.length>0?await this.view.goTo(t):r.length>0?await this.view.goTo(r):i.length>1?await this.view.goTo(i):await this.view.goTo({target:i[0].geometry,scale:1500}),{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(r=>r.attributes.id===e);return t||(t=this.subDistrictControllerLayer.graphics.find(r=>r.attributes.id===e)),t||(t=this.crossLayer.graphics.find(r=>r.attributes.id===e)),t}drawArea(e,t){const r=e.getAllCrossCoordinates();if(r.length>=2){let s=null;if(r.length===2)s=n.lineString(r);else if(r.length>2){const g=n.featureCollection(r.map(d=>n.point(d)));s=f(g)}if(!s)return;const y=b(s.geometry,t?200:30,{units:"meters"});let o;t?o=[{fieldName:"id",label:"区控编号"},{fieldName:"crossCount",label:"路口数量"},{fieldName:"subDistrictCount",label:"子区数量"}]:o=[{fieldName:"parentName",label:"所属区控"},{fieldName:"crossCount",label:"路口数量"}];const h=new u({geometry:{type:"polygon",rings:y.geometry.coordinates},symbol:{type:"simple-fill",color:[...e.areaColor,t?.6:.8],outline:{color:e.areaColor,width:2,style:t?"solid":"long-dash"}},attributes:{type:"signalControlArea",id:e.id,name:e.name,parentId:e.parentId,parentName:e.parentName,crossCount:e.crossCount,subDistrictCount:e.subDistrictCount},popupTemplate:{title:`${t?"区控":"子区"} ${e.name}`,content:[{type:"fields",fieldInfos:o}]}});t?this.districtControllerLayer.add(h):this.subDistrictControllerLayer.add(h)}for(const s of e.subDistricts)this.drawArea(s,!1);const i=e.crosses.map(s=>new u({geometry:{type:"point",x:s.longitude,y:s.latitude},symbol:{type:"simple-marker",style:s.isKey?"diamond":"circle",color:e.areaColor,size:s.isKey?16:8,outline:{color:s.isKey?"red":"white",width:s.isKey?2:1}},attributes:{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},popupTemplate:{title:s.name,content:[{type:"fields",fieldInfos:[{fieldName:"districtName",label:"区控名称"},{fieldName:"subDistrictName",label:"子区名称"},{fieldName:"id",label:"路口编号"},{fieldName:"signalId",label:"信号机编号"}]}]}}));this.crossLayer.addMany(i)}}exports.default=w;
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.138",
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",