@carto/api-client 0.5.7-alpha.3 → 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();
@@ -5632,17 +5690,13 @@ function normalizeSortByOptions({
5632
5690
  });
5633
5691
  }
5634
5692
 
5635
- // src/widget-sources/constants.ts
5636
- var OTHERS_CATEGORY_NAME = "_carto_others";
5637
-
5638
5693
  // src/operations/groupBy.ts
5639
5694
  function groupValuesByColumn({
5640
5695
  data,
5641
5696
  valuesColumns,
5642
5697
  joinOperation,
5643
5698
  keysColumn,
5644
- operation: operation2,
5645
- othersThreshold
5699
+ operation: operation2
5646
5700
  }) {
5647
5701
  if (Array.isArray(data) && data.length === 0) {
5648
5702
  return null;
@@ -5660,23 +5714,13 @@ function groupValuesByColumn({
5660
5714
  return accumulator;
5661
5715
  }, /* @__PURE__ */ new Map());
5662
5716
  const targetOperation = aggregationFunctions[operation2];
5663
- if (!targetOperation) {
5664
- return [];
5717
+ if (targetOperation) {
5718
+ return Array.from(groups).map(([name, value]) => ({
5719
+ name,
5720
+ value: targetOperation(value)
5721
+ }));
5665
5722
  }
5666
- const allCategories = Array.from(groups).map(([name, value]) => ({
5667
- name,
5668
- value: targetOperation(value)
5669
- }));
5670
- allCategories.sort((a, b) => b.value - a.value);
5671
- if (othersThreshold && allCategories.length > othersThreshold) {
5672
- const otherNames = allCategories.map((entry) => entry.name).slice(othersThreshold);
5673
- const otherValue = otherNames.flatMap((name) => groups.get(name));
5674
- allCategories.push({
5675
- name: OTHERS_CATEGORY_NAME,
5676
- value: targetOperation(otherValue)
5677
- });
5678
- }
5679
- return allCategories;
5723
+ return [];
5680
5724
  }
5681
5725
 
5682
5726
  // src/utils/dateUtils.ts
@@ -6295,8 +6339,7 @@ var WidgetTilesetSourceImpl = class extends WidgetSource {
6295
6339
  joinOperation,
6296
6340
  filters,
6297
6341
  filterOwner,
6298
- spatialFilter,
6299
- othersThreshold
6342
+ spatialFilter
6300
6343
  }) {
6301
6344
  const filteredFeatures = this._getFilteredFeatures(
6302
6345
  spatialFilter,
@@ -6312,8 +6355,7 @@ var WidgetTilesetSourceImpl = class extends WidgetSource {
6312
6355
  valuesColumns: normalizeColumns(operationColumn || column),
6313
6356
  joinOperation,
6314
6357
  keysColumn: column,
6315
- operation: operation2,
6316
- othersThreshold
6358
+ operation: operation2
6317
6359
  });
6318
6360
  return groups || [];
6319
6361
  }