@dra2020/baseclient 1.0.108 → 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.
@@ -2655,12 +2655,19 @@ class GeoMultiCollection {
2655
2655
  e.topo = geoCollectionToTopoNonNull(e.col);
2656
2656
  else if (e.map) {
2657
2657
  e.col = geoMapToCollectionNonNull(e.map);
2658
- console.log(`toposplice: constructing topology for ${e.col.features.length} features`);
2659
2658
  e.topo = geoCollectionToTopoNonNull(e.col);
2660
2659
  }
2661
2660
  }
2662
2661
  return e.topo;
2663
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
+ }
2664
2671
  colOf(tag) { return this._col(this.entries[tag]); }
2665
2672
  mapOf(tag) { return this._map(this.entries[tag]); }
2666
2673
  topoOf(tag) { return this._topo(this.entries[tag]); }
@@ -2735,9 +2742,9 @@ class GeoMultiCollection {
2735
2742
  // Old-style, goes through map (to filter hidden) and then collection
2736
2743
  // this.all.topo = geoCollectionToTopoNonNull(this.allCol());
2737
2744
  // New style, use splice on packed topologies
2738
- console.log(`toposplice: splicing ${this.nEntries} topologies`);
2739
- let topoarray = Object.values(this.entries).map((e) => { return { topology: this._topo(e), filterout: this.hidden }; });
2740
- 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);
2741
2748
  }
2742
2749
  }
2743
2750
  return this.all.topo;
@@ -2789,14 +2796,7 @@ class GeoMultiCollection {
2789
2796
  }
2790
2797
  get length() {
2791
2798
  let n = 0;
2792
- this.forEachEntry(e => {
2793
- if (e.col)
2794
- n += e.col.features.length;
2795
- else if (e.map)
2796
- n += Util.countKeys(e.map);
2797
- else if (e.topo)
2798
- n += Util.countKeys(e.topo.objects);
2799
- });
2799
+ this.forEachEntry(e => n += this._length(e));
2800
2800
  return n;
2801
2801
  }
2802
2802
  // Use forEach in preference to iteration using this function