@dra2020/baseclient 1.0.162 → 1.0.164

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/all/all.d.ts CHANGED
@@ -28,3 +28,5 @@ import * as DataFlow from '../dataflow/all';
28
28
  export { DataFlow };
29
29
  import * as Detail from '../detail/all';
30
30
  export { Detail };
31
+ import * as Control from '../control/all';
32
+ export { Control };
@@ -53,7 +53,7 @@ var __importStar = (this && this.__importStar) || (function () {
53
53
  };
54
54
  })();
55
55
  Object.defineProperty(exports, "__esModule", ({ value: true }));
56
- exports.Detail = exports.DataFlow = exports.Colors = exports.CSV = exports.Emit = exports.G = exports.FilterExpr = exports.OTE = exports.OT = exports.LogClient = exports.LogAbstract = exports.Poly = exports.FSM = exports.Context = exports.Util = void 0;
56
+ exports.Control = exports.Detail = exports.DataFlow = exports.Colors = exports.CSV = exports.Emit = exports.G = exports.FilterExpr = exports.OTE = exports.OT = exports.LogClient = exports.LogAbstract = exports.Poly = exports.FSM = exports.Context = exports.Util = void 0;
57
57
  // Client and Server
58
58
  const Util = __importStar(__webpack_require__(/*! ../util/all */ "./lib/util/all.ts"));
59
59
  exports.Util = Util;
@@ -85,6 +85,8 @@ const DataFlow = __importStar(__webpack_require__(/*! ../dataflow/all */ "./lib/
85
85
  exports.DataFlow = DataFlow;
86
86
  const Detail = __importStar(__webpack_require__(/*! ../detail/all */ "./lib/detail/all.ts"));
87
87
  exports.Detail = Detail;
88
+ const Control = __importStar(__webpack_require__(/*! ../control/all */ "./lib/control/all.ts"));
89
+ exports.Control = Control;
88
90
 
89
91
 
90
92
  /***/ }),
@@ -729,6 +731,45 @@ function create() {
729
731
  }
730
732
 
731
733
 
734
+ /***/ }),
735
+
736
+ /***/ "./lib/control/all.ts":
737
+ /*!****************************!*\
738
+ !*** ./lib/control/all.ts ***!
739
+ \****************************/
740
+ /***/ (function(__unused_webpack_module, exports, __webpack_require__) {
741
+
742
+
743
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
744
+ if (k2 === undefined) k2 = k;
745
+ var desc = Object.getOwnPropertyDescriptor(m, k);
746
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
747
+ desc = { enumerable: true, get: function() { return m[k]; } };
748
+ }
749
+ Object.defineProperty(o, k2, desc);
750
+ }) : (function(o, m, k, k2) {
751
+ if (k2 === undefined) k2 = k;
752
+ o[k2] = m[k];
753
+ }));
754
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
755
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
756
+ };
757
+ Object.defineProperty(exports, "__esModule", ({ value: true }));
758
+ __exportStar(__webpack_require__(/*! ./control */ "./lib/control/control.ts"), exports);
759
+
760
+
761
+ /***/ }),
762
+
763
+ /***/ "./lib/control/control.ts":
764
+ /*!********************************!*\
765
+ !*** ./lib/control/control.ts ***!
766
+ \********************************/
767
+ /***/ ((__unused_webpack_module, exports) => {
768
+
769
+
770
+ Object.defineProperty(exports, "__esModule", ({ value: true }));
771
+
772
+
732
773
  /***/ }),
733
774
 
734
775
  /***/ "./lib/csv/all.ts":
