@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.
- package/build/api-client.cjs +69 -66
- package/build/api-client.cjs.map +1 -1
- package/build/api-client.js +69 -65
- package/build/api-client.js.map +1 -1
- package/build/worker-compat.js +42 -65
- package/build/worker-compat.js.map +1 -1
- package/build/worker.js +13 -65
- package/build/worker.js.map +1 -1
- package/package.json +1 -1
- package/src/filters/tileFeaturesRaster.ts +25 -11
package/build/api-client.js
CHANGED
|
@@ -5434,68 +5434,11 @@ var DEFAULT_AGGREGATION_EXP = `1 AS ${DEFAULT_AGGREGATION_EXP_ALIAS}`;
|
|
|
5434
5434
|
// src/filters/tileFeaturesRaster.ts
|
|
5435
5435
|
import {
|
|
5436
5436
|
cellToChildren as _cellToChildren,
|
|
5437
|
+
cellToBoundary,
|
|
5437
5438
|
cellToTile,
|
|
5438
5439
|
geometryToCells as geometryToCells2,
|
|
5439
5440
|
getResolution as getResolution2
|
|
5440
5441
|
} from "quadbin";
|
|
5441
|
-
|
|
5442
|
-
// src/utils/CellSet.ts
|
|
5443
|
-
var EMPTY_U32 = 2 ** 32 - 1;
|
|
5444
|
-
var CellSet = class {
|
|
5445
|
-
constructor(cells) {
|
|
5446
|
-
/** List of cells stored by the set. Stored by reference, without copying. */
|
|
5447
|
-
__publicField(this, "cells");
|
|
5448
|
-
/** DataView representing a single cell ID. Pre-allocated to reduce memory during queries. */
|
|
5449
|
-
__publicField(this, "cellView", new DataView(new ArrayBuffer(8)));
|
|
5450
|
-
/** Hash table, mapping a hash index (computed) to an index in the 'cells' array. */
|
|
5451
|
-
__publicField(this, "hashTable");
|
|
5452
|
-
this.cells = cells;
|
|
5453
|
-
this.hashTable = new Uint32Array(hashBuckets(cells.length)).fill(EMPTY_U32);
|
|
5454
|
-
for (let cellIndex = 0; cellIndex < cells.length; cellIndex++) {
|
|
5455
|
-
this.hashTable[this.hashLookup(cells[cellIndex])] = cellIndex;
|
|
5456
|
-
}
|
|
5457
|
-
}
|
|
5458
|
-
has(cell) {
|
|
5459
|
-
const hashIndex = this.hashLookup(cell);
|
|
5460
|
-
return this.hashTable[hashIndex] !== EMPTY_U32;
|
|
5461
|
-
}
|
|
5462
|
-
hashLookup(cell) {
|
|
5463
|
-
this.cellView.setBigUint64(0, cell);
|
|
5464
|
-
const hashval = hash(this.cellView);
|
|
5465
|
-
const hashmod = this.hashTable.length - 1;
|
|
5466
|
-
let bucket = hashval & hashmod;
|
|
5467
|
-
for (let probe = 0; probe <= hashmod; probe++) {
|
|
5468
|
-
const cellIndex = this.hashTable[bucket];
|
|
5469
|
-
if (cellIndex === EMPTY_U32 || cell === this.cells[cellIndex]) {
|
|
5470
|
-
return bucket;
|
|
5471
|
-
}
|
|
5472
|
-
bucket = bucket + probe + 1 & hashmod;
|
|
5473
|
-
}
|
|
5474
|
-
throw new Error("Hash table full.");
|
|
5475
|
-
}
|
|
5476
|
-
};
|
|
5477
|
-
function hash(view, h = 0) {
|
|
5478
|
-
const m = 1540483477;
|
|
5479
|
-
const r = 24;
|
|
5480
|
-
for (let i = 0, il = view.byteLength / 4; i < il; i++) {
|
|
5481
|
-
let k = view.getUint32(i * 4);
|
|
5482
|
-
k = Math.imul(k, m) >>> 0;
|
|
5483
|
-
k = (k ^ k >> r) >>> 0;
|
|
5484
|
-
k = Math.imul(k, m) >>> 0;
|
|
5485
|
-
h = Math.imul(h, m) >>> 0;
|
|
5486
|
-
h = (h ^ k) >>> 0;
|
|
5487
|
-
}
|
|
5488
|
-
return h;
|
|
5489
|
-
}
|
|
5490
|
-
function hashBuckets(initialCount) {
|
|
5491
|
-
let buckets = 1;
|
|
5492
|
-
while (buckets < initialCount + initialCount / 4) {
|
|
5493
|
-
buckets *= 2;
|
|
5494
|
-
}
|
|
5495
|
-
return buckets;
|
|
5496
|
-
}
|
|
5497
|
-
|
|
5498
|
-
// src/filters/tileFeaturesRaster.ts
|
|
5499
5442
|
function tileFeaturesRaster({
|
|
5500
5443
|
tiles,
|
|
5501
5444
|
...options
|
|
@@ -5509,15 +5452,20 @@ function tileFeaturesRaster({
|
|
|
5509
5452
|
const tileResolution = getResolution2(tiles[0].index.q);
|
|
5510
5453
|
const tileBlockSize = tiles[0].data.blockSize;
|
|
5511
5454
|
const cellResolution = tileResolution + BigInt(Math.log2(tileBlockSize));
|
|
5512
|
-
const spatialFilterCells = new CellSet(
|
|
5513
|
-
geometryToCells2(options.spatialFilter, cellResolution)
|
|
5514
|
-
);
|
|
5515
5455
|
const data = /* @__PURE__ */ new Map();
|
|
5516
5456
|
for (const tile of tiles) {
|
|
5517
5457
|
const parent = tile.index.q;
|
|
5518
|
-
const
|
|
5519
|
-
|
|
5520
|
-
|
|
5458
|
+
const tilePolygon = cellToBoundary(parent);
|
|
5459
|
+
const tileFilter = turf_intersect_default(
|
|
5460
|
+
featureCollection([feature(tilePolygon), feature(options.spatialFilter)])
|
|
5461
|
+
);
|
|
5462
|
+
const needsFilter = tileFilter ? !turf_boolean_within_default(tilePolygon, options.spatialFilter) : false;
|
|
5463
|
+
const tileFilterCells = needsFilter ? new Set(geometryToCells2(tileFilter.geometry, cellResolution)) : null;
|
|
5464
|
+
const tileSortedCells = cellToChildrenSorted(parent, cellResolution);
|
|
5465
|
+
for (let i = 0; i < tileSortedCells.length; i++) {
|
|
5466
|
+
if (needsFilter && !tileFilterCells.has(tileSortedCells[i])) {
|
|
5467
|
+
continue;
|
|
5468
|
+
}
|
|
5521
5469
|
const cellData = {};
|
|
5522
5470
|
let cellDataExists = false;
|
|
5523
5471
|
for (const band in tile.data.cells.numericProps) {
|
|
@@ -5529,7 +5477,7 @@ function tileFeaturesRaster({
|
|
|
5529
5477
|
}
|
|
5530
5478
|
}
|
|
5531
5479
|
if (cellDataExists) {
|
|
5532
|
-
data.set(
|
|
5480
|
+
data.set(tileSortedCells[i], cellData);
|
|
5533
5481
|
}
|
|
5534
5482
|
}
|
|
5535
5483
|
}
|
|
@@ -10021,6 +9969,62 @@ function _getHexagonResolution(viewport, tileSize) {
|
|
|
10021
9969
|
Math.floor(hexagonScaleFactor + latitudeScaleFactor - BIAS)
|
|
10022
9970
|
);
|
|
10023
9971
|
}
|
|
9972
|
+
|
|
9973
|
+
// src/utils/CellSet.ts
|
|
9974
|
+
var EMPTY_U32 = 2 ** 32 - 1;
|
|
9975
|
+
var CellSet = class {
|
|
9976
|
+
constructor(cells) {
|
|
9977
|
+
/** List of cells stored by the set. Stored by reference, without copying. */
|
|
9978
|
+
__publicField(this, "cells");
|
|
9979
|
+
/** DataView representing a single cell ID. Pre-allocated to reduce memory during queries. */
|
|
9980
|
+
__publicField(this, "cellView", new DataView(new ArrayBuffer(8)));
|
|
9981
|
+
/** Hash table, mapping a hash index (computed) to an index in the 'cells' array. */
|
|
9982
|
+
__publicField(this, "hashTable");
|
|
9983
|
+
this.cells = cells;
|
|
9984
|
+
this.hashTable = new Uint32Array(hashBuckets(cells.length)).fill(EMPTY_U32);
|
|
9985
|
+
for (let cellIndex = 0; cellIndex < cells.length; cellIndex++) {
|
|
9986
|
+
this.hashTable[this.hashLookup(cells[cellIndex])] = cellIndex;
|
|
9987
|
+
}
|
|
9988
|
+
}
|
|
9989
|
+
has(cell) {
|
|
9990
|
+
const hashIndex = this.hashLookup(cell);
|
|
9991
|
+
return this.hashTable[hashIndex] !== EMPTY_U32;
|
|
9992
|
+
}
|
|
9993
|
+
hashLookup(cell) {
|
|
9994
|
+
this.cellView.setBigUint64(0, cell);
|
|
9995
|
+
const hashval = hash(this.cellView);
|
|
9996
|
+
const hashmod = this.hashTable.length - 1;
|
|
9997
|
+
let bucket = hashval & hashmod;
|
|
9998
|
+
for (let probe = 0; probe <= hashmod; probe++) {
|
|
9999
|
+
const cellIndex = this.hashTable[bucket];
|
|
10000
|
+
if (cellIndex === EMPTY_U32 || cell === this.cells[cellIndex]) {
|
|
10001
|
+
return bucket;
|
|
10002
|
+
}
|
|
10003
|
+
bucket = bucket + probe + 1 & hashmod;
|
|
10004
|
+
}
|
|
10005
|
+
throw new Error("Hash table full.");
|
|
10006
|
+
}
|
|
10007
|
+
};
|
|
10008
|
+
function hash(view, h = 0) {
|
|
10009
|
+
const m = 1540483477;
|
|
10010
|
+
const r = 24;
|
|
10011
|
+
for (let i = 0, il = view.byteLength / 4; i < il; i++) {
|
|
10012
|
+
let k = view.getUint32(i * 4);
|
|
10013
|
+
k = Math.imul(k, m) >>> 0;
|
|
10014
|
+
k = (k ^ k >> r) >>> 0;
|
|
10015
|
+
k = Math.imul(k, m) >>> 0;
|
|
10016
|
+
h = Math.imul(h, m) >>> 0;
|
|
10017
|
+
h = (h ^ k) >>> 0;
|
|
10018
|
+
}
|
|
10019
|
+
return h;
|
|
10020
|
+
}
|
|
10021
|
+
function hashBuckets(initialCount) {
|
|
10022
|
+
let buckets = 1;
|
|
10023
|
+
while (buckets < initialCount + initialCount / 4) {
|
|
10024
|
+
buckets *= 2;
|
|
10025
|
+
}
|
|
10026
|
+
return buckets;
|
|
10027
|
+
}
|
|
10024
10028
|
export {
|
|
10025
10029
|
AggregationTypes,
|
|
10026
10030
|
ApiVersion,
|