@dra2020/baseclient 1.0.21 → 1.0.24

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
@@ -18,3 +18,5 @@ import { FilterExpr } from '../filterexpr/all';
18
18
  export { FilterExpr };
19
19
  import * as G from '../geo/all';
20
20
  export { G };
21
+ import * as Emit from '../emit/all';
22
+ export { Emit };
@@ -39,7 +39,7 @@ var __importStar = (this && this.__importStar) || function (mod) {
39
39
  return result;
40
40
  };
41
41
  Object.defineProperty(exports, "__esModule", ({ value: true }));
42
- exports.G = exports.FilterExpr = exports.OTE = exports.OT = exports.LogClient = exports.LogAbstract = exports.Poly = exports.FSM = exports.Context = exports.Util = void 0;
42
+ exports.Emit = exports.G = exports.FilterExpr = exports.OTE = exports.OT = exports.LogClient = exports.LogAbstract = exports.Poly = exports.FSM = exports.Context = exports.Util = void 0;
43
43
  // Client and Server
44
44
  const Util = __importStar(__webpack_require__(/*! ../util/all */ "./lib/util/all.ts"));
45
45
  exports.Util = Util;
@@ -61,6 +61,8 @@ const all_1 = __webpack_require__(/*! ../filterexpr/all */ "./lib/filterexpr/all
61
61
  Object.defineProperty(exports, "FilterExpr", ({ enumerable: true, get: function () { return all_1.FilterExpr; } }));
62
62
  const G = __importStar(__webpack_require__(/*! ../geo/all */ "./lib/geo/all.ts"));
63
63
  exports.G = G;
64
+ const Emit = __importStar(__webpack_require__(/*! ../emit/all */ "./lib/emit/all.ts"));
65
+ exports.Emit = Emit;
64
66
 
65
67
 
66
68
  /***/ }),
@@ -167,6 +169,71 @@ function create() {
167
169
  exports.create = create;
168
170
 
169
171
 
172
+ /***/ }),
173
+
174
+ /***/ "./lib/emit/all.ts":
175
+ /*!*************************!*\
176
+ !*** ./lib/emit/all.ts ***!
177
+ \*************************/
178
+ /***/ (function(__unused_webpack_module, exports, __webpack_require__) {
179
+
180
+
181
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
182
+ if (k2 === undefined) k2 = k;
183
+ Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
184
+ }) : (function(o, m, k, k2) {
185
+ if (k2 === undefined) k2 = k;
186
+ o[k2] = m[k];
187
+ }));
188
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
189
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
190
+ };
191
+ Object.defineProperty(exports, "__esModule", ({ value: true }));
192
+ __exportStar(__webpack_require__(/*! ./emit */ "./lib/emit/emit.ts"), exports);
193
+
194
+
195
+ /***/ }),
196
+
197
+ /***/ "./lib/emit/emit.ts":
198
+ /*!**************************!*\
199
+ !*** ./lib/emit/emit.ts ***!
200
+ \**************************/
201
+ /***/ ((__unused_webpack_module, exports) => {
202
+
203
+
204
+ Object.defineProperty(exports, "__esModule", ({ value: true }));
205
+ exports.Emit = void 0;
206
+ class Emit {
207
+ constructor() {
208
+ this.onList = {};
209
+ }
210
+ on(eventName, cb) {
211
+ let aCB = this.onList[eventName];
212
+ if (aCB === undefined) {
213
+ aCB = [];
214
+ this.onList[eventName] = aCB;
215
+ }
216
+ aCB.push(cb);
217
+ }
218
+ emit(eventName, arg1, arg2, arg3) {
219
+ let aCB = this.onList[eventName];
220
+ if (aCB !== undefined)
221
+ for (let i = 0; i < aCB.length; i++)
222
+ (aCB[i])(arg1, arg2, arg3);
223
+ }
224
+ off(eventName, cb) {
225
+ let aCB = this.onList[eventName];
226
+ if (aCB !== undefined)
227
+ for (let i = 0; i < aCB.length; i++)
228
+ if (aCB[i] === cb) {
229
+ aCB.splice(i, 1);
230
+ break;
231
+ }
232
+ }
233
+ }
234
+ exports.Emit = Emit;
235
+
236
+
170
237
  /***/ }),
171
238
 
172
239
  /***/ "./lib/filterexpr/all.ts":
@@ -4673,7 +4740,7 @@ var __importStar = (this && this.__importStar) || function (mod) {
4673
4740
  return result;
4674
4741
  };
4675
4742
  Object.defineProperty(exports, "__esModule", ({ value: true }));
4676
- exports.boundboxIntersects = exports.boundboxArea = exports.boundboxPoly = exports.boundbox = exports.boundboxExtend = exports.clipLon = exports.boundboxCY = exports.boundboxCX = exports.boundboxHeight = exports.boundboxWidth = void 0;
4743
+ exports.boundboxContains = exports.boundboxIntersects = exports.boundboxArea = exports.boundboxPoly = exports.boundbox = exports.boundboxExtend = exports.clipLon = exports.boundboxCY = exports.boundboxCX = exports.boundboxHeight = exports.boundboxWidth = void 0;
4677
4744
  const P = __importStar(__webpack_require__(/*! ./poly */ "./lib/poly/poly.ts"));
4678
4745
  function boundboxWidth(bb) { return Math.abs(bb.right - bb.left); }
4679
4746
  exports.boundboxWidth = boundboxWidth;
@@ -4748,6 +4815,10 @@ function boundboxIntersects(bb1, bb2) {
4748
4815
  return !(bb1.left > bb2.right || bb1.right < bb2.left || bb1.top < bb2.bottom || bb1.bottom > bb2.top);
4749
4816
  }
