gisviewer-vue3-arcgis 1.0.139 → 1.0.141

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
  };
@@ -31,4 +31,11 @@ export default class SignalControlAreaController {
31
31
  * @returns
32
32
  */
33
33
  private drawArea;
34
+ /**
35
+ * 生成路口点符号。在不同比例尺下,使用不同的符号
36
+ * @param attributes
37
+ * @param symbolType
38
+ * @returns
39
+ */
40
+ private getCrossGraphicSymbol;
34
41
  }
@@ -1,11 +1,12 @@
1
- import * as g from "@arcgis/core/core/reactiveUtils.js";
2
- import n from "@arcgis/core/Graphic";
1
+ import * as p from "@arcgis/core/core/reactiveUtils.js";
2
+ import y from "@arcgis/core/Graphic";
3
3
  import o from "@arcgis/core/layers/GraphicsLayer";
4
- import m from "@turf/buffer";
5
- import d from "@turf/convex";
6
- import * as l from "@turf/helpers";
7
- import p from "./district-controller.mjs";
8
- class C {
4
+ import g from "@turf/buffer";
5
+ import d from "@turf/concave";
6
+ import f from "@turf/convex";
7
+ import * as n from "@turf/helpers";
8
+ import b from "./district-controller.mjs";
9
+ class x {
9
10
  constructor(e) {
10
11
  this.crossScale = 3e3, this.view = e, this.view.popup.visibleElements = {
11
12
  closeButton: !0,
@@ -34,51 +35,33 @@ 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 i of e) {
38
- const r = new p(i);
39
- this.drawArea(r, !0);
38
+ for (const t of e) {
39
+ const i = new b(t);
40
+ this.drawArea(i, !0);
40
41
  }
41
- return this.watchHandle = g.watch(
42
+ return this.watchHandle = p.watch(
42
43
  () => this.view.scale,
43
- (i, r) => {
44
- i > this.crossScale && r <= this.crossScale ? (this.crossLayer.graphics.forEach((t) => {
45
- t.symbol = {
46
- type: "simple-marker",
47
- style: t.getAttribute("isKey") ? "diamond" : "circle",
48
- color: t.getAttribute("color"),
49
- size: t.getAttribute("isKey") ? 16 : 8,
50
- outline: {
51
- color: t.getAttribute("isKey") ? "red" : "white",
52
- width: t.getAttribute("isKey") ? 2 : 1
53
- }
54
- };
55
- }), this.highlightLayer.graphics.forEach((t) => {
56
- t.getAttribute("type") === "cross" && (t.symbol = {
57
- type: "simple-marker",
58
- style: t.getAttribute("isKey") ? "diamond" : "circle",
59
- color: t.getAttribute("color"),
60
- size: t.getAttribute("isKey") ? 16 : 8,
61
- outline: {
62
- color: t.getAttribute("isKey") ? "red" : "white",
63
- width: t.getAttribute("isKey") ? 2 : 1
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((s) => {
46
+ s.symbol = this.getCrossGraphicSymbol(
47
+ s.attributes,
48
+ "marker"
49
+ );
50
+ }), this.highlightLayer.graphics.forEach((s) => {
51
+ s.getAttribute("type") === "cross" && (s.symbol = this.getCrossGraphicSymbol(
52
+ s.attributes,
53
+ "marker"
54
+ ));
55
+ })) : t <= this.crossScale && i > this.crossScale && (this.crossLayer.graphics.forEach((s) => {
56
+ s.symbol = this.getCrossGraphicSymbol(
57
+ s.attributes,
58
+ "picture"
59
+ );
60
+ }), this.highlightLayer.graphics.forEach((s) => {
61
+ s.getAttribute("type") === "cross" && (s.symbol = this.getCrossGraphicSymbol(
62
+ s.attributes,
63
+ "picture"
64
+ ));
82
65
  }));
83
66
  }
84
67
  ), { status: 0, message: "ok" };
@@ -88,30 +71,30 @@ class C {
88
71
  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
72
  }
90
73
  async locateSignalControlArea(e) {
91
- const i = this.findAreaGraphic(e.id);
92
- return i ? (i.attributes.type === "cross" ? await this.view.goTo({
93
- target: i.geometry,
74
+ const t = this.findAreaGraphic(e.id);
75
+ return t ? (t.attributes.type === "cross" ? await this.view.goTo({
76
+ target: t.geometry,
94
77
  scale: 1500
95
- }) : await this.view.goTo(i.geometry), this.showPopup(i), { status: 0, message: "ok" }) : { status: 1, message: "未找到" };
78
+ }) : await this.view.goTo(t.geometry), this.showPopup(t), { status: 0, message: "ok" }) : { status: 1, message: "未找到" };
96
79
  }
97
80
  showPopup(e) {
98
- const i = e.geometry.type === "point" ? e.geometry : e.geometry.centroid;
81
+ const t = e.geometry.type === "point" ? e.geometry : e.geometry.centroid;
99
82
  this.view.openPopup({
100
83
  features: [e],
101
- location: i
84
+ location: t
102
85
  });
103
86
  }
104
87
  async highlightSignalControlArea(e) {
105
88
  this.highlightLayer.removeAll(), this.districtControllerLayer.visible = !1, this.subDistrictControllerLayer.visible = !1, this.crossLayer.visible = !1;
106
- const i = this.districtControllerLayer.graphics.filter((s) => s.getAttribute("id") === e.id).toArray().map((s) => s.clone()), r = this.subDistrictControllerLayer.graphics.filter(
107
- (s) => s.getAttribute("id") === e.id || s.getAttribute("parentId") === e.id
108
- ).toArray().map((s) => s.clone()), t = this.crossLayer.graphics.filter(
109
- (s) => s.getAttribute("id") === e.id || s.getAttribute("districtId") === e.id || s.getAttribute("subDistrictId") === e.id
110
- ).toArray().map((s) => s.clone());
111
- return i.length > 0 && this.highlightLayer.addMany(i), r.length > 0 && (this.highlightLayer.addMany(r), this.showPopup(r[0])), t.length > 0 && this.highlightLayer.addMany(t), this.highlightLayer.graphics.length === 0 ? { status: 1, message: "未找到" } : (i.length > 0 ? (await this.view.goTo(i), this.showPopup(i[0])) : r.length > 0 ? (await this.view.goTo(r), this.showPopup(r[0])) : (t.length > 1 ? await this.view.goTo(t) : await this.view.goTo({
112
- target: t[0].geometry,
89
+ const t = this.districtControllerLayer.graphics.filter((r) => r.getAttribute("id") === e.id).toArray().map((r) => r.clone()), i = this.subDistrictControllerLayer.graphics.filter(
90
+ (r) => r.getAttribute("id") === e.id || r.getAttribute("parentId") === e.id
91
+ ).toArray().map((r) => r.clone()), s = this.crossLayer.graphics.filter(
92
+ (r) => r.getAttribute("id") === e.id || r.getAttribute("districtId") === e.id || r.getAttribute("subDistrictId") === e.id
93
+ ).toArray().map((r) => r.clone());
94
+ return t.length > 0 && this.highlightLayer.addMany(t), i.length > 0 && (this.highlightLayer.addMany(i), this.showPopup(i[0])), s.length > 0 && this.highlightLayer.addMany(s), 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])) : (s.length > 1 ? await this.view.goTo(s) : await this.view.goTo({
95
+ target: s[0].geometry,
113
96
  scale: 1500
114
- }), this.showPopup(t[0])), { status: 0, message: "ok" });
97
+ }), this.showPopup(s[0])), { status: 0, message: "ok" });
115
98
  }
116
99
  resetHighlight() {
117
100
  return this.highlightLayer.removeAll(), this.districtControllerLayer.visible = !0, this.subDistrictControllerLayer.visible = !0, this.crossLayer.visible = !0, { status: 0, message: "ok" };
@@ -122,12 +105,12 @@ class C {
122
105
  * @returns
123
106
  */
124
107
  findAreaGraphic(e) {
125
- let i = this.districtControllerLayer.graphics.find(
126
- (r) => r.attributes.id === e
108
+ let t = this.districtControllerLayer.graphics.find(
109
+ (i) => i.attributes.id === e
127
110
  );
128
- return i || (i = this.subDistrictControllerLayer.graphics.find(
129
- (r) => r.attributes.id === e
130
- )), i || (i = this.crossLayer.graphics.find((r) => r.attributes.id === e)), i;
111
+ return t || (t = this.subDistrictControllerLayer.graphics.find(
112
+ (i) => i.attributes.id === e
113
+ )), t || (t = this.crossLayer.graphics.find((i) => i.attributes.id === e)), t;
131
114
  }
132
115
  /**
133
116
  * 绘制区控与子区
@@ -135,30 +118,32 @@ class C {
135
118
  * @param isDistrict 是否是区控
136
119
  * @returns
137
120
  */
138
- drawArea(e, i) {
139
- const r = e.getAllCrossCoordinates();
140
- if (r.length >= 2) {
141
- let s = null;
142
- if (r.length === 2)
143
- s = l.lineString(r);
144
- else if (r.length > 2) {
145
- const u = l.featureCollection(
146
- r.map((c) => l.point(c))
121
+ drawArea(e, t) {
122
+ const i = e.getAllCrossCoordinates();
123
+ if (i.length >= 2) {
124
+ let r = null;
125
+ if (i.length === 2)
126
+ r = n.lineString(i);
127
+ else if (i.length > 2) {
128
+ const c = n.featureCollection(
129
+ i.map((u) => n.point(u))
147
130
  );
148
- s = d(u);
131
+ r = d(c, { maxEdge: 400, units: "meters" }), r || (r = f(c));
149
132
  }
150
- if (!s)
133
+ if (!r) {
134
+ console.log("生成区控面失败", e);
151
135
  return;
152
- const y = m(
153
- s.geometry,
136
+ }
137
+ const a = g(
138
+ r.geometry,
154
139
  // 区控面积更大,需要更大的缓冲半径
155
- i ? 200 : 30,
140
+ t ? 200 : 30,
156
141
  {
157
142
  units: "meters"
158
143
  }
159
144
  );
160
- let a;
161
- i ? a = [
145
+ let l;
146
+ t ? l = [
162
147
  {
163
148
  fieldName: "id",
164
149
  label: "区控编号"
@@ -171,7 +156,7 @@ class C {
171
156
  fieldName: "subDistrictCount",
172
157
  label: "子区数量"
173
158
  }
174
- ] : a = [
159
+ ] : l = [
175
160
  {
176
161
  fieldName: "parentName",
177
162
  label: "所属区控"
@@ -181,101 +166,207 @@ class C {
181
166
  label: "路口数量"
182
167
  }
183
168
  ];
184
- const h = new n({
169
+ const m = {
170
+ type: "signalControlArea",
171
+ id: e.id,
172
+ name: e.name,
173
+ parentId: e.parentId,
174
+ parentName: e.parentName,
175
+ crossCount: e.crossCount,
176
+ subDistrictCount: e.subDistrictCount
177
+ }, h = new y({
185
178
  geometry: {
186
179
  type: "polygon",
187
- rings: y.geometry.coordinates
180
+ rings: a.geometry.coordinates
188
181
  },
189
182
  symbol: {
190
183
  type: "simple-fill",
191
- color: [...e.areaColor, i ? 0.6 : 0.8],
184
+ color: [...e.areaColor, t ? 0.6 : 0.8],
192
185
  outline: {
193
186
  color: e.areaColor,
194
187
  width: 2,
195
- style: i ? "solid" : "long-dash"
188
+ style: t ? "solid" : "long-dash"
196
189
  }
197
190
  },
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
- },
191
+ attributes: m,
207
192
  popupTemplate: {
208
- title: `${i ? "区控" : "子区"} ${e.name}`,
193
+ title: `${t ? "区控" : "子区"} ${e.name}`,
209
194
  content: [
210
195
  {
211
196
  type: "fields",
212
- fieldInfos: a
197
+ fieldInfos: l
213
198
  }
214
199
  ]
215
200
  }
216
201
  });
217
- i ? this.districtControllerLayer.add(h) : this.subDistrictControllerLayer.add(h);
202
+ t ? this.districtControllerLayer.add(h) : this.subDistrictControllerLayer.add(h);
218
203
  }
219
- for (const s of e.subDistricts)
220
- this.drawArea(s, !1);
221
- const t = e.crosses.map((s) => new n({
222
- geometry: {
223
- type: "point",
224
- x: s.longitude,
225
- y: s.latitude
226
- },
227
- symbol: {
228
- type: "simple-marker",
229
- style: s.isKey ? "diamond" : "circle",
204
+ for (const r of e.subDistricts)
205
+ this.drawArea(r, !1);
206
+ const s = e.crosses.map((r) => {
207
+ const a = {
208
+ type: "cross",
209
+ id: r.id,
210
+ name: r.name,
230
211
  color: e.areaColor,
231
- size: s.isKey ? 16 : 8,
212
+ signalId: r.signalId,
213
+ districtId: t ? e.id : e.parentId,
214
+ districtName: t ? e.name : e.parentName,
215
+ subDistrictId: t ? "" : e.id,
216
+ subDistrictName: t ? "" : e.name,
217
+ isKey: r.isKey
218
+ };
219
+ return new y({
220
+ geometry: {
221
+ type: "point",
222
+ x: r.longitude,
223
+ y: r.latitude
224
+ },
225
+ symbol: this.getCrossGraphicSymbol(a, "marker"),
226
+ attributes: a,
227
+ popupTemplate: {
228
+ title: r.name,
229
+ content: [
230
+ {
231
+ type: "fields",
232
+ fieldInfos: [
233
+ {
234
+ fieldName: "districtName",
235
+ label: "区控名称"
236
+ },
237
+ {
238
+ fieldName: "subDistrictName",
239
+ label: "子区名称"
240
+ },
241
+ {
242
+ fieldName: "id",
243
+ label: "路口编号"
244
+ },
245
+ {
246
+ fieldName: "signalId",
247
+ label: "信号机编号"
248
+ }
249
+ ]
250
+ }
251
+ ]
252
+ }
253
+ });
254
+ });
255
+ this.crossLayer.addMany(s);
256
+ }
257
+ /**
258
+ * 生成路口点符号。在不同比例尺下,使用不同的符号
259
+ * @param attributes
260
+ * @param symbolType
261
+ * @returns
262
+ */
263
+ getCrossGraphicSymbol(e, t) {
264
+ const { isKey: i, color: s } = e;
265
+ if (t === "marker")
266
+ return {
267
+ type: "simple-marker",
268
+ style: i ? "diamond" : "circle",
269
+ color: s,
270
+ size: i ? 16 : 8,
232
271
  outline: {
233
- color: s.isKey ? "red" : "white",
234
- width: s.isKey ? 2 : 1
272
+ color: i ? "red" : "white",
273
+ width: i ? 2 : 1
235
274
  }
236
- },
237
- attributes: {
238
- type: "cross",
239
- id: s.id,
240
- name: s.name,
241
- color: e.areaColor,
242
- signalId: s.signalId,
243
- districtId: i ? e.id : e.parentId,
244
- districtName: i ? e.name : e.parentName,
245
- subDistrictId: i ? "" : e.id,
246
- subDistrictName: i ? "" : e.name,
247
- isKey: s.isKey
248
- },
249
- popupTemplate: {
250
- title: s.name,
251
- content: [
252
- {
253
- type: "fields",
254
- fieldInfos: [
255
- {
256
- fieldName: "districtName",
257
- label: "区控名称"
258
- },
259
- {
260
- fieldName: "subDistrictName",
261
- label: "子区名称"
262
- },
275
+ };
276
+ if (t === "picture")
277
+ return {
278
+ // type: 'picture-marker',
279
+ // url: `/GisViewerAssets/Images/xhj_${isKey ? 4 : 1}.png`,
280
+ // width: isKey ? '55px' : '37px',
281
+ // height: isKey ? '85px' : '57px',
282
+ // yoffset: isKey ? '37px' : '25px'
283
+ type: "cim",
284
+ data: {
285
+ type: "CIMSymbolReference",
286
+ primitiveOverrides: [
287
+ {
288
+ // 将textGraphic的TextString替换为graphic.attributes.showName
289
+ type: "CIMPrimitiveOverride",
290
+ primitiveName: "textGraphic",
291
+ propertyName: "TextString",
292
+ valueExpressionInfo: {
293
+ type: "CIMExpressionInfo",
294
+ title: "Custom",
295
+ expression: 'Replace($feature.name, "", "/") + " " + $feature.signalId',
296
+ returnType: "Default"
297
+ }
298
+ }
299
+ ],
300
+ symbol: {
301
+ type: "CIMPointSymbol",
302
+ symbolLayers: [
303
+ // 车辆号牌
263
304
  {
264
- fieldName: "id",
265
- label: "路口编号"
305
+ type: "CIMVectorMarker",
306
+ size: 32,
307
+ colorLocked: !0,
308
+ anchorPointUnits: "Relative",
309
+ frame: { xmin: -16, ymin: -16, xmax: 16, ymax: 16 },
310
+ markerGraphics: [
311
+ {
312
+ type: "CIMMarkerGraphic",
313
+ primitiveName: "textGraphic",
314
+ geometry: { x: 0, y: 0 },
315
+ symbol: {
316
+ type: "CIMTextSymbol",
317
+ height: 12,
318
+ horizontalAlignment: "Center",
319
+ offsetX: 0,
320
+ offsetY: i ? 30 : 22,
321
+ haloSize: 1,
322
+ haloSymbol: {
323
+ type: "CIMPolygonSymbol",
324
+ symbolLayers: [
325
+ {
326
+ type: "CIMSolidFill",
327
+ enable: !0,
328
+ color: [255, 255, 255, 255]
329
+ }
330
+ ]
331
+ },
332
+ symbol: {
333
+ type: "CIMPolygonSymbol",
334
+ symbolLayers: [
335
+ {
336
+ type: "CIMSolidFill",
337
+ enable: !0,
338
+ color: [0, 0, 0, 255]
339
+ }
340
+ ]
341
+ },
342
+ verticalAlignment: "Center"
343
+ },
344
+ textString: ""
345
+ }
346
+ ],
347
+ scaleSymbolsProportionally: !0,
348
+ respectFrame: !0
266
349
  },
350
+ // 车辆图标
267
351
  {
268
- fieldName: "signalId",
269
- label: "信号机编号"
352
+ type: "CIMPictureMarker",
353
+ enable: !0,
354
+ anchorPoint: {
355
+ x: 0,
356
+ y: 0
357
+ },
358
+ anchorPointUnits: "Relative",
359
+ size: i ? 45 : 30,
360
+ rotateClockwise: !0,
361
+ textureFilter: "Picture",
362
+ url: `/GisViewerAssets/Images/xhj_${i ? 4 : 1}.png`
270
363
  }
271
364
  ]
272
365
  }
273
- ]
274
- }
275
- }));
276
- this.crossLayer.addMany(t);
366
+ }
367
+ };
277
368
  }
278
369
  }
279
370
  export {
280
- C as default
371
+ x as default
281
372
  };
@@ -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;
@@ -31,4 +31,11 @@ export default class SignalControlAreaController {
31
31
  * @returns
32
32
  */
33
33
  private drawArea;
34
+ /**
35
+ * 生成路口点符号。在不同比例尺下,使用不同的符号
36
+ * @param attributes
37
+ * @param symbolType
38
+ * @returns
39
+ */
40
+ private getCrossGraphicSymbol;
34
41
  }
@@ -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"),o=require("@arcgis/core/layers/GraphicsLayer"),b=require("@turf/buffer"),p=require("@turf/convex"),f=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 w=c(m),n=c(f);class L{constructor(e){this.crossScale=3e3,this.view=e,this.view.popup.visibleElements={closeButton:!0,collapseButton:!1,actionBar:!0},this.districtControllerLayer=new o({id:"districtControllerLayer",maxScale:144447,minScale:1155582}),this.subDistrictControllerLayer=new o({id:"subDistrictControllerLayer",maxScale:0,minScale:144447}),this.crossLayer=new o({id:"crossLayer",maxScale:0,minScale:36112}),this.highlightLayer=new o({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=w.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);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()),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),this.showPopup(r[0])),i.length>0&&this.highlightLayer.addMany(i),this.highlightLayer.graphics.length===0?{status:1,message:"未找到"}:(t.length>0?(await this.view.goTo(t),this.showPopup(t[0])):r.length>0?(await this.view.goTo(r),this.showPopup(r[0])):(i.length>1?await this.view.goTo(i):await this.view.goTo({target:i[0].geometry,scale:1500}),this.showPopup(i[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(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=p(g)}if(!s)return;const y=b(s.geometry,t?200:30,{units:"meters"});let l;t?l=[{fieldName:"id",label:"区控编号"},{fieldName:"crossCount",label:"路口数量"},{fieldName:"subDistrictCount",label:"子区数量"}]:l=[{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:l}]}});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=L;
1
+ "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const d=require("@arcgis/core/core/reactiveUtils.js"),y=require("@arcgis/core/Graphic"),l=require("@arcgis/core/layers/GraphicsLayer"),b=require("@turf/buffer"),f=require("@turf/concave"),L=require("@turf/convex"),v=require("@turf/helpers"),C=require("./district-controller.js");function m(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 w=m(d),h=m(v);class S{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 C.default(t);this.drawArea(i,!0)}return this.watchHandle=w.watch(()=>this.view.scale,(t,i)=>{t>this.crossScale&&i<=this.crossScale?(this.crossLayer.graphics.forEach(s=>{s.symbol=this.getCrossGraphicSymbol(s.attributes,"marker")}),this.highlightLayer.graphics.forEach(s=>{s.getAttribute("type")==="cross"&&(s.symbol=this.getCrossGraphicSymbol(s.attributes,"marker"))})):t<=this.crossScale&&i>this.crossScale&&(this.crossLayer.graphics.forEach(s=>{s.symbol=this.getCrossGraphicSymbol(s.attributes,"picture")}),this.highlightLayer.graphics.forEach(s=>{s.getAttribute("type")==="cross"&&(s.symbol=this.getCrossGraphicSymbol(s.attributes,"picture"))}))}),{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);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(r=>r.getAttribute("id")===e.id).toArray().map(r=>r.clone()),i=this.subDistrictControllerLayer.graphics.filter(r=>r.getAttribute("id")===e.id||r.getAttribute("parentId")===e.id).toArray().map(r=>r.clone()),s=this.crossLayer.graphics.filter(r=>r.getAttribute("id")===e.id||r.getAttribute("districtId")===e.id||r.getAttribute("subDistrictId")===e.id).toArray().map(r=>r.clone());return t.length>0&&this.highlightLayer.addMany(t),i.length>0&&(this.highlightLayer.addMany(i),this.showPopup(i[0])),s.length>0&&this.highlightLayer.addMany(s),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])):(s.length>1?await this.view.goTo(s):await this.view.goTo({target:s[0].geometry,scale:1500}),this.showPopup(s[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 r=null;if(i.length===2)r=h.lineString(i);else if(i.length>2){const u=h.featureCollection(i.map(p=>h.point(p)));r=f(u,{maxEdge:400,units:"meters"}),r||(r=L(u))}if(!r){console.log("生成区控面失败",e);return}const o=b(r.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 g={type:"signalControlArea",id:e.id,name:e.name,parentId:e.parentId,parentName:e.parentName,crossCount:e.crossCount,subDistrictCount:e.subDistrictCount},c=new y({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:g,popupTemplate:{title:`${t?"区控":"子区"} ${e.name}`,content:[{type:"fields",fieldInfos:n}]}});t?this.districtControllerLayer.add(c):this.subDistrictControllerLayer.add(c)}for(const r of e.subDistricts)this.drawArea(r,!1);const s=e.crosses.map(r=>{const o={type:"cross",id:r.id,name:r.name,color:e.areaColor,signalId:r.signalId,districtId:t?e.id:e.parentId,districtName:t?e.name:e.parentName,subDistrictId:t?"":e.id,subDistrictName:t?"":e.name,isKey:r.isKey};return new y({geometry:{type:"point",x:r.longitude,y:r.latitude},symbol:this.getCrossGraphicSymbol(o,"marker"),attributes:o,popupTemplate:{title:r.name,content:[{type:"fields",fieldInfos:[{fieldName:"districtName",label:"区控名称"},{fieldName:"subDistrictName",label:"子区名称"},{fieldName:"id",label:"路口编号"},{fieldName:"signalId",label:"信号机编号"}]}]}})});this.crossLayer.addMany(s)}getCrossGraphicSymbol(e,t){const{isKey:i,color:s}=e;if(t==="marker")return{type:"simple-marker",style:i?"diamond":"circle",color:s,size:i?16:8,outline:{color:i?"red":"white",width:i?2:1}};if(t==="picture")return{type:"cim",data:{type:"CIMSymbolReference",primitiveOverrides:[{type:"CIMPrimitiveOverride",primitiveName:"textGraphic",propertyName:"TextString",valueExpressionInfo:{type:"CIMExpressionInfo",title:"Custom",expression:'Replace($feature.name, "与", "/") + " " + $feature.signalId',returnType:"Default"}}],symbol:{type:"CIMPointSymbol",symbolLayers:[{type:"CIMVectorMarker",size:32,colorLocked:!0,anchorPointUnits:"Relative",frame:{xmin:-16,ymin:-16,xmax:16,ymax:16},markerGraphics:[{type:"CIMMarkerGraphic",primitiveName:"textGraphic",geometry:{x:0,y:0},symbol:{type:"CIMTextSymbol",height:12,horizontalAlignment:"Center",offsetX:0,offsetY:i?30:22,haloSize:1,haloSymbol:{type:"CIMPolygonSymbol",symbolLayers:[{type:"CIMSolidFill",enable:!0,color:[255,255,255,255]}]},symbol:{type:"CIMPolygonSymbol",symbolLayers:[{type:"CIMSolidFill",enable:!0,color:[0,0,0,255]}]},verticalAlignment:"Center"},textString:""}],scaleSymbolsProportionally:!0,respectFrame:!0},{type:"CIMPictureMarker",enable:!0,anchorPoint:{x:0,y:0},anchorPointUnits:"Relative",size:i?45:30,rotateClockwise:!0,textureFilter:"Picture",url:`/GisViewerAssets/Images/xhj_${i?4:1}.png`}]}}}}}exports.default=S;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "gisviewer-vue3-arcgis",
3
- "version": "1.0.139",
3
+ "version": "1.0.141",
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",