@dra2020/baseclient 1.0.94 → 1.0.96

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.
@@ -2575,21 +2575,25 @@ class GeoMultiCollection {
2575
2575
  }
2576
2576
  // Add the "all" collection from the passed in multi, but do not force compute of any things not computed yet.
2577
2577
  addAll(tag, multi) {
2578
- let nEntries = Util.countKeys(multi.entries);
2579
- if (nEntries) {
2580
- // Make sure all collection is created
2581
- if (!multi.all.topo && !multi.all.col && !multi.all.map) {
2582
- // Create cheapest one (collection if I need to create, otherwise copy from single entry)
2583
- if (nEntries > 1)
2584
- multi.allCol();
2585
- else {
2586
- let e = multi.nthEntry(0);
2587
- multi.all.topo = e.topo;
2588
- multi.all.col = e.col;
2589
- multi.all.map = e.map;
2578
+ if (multi == null || Util.isEmpty(multi.entries))
2579
+ this.remove(tag);
2580
+ else {
2581
+ let nEntries = Util.countKeys(multi.entries);
2582
+ if (nEntries) {
2583
+ // Make sure all collection is created
2584
+ if (!multi.all.topo && !multi.all.col && !multi.all.map) {
2585
+ // Create cheapest one (collection if I need to create, otherwise copy from single entry)
2586
+ if (nEntries > 1)
2587
+ multi.allCol();
2588
+ else {
2589
+ let e = multi.nthEntry(0);
2590
+ multi.all.topo = e.topo;
2591
+ multi.all.col = e.col;
2592
+ multi.all.map = e.map;
2593
+ }
2590
2594
  }
2595
+ this.add(tag, multi.all.topo, multi.all.col, multi.all.map);
2591
2596
  }
2592
- this.add(tag, multi.all.topo, multi.all.col, multi.all.map);
2593
2597
  }
2594
2598
  }
2595
2599
  remove(tag) {
@@ -2654,8 +2658,12 @@ class GeoMultiCollection {
2654
2658
  if (!this.all.col) {
2655
2659
  // optimise case where one entry
2656
2660
  let n = this.nEntries;
2657
- if (n == 1)
2658
- 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
+ }
2659
2667
  else {
2660
2668
  // Going from map to collection guarantees that any duplicates are removed
2661
2669
  this.all.col = geoMapToCollectionNonNull(this.allMap());
@@ -2675,8 +2683,12 @@ class GeoMultiCollection {
2675
2683
  if (!this.all.map) {
2676
2684
  // optimise case where one entry
2677
2685
  let n = this.nEntries;
2678
- if (n == 1)
2679
- 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
+ }
2680
2692
  else {
2681
2693
  let map = {};
2682
2694
  this.all.map = map;
@@ -2691,8 +2703,12 @@ class GeoMultiCollection {
2691
2703
  if (!this.all.topo) {
2692
2704
  // optimise case where one entry
2693
2705
  let n = this.nEntries;
2694
- if (n == 1)
2695
- this.all.topo = this._topo(this.nthEntry(0));
2706
+ if (n == 1) {
2707
+ let e = this.nthEntry(0);
2708
+ this.all.topo = this._topo(e);
2709
+ this.all.col = this.all.col || e.col;
2710
+ this.all.map = this.all.map || e.map;
2711
+ }
2696
2712
  else
2697
2713
  this.all.topo = geoCollectionToTopoNonNull(this.allCol());
2698
2714
  }
@@ -2786,9 +2802,14 @@ class GeoMultiCollection {
2786
2802
  }
2787
2803
  forEach(cb) {
2788
2804
  this.forEachEntry(e => {
2789
- let col = this._col(e);
2790
2805
  if (e.col)
2791
- e.col.features.forEach(f => { if (this.hidden[f.properties.id] === undefined)
2806
+ e.col.features.forEach(f => { if (!this.hidden[f.properties.id])
2807
+ cb(f); });
2808
+ else if (e.topo)
2809
+ Object.values(e.topo.objects).forEach((f) => { if (!this.hidden[f.properties.id])
2810
+ cb(f); });
2811
+ else if (e.map)
2812
+ Object.values(e.map).forEach(f => { if (!this.hidden[f.properties.id])
2792
2813
  cb(f); });
2793
2814
  });
2794
2815
  }