@dra2020/baseclient 1.0.89 → 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.
@@ -2347,9 +2347,23 @@ var __importStar = (this && this.__importStar) || function (mod) {
2347
2347
  return result;
2348
2348
  };
2349
2349
  Object.defineProperty(exports, "__esModule", ({ value: true }));
2350
- exports.geoIntersect = exports.geoIntersectOptions = exports.GeoMultiCollection = exports.geoMapEqual = exports.geoEqual = exports.geoTopoToCollectionNonNull = exports.geoTopoToCollection = exports.geoCollectionToTopoNonNull = exports.geoCollectionToTopo = exports.geoMapToCollectionNonNull = exports.geoMapToCollection = exports.geoCollectionToMap = exports.geoNormalizeCollection = exports.geoNormalizeFeature = exports.geoEnsureID = void 0;
2350
+ exports.geoIntersect = exports.geoIntersectOptions = exports.GeoMultiCollection = exports.geoMapEqual = exports.geoEqual = exports.geoTopoToCollectionNonNull = exports.geoTopoToCollection = exports.geoCollectionToTopoNonNull = exports.geoCollectionToTopo = exports.geoMapToCollectionNonNull = exports.geoMapToCollection = exports.geoCollectionToMap = exports.geoNormalizeCollection = exports.geoNormalizeFeature = exports.geoEnsureID = exports.dumpMetrics = void 0;
2351
2351
  const Util = __importStar(__webpack_require__(/*! ../util/all */ "./lib/util/all.ts"));
2352
2352
  const Poly = __importStar(__webpack_require__(/*! ../poly/all */ "./lib/poly/all.ts"));
2353
+ // Tracing/debugging aid
2354
+ let metrics = {};
2355
+ function record(action, total) {
2356
+ if (metrics[action] === undefined)
2357
+ metrics[action] = { count: 0, total: 0 };
2358
+ metrics[action].count++;
2359
+ metrics[action].total += total;
2360
+ }
2361
+ function dumpMetrics() {
2362
+ Object.keys(metrics).forEach(action => {
2363
+ console.log(`G.${action}: count: ${metrics[action].count}, total: ${metrics[action].total}`);
2364
+ });
2365
+ }
2366
+ exports.dumpMetrics = dumpMetrics;
2353
2367
  const NormalizeAll = { joinPolygons: true, checkRewind: true, ensureID: true };
2354
2368
  // set the canonical 'id' property from the best property value.
2355
2369
  // if joinPolygons is true, we do not enforce uniqueness.
@@ -2443,6 +2457,7 @@ exports.geoNormalizeCollection = geoNormalizeCollection;
2443
2457
  function geoCollectionToMap(col) {
2444
2458
  if (col == null)
2445
2459
  return null;
2460
+ record('coltomap', col.features.length);
2446
2461
  let map = {};
2447
2462
  col.features.forEach((f) => { map[String(f.properties.id)] = f; });
2448
2463
  return map;
@@ -2459,12 +2474,14 @@ function geoMapToCollectionNonNull(map) {
2459
2474
  return null;
2460
2475
  let col = { type: 'FeatureCollection', features: [] };
2461
2476
  Object.keys(map).forEach((geoid) => { col.features.push(map[geoid]); });
2477
+ record('maptocol', col.features.length);
2462
2478
  return col;
2463
2479
  }
2464
2480
  exports.geoMapToCollectionNonNull = geoMapToCollectionNonNull;
2465
2481
  function geoCollectionToTopo(col) {
2466
2482
  let topo = Poly.topoFromCollection(col);
2467
2483
  Poly.topoPack(topo);
2484
+ record('coltotopo', col.features.length);
2468
2485
  return topo;
2469
2486
  }
2470
2487
  exports.geoCollectionToTopo = geoCollectionToTopo;
@@ -2475,6 +2492,7 @@ exports.geoCollectionToTopoNonNull = geoCollectionToTopoNonNull;
2475
2492
  function geoTopoToCollection(topo) {
2476
2493
  let col = Poly.topoToCollection(topo);
2477
2494
  Poly.featurePack(col);
2495
+ record('topotocol', col.features.length);
2478
2496
  return col;
2479
2497
  }
2480
2498
  exports.geoTopoToCollection = geoTopoToCollection;
@@ -2754,9 +2772,7 @@ class GeoMultiCollection {
2754
2772
  isHidden(id) {
2755
2773
  return this.hidden[id] !== undefined;
2756
2774
  }
2757
- find(id) {
2758
- if (this.hidden[id] !== undefined)
2759
- return undefined;
2775
+ findNoHide(id) {
2760
2776
  let entries = Object.values(this.entries);
2761
2777
  for (let i = 0; i < entries.length; i++) {
2762
2778
  let map = this._map(entries[i]);
@@ -2765,6 +2781,11 @@ class GeoMultiCollection {
2765
2781
  }
2766
2782
  return undefined;
2767
2783
  }
2784
+ find(id) {
2785
+ if (this.hidden[id] !== undefined)
2786
+ return undefined;
2787
+ return this.findNoHide(id);
2788
+ }
2768
2789
  filter(test) {
2769
2790
  let m = new GeoMultiCollection();
2770
2791
  this.forEachEntry(e => {