4750
4817
  exports.boundboxIntersects = boundboxIntersects;
4818
+ function boundboxContains(bb, x, y) {
4819
+ return !(bb.left >= x || bb.right < x || bb.top <= y || bb.bottom > y);
4820
+ }
4821
+ exports.boundboxContains = boundboxContains;
4751
4822
 
4752
4823
 
4753
4824
  /***/ }),
@@ -7378,6 +7449,7 @@ const Poly = __importStar(__webpack_require__(/*! ./poly */ "./lib/poly/poly.ts"
7378
7449
  const PP = __importStar(__webpack_require__(/*! ./polypack */ "./lib/poly/polypack.ts"));
7379
7450
  const BB = __importStar(__webpack_require__(/*! ./boundbox */ "./lib/poly/boundbox.ts"));
7380
7451
  const PR = __importStar(__webpack_require__(/*! ./polyround */ "./lib/poly/polyround.ts"));
7452
+ const pointinpoly_1 = __webpack_require__(/*! ./pointinpoly */ "./lib/poly/pointinpoly.ts");
7381
7453
  let _union = undefined;
7382
7454
  let anyPC = PC;
7383
7455
  if (anyPC.union)
@@ -7388,19 +7460,6 @@ if (_union === undefined)
7388
7460
  throw 'Unable to load union function from polygon-clipping';
7389
7461
  ;
7390
7462
  function featureCoords(feature) {
7391
- /*
7392
- if (feature.geometry !== undefined)
7393
- {
7394
- if (feature.geometry.packed !== undefined)
7395
- return PP.polyUnpack(feature.geometry.packed);
7396
- else
7397
- return feature.geometry.coordinates;
7398
- }
7399
- else if (feature.offset !== undefined)
7400
- return PP.polyUnpack(feature);
7401
- else
7402
- return feature;
7403
- */
7404
7463
  if (feature.geometry !== undefined) {
7405
7464
  if (feature.geometry.packed !== undefined)
7406
7465
  return feature.geometry.packed;
@@ -7437,7 +7496,7 @@ class QuadLevel {
7437
7496
  if (features.length <= options.maxLeafCount || this.level >= options.maxDepth) {
7438
7497
  if (this.level >= options.maxDepth)
7439
7498
  throw `QuadTree: maximum depth of ${options.maxDepth} exceeded`;
7440
- this.features = features.map((wp) => wp.p);
7499
+ this.features = features;
7441
7500
  this.children = null;
7442
7501
  }
7443
7502
  else {
@@ -7474,10 +7533,26 @@ class QuadLevel {
7474
7533
  featureInBox(box, f) {
7475
7534
  return BB.boundboxIntersects(box, f.box);
7476
7535
  }
7536
+ featureUnderCoord(coord) {
7537
+ if (!BB.boundboxContains(this.box, coord[0], coord[1]))
7538
+ return null;
7539
+ if (this.features) {
7540
+ let wp = this.features.find(wp => pointinpoly_1.polyContainsPoint(wp.p, coord[0], coord[1]));
7541
+ return wp ? wp.f : null;
7542
+ }
7543
+ else {
7544
+ for (let i = 0; i < this.children.length; i++) {
7545
+ let f = this.children[i].featureUnderCoord(coord);
7546
+ if (f)
7547
+ return f;
7548
+ }
7549
+ return null;
7550
+ }
7551
+ }
7477
7552
  union() {
7478
7553
  if (this.asyncUnion == null) {
7479
7554
  if (this.children == null)
7480
- this.asyncUnion = unionPolys(this.features);
7555
+ this.asyncUnion = unionPolys(this.features.map(f => f.p));
7481
7556
  else
7482
7557
  this.asyncUnion = unionPolys(this.children.map((q) => q.union()));
7483
7558
  }
@@ -7522,7 +7597,7 @@ class FsmQuadTree extends FSM.Fsm {
7522
7597
  this.work.nUnion = features.length;
7523
7598
  this.isempty = features.length == 0;
7524
7599
  // Compute BoundBox for each feature
7525
- let wrapped = features.map((f) => { return { box: BB.boundbox(f), p: featureCoords(f) }; });
7600
+ let wrapped = features.map((f) => { return { f: f, box: BB.boundbox(f), p: featureCoords(f) }; });
7526
7601
  let box = BB.boundbox(col);
7527
7602
  this.quad = new QuadLevel(this.options, 0, box, wrapped);
7528
7603
  }
@@ -8859,6 +8934,7 @@ Util.setCoder({ encoder: new u.TextEncoder(), decoder: new u.TextDecoder('utf-8'
8859
8934
  -- For Browser
8860
8935
  Util.setCoder({ encoder: new TextEncoder(), decoder: new TextDecoder('utf-8') });
8861
8936
  */
8937
+ const MaxKeyLength = 128;
8862
8938
  function s2u8(coder, s) {
8863
8939
  return coder.encoder.encode(s);
8864
8940
  }
@@ -9060,6 +9136,19 @@ class BinTrie {
9060
9136
  }
9061
9137
  return undefined;
9062
9138
  }
9139
+ forEach(cb) {
9140
+ let keybuf = new Uint8Array(MaxKeyLength);
9141
+ let keylen = 0;
9142
+ let processNode = (len, byteOffset) => {
9143
+ let iOffset = byteOffset >> 2;
9144
+ let n = this.i32[iOffset];
9145
+ byteOffset += 4;
9146
+ for (let j = 0; j < n; j++) {
9147
+ keybuf[keylen++] = this.u8[byteOffset + j];
9148
+ }
9149
+ };
9150
+ processNode(0, 4);
9151
+ }
9063
9152
  }
9064
9153
  exports.BinTrie = BinTrie;
9065
9154
  let DefaultOptions = { dedup: true, verbose: false };