@dra2020/baseclient 1.0.95 → 1.0.97

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.
@@ -2658,8 +2658,12 @@ class GeoMultiCollection {
2658
2658
  if (!this.all.col) {
2659
2659
  // optimise case where one entry
2660
2660
  let n = this.nEntries;
2661
- if (n == 1)
2662
- this.all.col = this._col(this.nthEntry(0));
2661
+ if (n == 1) {
2662
+ let e = this.nthEntry(0);
2663
+ this.all.col = this._col(e);
2664
+ this.all.topo = this.all.topo || e.topo;
2665
+ this.all.map = this.all.map || e.map;
2666
+ }
2663
2667
  else {
2664
2668
  // Going from map to collection guarantees that any duplicates are removed
2665
2669
  this.all.col = geoMapToCollectionNonNull(this.allMap());
@@ -2679,12 +2683,19 @@ class GeoMultiCollection {
2679
2683
  if (!this.all.map) {
2680
2684
  // optimise case where one entry
2681
2685
  let n = this.nEntries;
2682
- if (n == 1)
2683
- this.all.map = this._map(this.nthEntry(0));
2686
+ if (n == 1) {
2687
+ let e = this.nthEntry(0);
2688
+ this.all.map = this._map(e);
2689
+ this.all.topo = this.all.topo || e.topo;
2690
+ this.all.col = this.all.col || e.col;
2691
+ }
2684
2692
  else {
2685
2693
  let map = {};
2686
2694
  this.all.map = map;
2687
- this.forEach(f => { map[String(f.properties.id)] = f; });
2695
+ this.forEachEntry(e => {
2696
+ let col = this._col(e); // this ensures we convert feature geometry from topo to polygon
2697
+ col.features.forEach(f => { map[String(f.properties.id)] = f; });
2698
+ });
2688
2699
  }
2689
2700
  }
2690
2701
  return this.all.map;
@@ -2695,8 +2706,12 @@ class GeoMultiCollection {
2695
2706
  if (!this.all.topo) {
2696
2707
  // optimise case where one entry
2697
2708
  let n = this.nEntries;
2698
- if (n == 1)
2699
- this.all.topo = this._topo(this.nthEntry(0));
2709
+ if (n == 1) {
2710
+ let e = this.nthEntry(0);
2711
+ this.all.topo = this._topo(e);
2712
+ this.all.col = this.all.col || e.col;
2713
+ this.all.map = this.all.map || e.map;
2714
+ }
2700
2715
  else
2701
2716
  this.all.topo = geoCollectionToTopoNonNull(this.allCol());
2702
2717
  }
@@ -2790,9 +2805,14 @@ class GeoMultiCollection {
2790
2805
  }
2791
2806
  forEach(cb) {
2792
2807
  this.forEachEntry(e => {
2793
- let col = this._col(e);
2794
2808
  if (e.col)
2795
- e.col.features.forEach(f => { if (this.hidden[f.properties.id] === undefined)
2809
+ e.col.features.forEach(f => { if (!this.hidden[f.properties.id])
2810
+ cb(f); });
2811
+ else if (e.topo)
2812
+ Object.values(e.topo.objects).forEach((f) => { if (!this.hidden[f.properties.id])
2813
+ cb(f); });
2814
+ else if (e.map)
2815
+ Object.values(e.map).forEach(f => { if (!this.hidden[f.properties.id])
2796
2816
  cb(f); });
2797
2817
  });
2798
2818
  }