@@ -2702,16 +2743,20 @@ const Util = __importStar(__webpack_require__(/*! ../util/all */ "./lib/util/all
2702
2743
  const Poly = __importStar(__webpack_require__(/*! ../poly/all */ "./lib/poly/all.ts"));
2703
2744
  // Tracing/debugging aid
2704
2745
  let metrics = {};
2746
+ const MinRecordTotal = 500;
2705
2747
  function record(action, total) {
2706
- if (metrics[action] === undefined)
2707
- metrics[action] = { count: 0, total: 0 };
2708
- metrics[action].count++;
2709
- metrics[action].total += total;
2748
+ if (total > MinRecordTotal) {
2749
+ if (metrics[action] === undefined)
2750
+ metrics[action] = { count: 0, total: 0 };
2751
+ metrics[action].count++;
2752
+ metrics[action].total += total;
2753
+ }
2710
2754
  }
2711
2755
  function dumpMetrics() {
2712
2756
  Object.keys(metrics).forEach(action => {
2713
2757
  console.log(`G.${action}: count: ${metrics[action].count}, total: ${metrics[action].total}`);
2714
2758
  });
2759
+ metrics = {};
2715
2760
  }
2716
2761
  function hidemapConcat(...args) {
2717
2762
  let hm = {};
@@ -6594,6 +6639,7 @@ __exportStar(__webpack_require__(/*! ./shamos */ "./lib/poly/shamos.ts"), export
6594
6639
  __exportStar(__webpack_require__(/*! ./pointinpoly */ "./lib/poly/pointinpoly.ts"), exports);
6595
6640
  __exportStar(__webpack_require__(/*! ./mapto */ "./lib/poly/mapto.ts"), exports);
6596
6641
  __exportStar(__webpack_require__(/*! ./featurecleanholes */ "./lib/poly/featurecleanholes.ts"), exports);
6642
+ __exportStar(__webpack_require__(/*! ./polyhash */ "./lib/poly/polyhash.ts"), exports);
6597
6643
 
6598
6644
 
6599
6645
  /***/ }),
@@ -7488,14 +7534,19 @@ function setLabels(c) {
7488
7534
  //
7489
7535
  // The return value is an object that maps the block feature ids to the district feature id.
7490
7536
  //
7491
- function polyMapToByCentroid(districts, centroids) {
7537
+ function polyMapToByCentroid(districts, centroids, control) {
7492
7538
  let map = {};
7493
7539
  // Cache district boundboxes for quick containment exclusion
7494
7540
  let fs = districts.features;
7495
7541
  let bbDistricts = fs.map(f => BB.boundbox(f));
7496
7542
  let aDistricts = fs.map(f => P.polyArea(f));
7497
7543
  // Walk over blocks, mapping centroid to district
7498
- Object.keys(centroids).forEach(blockid => {
7544
+ let canceled = false;
7545
+ let keys = Object.keys(centroids);
7546
+ keys.forEach((blockid, k) => {
7547
+ canceled = canceled || (control === null || control === void 0 ? void 0 : control.isCanceled());
7548
+ if (canceled)
7549
+ return;
7499
7550
  let x = centroids[blockid].x;
7500
7551
  let y = centroids[blockid].y;
7501
7552
  let fIn = [];
@@ -7516,17 +7567,19 @@ function polyMapToByCentroid(districts, centroids) {
7516
7567
  iLow = fIn[i];
7517
7568
  map[blockid] = fs[iLow].properties.id;
7518
7569
  }
7570
+ if (control)
7571
+ control.statusUpdate(k, keys.length);
7519
7572
  });
7520
- return map;
7573
+ return canceled ? undefined : map;
7521
7574
  }
7522
- function polyMapTo(districts, blocks) {
7575
+ function polyMapTo(districts, blocks, control) {
7523
7576
  // Cache labelx, labely if necessary
7524
7577
  setLabels(blocks);
7525
7578
  let centroids = {};
7526
7579
  blocks.features.forEach(f => {
7527
7580
  centroids[f.properties.id] = { x: f.properties.labelx, y: f.properties.labely };
7528
7581
  });
7529
- return polyMapToByCentroid(districts, centroids);
7582
+ return polyMapToByCentroid(districts, centroids, control);
7530
7583
  }
7531
7584
 
7532
7585
 
@@ -9015,6 +9068,98 @@ function topoFromBuffer(coder, ab) {
9015
9068
  }
9016
9069
 
9017
9070
 
9071
+ /***/ }),
9072
+
9073
+ /***/ "./lib/poly/polyhash.ts":
9074
+ /*!******************************!*\
9075
+ !*** ./lib/poly/polyhash.ts ***!
9076
+ \******************************/
9077
+ /***/ (function(__unused_webpack_module, exports, __webpack_require__) {
9078
+
9079
+
9080
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
9081
+ if (k2 === undefined) k2 = k;
9082
+ var desc = Object.getOwnPropertyDescriptor(m, k);
9083
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
9084
+ desc = { enumerable: true, get: function() { return m[k]; } };
9085
+ }
9086
+ Object.defineProperty(o, k2, desc);
9087
+ }) : (function(o, m, k, k2) {
9088
+ if (k2 === undefined) k2 = k;
9089
+ o[k2] = m[k];
9090
+ }));
9091
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
9092
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
9093
+ }) : function(o, v) {
9094
+ o["default"] = v;
9095
+ });
9096
+ var __importStar = (this && this.__importStar) || (function () {
9097
+ var ownKeys = function(o) {
9098
+ ownKeys = Object.getOwnPropertyNames || function (o) {
9099
+ var ar = [];
9100
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
9101
+ return ar;
9102
+ };
9103
+ return ownKeys(o);
9104
+ };
9105
+ return function (mod) {
9106
+ if (mod && mod.__esModule) return mod;
9107
+ var result = {};
9108
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
9109
+ __setModuleDefault(result, mod);
9110
+ return result;
9111
+ };
9112
+ })();
9113
+ Object.defineProperty(exports, "__esModule", ({ value: true }));
9114
+ exports.polyHash32 = polyHash32;
9115
+ const P = __importStar(__webpack_require__(/*! ./poly */ "./lib/poly/poly.ts"));
9116
+ const PP = __importStar(__webpack_require__(/*! ./polypack */ "./lib/poly/polypack.ts"));
9117
+ // Hash coordinates to 32 bit number in order to produce a fast (and a little sloppy) equivalence test.
9118
+ // Note that this depends on ordering, so an equivalent polygon with different coordinate ordering would
9119
+ // not test as equivalent. As a 32 bit number, you can expect collisions when used for large numbers of
9120
+ // polygons (e.g. a 700k block set might expect ~57 collisions - TX at 660K gets 62 collisions, e.g.).
9121
+ //
9122
+ function polyHash32(poly, seed = 0) {
9123
+ let pp = P.polyNormalize(poly);
9124
+ if (!pp)
9125
+ return 0;
9126
+ let h = (seed | 0) ^ 0x9e3779b9;
9127
+ const buf = new ArrayBuffer(8);
9128
+ const dv = new DataView(buf);
9129
+ function mix32(x) {
9130
+ x ^= x >>> 16;
9131
+ x = Math.imul(x, 0x7feb352d);
9132
+ x ^= x >>> 15;
9133
+ x = Math.imul(x, 0x846ca68b);
9134
+ x ^= x >>> 16;
9135
+ return x | 0;
9136
+ }
9137
+ let l = 0;
9138
+ PP.polyPackEachRing(pp, (b, iPoly, iRing, iOffset, nPoints) => {
9139
+ let iEnd = iOffset + (nPoints * 2);
9140
+ for (; iOffset < iEnd; iOffset++) {
9141
+ const x = b[iOffset];
9142
+ if (Number.isNaN(x)) {
9143
+ dv.setUint32(0, 0x7ff80001, true);
9144
+ dv.setUint32(4, 0, true);
9145
+ }
9146
+ else
9147
+ dv.setFloat64(0, x, true);
9148
+ const lo = dv.getUint32(0, true) | 0;
9149
+ const hi = dv.getUint32(4, true) | 0;
9150
+ let z = mix32(lo ^ Math.imul(hi, 0x9e3779b9) ^ Math.imul(l + 1, 0x85ebca6b));
9151
+ h ^= z;
9152
+ h = mix32(h);
9153
+ l++;
9154
+ }
9155
+ });
9156
+ h ^= l | 0;
9157
+ h = mix32(h);
9158
+ // return as unsigned 32-bit in a JS number
9159
+ return h >>> 0;
9160
+ }
9161
+
9162
+
9018
9163
  /***/ }),
