@carto/api-client 0.5.7-alpha.2 → 0.5.7-alpha.5

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/build/worker.js CHANGED
@@ -5378,6 +5378,64 @@ import {
5378
5378
  geometryToCells as geometryToCells2,
5379
5379
  getResolution as getResolution2
5380
5380
  } from "quadbin";
5381
+
5382
+ // src/utils/CellSet.ts
5383
+ var EMPTY_U32 = 2 ** 32 - 1;
5384
+ var CellSet = class {
5385
+ constructor(cells) {
5386
+ /** List of cells stored by the set. Stored by reference, without copying. */
5387
+ __publicField(this, "cells");
5388
+ /** DataView representing a single cell ID. Pre-allocated to reduce memory during queries. */
5389
+ __publicField(this, "cellView", new DataView(new ArrayBuffer(8)));
5390
+ /** Hash table, mapping a hash index (computed) to an index in the 'cells' array. */
5391
+ __publicField(this, "hashTable");
5392
+ this.cells = cells;
5393
+ this.hashTable = new Uint32Array(hashBuckets(cells.length)).fill(EMPTY_U32);
5394
+ for (let cellIndex = 0; cellIndex < cells.length; cellIndex++) {
5395
+ this.hashTable[this.hashLookup(cells[cellIndex])] = cellIndex;
5396
+ }
5397
+ }
5398
+ has(cell) {
5399
+ const hashIndex = this.hashLookup(cell);
5400
+ return this.hashTable[hashIndex] !== EMPTY_U32;
5401
+ }
5402
+ hashLookup(cell) {
5403
+ this.cellView.setBigUint64(0, cell);
5404
+ const hashval = hash(this.cellView);
5405
+ const hashmod = this.hashTable.length - 1;
5406
+ let bucket = hashval & hashmod;
5407
+ for (let probe = 0; probe <= hashmod; probe++) {
5408
+ const cellIndex = this.hashTable[bucket];
5409
+ if (cellIndex === EMPTY_U32 || cell === this.cells[cellIndex]) {
5410
+ return bucket;
5411
+ }
5412
+ bucket = bucket + probe + 1 & hashmod;
5413
+ }
5414
+ throw new Error("Hash table full.");
5415
+ }
5416
+ };
5417
+ function hash(view, h = 0) {
5418
+ const m = 1540483477;
5419
+ const r = 24;
5420
+ for (let i = 0, il = view.byteLength / 4; i < il; i++) {
5421
+ let k = view.getUint32(i * 4);
5422
+ k = Math.imul(k, m) >>> 0;
5423
+ k = (k ^ k >> r) >>> 0;
5424
+ k = Math.imul(k, m) >>> 0;
5425
+ h = Math.imul(h, m) >>> 0;
5426
+ h = (h ^ k) >>> 0;
5427
+ }
5428
+ return h;
5429
+ }
5430
+ function hashBuckets(initialCount) {
5431
+ let buckets = 1;
5432
+ while (buckets < initialCount + initialCount / 4) {
5433
+ buckets *= 2;
5434
+ }
5435
+ return buckets;
5436
+ }
5437
+
5438
+ // src/filters/tileFeaturesRaster.ts
5381
5439
  function tileFeaturesRaster({
5382
5440
  tiles,
5383
5441
  ...options
@@ -5391,7 +5449,7 @@ function tileFeaturesRaster({
5391
5449
  const tileResolution = getResolution2(tiles[0].index.q);
5392
5450
  const tileBlockSize = tiles[0].data.blockSize;
5393
5451
  const cellResolution = tileResolution + BigInt(Math.log2(tileBlockSize));
5394
- const spatialFilterCells = new Set(
5452
+ const spatialFilterCells = new CellSet(
5395
5453
  geometryToCells2(options.spatialFilter, cellResolution)
5396
5454
  );
5397
5455
  const data = /* @__PURE__ */ new Map();