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

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.
@@ -5651,65 +5651,6 @@ var DEFAULT_AGGREGATION_EXP = `1 AS ${DEFAULT_AGGREGATION_EXP_ALIAS}`;
5651
5651
  // src/filters/tileFeaturesRaster.ts
5652
5652
  init_cjs_shims();
5653
5653
  var import_quadbin2 = require("quadbin");
5654
-
5655
- // src/utils/CellSet.ts
5656
- init_cjs_shims();
5657
- var EMPTY_U32 = 2 ** 32 - 1;
5658
- var CellSet = class {
5659
- constructor(cells) {
5660
- /** List of cells stored by the set. Stored by reference, without copying. */
5661
- __publicField(this, "cells");
5662
- /** DataView representing a single cell ID. Pre-allocated to reduce memory during queries. */
5663
- __publicField(this, "cellView", new DataView(new ArrayBuffer(8)));
5664
- /** Hash table, mapping a hash index (computed) to an index in the 'cells' array. */
5665
- __publicField(this, "hashTable");
5666
- this.cells = cells;
5667
- this.hashTable = new Uint32Array(hashBuckets(cells.length)).fill(EMPTY_U32);
5668
- for (let cellIndex = 0; cellIndex < cells.length; cellIndex++) {
5669
- this.hashTable[this.hashLookup(cells[cellIndex])] = cellIndex;
5670
- }
5671
- }
5672
- has(cell) {
5673
- const hashIndex = this.hashLookup(cell);
5674
- return this.hashTable[hashIndex] !== EMPTY_U32;
5675
- }
5676
- hashLookup(cell) {
5677
- this.cellView.setBigUint64(0, cell);
5678
- const hashval = hash(this.cellView);
5679
- const hashmod = this.hashTable.length - 1;
5680
- let bucket = hashval & hashmod;
5681
- for (let probe = 0; probe <= hashmod; probe++) {
5682
- const cellIndex = this.hashTable[bucket];
5683
- if (cellIndex === EMPTY_U32 || cell === this.cells[cellIndex]) {
5684
- return bucket;
5685
- }
5686
- bucket = bucket + probe + 1 & hashmod;
5687
- }
5688
- throw new Error("Hash table full.");
5689
- }
5690
- };
5691
- function hash(view, h = 0) {
5692
- const m = 1540483477;
5693
- const r = 24;
5694
- for (let i = 0, il = view.byteLength / 4; i < il; i++) {
5695
- let k = view.getUint32(i * 4);
5696
- k = Math.imul(k, m) >>> 0;
5697
- k = (k ^ k >> r) >>> 0;
5698
- k = Math.imul(k, m) >>> 0;
5699
- h = Math.imul(h, m) >>> 0;
5700
- h = (h ^ k) >>> 0;
5701
- }
5702
- return h;
5703
- }
5704
- function hashBuckets(initialCount) {
5705
- let buckets = 1;
5706
- while (buckets < initialCount + initialCount / 4) {
5707
- buckets *= 2;
5708
- }
5709
- return buckets;
5710
- }
5711
-
5712
- // src/filters/tileFeaturesRaster.ts
5713
5654
  function tileFeaturesRaster({
5714
5655
  tiles,
5715
5656
  ...options
@@ -5723,15 +5664,20 @@ function tileFeaturesRaster({
5723
5664
  const tileResolution = (0, import_quadbin2.getResolution)(tiles[0].index.q);
5724
5665
  const tileBlockSize = tiles[0].data.blockSize;
5725
5666
  const cellResolution = tileResolution + BigInt(Math.log2(tileBlockSize));
5726
- const spatialFilterCells = new CellSet(
5727
- (0, import_quadbin2.geometryToCells)(options.spatialFilter, cellResolution)
5728
- );
5729
5667
  const data = /* @__PURE__ */ new Map();
5730
5668
  for (const tile of tiles) {
5731
5669
  const parent = tile.index.q;
5732
- const children = cellToChildrenSorted(parent, cellResolution);
5733
- for (let i = 0; i < children.length; i++) {
5734
- if (!spatialFilterCells.has(children[i])) continue;
5670
+ const tilePolygon = (0, import_quadbin2.cellToBoundary)(parent);
5671
+ const tileFilter = turf_intersect_default(
5672
+ featureCollection([feature(tilePolygon), feature(options.spatialFilter)])
5673
+ );
5674
+ const needsFilter = tileFilter ? !turf_boolean_within_default(tilePolygon, options.spatialFilter) : false;
5675
+ const tileFilterCells = needsFilter ? new Set((0, import_quadbin2.geometryToCells)(tileFilter.geometry, cellResolution)) : null;
5676
+ const tileSortedCells = cellToChildrenSorted(parent, cellResolution);
5677
+ for (let i = 0; i < tileSortedCells.length; i++) {
5678
+ if (needsFilter && !tileFilterCells.has(tileSortedCells[i])) {
5679
+ continue;
5680
+ }
5735
5681
  const cellData = {};
5736
5682
  let cellDataExists = false;
5737
5683
  for (const band in tile.data.cells.numericProps) {
@@ -5743,7 +5689,7 @@ function tileFeaturesRaster({
5743
5689
  }
5744
5690
  }
5745
5691
  if (cellDataExists) {
5746
- data.set(children[i], cellData);
5692
+ data.set(tileSortedCells[i], cellData);
5747
5693
  }
5748
5694
  }
5749
5695
  }
@@ -10348,6 +10294,63 @@ function _getHexagonResolution(viewport, tileSize) {
10348
10294
  Math.floor(hexagonScaleFactor + latitudeScaleFactor - BIAS)
10349
10295
  );
10350
10296
  }
10297
+
10298
+ // src/utils/CellSet.ts
10299
+ init_cjs_shims();
10300
+ var EMPTY_U32 = 2 ** 32 - 1;
10301
+ var CellSet = class {
10302
+ constructor(cells) {
10303
+ /** List of cells stored by the set. Stored by reference, without copying. */
10304
+ __publicField(this, "cells");
10305
+ /** DataView representing a single cell ID. Pre-allocated to reduce memory during queries. */
10306
+ __publicField(this, "cellView", new DataView(new ArrayBuffer(8)));
10307
+ /** Hash table, mapping a hash index (computed) to an index in the 'cells' array. */
10308
+ __publicField(this, "hashTable");
10309
+ this.cells = cells;
10310
+ this.hashTable = new Uint32Array(hashBuckets(cells.length)).fill(EMPTY_U32);
10311
+ for (let cellIndex = 0; cellIndex < cells.length; cellIndex++) {
10312
+ this.hashTable[this.hashLookup(cells[cellIndex])] = cellIndex;
10313
+ }
10314
+ }
10315
+ has(cell) {
10316
+ const hashIndex = this.hashLookup(cell);
10317
+ return this.hashTable[hashIndex] !== EMPTY_U32;
10318
+ }
10319
+ hashLookup(cell) {
10320
+ this.cellView.setBigUint64(0, cell);
10321
+ const hashval = hash(this.cellView);
10322
+ const hashmod = this.hashTable.length - 1;
10323
+ let bucket = hashval & hashmod;
10324
+ for (let probe = 0; probe <= hashmod; probe++) {
10325
+ const cellIndex = this.hashTable[bucket];
10326
+ if (cellIndex === EMPTY_U32 || cell === this.cells[cellIndex]) {
10327
+ return bucket;
10328
+ }
10329
+ bucket = bucket + probe + 1 & hashmod;
10330
+ }
10331
+ throw new Error("Hash table full.");
10332
+ }
10333
+ };
10334
+ function hash(view, h = 0) {
10335
+ const m = 1540483477;
10336
+ const r = 24;
10337
+ for (let i = 0, il = view.byteLength / 4; i < il; i++) {
10338
+ let k = view.getUint32(i * 4);
10339
+ k = Math.imul(k, m) >>> 0;
10340
+ k = (k ^ k >> r) >>> 0;
10341
+ k = Math.imul(k, m) >>> 0;
10342
+ h = Math.imul(h, m) >>> 0;
10343
+ h = (h ^ k) >>> 0;
10344
+ }
10345
+ return h;
10346
+ }
10347
+ function hashBuckets(initialCount) {
10348
+ let buckets = 1;
10349
+ while (buckets < initialCount + initialCount / 4) {
10350
+ buckets *= 2;
10351
+ }
10352
+ return buckets;
10353
+ }
10351
10354
  // Annotate the CommonJS export names for ESM import in node:
10352
10355
  0 && (module.exports = {
10353
10356
  AggregationTypes,