@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.
package/dist/geo/geo.d.ts CHANGED
@@ -62,6 +62,7 @@ export declare class GeoMultiCollection {
62
62
  _col(e: GeoEntry): GeoFeatureCollection;
63
63
  _map(e: GeoEntry): GeoFeatureMap;
64
64
  _topo(e: GeoEntry): Poly.Topo;
65
+ _length(e: GeoEntry): number;
65
66
  colOf(tag: string): GeoFeatureCollection;
66
67
  mapOf(tag: string): GeoFeatureMap;
67
68
  topoOf(tag: string): Poly.Topo;
package/lib/geo/geo.ts CHANGED
@@ -390,13 +390,21 @@ export class GeoMultiCollection
390
390
  else if (e.map)
391
391
  {
392
392
  e.col = geoMapToCollectionNonNull(e.map);
393
- console.log(`toposplice: constructing topology for ${e.col.features.length} features`);
394
393
  e.topo = geoCollectionToTopoNonNull(e.col);
395
394
  }
396
395
  }
397
396
  return e.topo;
398
397
  }
399
398
 
399
+ _length(e: GeoEntry): number
400
+ {
401
+ if (e == null) return 0;
402
+ return e.col ? e.col.features.length
403
+ : e.map ? Util.countKeys(e.map)
404
+ : e.topo ? Util.countKeys(e.topo.objects)
405
+ : 0;
406
+ }
407
+
400
408
  colOf(tag: string): GeoFeatureCollection { return this._col(this.entries[tag]); }
401
409
  mapOf(tag: string): GeoFeatureMap { return this._map(this.entries[tag]); }
402
410
  topoOf(tag: string): Poly.Topo { return this._topo(this.entries[tag]); }
@@ -485,10 +493,9 @@ export class GeoMultiCollection
485
493
  // Old-style, goes through map (to filter hidden) and then collection
486
494
  // this.all.topo = geoCollectionToTopoNonNull(this.allCol());
487
495
  // New style, use splice on packed topologies
488
- console.log(`toposplice: splicing ${this.nEntries} topologies`);
489
- let topoarray = Object.values(this.entries).map((e: GeoEntry) =>
490
- { return { topology: this._topo(e), filterout: this.hidden } });
491
- this.all.topo = Poly.topoSplice(topoarray);
496
+ let topoarray = Object.values(this.entries).filter((e: GeoEntry) => this._length(e) > 0)
497
+ .map((e: GeoEntry) => { return { topology: this._topo(e), filterout: this.hidden } });
498
+ this.all.topo = topoarray.length == 0 ? null : topoarray.length == 1 ? topoarray[0].topology : Poly.topoSplice(topoarray);
492
499
  }
493
500
  }
494
501
  return this.all.topo;
@@ -554,14 +561,7 @@ export class GeoMultiCollection
554
561
  get length(): number
555
562
  {
556
563
  let n = 0;
557
- this.forEachEntry(e => {
558
- if (e.col)
559
- n += e.col.features.length;
560
- else if (e.map)
561
- n += Util.countKeys(e.map);
562
- else if (e.topo)
563
- n += Util.countKeys(e.topo.objects);
564
- });
564
+ this.forEachEntry(e => n += this._length(e));
565
565
  return n;
566
566
  }
567
567
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dra2020/baseclient",
3
- "version": "1.0.108",
3
+ "version": "1.0.110",
4
4
  "description": "Utility functions for Javascript projects.",
5
5
  "main": "dist/baseclient.js",
6
6
  "types": "./dist/all/all.d.ts",