@dra2020/baseclient 1.0.90 → 1.0.92

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
@@ -10,6 +10,7 @@ export declare type GeoCentroidMap = {
10
10
  y: number;
11
11
  };
12
12
  };
13
+ export declare function dumpMetrics(): void;
13
14
  export interface NormalizeOptions {
14
15
  joinPolygons?: boolean;
15
16
  checkRewind?: boolean;
package/lib/geo/geo.ts CHANGED
@@ -8,6 +8,24 @@ export type GeoFeatureArray = GeoFeature[];
8
8
  export type GeoFeatureCollection = geojson.FeatureCollection;
9
9
  export type GeoCentroidMap = { [geoid: string]: { x: number, y: number } };
10
10
 
11
+ // Tracing/debugging aid
12
+ let metrics: { [action: string]: { count: number, total: number } } = {};
13
+
14
+ function record(action: string, total: number): void
15
+ {
16
+ if (metrics[action] === undefined)
17
+ metrics[action] = { count: 0, total: 0 };
18
+ metrics[action].count++;
19
+ metrics[action].total += total;
20
+ }
21
+
22
+ export function dumpMetrics(): void
23
+ {
24
+ Object.keys(metrics).forEach(action => {
25
+ console.log(`G.${action}: count: ${metrics[action].count}, total: ${metrics[action].total}`);
26
+ });
27
+ }
28
+
11
29
  export interface NormalizeOptions
12
30
  {
13
31
  joinPolygons?: boolean,
@@ -151,6 +169,8 @@ export function geoCollectionToTopo(col: GeoFeatureCollection): Poly.Topo
151
169
  {
152
170
  let topo = Poly.topoFromCollection(col);
153
171
  Poly.topoPack(topo);
172
+ record('coltotopo', col.features.length);
173
+ if ((col as any).datasets) (topo as any).datasets = (col as any).datasets;
154
174
  return topo;
155
175
  }
156
176
 
@@ -163,6 +183,8 @@ export function geoTopoToCollection(topo: Poly.Topo): GeoFeatureCollection
163
183
  {
164
184
  let col = Poly.topoToCollection(topo);
165
185
  Poly.featurePack(col);
186
+ record('topotocol', col.features.length);
187
+ if ((topo as any).datasets) (col as any).datasets = (topo as any).datasets;
166
188
  return col;
167
189
  }
168
190
 
@@ -354,8 +376,16 @@ export class GeoMultiCollection
354
376
  if (n == 1)
355
377
  this.all.col = this._col(this.nthEntry(0));
356
378
  else
379
+ {
357
380
  // Going from map to collection guarantees that any duplicates are removed
358
381
  this.all.col = geoMapToCollectionNonNull(this.allMap());
382
+ this.forEachEntry(e => {
383
+ if (e.col && (e.col as any).datasets)
384
+ (this.all.col as any).datasets = (e.col as any).datasets;
385
+ if (e.topo && (e.topo as any).datasets)
386
+ (this.all.col as any).datasets = (e.topo as any).datasets;
387
+ });
388
+ }
359
389
  }
360
390
  return this.all.col;
361
391
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dra2020/baseclient",
3
- "version": "1.0.90",
3
+ "version": "1.0.92",
4
4
  "description": "Utility functions for Javascript projects.",
5
5
  "main": "dist/baseclient.js",
6
6
  "types": "./dist/all/all.d.ts",