@vcmap/viewshed 2.0.1 → 2.0.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -1,12 +1,12 @@
1
- var ue = Object.defineProperty;
2
- var fe = (s, e, t) => e in s ? ue(s, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : s[e] = t;
3
- var Z = (s, e, t) => (fe(s, typeof e != "symbol" ? e + "" : e, t), t);
4
- import { VcsCameraPrimitive as ve, VcsObject as pe, VcsEvent as L, AbstractInteraction as we, EventType as D, Projection as I, SessionType as me, CesiumMap as B, startEditFeaturesSession as ge, startEditGeometrySession as _e, VectorLayer as Ce, wgs84Projection as Ee, maxZIndex as Ve, markVolatile as ye, Viewpoint as be, TransformationMode as Me, Category as Te, moduleIdSymbol as Oe } from "../../../assets/core.js";
5
- import { Color as k, Matrix4 as Se, Transforms as Pe, Primitive as q, GeometryInstance as Q, SphereGeometry as Ae, ColorGeometryInstanceAttribute as ee, PerInstanceColorAppearance as te, SphereOutlineGeometry as Ie, Math as O, Cartesian3 as S, ShadowMap as Re, Camera as $e, HeightReference as Ne } from "../../../assets/cesium.js";
6
- import { shallowRef as H, ref as A, nextTick as xe, inject as ie, reactive as j, watchEffect as De, watch as R, onMounted as Le, onUnmounted as Fe, computed as ke } from "../../../assets/vue.js";
1
+ var fe = Object.defineProperty;
2
+ var ve = (s, e, t) => e in s ? fe(s, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : s[e] = t;
3
+ var Z = (s, e, t) => (ve(s, typeof e != "symbol" ? e + "" : e, t), t);
4
+ import { VcsCameraPrimitive as pe, VcsObject as we, VcsEvent as L, AbstractInteraction as me, EventType as D, Projection as I, SessionType as ge, CesiumMap as B, startEditFeaturesSession as _e, startEditGeometrySession as Ce, VectorLayer as Ee, wgs84Projection as Ve, maxZIndex as ye, markVolatile as be, Viewpoint as Me, TransformationMode as Te, Category as Oe, moduleIdSymbol as Se } from "../../../assets/core.js";
5
+ import { Color as k, Matrix4 as Pe, Transforms as Ae, Primitive as q, GeometryInstance as Q, SphereGeometry as Ie, ColorGeometryInstanceAttribute as ee, PerInstanceColorAppearance as te, SphereOutlineGeometry as Re, Math as O, Cartesian3 as S, ShadowMap as $e, Camera as Ne, HeightReference as xe } from "../../../assets/cesium.js";
6
+ import { shallowRef as H, ref as A, nextTick as De, inject as ie, computed as se, reactive as j, watchEffect as Le, watch as R, onMounted as Fe, onUnmounted as ke } from "../../../assets/vue.js";
7
7
  import { ol$Observable$unByKey as je, Feature as We, ol$geom$Point as Be, ol$style$Style as ze } from "../../../assets/ol.js";
8
- import { VcsTextField as Ge, VcsSlider as Ue, VcsLabel as oe, VcsFormSection as ne, VcsSelect as re, VcsFormButton as He, VcsFeatureTransforms as Xe, makeEditorCollectionComponentClass as Ke, WindowSlot as Ye, ToolboxType as Je, createListExportAction as Ze, downloadText as qe, createListImportAction as Qe, AbstractConfigEditor as et } from "../../../assets/ui.js";
9
- import { VContainer as ae, VRow as le, VCol as ce, VDivider as tt, VColorPicker as it } from "../../../assets/vuetify.js";
8
+ import { VcsTextField as Ge, VcsSlider as Ue, VcsLabel as ne, VcsFormSection as re, VcsSelect as ae, VcsFormButton as He, VcsFeatureTransforms as Xe, makeEditorCollectionComponentClass as Ke, WindowSlot as Ye, ToolboxType as Je, createListExportAction as Ze, downloadText as qe, createListImportAction as Qe, AbstractConfigEditor as et } from "../../../assets/ui.js";
9
+ import { VContainer as le, VRow as ce, VCol as de, VDivider as tt, VColorPicker as it } from "../../../assets/vuetify.js";
10
10
  const x = [
11
11
  [String, "string"],
12
12
  [Number, "number"],
@@ -117,13 +117,13 @@ function K(s) {
117
117
  }
118
118
  return t;
119
119
  }
120
- function de(s, e, t) {
120
+ function he(s, e, t) {
121
121
  const i = t ? `${t}.` : "";
122
122
  let o = !1;
123
123
  return Object.keys(s).find((a) => {
124
124
  if (W(e[a])) {
125
125
  const l = s[a];
126
- o = de(l, e[a], i + a);
126
+ o = he(l, e[a], i + a);
127
127
  } else
128
128
  e[a] || (o = `Found additional key ${i}${a}`);
129
129
  return o = o ? o.replace(/\sin.*/, "") : !1, o;
@@ -148,7 +148,7 @@ function rt(s, e, t) {
148
148
  if (typeof l != "object")
149
149
  throw new Error(`Cannot handler pattern ${l}`);
150
150
  const c = X(a, l);
151
- return c || (t ? de(a, l) : !1);
151
+ return c || (t ? he(a, l) : !1);
152
152
  };
153
153
  let o;
154
154
  return Array.isArray(e) && e.length > 1 ? e.every((a) => i(s, a)) && (o = `Expected ${M(s)} to be a ${e.map((a) => K(a)).join(" or ")}`) : o = i(s, e), o;
@@ -167,8 +167,8 @@ function at(s, e, t) {
167
167
  }
168
168
  return t;
169
169
  }
170
- const lt = new k(), G = new Se();
171
- class ct extends ve {
170
+ const lt = new k(), G = new Pe();
171
+ class ct extends pe {
172
172
  constructor(e) {
173
173
  super(e), this.spot = e.spot;
174
174
  }
@@ -182,14 +182,14 @@ class ct extends ve {
182
182
  super.update(e);
183
183
  else {
184
184
  const t = this._planesPrimitives, i = this._outlinePrimitives;
185
- t.length === 0 && (Pe.eastNorthUpToFixedFrame(
185
+ t.length === 0 && (Ae.eastNorthUpToFixedFrame(
186
186
  this._camera.positionWC,
187
187
  void 0,
188
188
  G
189
189
  ), t[0] = new q({
190
190
  allowPicking: this.allowPicking,
191
191
  geometryInstances: new Q({
192
- geometry: new Ae({
192
+ geometry: new Ie({
193
193
  radius: 2
194
194
  }),
195
195
  attributes: {
@@ -207,7 +207,7 @@ class ct extends ve {
207
207
  }), i[0] = new q({
208
208
  allowPicking: this.allowPicking,
209
209
  geometryInstances: new Q({
210
- geometry: new Ie({
210
+ geometry: new Re({
211
211
  radius: 2
212
212
  }),
213
213
  attributes: {
@@ -232,13 +232,13 @@ const w = {
232
232
  THREESIXTY: "360"
233
233
  };
234
234
  function dt(s, e) {
235
- const t = new $e(s), i = (
235
+ const t = new Ne(s), i = (
236
236
  /** @type {import("@vcmap-cesium/engine").PerspectiveFrustum} */
237
237
  t.frustum
238
238
  );
239
239
  return i.fov = e.fov, i.near = e.near, i.aspectRatio = e.aspectRatio, i.far = e.far, t;
240
240
  }
241
- const E = class E extends pe {
241
+ const E = class E extends we {
242
242
  static get className() {
243
243
  return "Viewshed";
244
244
  }
@@ -442,7 +442,7 @@ const E = class E extends pe {
442
442
  * Updates the shadow map by creating a new one and applying all the current parameters.
443
443
  */
444
444
  _updateShadowMap() {
445
- !this._active || !this._shadowCamera || !this._cesiumMap || !this._scene || (this._shadowMap = new Re({
445
+ !this._active || !this._shadowCamera || !this._cesiumMap || !this._scene || (this._shadowMap = new $e({
446
446
  // @ts-ignore
447
447
  context: this._scene.context,
448
448
  lightCamera: this._shadowCamera,
@@ -454,7 +454,7 @@ const E = class E extends pe {
454
454
  pointLightRadius: this._shadowCamera.frustum.far,
455
455
  maximumDistance: 200,
456
456
  size: 2048
457
- }), this._shadowMap.viewshed = this._colors, this._scene.shadowMap = this._shadowMap, this._cesiumMap.setShadowMap(this._shadowMap));
457
+ }), this._shadowMap.viewshed = this._colors, this._cesiumMap.setShadowMap(this._shadowMap));
458
458
  }
459
459
  _removePrimitive() {
460
460
  var e;
@@ -514,7 +514,7 @@ const E = class E extends pe {
514
514
  };
515
515
  Z(E, "MIN_DISTANCE", 10);
516
516
  let T = E;
517
- class ht extends we {
517
+ class ht extends me {
518
518
  /**
519
519
  *
520
520
  * @param {import("./viewshed").default} viewshed
@@ -544,15 +544,15 @@ const V = {
544
544
  EDIT: "edit",
545
545
  MOVE: "move",
546
546
  MULTI_SELECT: "multiSelect"
547
- }, se = 1.8;
547
+ }, oe = 1.8;
548
548
  function ut(s) {
549
- const e = new Ce({
550
- projection: Ee.toJSON(),
551
- zIndex: Ve - 1
549
+ const e = new Ee({
550
+ projection: Ve.toJSON(),
551
+ zIndex: ye - 1
552
552
  });
553
- ye(e), e.activate();
553
+ be(e), e.activate();
554
554
  const t = new We(new Be(s));
555
- return t.setStyle(new ze({})), e.addFeatures([t]), e.vectorProperties.altitudeMode = Ne.NONE, {
555
+ return t.setStyle(new ze({})), e.addFeatures([t]), e.vectorProperties.altitudeMode = xe.NONE, {
556
556
  layer: e,
557
557
  feature: t,
558
558
  destroy() {
@@ -569,24 +569,24 @@ function ft(s, e, t) {
569
569
  let l = () => {
570
570
  };
571
571
  const n = H(null);
572
- function u(d) {
573
- var f, h;
574
- o.value && i.value ? (i.value.deactivate(), t.setVisibility(i.value.name, !1)) : (f = i.value) == null || f.destroy(), i.value = d, (h = i.value) == null || h.activate(s.maps.activeMap);
572
+ function u(h) {
573
+ var f, d;
574
+ o.value && i.value ? (i.value.deactivate(), t.setVisibility(i.value.name, !1)) : (f = i.value) == null || f.destroy(), i.value = h, (d = i.value) == null || d.activate(s.maps.activeMap);
575
575
  }
576
- function c(d = !0) {
577
- l(), u(null), d && t.clearSelection(), o.value = null, r.value = null;
576
+ function c(h = !0) {
577
+ l(), u(null), h && t.clearSelection(), o.value = null, r.value = null;
578
578
  }
579
- async function m(d) {
580
- c(), await xe();
581
- const { eventHandler: f } = s.maps, { featureInteraction: h } = f;
579
+ async function m(h) {
580
+ c(), await De();
581
+ const { eventHandler: f } = s.maps, { featureInteraction: d } = f;
582
582
  i.value = new T(
583
583
  {
584
- viewshedType: d,
584
+ viewshedType: h,
585
585
  colorOptions: {
586
586
  visibleColor: e.visibleColor,
587
587
  shadowColor: e.shadowColor
588
588
  },
589
- heightOffset: a.value === V.ABSOLUTE ? 0 : se
589
+ heightOffset: a.value === V.ABSOLUTE ? 0 : oe
590
590
  },
591
591
  /** @type {import("@vcmap/core").CesiumMap} */
592
592
  s.maps.activeMap
@@ -601,23 +601,23 @@ function ft(s, e, t) {
601
601
  p.destroy();
602
602
  }
603
603
  );
604
- U(h, a.value), p.positioned.addEventListener(() => {
605
- U(h, V.ABSOLUTE);
604
+ U(d, a.value), p.positioned.addEventListener(() => {
605
+ U(d, V.ABSOLUTE);
606
606
  }), l = () => {
607
- C(), p.destroy(), h.setActive(), l = () => {
607
+ C(), p.destroy(), d.setActive(), l = () => {
608
608
  };
609
609
  }, r.value = g.CREATE;
610
610
  }
611
- function v(d) {
611
+ function v(h) {
612
612
  var f;
613
- if (i.value && d) {
613
+ if (i.value && h) {
614
614
  l();
615
615
  const {
616
- layer: h,
616
+ layer: d,
617
617
  feature: p,
618
618
  destroy: C
619
619
  } = ut(i.value.position);
620
- s.layers.add(h), a.value === V.ABSOLUTE ? (n.value = ge(s, h), n.value.setFeatures([p])) : (n.value = _e(s, h), n.value.setFeature(p)), n.value.stopped.addEventListener(() => {
620
+ s.layers.add(d), a.value === V.ABSOLUTE ? (n.value = _e(s, d), n.value.setFeatures([p])) : (n.value = Ce(s, d), n.value.setFeature(p)), n.value.stopped.addEventListener(() => {
621
621
  l();
622
622
  });
623
623
  const b = (f = p.getGeometry()) == null ? void 0 : f.on("change", () => {
@@ -629,50 +629,50 @@ function ft(s, e, t) {
629
629
  r.value = g.MOVE, l = () => {
630
630
  var N;
631
631
  l = () => {
632
- }, b && je(b), (N = n.value) == null || N.stop(), n.value = null, s.layers.remove(h), C(), r.value = g.EDIT;
632
+ }, b && je(b), (N = n.value) == null || N.stop(), n.value = null, s.layers.remove(d), C(), r.value = g.EDIT;
633
633
  };
634
634
  } else
635
635
  l();
636
636
  }
637
- function _(d, f) {
638
- l(), i.value !== f && (u(f), a.value = f.heightOffset ? V.RELATIVE : V.ABSOLUTE), o.value = !!f.properties.title, r.value = d, o.value && t.setVisibility(f.name, !0);
637
+ function _(h, f) {
638
+ l(), i.value !== f && (u(f), a.value = f.heightOffset ? V.RELATIVE : V.ABSOLUTE), o.value = !!f.properties.title, r.value = h, o.value && t.setVisibility(f.name, !0);
639
639
  }
640
640
  const y = [
641
641
  t.collectionComponent.collection.removed.addEventListener(
642
- (d) => {
642
+ (h) => {
643
643
  var f;
644
- t.remove(d.name), ((f = i.value) == null ? void 0 : f.name) === d.name && c();
644
+ t.remove(h.name), ((f = i.value) == null ? void 0 : f.name) === h.name && c();
645
645
  }
646
646
  ),
647
- t.renamed.addEventListener(({ item: d, title: f }) => {
647
+ t.renamed.addEventListener(({ item: h, title: f }) => {
648
648
  var p;
649
- const h = s.windowManager.get(
649
+ const d = s.windowManager.get(
650
650
  `${t.collectionComponent.id}-editor`
651
651
  );
652
- h && ((p = i.value) == null ? void 0 : p.name) === d.name && (h.state.headerTitle = f);
652
+ d && ((p = i.value) == null ? void 0 : p.name) === h.name && (d.state.headerTitle = f);
653
653
  }),
654
- t.visibilityChanged.addEventListener((d) => {
655
- var h;
656
- const f = ((h = i.value) == null ? void 0 : h.name) === d.name;
657
- f ? c() : (_(g.VIEW, d), t.clearSelection()), t.setVisibility(d.name, !f);
654
+ t.visibilityChanged.addEventListener((h) => {
655
+ var d;
656
+ const f = ((d = i.value) == null ? void 0 : d.name) === h.name;
657
+ f ? c() : (_(g.VIEW, h), t.clearSelection()), t.setVisibility(h.name, !f);
658
658
  })
659
659
  ];
660
- function $(d) {
661
- if (!(d === a.value || !i.value)) {
662
- if (a.value = d, r.value === g.MOVE && l(), r.value === g.CREATE)
660
+ function $(h) {
661
+ if (!(h === a.value || !i.value)) {
662
+ if (a.value = h, r.value === g.MOVE && l(), r.value === g.CREATE)
663
663
  U(
664
664
  s.maps.eventHandler.featureInteraction,
665
- d
666
- ), i.value.heightOffset = d === V.ABSOLUTE ? 0 : se;
665
+ h
666
+ ), i.value.heightOffset = h === V.ABSOLUTE ? 0 : oe;
667
667
  else if (r.value === g.EDIT) {
668
- const { position: f, heightOffset: h } = i.value;
669
- d === V.RELATIVE ? s.maps.activeMap.getHeightFromTerrain([I.wgs84ToMercator(f)]).then((p) => {
668
+ const { position: f, heightOffset: d } = i.value;
669
+ h === V.RELATIVE ? s.maps.activeMap.getHeightFromTerrain([I.wgs84ToMercator(f)]).then((p) => {
670
670
  const C = I.mercatorToWgs84(p[0]);
671
671
  i.value && (i.value.heightOffset = f[2] - C[2], i.value.position = C);
672
672
  }) : (i.value.position = [
673
673
  f[0],
674
674
  f[1],
675
- f[2] + h
675
+ f[2] + d
676
676
  ], i.value.heightOffset = 0);
677
677
  }
678
678
  }
@@ -682,11 +682,11 @@ function ft(s, e, t) {
682
682
  currentIsPersisted: o,
683
683
  currentEditSession: n,
684
684
  createViewshed: m,
685
- viewViewshed(d) {
686
- _(g.VIEW, d);
685
+ viewViewshed(h) {
686
+ _(g.VIEW, h);
687
687
  },
688
- editViewshed(d) {
689
- _(g.EDIT, d), o.value && (t.setSelection(d.name), t.collectionComponent.openEditorWindow(d));
688
+ editViewshed(h) {
689
+ _(g.EDIT, h), o.value && (t.setSelection(h.name), t.collectionComponent.openEditorWindow(h));
690
690
  },
691
691
  persistCurrent() {
692
692
  i.value && (t.add(i.value), o.value = !0, t.setSelection(i.value.name), t.setVisibility(i.value.name, !0));
@@ -699,8 +699,8 @@ function ft(s, e, t) {
699
699
  heightMode: a,
700
700
  changeHeightMode: $,
701
701
  async placeCurrentFeaturesOnTerrain() {
702
- var d, f;
703
- if (i.value && ((d = n.value) == null ? void 0 : d.type) === me.EDIT_FEATURES && s.maps.activeMap instanceof B) {
702
+ var h, f;
703
+ if (i.value && ((h = n.value) == null ? void 0 : h.type) === ge.EDIT_FEATURES && s.maps.activeMap instanceof B) {
704
704
  const p = (await s.maps.activeMap.getHeightFromTerrain([
705
705
  I.wgs84ToMercator((f = i.value) == null ? void 0 : f.position)
706
706
  ]))[0][2] - i.value.position[2];
@@ -709,11 +709,11 @@ function ft(s, e, t) {
709
709
  },
710
710
  stop: c,
711
711
  destroy() {
712
- c(), y.forEach((d) => d());
712
+ c(), y.forEach((h) => h());
713
713
  }
714
714
  };
715
715
  }
716
- function he(s, e, t, i, o, r, a, l) {
716
+ function ue(s, e, t, i, o, r, a, l) {
717
717
  var n = typeof s == "function" ? s.options : s;
718
718
  e && (n.render = e, n.staticRenderFns = t, n._compiled = !0), i && (n.functional = !0), r && (n._scopeId = "data-v-" + r);
719
719
  var u;
@@ -750,14 +750,14 @@ const vt = {
750
750
  }, pt = {
751
751
  components: {
752
752
  VcsTextField: Ge,
753
- VContainer: ae,
754
- VRow: le,
755
- VCol: ce,
753
+ VContainer: le,
754
+ VRow: ce,
755
+ VCol: de,
756
756
  VcsSlider: Ue,
757
- VcsLabel: oe,
758
- VcsFormSection: ne,
757
+ VcsLabel: ne,
758
+ VcsFormSection: re,
759
759
  VDivider: tt,
760
- VcsSelect: re,
760
+ VcsSelect: ae,
761
761
  VcsFormButton: He,
762
762
  VcsFeatureTransforms: Xe
763
763
  },
@@ -785,7 +785,7 @@ const vt = {
785
785
  currentViewshed: i,
786
786
  mode: o,
787
787
  currentIsPersisted: r
788
- } = e, a = A(s.selection);
788
+ } = e, a = se(() => s.selection);
789
789
  let l = () => {
790
790
  };
791
791
  const n = j({
@@ -808,7 +808,7 @@ const vt = {
808
808
  function y() {
809
809
  _(), i.value && (m.distance = i.value.distance, m.fov = i.value.fov, m.heading = i.value.heading, m.pitch = i.value.pitch, m.showPrimitive = i.value.showPrimitive, v.value = i.value.type);
810
810
  }
811
- De(() => {
811
+ Le(() => {
812
812
  i.value && o.value !== g.CREATE && y();
813
813
  }), R(
814
814
  i,
@@ -822,10 +822,10 @@ const vt = {
822
822
  async function $() {
823
823
  var C, b;
824
824
  (C = i.value) == null || C.deactivate();
825
- const h = (
825
+ const d = (
826
826
  /** @type {import("@vcmap/core").CesiumMap} */
827
827
  (b = t.maps.activeMap.getScene()) == null ? void 0 : b.camera
828
- ), p = h == null ? void 0 : h.changed.addEventListener(() => {
828
+ ), p = d == null ? void 0 : d.changed.addEventListener(() => {
829
829
  c();
830
830
  });
831
831
  c = () => {
@@ -834,22 +834,22 @@ const vt = {
834
834
  };
835
835
  };
836
836
  }
837
- Le(() => {
837
+ Fe(() => {
838
838
  var p;
839
- const h = (p = s.getViewshed) == null ? void 0 : p.call(s);
840
- h && e.editViewshed(h);
841
- }), Fe(() => {
839
+ const d = (p = s.getViewshed) == null ? void 0 : p.call(s);
840
+ d && e.editViewshed(d);
841
+ }), ke(() => {
842
842
  l(), c(), r.value || ((o.value === g.EDIT || o.value === g.MOVE) && i.value ? e.viewViewshed(i.value) : o.value === g.CREATE && e.stop()), a.value && (a.value.length > 1 ? e.setupMultiSelect() : a.value.length === 1 && i.value ? e.viewViewshed(i.value) : (
843
843
  // when a persited viewshed is deselected, stops plugin
844
844
  !a.value.length && o.value === g.EDIT && e.stop(!1)
845
845
  ));
846
846
  }), y();
847
- function d(h, p) {
848
- c(), i.value && (m[h] = p, i.value[h] = p);
847
+ function h(d, p) {
848
+ c(), i.value && (m[d] = p, i.value[d] = p);
849
849
  }
850
- const f = ke(() => {
851
- const h = [];
852
- return v.value === w.CONE && h.push({
850
+ const f = se(() => {
851
+ const d = [];
852
+ return v.value === w.CONE && d.push({
853
853
  name: "jumpToViewpoint",
854
854
  title: u.value ? "viewshed.returnToViewpoint" : "viewshed.jumpToViewpoint",
855
855
  icon: "mdi-human-male",
@@ -857,7 +857,7 @@ const vt = {
857
857
  async callback() {
858
858
  var p, C, b;
859
859
  e.moveCurrentViewshed(!1), i.value && !u.value ? (u.value = await ((p = t.maps.activeMap) == null ? void 0 : p.getViewpoint()), await ((C = t.maps.activeMap) == null ? void 0 : C.gotoViewpoint(
860
- new be({
860
+ new Me({
861
861
  groundPosition: [
862
862
  i.value.position[0],
863
863
  i.value.position[1],
@@ -871,7 +871,7 @@ const vt = {
871
871
  })
872
872
  )), $()) : u.value && ((b = t.maps.activeMap) == null || b.gotoViewpoint(u.value), c());
873
873
  }
874
- }), h.push({
874
+ }), d.push({
875
875
  name: "moveViewshed",
876
876
  title: "viewshed.move",
877
877
  icon: e.heightMode.value === V.RELATIVE ? "$vcsEditVertices" : "mdi-axis-arrow",
@@ -881,31 +881,31 @@ const vt = {
881
881
  o.value !== g.MOVE
882
882
  );
883
883
  }
884
- }), h.unshift({
884
+ }), d.unshift({
885
885
  name: "showPrimitive",
886
886
  title: "viewshed.showPrimitive",
887
887
  icon: "mdi-eye",
888
888
  active: m.showPrimitive,
889
889
  callback() {
890
- this.active = !this.active, d("showPrimitive", this.active);
890
+ this.active = !this.active, h("showPrimitive", this.active);
891
891
  }
892
- }), h;
892
+ }), d;
893
893
  });
894
894
  return {
895
895
  position: n,
896
- setPosition(h, p, C) {
896
+ setPosition(d, p, C) {
897
897
  if (c(), !!i.value) {
898
898
  if (C === 2 && e.heightMode.value === V.RELATIVE)
899
- i.value.heightOffset = Number(h);
899
+ i.value.heightOffset = Number(d);
900
900
  else {
901
901
  const b = [...i.value.position];
902
- b[C] = Number(h), i.value.position = b;
902
+ b[C] = Number(d), i.value.position = b;
903
903
  }
904
- n[p] = Number(h);
904
+ n[p] = Number(d);
905
905
  }
906
906
  },
907
907
  parameters: m,
908
- setParameter: d,
908
+ setParameter: h,
909
909
  parameterRanges: vt,
910
910
  ViewshedPluginModes: g,
911
911
  viewshedMode: o,
@@ -914,7 +914,7 @@ const vt = {
914
914
  ViewshedTypes: w,
915
915
  HeightModes: V,
916
916
  heightMode: e.heightMode,
917
- TransformationMode: Me,
917
+ TransformationMode: Te,
918
918
  changeHeightMode: e.changeHeightMode,
919
919
  async createNewViewshed() {
920
920
  await e.createViewshed(v.value);
@@ -941,7 +941,7 @@ var wt = function() {
941
941
  } } }, [e._v(" " + e._s(e.$t("viewshed.new")) + " ")])], 1) : e.viewshedMode === e.ViewshedPluginModes.CREATE ? t("div", { staticClass: "d-flex w-full justify-end px-2 pt-2 pb-1" }, [t("VcsFormButton", { attrs: { variant: "filled" }, on: { click: function(i) {
942
942
  return e.cancel();
943
943
  } } }, [e._v(" " + e._s(e.$t("viewshed.cancel")) + " ")])], 1) : e._e()], 1);
944
- }, mt = [], gt = /* @__PURE__ */ he(
944
+ }, mt = [], gt = /* @__PURE__ */ ue(
945
945
  pt,
946
946
  wt,
947
947
  mt,
@@ -951,7 +951,7 @@ var wt = function() {
951
951
  null,
952
952
  null
953
953
  );
954
- const _t = gt.exports, P = "@vcmap/viewshed", Ct = "2.0.1", Et = "^5.1", Y = {
954
+ const _t = gt.exports, P = "@vcmap/viewshed", Ct = "2.0.3", Et = "^5.1", Y = {
955
955
  [w.CONE]: "$vcsViewshed",
956
956
  [w.THREESIXTY]: "$vcsViewshedCone"
957
957
  };
@@ -1070,7 +1070,7 @@ function bt(s, e, t, i) {
1070
1070
  s.toolboxManager.remove(a), r();
1071
1071
  };
1072
1072
  }
1073
- class J extends Te {
1073
+ class J extends Oe {
1074
1074
  static get className() {
1075
1075
  return "ViewshedCategory";
1076
1076
  }
@@ -1138,22 +1138,15 @@ async function Tt(s) {
1138
1138
  P
1139
1139
  ), { action: n, destroy: u } = Qe(
1140
1140
  async (c) => {
1141
- const m = c.map((v) => {
1142
- const _ = new FileReader();
1143
- return new Promise((y, $) => {
1144
- _.onload = () => {
1145
- try {
1146
- JSON.parse(_.result).forEach((f) => {
1147
- const h = new T(f);
1148
- o.collection.add(h);
1149
- }), y();
1150
- } catch (d) {
1151
- $(d);
1152
- }
1153
- }, _.readAsText(v);
1154
- });
1155
- });
1156
- await Promise.all(m);
1141
+ await Promise.all(
1142
+ c.map(async (m) => {
1143
+ const v = await m.text();
1144
+ JSON.parse(v).forEach((y) => {
1145
+ const $ = new T(y);
1146
+ o.collection.add($);
1147
+ });
1148
+ })
1149
+ );
1157
1150
  },
1158
1151
  s.windowManager,
1159
1152
  P,
@@ -1210,12 +1203,12 @@ const Ot = {
1210
1203
  title: "Viewshed Editor",
1211
1204
  components: {
1212
1205
  AbstractConfigEditor: et,
1213
- VcsFormSection: ne,
1214
- VContainer: ae,
1215
- VRow: le,
1216
- VCol: ce,
1217
- VcsLabel: oe,
1218
- VcsSelect: re,
1206
+ VcsFormSection: re,
1207
+ VContainer: le,
1208
+ VRow: ce,
1209
+ VCol: de,
1210
+ VcsLabel: ne,
1211
+ VcsSelect: ae,
1219
1212
  VColorPicker: it
1220
1213
  },
1221
1214
  props: {
@@ -1256,7 +1249,7 @@ var St = function() {
1256
1249
  }, expression: "localConfig.visibleColor" } })], 1)], 1), t("v-row", { attrs: { "no-gutters": "" } }, [t("v-col", [t("VcsLabel", { attrs: { "html-for": "viewshed-editor-shadow-color" } }, [e._v(e._s(e.$t("viewshed.editor.shadowColor")))])], 1), t("v-col", [t("VColorPicker", { attrs: { mode: "rgba" }, model: { value: e.localConfig.shadowColor, callback: function(i) {
1257
1250
  e.$set(e.localConfig, "shadowColor", i);
1258
1251
  }, expression: "localConfig.shadowColor" } })], 1)], 1)], 1)], 1) : e._e()], 1);
1259
- }, Pt = [], At = /* @__PURE__ */ he(
1252
+ }, Pt = [], At = /* @__PURE__ */ ue(
1260
1253
  Ot,
1261
1254
  St,
1262
1255
  Pt,
@@ -1287,7 +1280,7 @@ function kt(s) {
1287
1280
  */
1288
1281
  async initialize(i, o) {
1289
1282
  i.categoryClassRegistry.registerClass(
1290
- this[Oe],
1283
+ this[Se],
1291
1284
  J.className,
1292
1285
  J
1293
1286
  );
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vcmap/viewshed",
3
- "version": "2.0.1",
3
+ "version": "2.0.3",
4
4
  "description": "Tool to simulate a \"viewer\" and their field of vision from a certain standpoint in the map. It allows the user to see which areas and buildings can or can't be seen from a specific standpoint, regarding different viewing distances, viewers' sizes and orientations.Th",
5
5
  "type": "module",
6
6
  "main": "src/index.js",
@@ -220,7 +220,7 @@
220
220
  currentIsPersisted,
221
221
  } = viewshedManager;
222
222
 
223
- const selection = ref(props.selection);
223
+ const selection = computed(() => props.selection);
224
224
 
225
225
  let removePositionChangedListener = () => {};
226
226
 
package/src/viewshed.js CHANGED
@@ -486,7 +486,6 @@ export default class Viewshed extends VcsObject {
486
486
  size: 2048,
487
487
  });
488
488
  this._shadowMap.viewshed = this._colors;
489
- this._scene.shadowMap = this._shadowMap;
490
489
  this._cesiumMap.setShadowMap(this._shadowMap);
491
490
  }
492
491
 
@@ -133,25 +133,16 @@ export async function createCategory(app) {
133
133
  const { action: importAction, destroy: destroyImportAction } =
134
134
  createListImportAction(
135
135
  async (files) => {
136
- const promises = files.map((file) => {
137
- const reader = new FileReader();
138
- return new Promise((resolve, reject) => {
139
- reader.onload = () => {
140
- try {
141
- const viewshedOptions = JSON.parse(reader.result);
142
- viewshedOptions.forEach((options) => {
143
- const viewshed = new Viewshed(options);
144
- category.collection.add(viewshed);
145
- });
146
- resolve();
147
- } catch (e) {
148
- reject(e);
149
- }
150
- };
151
- reader.readAsText(file);
152
- });
153
- });
154
- await Promise.all(promises);
136
+ await Promise.all(
137
+ files.map(async (file) => {
138
+ const text = await file.text();
139
+ const viewshedOptions = JSON.parse(text);
140
+ viewshedOptions.forEach((options) => {
141
+ const viewshed = new Viewshed(options);
142
+ category.collection.add(viewshed);
143
+ });
144
+ }),
145
+ );
155
146
  },
156
147
  app.windowManager,
157
148
  name,