gisviewer-vue3-arcgis 1.0.131 → 1.0.133

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.
@@ -418,7 +418,7 @@ class I {
418
418
  } else {
419
419
  t.segmentStartTime = Date.now();
420
420
  const o = a - t.segmentTotalTime;
421
- return t.segmentTotalTime = e[1].time - e[0].time - o, console.log(t.segmentStartTime, t.segmentTotalTime), (e[1].heading >= 270 && e[0].heading <= 90 || e[1].heading <= 90 && e[0].heading >= 270) && (e[1].heading > e[0].heading ? e[0].heading += 360 : e[1].heading += 360), e[0].pos.concat(e[0].heading);
421
+ return t.segmentTotalTime = e[1].time - e[0].time - o, (e[1].heading >= 270 && e[0].heading <= 90 || e[1].heading <= 90 && e[0].heading >= 270) && (e[1].heading > e[0].heading ? e[0].heading += 360 : e[1].heading += 360), e[0].pos.concat(e[0].heading);
422
422
  }
423
423
  else if (e.length >= 2) {
424
424
  const o = e[0].pos[0] + (e[1].pos[0] - e[0].pos[0]) * n, d = e[0].pos[1] + (e[1].pos[1] - e[0].pos[1]) * n, h = e[0].heading + (e[1].heading - e[0].heading) * n;
@@ -287,8 +287,8 @@ class C {
287
287
  }
288
288
  async makeMd5FromFile(e) {
289
289
  try {
290
- const s = await (await fetch(e)).text();
291
- return { status: 0, message: "ok", result: F(s) };
290
+ const i = await (await fetch(e)).text();
291
+ return { status: 0, message: "ok", result: F(i) };
292
292
  } catch (t) {
293
293
  return { status: -1, message: t.message };
294
294
  }
@@ -305,11 +305,11 @@ class C {
305
305
  if (t.status !== 0)
306
306
  return t;
307
307
  this.projectName = t.result, console.timeEnd("md5用时"), this.openDriveServer = e.server, await this.makeMd5FromFile(e.file);
308
- const s = `http://${this.openDriveServer}/api/openDrive/uploadXodr`;
308
+ const i = `http://${this.openDriveServer}/api/openDrive/uploadXodr`;
309
309
  let o;
310
310
  try {
311
311
  o = await m.post(
312
- s,
312
+ i,
313
313
  {},
314
314
  {
315
315
  params: {
@@ -324,15 +324,15 @@ class C {
324
324
  if (o.status !== 200)
325
325
  return { status: -1, message: o.statusText };
326
326
  console.time("渲染用时");
327
- const i = o.data.result.geoSetting;
327
+ const s = o.data.result.geoSetting;
328
328
  A.setGeoData(
329
- i.geoReference,
330
- i.offsetX,
331
- i.offsetY
329
+ s.geoReference,
330
+ s.offsetX,
331
+ s.offsetY
332
332
  );
333
333
  let l = o.data.result.json;
334
334
  l.startsWith(window.location.protocol) || (l = `${window.location.protocol}//${e.server}${l}`);
335
- const n = await (await fetch(l)).arrayBuffer(), r = S.inflate(n, { to: "string" }), c = JSON.parse(r);
335
+ const a = await (await fetch(l)).arrayBuffer(), r = S.inflate(a, { to: "string" }), c = JSON.parse(r);
336
336
  await this.showAllLanes(
337
337
  c,
338
338
  ((d = e.options) == null ? void 0 : d.showJunctionLane) || !1,
@@ -351,7 +351,7 @@ class C {
351
351
  * @param projectName
352
352
  */
353
353
  async showOpenDriveFromServer(e, t) {
354
- const s = `http://${e}/api/openDrive/analyzeXodr`, o = await m.get(s, {
354
+ const i = `http://${e}/api/openDrive/analyzeXodr`, o = await m.get(i, {
355
355
  headers: {
356
356
  projectName: t
357
357
  },
@@ -362,9 +362,9 @@ class C {
362
362
  });
363
363
  if (o.status !== 200)
364
364
  throw new Error(`OpenDriveRenderer: ${o.statusText}`);
365
- let i = o.data.result.json;
366
- i.startsWith(window.location.protocol) || (i = `${window.location.protocol}//${e}${i}`);
367
- const a = await (await fetch(i)).arrayBuffer(), n = S.inflate(a, { to: "string" }), r = JSON.parse(n);
365
+ let s = o.data.result.json;
366
+ 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);
368
368
  return await this.showAllLanes(r, !1, !1), { status: 0, message: "ok" };
369
369
  }
370
370
  /**
@@ -374,14 +374,14 @@ class C {
374
374
  * @param showRoadName 是否显示道路名称
375
375
  * @returns
376
376
  */
377
- async showAllLanes(e, t, s) {
377
+ async showAllLanes(e, t, i) {
378
378
  const o = await this.laneLayer.queryFeatures();
379
379
  return o.features.length > 0 && this.laneLayer.applyEdits({
380
380
  deleteFeatures: o.features
381
- }), this.roadNameLayer.visible = s, new Promise((i) => {
381
+ }), this.roadNameLayer.visible = i, new Promise((s) => {
382
382
  let l = 0;
383
383
  this.allLaneGraphics = [], this.allRefLineGraphics = [];
384
- const a = [];
384
+ const n = [];
385
385
  for (const r of e) {
386
386
  if (!t && r.junction !== "-1")
387
387
  continue;
@@ -432,15 +432,15 @@ class C {
432
432
  sumoId: ""
433
433
  }
434
434
  });
435
- this.allLaneGraphics.push(k), a.push(k);
435
+ this.allLaneGraphics.push(k), n.push(k);
436
436
  }
437
437
  }
438
438
  }
439
439
  }
440
- const n = setInterval(() => {
441
- if (a.length > 0 || this.allRefLineGraphics.length > 0) {
442
- if (a.length > 0) {
443
- const r = a.splice(0, 100);
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);
444
444
  this.laneLayer.applyEdits({
445
445
  addFeatures: r
446
446
  });
@@ -452,7 +452,7 @@ class C {
452
452
  });
453
453
  }
454
454
  } else
455
- clearInterval(n), i();
455
+ clearInterval(a), s();
456
456
  }, 10);
457
457
  });
458
458
  }
@@ -463,22 +463,24 @@ class C {
463
463
  */
464
464
  showJunction(e) {
465
465
  const t = [];
466
- for (const s of e) {
467
- s.nodeType = s.type;
466
+ for (const i of e) {
467
+ if (!i)
468
+ continue;
469
+ i.nodeType = i.type;
468
470
  const o = new p({
469
471
  geometry: {
470
472
  type: "point",
471
- x: s.coordinates[0],
472
- y: s.coordinates[1]
473
+ x: i.coordinates[0],
474
+ y: i.coordinates[1]
473
475
  },
474
476
  attributes: {
475
- ...s,
477
+ ...i,
476
478
  selected: !1,
477
479
  type: "OpenDriveJunction"
478
480
  },
479
481
  symbol: {
480
482
  type: "picture-marker",
481
- url: s.crossId ? "/GisViewerAssets/Images/point_green.png" : "/GisViewerAssets/Images/point_yellow.png",
483
+ url: i.crossId ? "/GisViewerAssets/Images/point_green.png" : "/GisViewerAssets/Images/point_yellow.png",
482
484
  width: 30,
483
485
  height: 30
484
486
  }
@@ -496,22 +498,22 @@ class C {
496
498
  const o = (l = (await this.view.hitTest(t, {
497
499
  include: [this.laneLayer, this.junctionLayer]
498
500
  })).results) == null ? void 0 : l.filter(
499
- (a) => a.type === "graphic"
501
+ (n) => n.type === "graphic"
500
502
  );
501
503
  if (o.length === 0) {
502
504
  this.currentSectionCode !== "" && (this.currentSectionCode = "", this.highlightGraphic = void 0, this.highlightLayer.removeAll()), this.currentJunctionId !== "" && (this.currentJunctionId = "", this.view.closePopup());
503
505
  return;
504
506
  }
505
- const i = o[0];
506
- if (this.hitGraphic = i.graphic, i.layer.id === "OpenDriveLane") {
507
- const a = `${this.hitGraphic.attributes.roadId}+${this.hitGraphic.attributes.sectionId}`;
508
- if (a === this.currentSectionCode || this.sectionLayer.graphics.findIndex(
509
- (h) => h.getAttribute("id") === a
507
+ const s = o[0];
508
+ if (this.hitGraphic = s.graphic, s.layer.id === "OpenDriveLane") {
509
+ const n = `${this.hitGraphic.attributes.roadId}+${this.hitGraphic.attributes.sectionId}`;
510
+ if (n === this.currentSectionCode || this.sectionLayer.graphics.findIndex(
511
+ (h) => h.getAttribute("id") === n
510
512
  ) >= 0)
511
513
  return;
512
- this.currentSectionCode = a;
514
+ this.currentSectionCode = n;
513
515
  const r = this.allLaneGraphics.filter(
514
- (h) => `${h.attributes.roadId}+${h.attributes.sectionId}` === a
516
+ (h) => `${h.attributes.roadId}+${h.attributes.sectionId}` === n
515
517
  ), c = I.union(
516
518
  r.map((h) => h.geometry)
517
519
  );
@@ -528,20 +530,20 @@ class C {
528
530
  },
529
531
  attributes: {
530
532
  type: "OpenDriveSection",
531
- id: a,
533
+ id: n,
532
534
  selected: !1
533
535
  }
534
536
  }), this.highlightLayer.removeAll(), this.highlightLayer.add(this.highlightGraphic);
535
- } else if (i.layer.id === "OpenDriveJunction") {
536
- const a = this.hitGraphic.getAttribute("id");
537
- if (a === this.currentJunctionId)
537
+ } else if (s.layer.id === "OpenDriveJunction") {
538
+ const n = this.hitGraphic.getAttribute("id");
539
+ if (n === this.currentJunctionId)
538
540
  return;
539
- this.currentJunctionId = a;
540
- const n = this.hitGraphic.getAttribute("name"), r = this.hitGraphic.getAttribute("crossId");
541
- this.view.popup.open({
542
- title: n,
541
+ this.currentJunctionId = n;
542
+ const a = this.hitGraphic.getAttribute("name"), r = this.hitGraphic.getAttribute("crossId");
543
+ this.view.openPopup({
544
+ title: a,
543
545
  content: `<table>
544
- <tr><td>路口编号</td><td>${a}</td></tr>
546
+ <tr><td>路口编号</td><td>${n}</td></tr>
545
547
  <tr><td>信号机编号</td><td>${r || "无信控"}</td></tr>
546
548
  </table>`,
547
549
  location: this.hitGraphic.geometry
@@ -558,55 +560,55 @@ class C {
558
560
  */
559
561
  monitorMouseClick() {
560
562
  const e = j.debounce(async (t) => {
561
- var n;
562
- const o = (n = (await this.view.hitTest(t, {
563
+ var a;
564
+ const o = (a = (await this.view.hitTest(t, {
563
565
  include: [this.highlightLayer, this.junctionLayer, this.sectionLayer]
564
- })).results) == null ? void 0 : n.filter(
566
+ })).results) == null ? void 0 : a.filter(
565
567
  (r) => r.type === "graphic"
566
568
  );
567
569
  if (o.length === 0)
568
570
  return;
569
- const i = o[0].graphic, l = i.getAttribute("type"), a = i.getAttribute("id");
571
+ const s = o[0].graphic, l = s.getAttribute("type"), n = s.getAttribute("id");
570
572
  if (l === "OpenDriveJunction")
571
- if (i.getAttribute("selected") === !1) {
573
+ if (s.getAttribute("selected") === !1) {
572
574
  const r = `http://${this.openDriveServer}/api/sumo/getSumoJunction`, c = await m.get(r, {
573
575
  params: {
574
- id: a,
576
+ id: n,
575
577
  projectName: this.projectName
576
578
  }
577
579
  });
578
580
  c.status === 200 && c.data.status === 0 && (this.openDriveClickCallback && this.openDriveClickCallback({
579
581
  type: "OpenDriveJunction",
580
- id: a,
582
+ id: n,
581
583
  details: c.data.result
582
- }), i.setAttribute("selected", !0), i.symbol.url = "/GisViewerAssets/Images/point_red.png", this.increasePictureMarkerSize(i, 50));
584
+ }), s.setAttribute("selected", !0), s.symbol.url = "/GisViewerAssets/Images/point_red.png", this.increasePictureMarkerSize(s, 50));
583
585
  } else {
584
586
  this.openDriveClickCallback && this.openDriveClickCallback({
585
587
  type: "OpenDriveJunction",
586
- id: a,
588
+ id: n,
587
589
  details: void 0
588
- }), i.setAttribute("selected", !1);
589
- const r = i.getAttribute("crossId");
590
- i.symbol.url = r ? "/GisViewerAssets/Images/point_green.png" : "/GisViewerAssets/Images/point_yellow.png", this.decreasePictureMarkerSize(i, 30);
590
+ }), s.setAttribute("selected", !1);
591
+ const r = s.getAttribute("crossId");
592
+ s.symbol.url = r ? "/GisViewerAssets/Images/point_green.png" : "/GisViewerAssets/Images/point_yellow.png", this.decreasePictureMarkerSize(s, 30);
591
593
  }
592
594
  else if (l === "OpenDriveSection")
593
- if (i.getAttribute("selected"))
594
- this.sectionLayer.remove(i), this.openDriveClickCallback && this.openDriveClickCallback({
595
+ if (s.getAttribute("selected"))
596
+ this.sectionLayer.remove(s), this.openDriveClickCallback && this.openDriveClickCallback({
595
597
  type: "OpenDriveSection",
596
- id: a,
598
+ id: n,
597
599
  details: void 0
598
600
  });
599
601
  else {
600
- this.highlightLayer.remove(i), this.sectionLayer.add(i), i.setAttribute("selected", !0);
602
+ this.highlightLayer.remove(s), this.sectionLayer.add(s), s.setAttribute("selected", !0);
601
603
  const r = `http://${this.openDriveServer}/api/sumo/getSumoEdge`, c = await m.get(r, {
602
604
  params: {
603
- id: a,
605
+ id: n,
604
606
  projectName: this.projectName
605
607
  }
606
608
  });
607
- c.status === 200 && c.data.status === 0 && this.openDriveClickCallback && (i.setAttribute("edgeId", c.data.result.obj_id), this.openDriveClickCallback({
609
+ c.status === 200 && c.data.status === 0 && this.openDriveClickCallback && (s.setAttribute("edgeId", c.data.result.obj_id), this.openDriveClickCallback({
608
610
  type: "OpenDriveSection",
609
- id: a,
611
+ id: n,
610
612
  details: c.data.result
611
613
  }));
612
614
  }
@@ -622,14 +624,14 @@ class C {
622
624
  * @param targetSize
623
625
  */
624
626
  increasePictureMarkerSize(e, t) {
625
- const s = setInterval(() => {
626
- const o = e.symbol, i = o.width;
627
- i < t ? e.symbol = {
627
+ const i = setInterval(() => {
628
+ const o = e.symbol, s = o.width;
629
+ s < t ? e.symbol = {
628
630
  type: "picture-marker",
629
631
  url: o.url,
630
- width: i + 1,
631
- height: i + 1
632
- } : clearInterval(s);
632
+ width: s + 1,
633
+ height: s + 1
634
+ } : clearInterval(i);
633
635
  }, 20);
634
636
  }
635
637
  /**
@@ -638,46 +640,46 @@ class C {
638
640
  * @param targetSize
639
641
  */
640
642
  decreasePictureMarkerSize(e, t) {
641
- const s = setInterval(() => {
642
- const o = e.symbol, i = o.width;
643
- i > t ? e.symbol = {
643
+ const i = setInterval(() => {
644
+ const o = e.symbol, s = o.width;
645
+ s > t ? e.symbol = {
644
646
  type: "picture-marker",
645
647
  url: o.url,
646
- width: i - 1,
647
- height: i - 1
648
- } : clearInterval(s);
648
+ width: s - 1,
649
+ height: s - 1
650
+ } : clearInterval(i);
649
651
  }, 20);
650
652
  }
651
653
  async getSumoInfo(e) {
652
654
  switch (e.type) {
653
655
  case "junction": {
654
- const t = `http://${this.openDriveServer}/api/sumo/getSumoJunction`, s = await m.get(t, {
656
+ const t = `http://${this.openDriveServer}/api/sumo/getSumoJunction`, i = await m.get(t, {
655
657
  params: {
656
658
  id: e.id,
657
659
  projectName: this.projectName
658
660
  }
659
661
  });
660
- return s.status === 200 ? s.data : { status: -1, message: `路口信息查询失败: ${e.id}` };
662
+ return i.status === 200 ? i.data : { status: -1, message: `路口信息查询失败: ${e.id}` };
661
663
  }
662
664
  case "edge": {
663
665
  const t = e.id.split("#");
664
- let s = t[0];
665
- s.startsWith("-") && (s = s.slice(1));
666
+ let i = t[0];
667
+ i.startsWith("-") && (i = i.slice(1));
666
668
  let o = 0;
667
669
  t.length === 2 && (o = Number(t[1]));
668
- const i = this.allLaneGraphics.find(
669
- (l) => l.getAttribute("roadId") === s && l.getAttribute("sectionIndex") === o
670
+ const s = this.allLaneGraphics.find(
671
+ (l) => l.getAttribute("roadId") === i && l.getAttribute("sectionIndex") === o
670
672
  );
671
- if (i) {
672
- const l = `${s}+${i.getAttribute(
673
+ if (s) {
674
+ const l = `${i}+${s.getAttribute(
673
675
  "sectionId"
674
- )}`, a = `http://${this.openDriveServer}/api/sumo/getSumoEdge`, n = await m.get(a, {
676
+ )}`, n = `http://${this.openDriveServer}/api/sumo/getSumoEdge`, a = await m.get(n, {
675
677
  params: {
676
678
  id: l,
677
679
  projectName: this.projectName
678
680
  }
679
681
  });
680
- return n.status === 200 ? n.data : { status: -1, message: `路段信息查询失败: ${l}` };
682
+ return a.status === 200 ? a.data : { status: -1, message: `路段信息查询失败: ${l}` };
681
683
  } else
682
684
  return { status: -1, message: "未知类型" };
683
685
  }
@@ -689,13 +691,13 @@ class C {
689
691
  * 清除OpenDrive内容
690
692
  */
691
693
  async clearOpenDrive() {
692
- var t, s;
694
+ var t, i;
693
695
  let e = await this.laneLayer.queryFeatures();
694
696
  e.features.length > 0 && await this.laneLayer.applyEdits({
695
697
  deleteFeatures: e.features
696
698
  }), e = await this.roadNameLayer.queryFeatures(), e.features.length > 0 && await this.roadNameLayer.applyEdits({
697
699
  deleteFeatures: e.features
698
- }), this.highlightLayer.removeAll(), this.junctionLayer.removeAll(), this.sectionLayer.removeAll(), this.flashLayer.removeAll(), (t = this.mouseMoveHandler) == null || t.remove(), this.mouseMoveHandler = void 0, (s = this.mouseClickHandler) == null || s.remove(), this.mouseClickHandler = void 0;
700
+ }), 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;
699
701
  }
700
702
  /**
701
703
  * 用sumo的id定位车道、基本段、路段
@@ -703,30 +705,30 @@ class C {
703
705
  * @returns
704
706
  */
705
707
  async findSumo(e) {
706
- const { type: t, id: s } = e, o = e.flash === void 0 ? !0 : e.flash;
708
+ const { type: t, id: i } = e, o = e.flash === void 0 ? !0 : e.flash;
707
709
  if (t === "junction")
708
- return await this.findJunction(s, o);
710
+ return await this.findJunction(i, o);
709
711
  if (t === "edge") {
710
- const i = s.split("+");
711
- if (i.length > 2)
712
+ const s = i.split("+");
713
+ if (s.length > 2)
712
714
  return { status: -1, message: "id格式错误" };
713
- const l = i.length === 2 ? Number(i[1]) : void 0, a = i[0].split("#");
714
- if (a.length > 2)
715
+ const l = s.length === 2 ? Number(s[1]) : void 0, n = s[0].split("#");
716
+ if (n.length > 2)
715
717
  return { status: -1, message: "id格式错误" };
716
- const n = a[0], r = a.length === 2 ? Number(a[1]) : void 0;
717
- return await this.findLane({ roadsectId: n, segmentId: r, laneId: l, flash: o });
718
+ const a = n[0], r = n.length === 2 ? Number(n[1]) : void 0;
719
+ return await this.findLane({ roadsectId: a, segmentId: r, laneId: l, flash: o });
718
720
  } else
719
721
  return { status: -1, message: "未知类型" };
720
722
  }
721
723
  async findJunction(e, t) {
722
- const s = this.junctionLayer.graphics.find(
724
+ const i = this.junctionLayer.graphics.find(
723
725
  (o) => o.attributes.id === e
724
726
  );
725
- if (!s)
727
+ if (!i)
726
728
  return { status: -1, message: "未找到。请检查路口编号" };
727
729
  if (t) {
728
730
  const o = new p({
729
- geometry: s.geometry,
731
+ geometry: i.geometry,
730
732
  symbol: {
731
733
  type: "simple-marker",
732
734
  style: "circle",
@@ -740,7 +742,7 @@ class C {
740
742
  });
741
743
  this.flashGraphic(o);
742
744
  }
743
- return await this.view.goTo(s.geometry, { duration: 1e3 }), { status: 0, message: "ok" };
745
+ return await this.view.goTo(i.geometry, { duration: 1e3 }), { status: 0, message: "ok" };
744
746
  }
745
747
  /**
746
748
  * 用sumo的id定位车道、基本段、路段
@@ -748,41 +750,41 @@ class C {
748
750
  * @returns
749
751
  */
750
752
  async findLane(e) {
751
- let { roadsectId: t, segmentId: s, laneId: o } = e;
753
+ let { roadsectId: t, segmentId: i, laneId: o } = e;
752
754
  t.startsWith("-") && (t = t.slice(1));
753
- let i = this.allLaneGraphics.filter(
754
- (n) => n.attributes.roadId === t
755
+ let s = this.allLaneGraphics.filter(
756
+ (a) => a.attributes.roadId === t
755
757
  );
756
- if (i.length === 0)
758
+ if (s.length === 0)
757
759
  return { status: -1, message: "未找到。请检查路段编号" };
758
- if (s !== void 0) {
759
- const n = [];
760
- if (i.forEach((r) => {
760
+ if (i !== void 0) {
761
+ const a = [];
762
+ if (s.forEach((r) => {
761
763
  const c = Number(r.attributes.sectionId);
762
- n.indexOf(c) === -1 && n.push(c);
763
- }), n.sort((r, c) => r - c), s > n.length - 1)
764
+ a.indexOf(c) === -1 && a.push(c);
765
+ }), a.sort((r, c) => r - c), i > a.length - 1)
764
766
  return { status: -1, message: "未找到。请检查基本段编号" };
765
- s = n[s], i = i.filter(
766
- (r) => Number(r.attributes.sectionId) === s
767
+ i = a[i], s = s.filter(
768
+ (r) => Number(r.attributes.sectionId) === i
767
769
  );
768
770
  }
769
771
  if (o !== void 0) {
770
- const n = [];
771
- if (i.forEach((r) => {
772
+ const a = [];
773
+ if (s.forEach((r) => {
772
774
  const c = Number(r.attributes.laneId);
773
- n.indexOf(c) === -1 && n.push(c);
774
- }), n.sort((r, c) => r - c), o > n.length - 1)
775
+ a.indexOf(c) === -1 && a.push(c);
776
+ }), a.sort((r, c) => r - c), o > a.length - 1)
775
777
  return { status: -1, message: "未找到。请检查车道编号" };
776
- o = n[o], i = i.filter(
778
+ o = a[o], s = s.filter(
777
779
  (r) => Number(r.attributes.laneId) === o
778
780
  );
779
781
  }
780
- const l = i.map(
781
- (n) => n.geometry
782
- ), a = I.union(l);
782
+ const l = s.map(
783
+ (a) => a.geometry
784
+ ), n = I.union(l);
783
785
  if (e.flash) {
784
- const n = new p({
785
- geometry: a,
786
+ const a = new p({
787
+ geometry: n,
786
788
  symbol: {
787
789
  type: "simple-fill",
788
790
  color: [255, 0, 0, 0.5],
@@ -793,9 +795,9 @@ class C {
793
795
  }
794
796
  }
795
797
  });
796
- this.flashGraphic(n);
798
+ this.flashGraphic(a);
797
799
  }
798
- return await this.view.goTo(a, { duration: 1e3 }), { status: 0, message: "ok" };
800
+ return await this.view.goTo(n, { duration: 1e3 }), { status: 0, message: "ok" };
799
801
  }
800
802
  /**
801
803
  * graphic渐隐渐显闪烁
@@ -803,9 +805,9 @@ class C {
803
805
  */
804
806
  flashGraphic(e) {
805
807
  this.flashLayer.removeAll(), this.flashLayer.add(e);
806
- let t = 0, s = !0;
808
+ let t = 0, i = !0;
807
809
  const o = setInterval(() => {
808
- s ? (this.flashLayer.opacity -= 0.02, this.flashLayer.opacity <= 0.1 && (s = !1, t++)) : (this.flashLayer.opacity += 0.02, this.flashLayer.opacity >= 1 && (s = !0)), t >= 5 && (this.flashLayer.removeAll(), this.flashLayer.opacity = 1, clearInterval(o));
810
+ i ? (this.flashLayer.opacity -= 0.02, this.flashLayer.opacity <= 0.1 && (i = !1, t++)) : (this.flashLayer.opacity += 0.02, this.flashLayer.opacity >= 1 && (i = !0)), t >= 5 && (this.flashLayer.removeAll(), this.flashLayer.opacity = 1, clearInterval(o));
809
811
  }, 10);
810
812
  }
811
813
  /**
@@ -817,15 +819,15 @@ class C {
817
819
  if ((!e || e.type === "junction") && this.junctionLayer.graphics.forEach((t) => {
818
820
  if ((!e || !e.id || e.id === "" || e.id === t.getAttribute("id")) && t.getAttribute("selected")) {
819
821
  t.setAttribute("selected", !1);
820
- const s = t.getAttribute("crossId");
821
- t.symbol.url = s ? "/GisViewerAssets/Images/point_green.png" : "/GisViewerAssets/Images/point_yellow.png", this.decreasePictureMarkerSize(t, 30);
822
+ const i = t.getAttribute("crossId");
823
+ t.symbol.url = i ? "/GisViewerAssets/Images/point_green.png" : "/GisViewerAssets/Images/point_yellow.png", this.decreasePictureMarkerSize(t, 30);
822
824
  }
823
825
  }), !e || e.type === "edge")
824
826
  if (!e || !e.id || e.id === "")
825
827
  this.sectionLayer.removeAll();
826
828
  else {
827
829
  const t = this.sectionLayer.graphics.find(
828
- (s) => s.getAttribute("edgeId") === e.id
830
+ (i) => i.getAttribute("edgeId") === e.id
829
831
  );
830
832
  t && this.sectionLayer.remove(t);
831
833
  }
@@ -845,17 +847,17 @@ class C {
845
847
  }), { status: -1, message: "未找到路口" };
846
848
  case "edge": {
847
849
  const t = e.id.split("#");
848
- let s = t[0];
849
- s.startsWith("-") && (s = s.slice(1));
850
+ let i = t[0];
851
+ i.startsWith("-") && (i = i.slice(1));
850
852
  let o = 0;
851
853
  t.length === 2 && (o = Number(t[1]));
852
- const i = this.allLaneGraphics.filter(
853
- (l) => l.getAttribute("roadId") === s && l.getAttribute("sectionIndex") === o
854
+ const s = this.allLaneGraphics.filter(
855
+ (l) => l.getAttribute("roadId") === i && l.getAttribute("sectionIndex") === o
854
856
  );
855
- if (i.length > 0) {
857
+ if (s.length > 0) {
856
858
  const l = I.union(
857
- i.map((n) => n.geometry)
858
- ), a = new p({
859
+ s.map((a) => a.geometry)
860
+ ), n = new p({
859
861
  geometry: l,
860
862
  symbol: {
861
863
  type: "simple-fill",
@@ -872,7 +874,7 @@ class C {
872
874
  selected: !0
873
875
  }
874
876
  });
875
- return this.sectionLayer.add(a), { status: 0, message: "ok" };
877
+ return this.sectionLayer.add(n), { status: 0, message: "ok" };
876
878
  } else
877
879
  return { status: -1, message: "未找到路段" };
878
880
  }
@@ -48,7 +48,7 @@ class C {
48
48
  if (t) {
49
49
  await this.view.goTo(t.geometry);
50
50
  const r = t.geometry.type === "point" ? t.geometry : t.geometry.centroid;
51
- return this.view.popup.open({
51
+ return this.view.openPopup({
52
52
  features: [t],
53
53
  location: r
54
54
  }), { status: 0, message: "ok" };
@@ -57,11 +57,11 @@ class C {
57
57
  }
58
58
  async highlightSignalControlArea(e) {
59
59
  this.highlightLayer.removeAll(), this.districtControllerLayer.visible = !1, this.subDistrictControllerLayer.visible = !1, this.crossLayer.visible = !1;
60
- const t = this.districtControllerLayer.graphics.filter((i) => i.getAttribute("id") === e.id).toArray(), r = this.subDistrictControllerLayer.graphics.filter(
60
+ const t = this.districtControllerLayer.graphics.filter((i) => i.getAttribute("id") === e.id).toArray().map((i) => i.clone()), r = this.subDistrictControllerLayer.graphics.filter(
61
61
  (i) => i.getAttribute("id") === e.id || i.getAttribute("parentId") === e.id
62
- ).toArray(), s = this.crossLayer.graphics.filter(
62
+ ).toArray().map((i) => i.clone()), s = this.crossLayer.graphics.filter(
63
63
  (i) => i.getAttribute("id") === e.id || i.getAttribute("districtId") === e.id || i.getAttribute("subDistrictId") === e.id
64
- ).toArray();
64
+ ).toArray().map((i) => i.clone());
65
65
  return t.length > 0 && this.highlightLayer.addMany(t), r.length > 0 && this.highlightLayer.addMany(r), s.length > 0 && this.highlightLayer.addMany(s), this.highlightLayer.graphics.length === 0 ? { status: 1, message: "未找到" } : (await this.view.goTo(
66
66
  t.length > 0 ? t : r.length > 0 ? r : s
67
67
  ), { status: 0, message: "ok" });
@@ -1 +1 @@
1
- "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const v=require("@arcgis/core/core/promiseUtils.js"),y=require("@arcgis/core/core/reactiveUtils.js"),T=require("@arcgis/core/geometry/SpatialReference"),S=require("@arcgis/core/views/3d/externalRenderers"),C=require("three"),G=require("three/examples/jsm/loaders/GLTFLoader"),m=require("../../../types/index.js"),B=require("../../stores/index.js");function f(u){const i=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(u){for(const e in u)if(e!=="default"){const t=Object.getOwnPropertyDescriptor(u,e);Object.defineProperty(i,e,t.get?t:{enumerable:!0,get:()=>u[e]})}}return i.default=u,Object.freeze(i)}const R=f(v),I=f(y),M=f(S),r=f(C);class V{constructor(i){this.cameraHeightThreshold=1e3,this.roughness=.2,this.metalness=.8,this.defaultMaterial=new r.MeshPhongMaterial({color:16777215}),this.materialMap=new Map([[1,this.createCarMaterial(16777215)],[2,this.createCarMaterial(7833753)],[3,this.createCarMaterial(16766720)],[4,this.createCarMaterial(16758465)],[5,this.createCarMaterial(14423100)],[6,this.createCarMaterial(3329330)],[7,this.createCarMaterial(2003183)],[8,this.createCarMaterial(16032864)],[9,this.createCarMaterial(2105376)],[10,this.createCarMaterial(9662683)],[99,this.createCarMaterial(6908265)]]),this.isInitialized=!1,this.showGroundVehicle=!0,this.showElevatedVehicle=!0,this.isPaused=!1,this.currentSpriteContent=m.EVehiclePlateState.None,this.historyPositionMap=new Map,this.vehicleObjectMap=new Map,this.needInterpolate=!0,this.updateModel=!1,this.appDataStore=B.default.useAppDataStore,this.logTable=[["ptcId","plateno","timestamp","localTimestamp","speed","longitude","latitude","ptcType","vehicleType","vehicleColor","plateColor","heading","fixAngle","roadLayer","step","receiveTimestamp","queueLength","status"]],this.assetsRoot=JSON.parse(JSON.stringify(this.appDataStore.mapConfig)).assetsRoot,this.view=i,I.watch(()=>this.view.camera.position.z,(e,t)=>{(t<=this.cameraHeightThreshold&&e>this.cameraHeightThreshold||t>this.cameraHeightThreshold&&e<=this.cameraHeightThreshold)&&(this.updateModel=!0)})}createCarMaterial(i){return new r.MeshPhongMaterial({color:i})}getLog(){return this.logTable}async init(){const i=new G.GLTFLoader;await R.eachAlways([new Promise(e=>{i.load(`${this.assetsRoot}/3DModels/car.glb`,t=>{this.carModel=t.scene,this.carModel.rotation.x=r.MathUtils.degToRad(90),e()})}),new Promise(e=>{i.load(`${this.assetsRoot}/3DModels/van.glb`,t=>{this.vanModel=t.scene,this.vanModel.rotation.x=r.MathUtils.degToRad(90),e()})}),new Promise(e=>{i.load(`${this.assetsRoot}/3DModels/truck.glb`,t=>{this.truckModel=t.scene,this.truckModel.scale.set(1.2,1,1.5),this.truckModel.rotation.x=r.MathUtils.degToRad(90),e()})}),new Promise(e=>{i.load(`${this.assetsRoot}/3DModels/bus.glb`,t=>{this.busModel=t.scene,this.busModel.rotation.x=r.MathUtils.degToRad(90),e()})}),new Promise(e=>{i.load(`${this.assetsRoot}/3DModels/bicycle.glb`,t=>{this.bicycleModel=t.scene,this.bicycleModel.rotation.x=r.MathUtils.degToRad(90),this.bicycleModel.rotation.y=r.MathUtils.degToRad(180),e()})}),new Promise(e=>{this.bluePlateBG=new Image,this.bluePlateBG.src=`${this.assetsRoot}/Images/PlateBG/blue.png`,this.bluePlateBG.onload=()=>{e()}}),new Promise(e=>{this.yellowPlateBG=new Image,this.yellowPlateBG.src=`${this.assetsRoot}/Images/PlateBG/yellow.png`,this.yellowPlateBG.onload=()=>{e()}}),new Promise(e=>{this.whitePlateBG=new Image,this.whitePlateBG.src=`${this.assetsRoot}/Images/PlateBG/white.png`,this.whitePlateBG.onload=()=>{e()}}),new Promise(e=>{this.blackPlateBG=new Image,this.blackPlateBG.src=`${this.assetsRoot}/Images/PlateBG/black.png`,this.blackPlateBG.onload=()=>{e()}}),new Promise(e=>{this.neoYellowPlateBG=new Image,this.neoYellowPlateBG.src=`${this.assetsRoot}/Images/PlateBG/neo_yellow.png`,this.neoYellowPlateBG.onload=()=>{e()}}),new Promise(e=>{this.neoGreenPlateBG=new Image,this.neoGreenPlateBG.src=`${this.assetsRoot}/Images/PlateBG/neo_green.png`,this.neoGreenPlateBG.onload=()=>{e()}}),new Promise(e=>{this.greyPlateBG=new Image,this.greyPlateBG.src=`${this.assetsRoot}/Images/PlateBG/grey.png`,this.greyPlateBG.onload=()=>{e()}})]),this.isInitialized=!0}setInterpolate(i){this.clearVehicles(),this.needInterpolate=i}async setup(i){this.context=i,this.renderer=new r.WebGLRenderer({context:i.gl,premultipliedAlpha:!0,logarithmicDepthBuffer:!0,antialias:!0,powerPreference:"high-performance"}),this.renderer.shadowMap.enabled=!0,this.renderer.setPixelRatio(window.devicePixelRatio),this.renderer.setViewport(0,0,this.view.width,this.view.height),this.renderer.autoClearDepth=!1,this.renderer.autoClearStencil=!1,this.renderer.autoClearColor=!1;const e=this.renderer.setRenderTarget.bind(this.renderer);this.renderer.setRenderTarget=s=>{e(s),s==null&&i.bindRenderTarget()},this.scene=new r.Scene;const{camera:t}=i;this.camera=new r.PerspectiveCamera(t.fovY,t.aspect,.1,1e5),this.ambient=new r.AmbientLight(16777215,2),this.scene.add(this.ambient),this.sun=new r.DirectionalLight(16777215,2),this.scene.add(this.sun),i.resetWebGLState()}async render(i){var s;const e=i.camera;if(this.camera.position.set(e.eye[0],e.eye[1],e.eye[2]),this.camera.up.set(e.up[0],e.up[1],e.up[2]),this.camera.lookAt(new r.Vector3(e.center[0],e.center[1],e.center[2])),this.camera.projectionMatrix.fromArray(e.projectionMatrix),!this.isPaused&&this.needInterpolate)for(const a of this.vehicleObjectMap.keys()){const n=(s=this.vehicleObjectMap.get(a))==null?void 0:s.model;if(!n)continue;const o=this.computeVehiclePosition(a);if(o){const d=this.toRenderCoordinates(o);n.position.set(d[0],d[1],d[2]),n.rotation.y=r.MathUtils.degToRad(-o[3])}}const t=i.sunLight;this.sun.position.set(t.direction[0],t.direction[1],t.direction[2]),this.sun.intensity=t.diffuse.intensity,this.sun.color=new r.Color(t.diffuse.color[0],t.diffuse.color[1],t.diffuse.color[2]),this.ambient.intensity=t.ambient.intensity,this.ambient.color=new r.Color(t.ambient.color[0],t.ambient.color[1],t.ambient.color[2]),this.renderer.resetState(),i.bindRenderTarget(),this.renderer.render(this.scene,this.camera),M.requestRender(this.view),i.resetWebGLState()}async addVehicles(i){if(this.isPaused||!this.isInitialized)return;const e=Date.now();for(const t of i){this.appDataStore.saveTrackLog&&this.logTable.push([t.ptcId,t.plateNo,t.timestamp,t.localTimestamp,t.speed,t.x,t.y,t.ptcType,t.vehicleType,t.vehicleColor,t.plateColor,t.heading,t.fixAngle,t.roadLayer,t.step,e,0,0]);const{vehicleId:s,localTimestamp:a}=t,n=Number(t.x),o=Number(t.y),d=Number(t.heading);this.historyPositionMap.set(s,[{pos:[n,o,0],heading:d,time:a}]);const h=this.getVehicleModel(t);h.name=s,h.visible=!1;try{const l=await this.createPlateSprite(t);l&&(h.add(l),l.position.set(0,5,-4))}catch(l){console.log("createPlateSprite error:",l)}this.scene.add(h),this.vehicleObjectMap.set(s,{model:h,data:t,waitForDelete:!1,isMoving:!1})}}async updateVehicles(i){if(this.isPaused||!this.isInitialized)return;const e=[],t=Date.now();for(const s of i){const{vehicleId:a,localTimestamp:n}=s,o=Number(s.x),d=Number(s.y);let h=Number(s.heading);const l=this.vehicleObjectMap.get(a),p=this.historyPositionMap.get(a);if(!l||!p)e.push(s);else{if(this.appDataStore.saveTrackLog&&this.logTable.push([s.ptcId,s.plateNo,s.timestamp,s.localTimestamp,s.speed,s.x,s.y,s.ptcType,s.vehicleType,s.vehicleColor,s.plateColor,s.heading,s.fixAngle,s.roadLayer,s.step,t,p.length,1]),this.updateModel||l.data.vehicleColor!==s.vehicleColor||l.data.vehicleType!==s.vehicleType){this.scene.remove(l.model),this.disposeModel(l.model),l.model=this.getVehicleModel(s),l.model.visible=!0;const c=await this.createPlateSprite(s);c&&(l.model.add(c),c.position.set(0,5,-4)),this.scene.add(l.model)}if(l.data.showName!==s.showName||l.data.plateColor!==s.plateColor){const c=l.model.getObjectByName("VehiclePlate");c&&(l.model.remove(c),this.disposeModel(c));const g=await this.createPlateSprite(s);g&&(l.model.add(g),g.position.set(0,5,-4))}if(l.data=s,this.needInterpolate){const c=p[p.length-1];Math.abs(h-c.heading)>=180&&(h>c.heading?c.heading+=360:h+=360),p.push({pos:[o,d,0],heading:h,time:n})}else{this.historyPositionMap.set(a,[{pos:[o,d,0],heading:h,time:n}]);const c=this.toRenderCoordinates([o,d,0]);l.model.position.set(c[0],c[1],c[2]),l.model.rotation.y=r.MathUtils.degToRad(-h)}}}await this.addVehicles(e),this.updateModel=!1,this.needInterpolate||this.render(this.context)}toRenderCoordinates(i){const e=[0,0,0];return M.toRenderCoordinates(this.view,i,0,T.WGS84,e,0,1),e}deleteVehicles(i){if(this.isPaused)return;const e=Date.now();i.forEach(t=>{if(this.appDataStore.saveTrackLog){const a=this.historyPositionMap.get(t);this.logTable.push([t,"","","","","","","","","","","","","","",e,a?a.length:0,2])}const s=this.vehicleObjectMap.get(t);s&&(this.needInterpolate?s.isMoving?s.waitForDelete=!0:this.deleteVehicle(s):this.deleteVehicle(s))})}deleteVehicle(i){this.scene.remove(i.model),this.disposeModel(i.model);const e=i.data.vehicleId;this.vehicleObjectMap.delete(e),this.historyPositionMap.delete(e)}async toggleTrafficInfo(i){i.name==="vehiclePlate"&&(i.visible===!0&&this.currentSpriteContent===m.EVehiclePlateState.None?await this.updatePanelContent(m.EVehiclePlateState.PlateNumber):await this.updatePanelContent(i.visible?this.currentSpriteContent:m.EVehiclePlateState.None))}togglePause(i){this.isPaused=i}clearVehicles(){for(const i of this.vehicleObjectMap.keys()){const e=this.vehicleObjectMap.get(i);e&&(this.scene.remove(e.model),this.disposeModel(e.model))}this.vehicleObjectMap.clear(),this.historyPositionMap.clear()}async updatePanelContent(i){if(i!==this.currentSpriteContent){this.currentSpriteContent=i;for(const e of this.vehicleObjectMap.keys()){const t=this.vehicleObjectMap.get(e);if(t){const s=t.model.getObjectByName("VehiclePlate");if(s&&(t.model.remove(s),this.disposeModel(s)),i!==m.EVehiclePlateState.None){const a=await this.createPlateSprite(t.data);a&&(t.model.add(a),a.position.set(0,5,-4))}}}}}toggleGroundVehicle(i){console.log("toggleGroundVehicle",i),this.showGroundVehicle=i}toggleElevatedVehicle(i){this.showElevatedVehicle=i}disposeModel(i){i.traverse(e=>{e instanceof r.Mesh&&(e.geometry.dispose(),e.material.dispose())})}computeVehiclePosition(i){const e=this.historyPositionMap.get(i),t=this.vehicleObjectMap.get(i);if(!t||!e||!t.isMoving&&e.length<=2)return;const s=Date.now();t.isMoving=!0,t.data.roadLayer==="1"?t.model.visible=this.showGroundVehicle:t.model.visible=this.showElevatedVehicle,t.segmentStartTime||(t.segmentStartTime=s,t.segmentTotalTime=e[1].time-e[0].time);const a=s-t.segmentStartTime,n=Math.min(a/t.segmentTotalTime,1);if(n===1)if(e.shift(),e.length===1){t.waitForDelete===!0?this.deleteVehicle(t):(t.segmentStartTime=void 0,t.segmentTotalTime=void 0,t.model.visible=!1,t.isMoving=!1,console.log("hide vehicle",i));return}else{t.segmentStartTime=Date.now();const o=a-t.segmentTotalTime;return t.segmentTotalTime=e[1].time-e[0].time-o,console.log(t.segmentStartTime,t.segmentTotalTime),(e[1].heading>=270&&e[0].heading<=90||e[1].heading<=90&&e[0].heading>=270)&&(e[1].heading>e[0].heading?e[0].heading+=360:e[1].heading+=360),e[0].pos.concat(e[0].heading)}else if(e.length>=2){const o=e[0].pos[0]+(e[1].pos[0]-e[0].pos[0])*n,d=e[0].pos[1]+(e[1].pos[1]-e[0].pos[1])*n,h=e[0].heading+(e[1].heading-e[0].heading)*n;return[o,d,0,h]}else return}getVehicleModel(i){if(this.view.camera.position.z>=this.cameraHeightThreshold){const e=new r.SphereGeometry(5,32,32),t=new r.MeshPhysicalMaterial({color:325253,emissive:0,roughness:this.roughness,metalness:this.metalness});return new r.Mesh(e,t)}else{let e;if(i.ptcType===2)e=this.bicycleModel.clone();else{switch(i.vehicleType){case 10:e=this.carModel.clone();break;case 20:e=this.vanModel.clone();break;case 25:e=this.truckModel.clone();break;case 50:e=this.busModel.clone();break;default:e=this.carModel.clone();break}const t=this.materialMap.get(i.vehicleColor)||this.defaultMaterial;let s=!1;e.traverse(a=>{!s&&a instanceof r.Mesh&&(a.material=t,s=!0)})}return e}}createCanvas(i,e,t){const s=document.createElement("canvas"),a=i.width,n=i.height;s.width=a,s.height=n;const o=s.getContext("2d");if(!o){console.log("canvas创建失败");return}return o.fillStyle="rgba(0,0,0,0.0)",o.fillRect(0,0,a,n),o.drawImage(i,0,0,a,n),o.beginPath(),o.translate(a/2,n/2),o.fillStyle=t,o.font="bold 32px 宋体",o.textBaseline="middle",o.textAlign="center",o.fillText(e,0,0),s}createPlateSprite(i){return new Promise((e,t)=>{var h,l;const s=!i.plateNo||i.plateNo==="0"||i.plateNo==="000000";if(this.currentSpriteContent===m.EVehiclePlateState.None||this.currentSpriteContent===m.EVehiclePlateState.PlateNumber&&s){e(void 0);return}let a=new Image,n="",o="";if(this.currentSpriteContent===m.EVehiclePlateState.PlateNumber||this.currentSpriteContent===m.EVehiclePlateState.Mix)if(s)a=this.greyPlateBG,n=i.ptcId,o="#ffffff";else switch(n=((h=i.showName)==null?void 0:h.substring(0,2))+"•"+((l=i.showName)==null?void 0:l.substring(2)),i.plateColor){case 1:a=this.bluePlateBG,o="#ffffff";break;case 2:a=this.yellowPlateBG,o="#000000";break;case 3:a=this.whitePlateBG,o="#000000";break;case 4:a=this.blackPlateBG,o="#ffffff";break;case 5:a=this.neoYellowPlateBG,o="#000000";break;case 6:a=this.neoGreenPlateBG,o="#000000";break;default:a=this.greyPlateBG,n=i.plateNo,o="#ffffff";break}else this.currentSpriteContent===m.EVehiclePlateState.Id&&(a=this.greyPlateBG,n=i.ptcId,o="#ffffff");const d=this.createCanvas(a,n,o);if(d){const p=new r.CanvasTexture(d),c=new r.SpriteMaterial({map:p,transparent:!1}),g=new r.Sprite(c),P=.05,w=d.width*P,b=d.height*P;g.scale.set(w,b,1),g.name="VehiclePlate",e(g)}else{t("canvas创建失败");return}a.onerror=p=>{console.log(`号牌背景加载失败: ${a.src}`,p),t(p)}})}}exports.default=V;
1
+ "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const v=require("@arcgis/core/core/promiseUtils.js"),y=require("@arcgis/core/core/reactiveUtils.js"),T=require("@arcgis/core/geometry/SpatialReference"),S=require("@arcgis/core/views/3d/externalRenderers"),C=require("three"),G=require("three/examples/jsm/loaders/GLTFLoader"),m=require("../../../types/index.js"),B=require("../../stores/index.js");function f(u){const i=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(u){for(const e in u)if(e!=="default"){const t=Object.getOwnPropertyDescriptor(u,e);Object.defineProperty(i,e,t.get?t:{enumerable:!0,get:()=>u[e]})}}return i.default=u,Object.freeze(i)}const R=f(v),I=f(y),M=f(S),l=f(C);class V{constructor(i){this.cameraHeightThreshold=1e3,this.roughness=.2,this.metalness=.8,this.defaultMaterial=new l.MeshPhongMaterial({color:16777215}),this.materialMap=new Map([[1,this.createCarMaterial(16777215)],[2,this.createCarMaterial(7833753)],[3,this.createCarMaterial(16766720)],[4,this.createCarMaterial(16758465)],[5,this.createCarMaterial(14423100)],[6,this.createCarMaterial(3329330)],[7,this.createCarMaterial(2003183)],[8,this.createCarMaterial(16032864)],[9,this.createCarMaterial(2105376)],[10,this.createCarMaterial(9662683)],[99,this.createCarMaterial(6908265)]]),this.isInitialized=!1,this.showGroundVehicle=!0,this.showElevatedVehicle=!0,this.isPaused=!1,this.currentSpriteContent=m.EVehiclePlateState.None,this.historyPositionMap=new Map,this.vehicleObjectMap=new Map,this.needInterpolate=!0,this.updateModel=!1,this.appDataStore=B.default.useAppDataStore,this.logTable=[["ptcId","plateno","timestamp","localTimestamp","speed","longitude","latitude","ptcType","vehicleType","vehicleColor","plateColor","heading","fixAngle","roadLayer","step","receiveTimestamp","queueLength","status"]],this.assetsRoot=JSON.parse(JSON.stringify(this.appDataStore.mapConfig)).assetsRoot,this.view=i,I.watch(()=>this.view.camera.position.z,(e,t)=>{(t<=this.cameraHeightThreshold&&e>this.cameraHeightThreshold||t>this.cameraHeightThreshold&&e<=this.cameraHeightThreshold)&&(this.updateModel=!0)})}createCarMaterial(i){return new l.MeshPhongMaterial({color:i})}getLog(){return this.logTable}async init(){const i=new G.GLTFLoader;await R.eachAlways([new Promise(e=>{i.load(`${this.assetsRoot}/3DModels/car.glb`,t=>{this.carModel=t.scene,this.carModel.rotation.x=l.MathUtils.degToRad(90),e()})}),new Promise(e=>{i.load(`${this.assetsRoot}/3DModels/van.glb`,t=>{this.vanModel=t.scene,this.vanModel.rotation.x=l.MathUtils.degToRad(90),e()})}),new Promise(e=>{i.load(`${this.assetsRoot}/3DModels/truck.glb`,t=>{this.truckModel=t.scene,this.truckModel.scale.set(1.2,1,1.5),this.truckModel.rotation.x=l.MathUtils.degToRad(90),e()})}),new Promise(e=>{i.load(`${this.assetsRoot}/3DModels/bus.glb`,t=>{this.busModel=t.scene,this.busModel.rotation.x=l.MathUtils.degToRad(90),e()})}),new Promise(e=>{i.load(`${this.assetsRoot}/3DModels/bicycle.glb`,t=>{this.bicycleModel=t.scene,this.bicycleModel.rotation.x=l.MathUtils.degToRad(90),this.bicycleModel.rotation.y=l.MathUtils.degToRad(180),e()})}),new Promise(e=>{this.bluePlateBG=new Image,this.bluePlateBG.src=`${this.assetsRoot}/Images/PlateBG/blue.png`,this.bluePlateBG.onload=()=>{e()}}),new Promise(e=>{this.yellowPlateBG=new Image,this.yellowPlateBG.src=`${this.assetsRoot}/Images/PlateBG/yellow.png`,this.yellowPlateBG.onload=()=>{e()}}),new Promise(e=>{this.whitePlateBG=new Image,this.whitePlateBG.src=`${this.assetsRoot}/Images/PlateBG/white.png`,this.whitePlateBG.onload=()=>{e()}}),new Promise(e=>{this.blackPlateBG=new Image,this.blackPlateBG.src=`${this.assetsRoot}/Images/PlateBG/black.png`,this.blackPlateBG.onload=()=>{e()}}),new Promise(e=>{this.neoYellowPlateBG=new Image,this.neoYellowPlateBG.src=`${this.assetsRoot}/Images/PlateBG/neo_yellow.png`,this.neoYellowPlateBG.onload=()=>{e()}}),new Promise(e=>{this.neoGreenPlateBG=new Image,this.neoGreenPlateBG.src=`${this.assetsRoot}/Images/PlateBG/neo_green.png`,this.neoGreenPlateBG.onload=()=>{e()}}),new Promise(e=>{this.greyPlateBG=new Image,this.greyPlateBG.src=`${this.assetsRoot}/Images/PlateBG/grey.png`,this.greyPlateBG.onload=()=>{e()}})]),this.isInitialized=!0}setInterpolate(i){this.clearVehicles(),this.needInterpolate=i}async setup(i){this.context=i,this.renderer=new l.WebGLRenderer({context:i.gl,premultipliedAlpha:!0,logarithmicDepthBuffer:!0,antialias:!0,powerPreference:"high-performance"}),this.renderer.shadowMap.enabled=!0,this.renderer.setPixelRatio(window.devicePixelRatio),this.renderer.setViewport(0,0,this.view.width,this.view.height),this.renderer.autoClearDepth=!1,this.renderer.autoClearStencil=!1,this.renderer.autoClearColor=!1;const e=this.renderer.setRenderTarget.bind(this.renderer);this.renderer.setRenderTarget=s=>{e(s),s==null&&i.bindRenderTarget()},this.scene=new l.Scene;const{camera:t}=i;this.camera=new l.PerspectiveCamera(t.fovY,t.aspect,.1,1e5),this.ambient=new l.AmbientLight(16777215,2),this.scene.add(this.ambient),this.sun=new l.DirectionalLight(16777215,2),this.scene.add(this.sun),i.resetWebGLState()}async render(i){var s;const e=i.camera;if(this.camera.position.set(e.eye[0],e.eye[1],e.eye[2]),this.camera.up.set(e.up[0],e.up[1],e.up[2]),this.camera.lookAt(new l.Vector3(e.center[0],e.center[1],e.center[2])),this.camera.projectionMatrix.fromArray(e.projectionMatrix),!this.isPaused&&this.needInterpolate)for(const a of this.vehicleObjectMap.keys()){const n=(s=this.vehicleObjectMap.get(a))==null?void 0:s.model;if(!n)continue;const o=this.computeVehiclePosition(a);if(o){const d=this.toRenderCoordinates(o);n.position.set(d[0],d[1],d[2]),n.rotation.y=l.MathUtils.degToRad(-o[3])}}const t=i.sunLight;this.sun.position.set(t.direction[0],t.direction[1],t.direction[2]),this.sun.intensity=t.diffuse.intensity,this.sun.color=new l.Color(t.diffuse.color[0],t.diffuse.color[1],t.diffuse.color[2]),this.ambient.intensity=t.ambient.intensity,this.ambient.color=new l.Color(t.ambient.color[0],t.ambient.color[1],t.ambient.color[2]),this.renderer.resetState(),i.bindRenderTarget(),this.renderer.render(this.scene,this.camera),M.requestRender(this.view),i.resetWebGLState()}async addVehicles(i){if(this.isPaused||!this.isInitialized)return;const e=Date.now();for(const t of i){this.appDataStore.saveTrackLog&&this.logTable.push([t.ptcId,t.plateNo,t.timestamp,t.localTimestamp,t.speed,t.x,t.y,t.ptcType,t.vehicleType,t.vehicleColor,t.plateColor,t.heading,t.fixAngle,t.roadLayer,t.step,e,0,0]);const{vehicleId:s,localTimestamp:a}=t,n=Number(t.x),o=Number(t.y),d=Number(t.heading);this.historyPositionMap.set(s,[{pos:[n,o,0],heading:d,time:a}]);const h=this.getVehicleModel(t);h.name=s,h.visible=!1;try{const r=await this.createPlateSprite(t);r&&(h.add(r),r.position.set(0,5,-4))}catch(r){console.log("createPlateSprite error:",r)}this.scene.add(h),this.vehicleObjectMap.set(s,{model:h,data:t,waitForDelete:!1,isMoving:!1})}}async updateVehicles(i){if(this.isPaused||!this.isInitialized)return;const e=[],t=Date.now();for(const s of i){const{vehicleId:a,localTimestamp:n}=s,o=Number(s.x),d=Number(s.y);let h=Number(s.heading);const r=this.vehicleObjectMap.get(a),p=this.historyPositionMap.get(a);if(!r||!p)e.push(s);else{if(this.appDataStore.saveTrackLog&&this.logTable.push([s.ptcId,s.plateNo,s.timestamp,s.localTimestamp,s.speed,s.x,s.y,s.ptcType,s.vehicleType,s.vehicleColor,s.plateColor,s.heading,s.fixAngle,s.roadLayer,s.step,t,p.length,1]),this.updateModel||r.data.vehicleColor!==s.vehicleColor||r.data.vehicleType!==s.vehicleType){this.scene.remove(r.model),this.disposeModel(r.model),r.model=this.getVehicleModel(s),r.model.visible=!0;const c=await this.createPlateSprite(s);c&&(r.model.add(c),c.position.set(0,5,-4)),this.scene.add(r.model)}if(r.data.showName!==s.showName||r.data.plateColor!==s.plateColor){const c=r.model.getObjectByName("VehiclePlate");c&&(r.model.remove(c),this.disposeModel(c));const g=await this.createPlateSprite(s);g&&(r.model.add(g),g.position.set(0,5,-4))}if(r.data=s,this.needInterpolate){const c=p[p.length-1];Math.abs(h-c.heading)>=180&&(h>c.heading?c.heading+=360:h+=360),p.push({pos:[o,d,0],heading:h,time:n})}else{this.historyPositionMap.set(a,[{pos:[o,d,0],heading:h,time:n}]);const c=this.toRenderCoordinates([o,d,0]);r.model.position.set(c[0],c[1],c[2]),r.model.rotation.y=l.MathUtils.degToRad(-h)}}}await this.addVehicles(e),this.updateModel=!1,this.needInterpolate||this.render(this.context)}toRenderCoordinates(i){const e=[0,0,0];return M.toRenderCoordinates(this.view,i,0,T.WGS84,e,0,1),e}deleteVehicles(i){if(this.isPaused)return;const e=Date.now();i.forEach(t=>{if(this.appDataStore.saveTrackLog){const a=this.historyPositionMap.get(t);this.logTable.push([t,"","","","","","","","","","","","","","",e,a?a.length:0,2])}const s=this.vehicleObjectMap.get(t);s&&(this.needInterpolate?s.isMoving?s.waitForDelete=!0:this.deleteVehicle(s):this.deleteVehicle(s))})}deleteVehicle(i){this.scene.remove(i.model),this.disposeModel(i.model);const e=i.data.vehicleId;this.vehicleObjectMap.delete(e),this.historyPositionMap.delete(e)}async toggleTrafficInfo(i){i.name==="vehiclePlate"&&(i.visible===!0&&this.currentSpriteContent===m.EVehiclePlateState.None?await this.updatePanelContent(m.EVehiclePlateState.PlateNumber):await this.updatePanelContent(i.visible?this.currentSpriteContent:m.EVehiclePlateState.None))}togglePause(i){this.isPaused=i}clearVehicles(){for(const i of this.vehicleObjectMap.keys()){const e=this.vehicleObjectMap.get(i);e&&(this.scene.remove(e.model),this.disposeModel(e.model))}this.vehicleObjectMap.clear(),this.historyPositionMap.clear()}async updatePanelContent(i){if(i!==this.currentSpriteContent){this.currentSpriteContent=i;for(const e of this.vehicleObjectMap.keys()){const t=this.vehicleObjectMap.get(e);if(t){const s=t.model.getObjectByName("VehiclePlate");if(s&&(t.model.remove(s),this.disposeModel(s)),i!==m.EVehiclePlateState.None){const a=await this.createPlateSprite(t.data);a&&(t.model.add(a),a.position.set(0,5,-4))}}}}}toggleGroundVehicle(i){console.log("toggleGroundVehicle",i),this.showGroundVehicle=i}toggleElevatedVehicle(i){this.showElevatedVehicle=i}disposeModel(i){i.traverse(e=>{e instanceof l.Mesh&&(e.geometry.dispose(),e.material.dispose())})}computeVehiclePosition(i){const e=this.historyPositionMap.get(i),t=this.vehicleObjectMap.get(i);if(!t||!e||!t.isMoving&&e.length<=2)return;const s=Date.now();t.isMoving=!0,t.data.roadLayer==="1"?t.model.visible=this.showGroundVehicle:t.model.visible=this.showElevatedVehicle,t.segmentStartTime||(t.segmentStartTime=s,t.segmentTotalTime=e[1].time-e[0].time);const a=s-t.segmentStartTime,n=Math.min(a/t.segmentTotalTime,1);if(n===1)if(e.shift(),e.length===1){t.waitForDelete===!0?this.deleteVehicle(t):(t.segmentStartTime=void 0,t.segmentTotalTime=void 0,t.model.visible=!1,t.isMoving=!1,console.log("hide vehicle",i));return}else{t.segmentStartTime=Date.now();const o=a-t.segmentTotalTime;return t.segmentTotalTime=e[1].time-e[0].time-o,(e[1].heading>=270&&e[0].heading<=90||e[1].heading<=90&&e[0].heading>=270)&&(e[1].heading>e[0].heading?e[0].heading+=360:e[1].heading+=360),e[0].pos.concat(e[0].heading)}else if(e.length>=2){const o=e[0].pos[0]+(e[1].pos[0]-e[0].pos[0])*n,d=e[0].pos[1]+(e[1].pos[1]-e[0].pos[1])*n,h=e[0].heading+(e[1].heading-e[0].heading)*n;return[o,d,0,h]}else return}getVehicleModel(i){if(this.view.camera.position.z>=this.cameraHeightThreshold){const e=new l.SphereGeometry(5,32,32),t=new l.MeshPhysicalMaterial({color:325253,emissive:0,roughness:this.roughness,metalness:this.metalness});return new l.Mesh(e,t)}else{let e;if(i.ptcType===2)e=this.bicycleModel.clone();else{switch(i.vehicleType){case 10:e=this.carModel.clone();break;case 20:e=this.vanModel.clone();break;case 25:e=this.truckModel.clone();break;case 50:e=this.busModel.clone();break;default:e=this.carModel.clone();break}const t=this.materialMap.get(i.vehicleColor)||this.defaultMaterial;let s=!1;e.traverse(a=>{!s&&a instanceof l.Mesh&&(a.material=t,s=!0)})}return e}}createCanvas(i,e,t){const s=document.createElement("canvas"),a=i.width,n=i.height;s.width=a,s.height=n;const o=s.getContext("2d");if(!o){console.log("canvas创建失败");return}return o.fillStyle="rgba(0,0,0,0.0)",o.fillRect(0,0,a,n),o.drawImage(i,0,0,a,n),o.beginPath(),o.translate(a/2,n/2),o.fillStyle=t,o.font="bold 32px 宋体",o.textBaseline="middle",o.textAlign="center",o.fillText(e,0,0),s}createPlateSprite(i){return new Promise((e,t)=>{var h,r;const s=!i.plateNo||i.plateNo==="0"||i.plateNo==="000000";if(this.currentSpriteContent===m.EVehiclePlateState.None||this.currentSpriteContent===m.EVehiclePlateState.PlateNumber&&s){e(void 0);return}let a=new Image,n="",o="";if(this.currentSpriteContent===m.EVehiclePlateState.PlateNumber||this.currentSpriteContent===m.EVehiclePlateState.Mix)if(s)a=this.greyPlateBG,n=i.ptcId,o="#ffffff";else switch(n=((h=i.showName)==null?void 0:h.substring(0,2))+"•"+((r=i.showName)==null?void 0:r.substring(2)),i.plateColor){case 1:a=this.bluePlateBG,o="#ffffff";break;case 2:a=this.yellowPlateBG,o="#000000";break;case 3:a=this.whitePlateBG,o="#000000";break;case 4:a=this.blackPlateBG,o="#ffffff";break;case 5:a=this.neoYellowPlateBG,o="#000000";break;case 6:a=this.neoGreenPlateBG,o="#000000";break;default:a=this.greyPlateBG,n=i.plateNo,o="#ffffff";break}else this.currentSpriteContent===m.EVehiclePlateState.Id&&(a=this.greyPlateBG,n=i.ptcId,o="#ffffff");const d=this.createCanvas(a,n,o);if(d){const p=new l.CanvasTexture(d),c=new l.SpriteMaterial({map:p,transparent:!1}),g=new l.Sprite(c),P=.05,w=d.width*P,b=d.height*P;g.scale.set(w,b,1),g.name="VehiclePlate",e(g)}else{t("canvas创建失败");return}a.onerror=p=>{console.log(`号牌背景加载失败: ${a.src}`,p),t(p)}})}}exports.default=V;
@@ -1,4 +1,4 @@
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"),J=require("@arcgis/core/geometry/geometryEngine"),G=require("@arcgis/core/layers/FeatureLayer"),v=require("@arcgis/core/layers/GraphicsLayer"),y=require("axios"),P=require("md5"),A=require("pako"),C=require("../common-utils.js"),x=require("./wasm-loader.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(J);class D{constructor(e){this.wasmLoader=x.default.getInstance(),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 v({id:"OpenDriveJunction"}),this.sectionLayer=new v({id:"OpenDriveSection"}),this.highlightLayer=new v({id:"OpenDriveHighlight"}),this.flashLayer=new v({id:"OpenDriveFlash"}),this.view.map.addMany([this.laneLayer,this.junctionLayer,this.sectionLayer,this.roadNameLayer,this.highlightLayer,this.flashLayer])}static getInstance(e){return this.instance||(this.instance=new D(e)),this.instance}async makeMd5FromFile(e){try{const i=await(await fetch(e)).text();return{status:0,message:"ok",result:P(i)}}catch(t){return{status:-1,message:t.message}}}async showOpenDriveFromFile(e){var h,g;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,((g=e.options)==null?void 0:g.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 g=new p({geometry:{type:"polyline",paths:[u]},attributes:{ObjectID:l++,roadId:c,roadName:h}});this.allRefLineGraphics.push(g),r.laneSections.sort((d,b)=>Number(d.id)-Number(b.id));for(let d=0;d<r.laneSections.length;d++){const b=r.laneSections[d],k=Number(b.id);for(const f of b.lanePaths){const w=Number(f.id);if(w===0)continue;const F=f.type,I=f.innerPath.concat(f.outerPath.reverse());if(I.length<=3){console.warn(`lane ${w} 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}+${w}`,roadId:c,roadName:r.name,sectionId:k,sectionIndex:d,laneId:w,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){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)}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.popup.open({title:a,content:`<table>
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"),v=require("@arcgis/core/layers/GraphicsLayer"),y=require("axios"),J=require("md5"),A=require("pako"),C=require("../common-utils.js"),x=require("./wasm-loader.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.wasmLoader=x.default.getInstance(),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 v({id:"OpenDriveJunction"}),this.sectionLayer=new v({id:"OpenDriveSection"}),this.highlightLayer=new v({id:"OpenDriveHighlight"}),this.flashLayer=new v({id:"OpenDriveFlash"}),this.view.map.addMany([this.laneLayer,this.junctionLayer,this.sectionLayer,this.roadNameLayer,this.highlightLayer,this.flashLayer])}static getInstance(e){return this.instance||(this.instance=new 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,g;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,((g=e.options)==null?void 0:g.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 g=new p({geometry:{type:"polyline",paths:[u]},attributes:{ObjectID:l++,roadId:c,roadName:h}});this.allRefLineGraphics.push(g),r.laneSections.sort((d,b)=>Number(d.id)-Number(b.id));for(let d=0;d<r.laneSections.length;d++){const b=r.laneSections[d],k=Number(b.id);for(const f of b.lanePaths){const w=Number(f.id);if(w===0)continue;const F=f.type,I=f.innerPath.concat(f.outerPath.reverse());if(I.length<=3){console.warn(`lane ${w} 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}+${w}`,roadId:c,roadName:r.name,sectionId:k,sectionIndex:d,laneId:w,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)}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
2
  <tr><td>路口编号</td><td>${n}</td></tr>
3
3
  <tr><td>信号机编号</td><td>${r||"无信控"}</td></tr>
4
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 +1 @@
1
- "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const c=require("@arcgis/core/Graphic"),l=require("@arcgis/core/layers/GraphicsLayer"),y=require("@turf/buffer"),f=require("@turf/convex"),p=require("@turf/helpers"),b=require("./district-controller.js");function m(s){const e=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(s){for(const t in s)if(t!=="default"){const r=Object.getOwnPropertyDescriptor(s,t);Object.defineProperty(e,t,r.get?r:{enumerable:!0,get:()=>s[t]})}}return e.default=s,Object.freeze(e)}const u=m(p);class L{constructor(e){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 b.default(t);this.drawArea(r,!0)}return{status:0,message:"ok"}}clearSignalControlArea(){var e;return this.districtControllerLayer.removeAll(),this.subDistrictControllerLayer.removeAll(),this.crossLayer.removeAll(),this.highlightLayer.removeAll(),(e=this.eventHandle)==null||e.remove(),this.view.closePopup(),{status:0,message:"ok"}}async locateSignalControlArea(e){const t=this.findAreaGraphic(e.id);if(t){await this.view.goTo(t.geometry);const r=t.geometry.type==="point"?t.geometry:t.geometry.centroid;return this.view.popup.open({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(i=>i.getAttribute("id")===e.id).toArray(),r=this.subDistrictControllerLayer.graphics.filter(i=>i.getAttribute("id")===e.id||i.getAttribute("parentId")===e.id).toArray(),a=this.crossLayer.graphics.filter(i=>i.getAttribute("id")===e.id||i.getAttribute("districtId")===e.id||i.getAttribute("subDistrictId")===e.id).toArray();return t.length>0&&this.highlightLayer.addMany(t),r.length>0&&this.highlightLayer.addMany(r),a.length>0&&this.highlightLayer.addMany(a),this.highlightLayer.graphics.length===0?{status:1,message:"未找到"}:(await this.view.goTo(t.length>0?t:r.length>0?r:a),{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){const i=u.featureCollection(r.map(g=>u.point(g))),n=f(i);if(!n)return;const d=y(n.geometry,t?200:30,{units:"meters"});let o;t?o=[{fieldName:"id",label:"区控编号"},{fieldName:"crossCount",label:"路口数量"},{fieldName:"subDistrictCount",label:"子区数量"}]:o=[{fieldName:"parentId",label:"区控编号"},{fieldName:"parentName",label:"区控名称"},{fieldName:"id",label:"子区编号"},{fieldName:"crossCount",label:"路口数量"}];const h=new c({geometry:{type:"polygon",rings:d.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:e.name,content:[{type:"fields",fieldInfos:o}]}});t?this.districtControllerLayer.add(h):this.subDistrictControllerLayer.add(h)}for(const i of e.subDistricts)this.drawArea(i,!1);const a=e.crosses.map(i=>new c({geometry:{type:"point",x:i.longitude,y:i.latitude},symbol:{type:"simple-marker",color:e.areaColor,size:8,outline:{color:"white",width:1}},attributes:{type:"cross",id:i.id,name:i.name,districtId:t?e.id:e.parentId,subDistrictId:t?"":e.id},popupTemplate:{title:i.name,content:[{type:"fields",fieldInfos:[{fieldName:"districtId",label:"区控编号"},{fieldName:"subDistrictId",label:"子区编号"},{fieldName:"id",label:"路口编号"}]}]}}));this.crossLayer.addMany(a)}}exports.default=L;
1
+ "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const c=require("@arcgis/core/Graphic"),l=require("@arcgis/core/layers/GraphicsLayer"),y=require("@turf/buffer"),p=require("@turf/convex"),m=require("@turf/helpers"),f=require("./district-controller.js");function b(s){const e=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(s){for(const t in s)if(t!=="default"){const i=Object.getOwnPropertyDescriptor(s,t);Object.defineProperty(e,t,i.get?i:{enumerable:!0,get:()=>s[t]})}}return e.default=s,Object.freeze(e)}const u=b(m);class L{constructor(e){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 f.default(t);this.drawArea(i,!0)}return{status:0,message:"ok"}}clearSignalControlArea(){var e;return this.districtControllerLayer.removeAll(),this.subDistrictControllerLayer.removeAll(),this.crossLayer.removeAll(),this.highlightLayer.removeAll(),(e=this.eventHandle)==null||e.remove(),this.view.closePopup(),{status:0,message:"ok"}}async locateSignalControlArea(e){const t=this.findAreaGraphic(e.id);if(t){await this.view.goTo(t.geometry);const i=t.geometry.type==="point"?t.geometry:t.geometry.centroid;return this.view.openPopup({features:[t],location:i}),{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(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()),a=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),a.length>0&&this.highlightLayer.addMany(a),this.highlightLayer.graphics.length===0?{status:1,message:"未找到"}:(await this.view.goTo(t.length>0?t:i.length>0?i:a),{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){const r=u.featureCollection(i.map(g=>u.point(g))),n=p(r);if(!n)return;const d=y(n.geometry,t?200:30,{units:"meters"});let o;t?o=[{fieldName:"id",label:"区控编号"},{fieldName:"crossCount",label:"路口数量"},{fieldName:"subDistrictCount",label:"子区数量"}]:o=[{fieldName:"parentId",label:"区控编号"},{fieldName:"parentName",label:"区控名称"},{fieldName:"id",label:"子区编号"},{fieldName:"crossCount",label:"路口数量"}];const h=new c({geometry:{type:"polygon",rings:d.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:e.name,content:[{type:"fields",fieldInfos:o}]}});t?this.districtControllerLayer.add(h):this.subDistrictControllerLayer.add(h)}for(const r of e.subDistricts)this.drawArea(r,!1);const a=e.crosses.map(r=>new c({geometry:{type:"point",x:r.longitude,y:r.latitude},symbol:{type:"simple-marker",color:e.areaColor,size:8,outline:{color:"white",width:1}},attributes:{type:"cross",id:r.id,name:r.name,districtId:t?e.id:e.parentId,subDistrictId:t?"":e.id},popupTemplate:{title:r.name,content:[{type:"fields",fieldInfos:[{fieldName:"districtId",label:"区控编号"},{fieldName:"subDistrictId",label:"子区编号"},{fieldName:"id",label:"路口编号"}]}]}}));this.crossLayer.addMany(a)}}exports.default=L;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "gisviewer-vue3-arcgis",
3
- "version": "1.0.131",
3
+ "version": "1.0.133",
4
4
  "main": "lib/index.js",
5
5
  "module": "es/index.mjs",
6
6
  "files": [