@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/api-client.cjs +73 -34
- package/build/api-client.cjs.map +1 -1
- package/build/api-client.d.cts +22 -14
- package/build/api-client.d.ts +22 -14
- package/build/api-client.js +71 -30
- package/build/api-client.js.map +1 -1
- package/build/worker-compat.js +3476 -2303
- package/build/worker-compat.js.map +1 -1
- package/build/worker.js +68 -26
- package/build/worker.js.map +1 -1
- package/package.json +2 -2
- package/src/filters/tileFeaturesRaster.ts +2 -1
- package/src/index.ts +1 -0
- package/src/operations/groupBy.ts +6 -24
- package/src/utils/CellSet.ts +90 -0
- package/src/widget-sources/index.ts +0 -1
- package/src/widget-sources/types.ts +1 -3
- package/src/widget-sources/widget-remote-source.ts +1 -3
- package/src/widget-sources/widget-tileset-source-impl.ts +0 -2
- package/src/widget-sources/constants.ts +0 -6
package/build/api-client.cjs
CHANGED
|
@@ -103,11 +103,11 @@ __export(src_exports, {
|
|
|
103
103
|
ApiVersion: () => ApiVersion,
|
|
104
104
|
BASEMAP: () => basemap_styles_default,
|
|
105
105
|
CartoAPIError: () => CartoAPIError,
|
|
106
|
+
CellSet: () => CellSet,
|
|
106
107
|
DEFAULT_API_BASE_URL: () => DEFAULT_API_BASE_URL,
|
|
107
108
|
FEATURE_GEOM_PROPERTY: () => FEATURE_GEOM_PROPERTY,
|
|
108
109
|
FilterType: () => FilterType,
|
|
109
110
|
OPACITY_MAP: () => OPACITY_MAP,
|
|
110
|
-
OTHERS_CATEGORY_NAME: () => OTHERS_CATEGORY_NAME,
|
|
111
111
|
Provider: () => Provider,
|
|
112
112
|
SOURCE_DEFAULTS: () => SOURCE_DEFAULTS,
|
|
113
113
|
SchemaFieldType: () => SchemaFieldType,
|
|
@@ -5651,6 +5651,65 @@ 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
|
|
5654
5713
|
function tileFeaturesRaster({
|
|
5655
5714
|
tiles,
|
|
5656
5715
|
...options
|
|
@@ -5664,7 +5723,7 @@ function tileFeaturesRaster({
|
|
|
5664
5723
|
const tileResolution = (0, import_quadbin2.getResolution)(tiles[0].index.q);
|
|
5665
5724
|
const tileBlockSize = tiles[0].data.blockSize;
|
|
5666
5725
|
const cellResolution = tileResolution + BigInt(Math.log2(tileBlockSize));
|
|
5667
|
-
const spatialFilterCells = new
|
|
5726
|
+
const spatialFilterCells = new CellSet(
|
|
5668
5727
|
(0, import_quadbin2.geometryToCells)(options.spatialFilter, cellResolution)
|
|
5669
5728
|
);
|
|
5670
5729
|
const data = /* @__PURE__ */ new Map();
|
|
@@ -6529,7 +6588,7 @@ var WidgetRemoteSource = class extends WidgetSource {
|
|
|
6529
6588
|
spatialFiltersMode,
|
|
6530
6589
|
...params
|
|
6531
6590
|
} = options;
|
|
6532
|
-
const { column, operation: operation2, operationColumn, operationExp
|
|
6591
|
+
const { column, operation: operation2, operationColumn, operationExp } = params;
|
|
6533
6592
|
if (operation2 === AggregationTypes.Custom) {
|
|
6534
6593
|
assert2(operationExp, "operationExp is required for custom operation");
|
|
6535
6594
|
}
|
|
@@ -6544,8 +6603,7 @@ var WidgetRemoteSource = class extends WidgetSource {
|
|
|
6544
6603
|
column,
|
|
6545
6604
|
operation: operation2,
|
|
6546
6605
|
operationExp,
|
|
6547
|
-
operationColumn: operationColumn || column
|
|
6548
|
-
othersThreshold
|
|
6606
|
+
operationColumn: operationColumn || column
|
|
6549
6607
|
},
|
|
6550
6608
|
opts: { signal, headers: this.props.headers }
|
|
6551
6609
|
}).then((res) => normalizeObjectKeys(res.rows));
|
|
@@ -6948,19 +7006,12 @@ function normalizeSortByOptions({
|
|
|
6948
7006
|
|
|
6949
7007
|
// src/operations/groupBy.ts
|
|
6950
7008
|
init_cjs_shims();
|
|
6951
|
-
|
|
6952
|
-
// src/widget-sources/constants.ts
|
|
6953
|
-
init_cjs_shims();
|
|
6954
|
-
var OTHERS_CATEGORY_NAME = "_carto_others";
|
|
6955
|
-
|
|
6956
|
-
// src/operations/groupBy.ts
|
|
6957
7009
|
function groupValuesByColumn({
|
|
6958
7010
|
data,
|
|
6959
7011
|
valuesColumns,
|
|
6960
7012
|
joinOperation,
|
|
6961
7013
|
keysColumn,
|
|
6962
|
-
operation: operation2
|
|
6963
|
-
othersThreshold
|
|
7014
|
+
operation: operation2
|
|
6964
7015
|
}) {
|
|
6965
7016
|
if (Array.isArray(data) && data.length === 0) {
|
|
6966
7017
|
return null;
|
|
@@ -6978,23 +7029,13 @@ function groupValuesByColumn({
|
|
|
6978
7029
|
return accumulator;
|
|
6979
7030
|
}, /* @__PURE__ */ new Map());
|
|
6980
7031
|
const targetOperation = aggregationFunctions[operation2];
|
|
6981
|
-
if (
|
|
6982
|
-
return []
|
|
6983
|
-
|
|
6984
|
-
|
|
6985
|
-
|
|
6986
|
-
value: targetOperation(value)
|
|
6987
|
-
}));
|
|
6988
|
-
allCategories.sort((a, b) => b.value - a.value);
|
|
6989
|
-
if (othersThreshold && allCategories.length > othersThreshold) {
|
|
6990
|
-
const otherNames = allCategories.map((entry) => entry.name).slice(othersThreshold);
|
|
6991
|
-
const otherValue = otherNames.flatMap((name) => groups.get(name));
|
|
6992
|
-
allCategories.push({
|
|
6993
|
-
name: OTHERS_CATEGORY_NAME,
|
|
6994
|
-
value: targetOperation(otherValue)
|
|
6995
|
-
});
|
|
7032
|
+
if (targetOperation) {
|
|
7033
|
+
return Array.from(groups).map(([name, value]) => ({
|
|
7034
|
+
name,
|
|
7035
|
+
value: targetOperation(value)
|
|
7036
|
+
}));
|
|
6996
7037
|
}
|
|
6997
|
-
return
|
|
7038
|
+
return [];
|
|
6998
7039
|
}
|
|
6999
7040
|
|
|
7000
7041
|
// src/operations/groupByDate.ts
|
|
@@ -7568,8 +7609,7 @@ var WidgetTilesetSourceImpl = class extends WidgetSource {
|
|
|
7568
7609
|
joinOperation,
|
|
7569
7610
|
filters,
|
|
7570
7611
|
filterOwner,
|
|
7571
|
-
spatialFilter
|
|
7572
|
-
othersThreshold
|
|
7612
|
+
spatialFilter
|
|
7573
7613
|
}) {
|
|
7574
7614
|
const filteredFeatures = this._getFilteredFeatures(
|
|
7575
7615
|
spatialFilter,
|
|
@@ -7585,8 +7625,7 @@ var WidgetTilesetSourceImpl = class extends WidgetSource {
|
|
|
7585
7625
|
valuesColumns: normalizeColumns(operationColumn || column),
|
|
7586
7626
|
joinOperation,
|
|
7587
7627
|
keysColumn: column,
|
|
7588
|
-
operation: operation2
|
|
7589
|
-
othersThreshold
|
|
7628
|
+
operation: operation2
|
|
7590
7629
|
});
|
|
7591
7630
|
return groups || [];
|
|
7592
7631
|
}
|
|
@@ -10315,11 +10354,11 @@ function _getHexagonResolution(viewport, tileSize) {
|
|
|
10315
10354
|
ApiVersion,
|
|
10316
10355
|
BASEMAP,
|
|
10317
10356
|
CartoAPIError,
|
|
10357
|
+
CellSet,
|
|
10318
10358
|
DEFAULT_API_BASE_URL,
|
|
10319
10359
|
FEATURE_GEOM_PROPERTY,
|
|
10320
10360
|
FilterType,
|
|
10321
10361
|
OPACITY_MAP,
|
|
10322
|
-
OTHERS_CATEGORY_NAME,
|
|
10323
10362
|
Provider,
|
|
10324
10363
|
SOURCE_DEFAULTS,
|
|
10325
10364
|
SchemaFieldType,
|