9019
9164
 
9020
9165
  /***/ "./lib/poly/polylabel.ts":
@@ -12375,6 +12520,11 @@ class Elapsed {
12375
12520
  if (this.tDur)
12376
12521
  this.tDur = undefined;
12377
12522
  }
12523
+ restart() {
12524
+ if (this.tStart === undefined)
12525
+ this.start();
12526
+ delete this.tDur;
12527
+ }
12378
12528
  end() {
12379
12529
  if (this.tStart === undefined)
12380
12530
  this.start();
@@ -12391,6 +12541,11 @@ class Elapsed {
12391
12541
  else
12392
12542
  return this.tDur;
12393
12543
  }
12544
+ mscur() {
12545
+ let ms = this.ms();
12546
+ this.restart();
12547
+ return ms;
12548
+ }
12394
12549
  nano() {
12395
12550
  if (this.tDur === undefined)
12396
12551
  this.end();
@@ -12399,6 +12554,11 @@ class Elapsed {
12399
12554
  else
12400
12555
  return this.tDur * 1000000;
12401
12556
  }
12557
+ nanocur() {
12558
+ let nano = this.nano();
12559
+ this.restart();
12560
+ return nano;
12561
+ }
12402
12562
  }
12403
12563
  exports.Elapsed = Elapsed;
12404
12564
  class MultiTimer {