@dra2020/baseclient 1.0.109 → 1.0.110

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.
@@ -2660,6 +2660,14 @@ class GeoMultiCollection {
2660
2660
  }
2661
2661
  return e.topo;
2662
2662
  }
2663
+ _length(e) {
2664
+ if (e == null)
2665
+ return 0;
2666
+ return e.col ? e.col.features.length
2667
+ : e.map ? Util.countKeys(e.map)
2668
+ : e.topo ? Util.countKeys(e.topo.objects)
2669
+ : 0;
2670
+ }
2663
2671
  colOf(tag) { return this._col(this.entries[tag]); }
2664
2672
  mapOf(tag) { return this._map(this.entries[tag]); }
2665
2673
  topoOf(tag) { return this._topo(this.entries[tag]); }
@@ -2734,8 +2742,9 @@ class GeoMultiCollection {
2734
2742
  // Old-style, goes through map (to filter hidden) and then collection
2735
2743
  // this.all.topo = geoCollectionToTopoNonNull(this.allCol());
2736
2744
  // New style, use splice on packed topologies
2737
- let topoarray = Object.values(this.entries).map((e) => { return { topology: this._topo(e), filterout: this.hidden }; });
2738
- this.all.topo = Poly.topoSplice(topoarray);
2745
+ let topoarray = Object.values(this.entries).filter((e) => this._length(e) > 0)
2746
+ .map((e) => { return { topology: this._topo(e), filterout: this.hidden }; });
2747
+ this.all.topo = topoarray.length == 0 ? null : topoarray.length == 1 ? topoarray[0].topology : Poly.topoSplice(topoarray);
2739
2748
  }
2740
2749
  }
2741
2750
  return this.all.topo;
@@ -2787,14 +2796,7 @@ class GeoMultiCollection {
2787
2796
  }
2788
2797
  get length() {
2789
2798
  let n = 0;
2790
- this.forEachEntry(e => {
2791
- if (e.col)
2792
- n += e.col.features.length;
2793
- else if (e.map)
2794
- n += Util.countKeys(e.map);
2795
- else if (e.topo)
2796
- n += Util.countKeys(e.topo.objects);
2797
- });
2799
+ this.forEachEntry(e => n += this._length(e));
2798
2800
  return n;
2799
2801
  }
2800
2802
  // Use forEach in preference to iteration using this function