@carto/api-client 0.5.8-alpha-others-orderby.2 → 0.5.8
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/CHANGELOG.md +5 -0
- package/build/api-client.cjs +19 -45
- package/build/api-client.cjs.map +1 -1
- package/build/api-client.d.cts +3 -12
- package/build/api-client.d.ts +3 -12
- package/build/api-client.js +20 -49
- package/build/api-client.js.map +1 -1
- package/build/worker-compat.js +17 -50
- package/build/worker-compat.js.map +1 -1
- package/build/worker.js +18 -38
- package/build/worker.js.map +1 -1
- package/package.json +2 -2
- package/src/filters/tileFeaturesRaster.ts +23 -20
- package/src/operations/groupBy.ts +2 -31
- package/src/widget-sources/types.ts +0 -12
- package/src/widget-sources/widget-remote-source.ts +2 -9
- package/src/widget-sources/widget-tileset-source-impl.ts +0 -2
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,11 @@
|
|
|
2
2
|
|
|
3
3
|
## 0.5
|
|
4
4
|
|
|
5
|
+
## 0.5.8
|
|
6
|
+
|
|
7
|
+
- feat(widgets): Add othersThreshold to WidgetSource.getCategories (#194)
|
|
8
|
+
- perf(rasters): Improve performance of raster widget spatial filtering (#207)
|
|
9
|
+
|
|
5
10
|
### 0.5.7
|
|
6
11
|
|
|
7
12
|
- feat(widgets): Allow local widget calculations without spatial filter (#204)
|
package/build/api-client.cjs
CHANGED
|
@@ -159,7 +159,6 @@ __export(src_exports, {
|
|
|
159
159
|
getLayerProps: () => getLayerProps,
|
|
160
160
|
getMaxMarkerSize: () => getMaxMarkerSize,
|
|
161
161
|
getSizeAccessor: () => getSizeAccessor,
|
|
162
|
-
getSorter: () => getSorter,
|
|
163
162
|
getSpatialIndexFromGeoColumn: () => getSpatialIndexFromGeoColumn,
|
|
164
163
|
getTextAccessor: () => getTextAccessor,
|
|
165
164
|
groupValuesByColumn: () => groupValuesByColumn,
|
|
@@ -5717,7 +5716,7 @@ function tileFeaturesRaster({
|
|
|
5717
5716
|
options.spatialFilter
|
|
5718
5717
|
);
|
|
5719
5718
|
if (intersection3 === false) continue;
|
|
5720
|
-
const tileSortedCells =
|
|
5719
|
+
const tileSortedCells = cellToChildrenRaster(parent, cellResolution);
|
|
5721
5720
|
for (let i = 0; i < tileSortedCells.length; i++) {
|
|
5722
5721
|
if (intersection3 !== true && !intersection3.has(tileSortedCells[i])) {
|
|
5723
5722
|
continue;
|
|
@@ -5745,17 +5744,19 @@ function isRasterTile(tile) {
|
|
|
5745
5744
|
function isRasterTileVisible(tile) {
|
|
5746
5745
|
return !!(tile.isVisible && tile.data?.cells?.numericProps);
|
|
5747
5746
|
}
|
|
5748
|
-
function
|
|
5749
|
-
|
|
5750
|
-
|
|
5751
|
-
|
|
5752
|
-
|
|
5753
|
-
|
|
5754
|
-
|
|
5755
|
-
|
|
5756
|
-
|
|
5757
|
-
|
|
5758
|
-
|
|
5747
|
+
function cellToChildrenRaster(parent, resolution) {
|
|
5748
|
+
const parentTile = (0, import_quadbin3.cellToTile)(parent);
|
|
5749
|
+
const childZ = Number(resolution);
|
|
5750
|
+
const blockSize = 2 ** (childZ - parentTile.z);
|
|
5751
|
+
const childBaseX = parentTile.x * blockSize;
|
|
5752
|
+
const childBaseY = parentTile.y * blockSize;
|
|
5753
|
+
const cells = [];
|
|
5754
|
+
for (let i = 0, il = blockSize ** 2; i < il; i++) {
|
|
5755
|
+
const x = childBaseX + i % blockSize;
|
|
5756
|
+
const y = childBaseY + Math.floor(i / blockSize);
|
|
5757
|
+
cells.push((0, import_quadbin3.tileToCell)({ x, y, z: childZ }));
|
|
5758
|
+
}
|
|
5759
|
+
return cells;
|
|
5759
5760
|
}
|
|
5760
5761
|
function isValidBandValue(value, nodata) {
|
|
5761
5762
|
return Number.isNaN(value) ? false : nodata !== value;
|
|
@@ -6583,14 +6584,7 @@ var WidgetRemoteSource = class extends WidgetSource {
|
|
|
6583
6584
|
rawResult,
|
|
6584
6585
|
...params
|
|
6585
6586
|
} = options;
|
|
6586
|
-
const {
|
|
6587
|
-
column,
|
|
6588
|
-
operation: operation2,
|
|
6589
|
-
operationColumn,
|
|
6590
|
-
operationExp,
|
|
6591
|
-
othersThreshold,
|
|
6592
|
-
orderBy
|
|
6593
|
-
} = params;
|
|
6587
|
+
const { column, operation: operation2, operationColumn, operationExp, othersThreshold } = params;
|
|
6594
6588
|
if (operation2 === AggregationTypes.Custom) {
|
|
6595
6589
|
assert2(operationExp, "operationExp is required for custom operation");
|
|
6596
6590
|
}
|
|
@@ -6606,8 +6600,7 @@ var WidgetRemoteSource = class extends WidgetSource {
|
|
|
6606
6600
|
operation: operation2,
|
|
6607
6601
|
operationExp,
|
|
6608
6602
|
operationColumn: operationColumn || column,
|
|
6609
|
-
othersThreshold
|
|
6610
|
-
orderBy
|
|
6603
|
+
othersThreshold
|
|
6611
6604
|
},
|
|
6612
6605
|
opts: { signal, headers: this.props.headers }
|
|
6613
6606
|
});
|
|
@@ -7027,8 +7020,7 @@ function groupValuesByColumn({
|
|
|
7027
7020
|
joinOperation,
|
|
7028
7021
|
keysColumn,
|
|
7029
7022
|
operation: operation2,
|
|
7030
|
-
othersThreshold
|
|
7031
|
-
orderBy = "frequency_desc"
|
|
7023
|
+
othersThreshold
|
|
7032
7024
|
}) {
|
|
7033
7025
|
if (Array.isArray(data) && data.length === 0) {
|
|
7034
7026
|
return { rows: null };
|
|
@@ -7052,7 +7044,7 @@ function groupValuesByColumn({
|
|
|
7052
7044
|
const allCategories = Array.from(groups).map(([name, value]) => ({
|
|
7053
7045
|
name,
|
|
7054
7046
|
value: targetOperation(value)
|
|
7055
|
-
})).sort(
|
|
7047
|
+
})).sort((a, b) => b.value - a.value);
|
|
7056
7048
|
if (othersThreshold && allCategories.length > othersThreshold) {
|
|
7057
7049
|
const otherValue = allCategories.slice(othersThreshold).flatMap(({ name }) => groups.get(name));
|
|
7058
7050
|
return {
|
|
@@ -7066,21 +7058,6 @@ function groupValuesByColumn({
|
|
|
7066
7058
|
rows: allCategories
|
|
7067
7059
|
};
|
|
7068
7060
|
}
|
|
7069
|
-
function getSorter(orderBy) {
|
|
7070
|
-
switch (orderBy) {
|
|
7071
|
-
case "frequency_asc":
|
|
7072
|
-
return (a, b) => a.value - b.value || localeCompare(a.name, b.name);
|
|
7073
|
-
case "frequency_desc":
|
|
7074
|
-
return (a, b) => b.value - a.value || localeCompare(a.name, b.name);
|
|
7075
|
-
case "alphabetical_asc":
|
|
7076
|
-
return (a, b) => localeCompare(a.name, b.name) || b.value - a.value;
|
|
7077
|
-
case "alphabetical_desc":
|
|
7078
|
-
return (a, b) => localeCompare(b.name, a.name) || b.value - a.value;
|
|
7079
|
-
}
|
|
7080
|
-
}
|
|
7081
|
-
function localeCompare(a, b) {
|
|
7082
|
-
return (a ?? "null").localeCompare(b ?? "null");
|
|
7083
|
-
}
|
|
7084
7061
|
|
|
7085
7062
|
// src/operations/groupByDate.ts
|
|
7086
7063
|
init_cjs_shims();
|
|
@@ -7655,7 +7632,6 @@ var WidgetTilesetSourceImpl = class extends WidgetSource {
|
|
|
7655
7632
|
filterOwner,
|
|
7656
7633
|
spatialFilter,
|
|
7657
7634
|
othersThreshold,
|
|
7658
|
-
orderBy = "frequency_desc",
|
|
7659
7635
|
rawResult
|
|
7660
7636
|
}) {
|
|
7661
7637
|
const filteredFeatures = this._getFilteredFeatures(
|
|
@@ -7673,8 +7649,7 @@ var WidgetTilesetSourceImpl = class extends WidgetSource {
|
|
|
7673
7649
|
joinOperation,
|
|
7674
7650
|
keysColumn: column,
|
|
7675
7651
|
operation: operation2,
|
|
7676
|
-
othersThreshold
|
|
7677
|
-
orderBy
|
|
7652
|
+
othersThreshold
|
|
7678
7653
|
});
|
|
7679
7654
|
if (rawResult) {
|
|
7680
7655
|
return result;
|
|
@@ -10529,7 +10504,6 @@ function hashBuckets(initialCount) {
|
|
|
10529
10504
|
getLayerProps,
|
|
10530
10505
|
getMaxMarkerSize,
|
|
10531
10506
|
getSizeAccessor,
|
|
10532
|
-
getSorter,
|
|
10533
10507
|
getSpatialIndexFromGeoColumn,
|
|
10534
10508
|
getTextAccessor,
|
|
10535
10509
|
groupValuesByColumn,
|