@carto/api-client 0.5.7-alpha.3 → 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 +82 -40
- 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 +81 -36
- package/build/api-client.js.map +1 -1
- package/build/worker-compat.js +3458 -2308
- package/build/worker-compat.js.map +1 -1
- package/build/worker.js +22 -32
- package/build/worker.js.map +1 -1
- package/package.json +2 -2
- package/src/filters/tileFeaturesRaster.ts +25 -10
- 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/worker.js
CHANGED
|
@@ -5374,6 +5374,7 @@ var DEFAULT_AGGREGATION_EXP = `1 AS ${DEFAULT_AGGREGATION_EXP_ALIAS}`;
|
|
|
5374
5374
|
// src/filters/tileFeaturesRaster.ts
|
|
5375
5375
|
import {
|
|
5376
5376
|
cellToChildren as _cellToChildren,
|
|
5377
|
+
cellToBoundary,
|
|
5377
5378
|
cellToTile,
|
|
5378
5379
|
geometryToCells as geometryToCells2,
|
|
5379
5380
|
getResolution as getResolution2
|
|
@@ -5391,15 +5392,20 @@ function tileFeaturesRaster({
|
|
|
5391
5392
|
const tileResolution = getResolution2(tiles[0].index.q);
|
|
5392
5393
|
const tileBlockSize = tiles[0].data.blockSize;
|
|
5393
5394
|
const cellResolution = tileResolution + BigInt(Math.log2(tileBlockSize));
|
|
5394
|
-
const spatialFilterCells = new Set(
|
|
5395
|
-
geometryToCells2(options.spatialFilter, cellResolution)
|
|
5396
|
-
);
|
|
5397
5395
|
const data = /* @__PURE__ */ new Map();
|
|
5398
5396
|
for (const tile of tiles) {
|
|
5399
5397
|
const parent = tile.index.q;
|
|
5400
|
-
const
|
|
5401
|
-
|
|
5402
|
-
|
|
5398
|
+
const tilePolygon = cellToBoundary(parent);
|
|
5399
|
+
const tileFilter = turf_intersect_default(
|
|
5400
|
+
featureCollection([feature(tilePolygon), feature(options.spatialFilter)])
|
|
5401
|
+
);
|
|
5402
|
+
const needsFilter = tileFilter ? !turf_boolean_within_default(tilePolygon, options.spatialFilter) : false;
|
|
5403
|
+
const tileFilterCells = needsFilter ? new Set(geometryToCells2(tileFilter.geometry, cellResolution)) : null;
|
|
5404
|
+
const tileSortedCells = cellToChildrenSorted(parent, cellResolution);
|
|
5405
|
+
for (let i = 0; i < tileSortedCells.length; i++) {
|
|
5406
|
+
if (needsFilter && !tileFilterCells.has(tileSortedCells[i])) {
|
|
5407
|
+
continue;
|
|
5408
|
+
}
|
|
5403
5409
|
const cellData = {};
|
|
5404
5410
|
let cellDataExists = false;
|
|
5405
5411
|
for (const band in tile.data.cells.numericProps) {
|
|
@@ -5411,7 +5417,7 @@ function tileFeaturesRaster({
|
|
|
5411
5417
|
}
|
|
5412
5418
|
}
|
|
5413
5419
|
if (cellDataExists) {
|
|
5414
|
-
data.set(
|
|
5420
|
+
data.set(tileSortedCells[i], cellData);
|
|
5415
5421
|
}
|
|
5416
5422
|
}
|
|
5417
5423
|
}
|
|
@@ -5632,17 +5638,13 @@ function normalizeSortByOptions({
|
|
|
5632
5638
|
});
|
|
5633
5639
|
}
|
|
5634
5640
|
|
|
5635
|
-
// src/widget-sources/constants.ts
|
|
5636
|
-
var OTHERS_CATEGORY_NAME = "_carto_others";
|
|
5637
|
-
|
|
5638
5641
|
// src/operations/groupBy.ts
|
|
5639
5642
|
function groupValuesByColumn({
|
|
5640
5643
|
data,
|
|
5641
5644
|
valuesColumns,
|
|
5642
5645
|
joinOperation,
|
|
5643
5646
|
keysColumn,
|
|
5644
|
-
operation: operation2
|
|
5645
|
-
othersThreshold
|
|
5647
|
+
operation: operation2
|
|
5646
5648
|
}) {
|
|
5647
5649
|
if (Array.isArray(data) && data.length === 0) {
|
|
5648
5650
|
return null;
|
|
@@ -5660,23 +5662,13 @@ function groupValuesByColumn({
|
|
|
5660
5662
|
return accumulator;
|
|
5661
5663
|
}, /* @__PURE__ */ new Map());
|
|
5662
5664
|
const targetOperation = aggregationFunctions[operation2];
|
|
5663
|
-
if (
|
|
5664
|
-
return []
|
|
5665
|
-
|
|
5666
|
-
|
|
5667
|
-
|
|
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
|
-
});
|
|
5665
|
+
if (targetOperation) {
|
|
5666
|
+
return Array.from(groups).map(([name, value]) => ({
|
|
5667
|
+
name,
|
|
5668
|
+
value: targetOperation(value)
|
|
5669
|
+
}));
|
|
5678
5670
|
}
|
|
5679
|
-
return
|
|
5671
|
+
return [];
|
|
5680
5672
|
}
|
|
5681
5673
|
|
|
5682
5674
|
// src/utils/dateUtils.ts
|
|
@@ -6295,8 +6287,7 @@ var WidgetTilesetSourceImpl = class extends WidgetSource {
|
|
|
6295
6287
|
joinOperation,
|
|
6296
6288
|
filters,
|
|
6297
6289
|
filterOwner,
|
|
6298
|
-
spatialFilter
|
|
6299
|
-
othersThreshold
|
|
6290
|
+
spatialFilter
|
|
6300
6291
|
}) {
|
|
6301
6292
|
const filteredFeatures = this._getFilteredFeatures(
|
|
6302
6293
|
spatialFilter,
|
|
@@ -6312,8 +6303,7 @@ var WidgetTilesetSourceImpl = class extends WidgetSource {
|
|
|
6312
6303
|
valuesColumns: normalizeColumns(operationColumn || column),
|
|
6313
6304
|
joinOperation,
|
|
6314
6305
|
keysColumn: column,
|
|
6315
|
-
operation: operation2
|
|
6316
|
-
othersThreshold
|
|
6306
|
+
operation: operation2
|
|
6317
6307
|
});
|
|
6318
6308
|
return groups || [];
|
|
6319
6309
|
}
|