@dra2020/baseclient 1.0.90 → 1.0.91

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,
@@ -128,6 +146,7 @@ export function geoNormalizeCollection(col: GeoFeatureCollection, options?: Norm
128
146
  export function geoCollectionToMap(col: GeoFeatureCollection): GeoFeatureMap
129
147
  {
130
148
  if (col == null) return null;
149
+ record('coltomap', col.features.length);
131
150
  let map: GeoFeatureMap = {};
132
151
  col.features.forEach((f: GeoFeature) => { map[String(f.properties.id)] = f; });
133
152
  return map;
@@ -144,6 +163,7 @@ export function geoMapToCollectionNonNull(map: GeoFeatureMap): GeoFeatureCollect
144
163
  if (map == null) return null;
145
164
  let col: GeoFeatureCollection = { type: 'FeatureCollection', features: [] };
146
165
  Object.keys(map).forEach((geoid: string) => { col.features.push(map[geoid]) });
166
+ record('maptocol', col.features.length);
147
167
  return col;
148
168
  }
149
169
 
@@ -151,6 +171,7 @@ export function geoCollectionToTopo(col: GeoFeatureCollection): Poly.Topo
151
171
  {
152
172
  let topo = Poly.topoFromCollection(col);
153
173
  Poly.topoPack(topo);
174
+ record('coltotopo', col.features.length);
154
175
  return topo;
155
176
  }
156
177
 
@@ -163,6 +184,7 @@ export function geoTopoToCollection(topo: Poly.Topo): GeoFeatureCollection
163
184
  {
164
185
  let col = Poly.topoToCollection(topo);
165
186
  Poly.featurePack(col);
187
+ record('topotocol', col.features.length);
166
188
  return col;
167
189
  }
168
190
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dra2020/baseclient",
3
- "version": "1.0.90",
3
+ "version": "1.0.91",
4
4
  "description": "Utility functions for Javascript projects.",
5
5
  "main": "dist/baseclient.js",
6
6
  "types": "./dist/all/all.d.ts",