@carto/api-client 0.5.8-alpha-others-orderby.1 → 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 -49
- 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 -53
- package/build/api-client.js.map +1 -1
- package/build/worker-compat.js +20 -57
- package/build/worker-compat.js.map +1 -1
- package/build/worker.js +21 -45
- 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 -36
- 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/build/worker.js
CHANGED
|
@@ -5414,11 +5414,7 @@ var DEFAULT_AGGREGATION_EXP_ALIAS = "__aggregationValue";
|
|
|
5414
5414
|
var DEFAULT_AGGREGATION_EXP = `1 AS ${DEFAULT_AGGREGATION_EXP_ALIAS}`;
|
|
5415
5415
|
|
|
5416
5416
|
// src/filters/tileFeaturesRaster.ts
|
|
5417
|
-
import {
|
|
5418
|
-
cellToChildren as _cellToChildren,
|
|
5419
|
-
cellToTile,
|
|
5420
|
-
getResolution as getResolution2
|
|
5421
|
-
} from "quadbin";
|
|
5417
|
+
import { cellToTile, getResolution as getResolution2, tileToCell } from "quadbin";
|
|
5422
5418
|
function tileFeaturesRaster({
|
|
5423
5419
|
tiles,
|
|
5424
5420
|
...options
|
|
@@ -5441,7 +5437,7 @@ function tileFeaturesRaster({
|
|
|
5441
5437
|
options.spatialFilter
|
|
5442
5438
|
);
|
|
5443
5439
|
if (intersection3 === false) continue;
|
|
5444
|
-
const tileSortedCells =
|
|
5440
|
+
const tileSortedCells = cellToChildrenRaster(parent, cellResolution);
|
|
5445
5441
|
for (let i = 0; i < tileSortedCells.length; i++) {
|
|
5446
5442
|
if (intersection3 !== true && !intersection3.has(tileSortedCells[i])) {
|
|
5447
5443
|
continue;
|
|
@@ -5469,17 +5465,19 @@ function isRasterTile(tile) {
|
|
|
5469
5465
|
function isRasterTileVisible(tile) {
|
|
5470
5466
|
return !!(tile.isVisible && tile.data?.cells?.numericProps);
|
|
5471
5467
|
}
|
|
5472
|
-
function
|
|
5473
|
-
|
|
5474
|
-
|
|
5475
|
-
|
|
5476
|
-
|
|
5477
|
-
|
|
5478
|
-
|
|
5479
|
-
|
|
5480
|
-
|
|
5481
|
-
|
|
5482
|
-
|
|
5468
|
+
function cellToChildrenRaster(parent, resolution) {
|
|
5469
|
+
const parentTile = cellToTile(parent);
|
|
5470
|
+
const childZ = Number(resolution);
|
|
5471
|
+
const blockSize = 2 ** (childZ - parentTile.z);
|
|
5472
|
+
const childBaseX = parentTile.x * blockSize;
|
|
5473
|
+
const childBaseY = parentTile.y * blockSize;
|
|
5474
|
+
const cells = [];
|
|
5475
|
+
for (let i = 0, il = blockSize ** 2; i < il; i++) {
|
|
5476
|
+
const x = childBaseX + i % blockSize;
|
|
5477
|
+
const y = childBaseY + Math.floor(i / blockSize);
|
|
5478
|
+
cells.push(tileToCell({ x, y, z: childZ }));
|
|
5479
|
+
}
|
|
5480
|
+
return cells;
|
|
5483
5481
|
}
|
|
5484
5482
|
function isValidBandValue(value, nodata) {
|
|
5485
5483
|
return Number.isNaN(value) ? false : nodata !== value;
|
|
@@ -5678,9 +5676,6 @@ function normalizeSortByOptions({
|
|
|
5678
5676
|
});
|
|
5679
5677
|
}
|
|
5680
5678
|
|
|
5681
|
-
// src/widget-sources/constants.ts
|
|
5682
|
-
var OTHERS_CATEGORY_NAME = "_carto_others";
|
|
5683
|
-
|
|
5684
5679
|
// src/operations/groupBy.ts
|
|
5685
5680
|
function groupValuesByColumn({
|
|
5686
5681
|
data,
|
|
@@ -5688,8 +5683,7 @@ function groupValuesByColumn({
|
|
|
5688
5683
|
joinOperation,
|
|
5689
5684
|
keysColumn,
|
|
5690
5685
|
operation: operation2,
|
|
5691
|
-
othersThreshold
|
|
5692
|
-
orderBy = "frequency_desc"
|
|
5686
|
+
othersThreshold
|
|
5693
5687
|
}) {
|
|
5694
5688
|
if (Array.isArray(data) && data.length === 0) {
|
|
5695
5689
|
return { rows: null };
|
|
@@ -5713,13 +5707,9 @@ function groupValuesByColumn({
|
|
|
5713
5707
|
const allCategories = Array.from(groups).map(([name, value]) => ({
|
|
5714
5708
|
name,
|
|
5715
5709
|
value: targetOperation(value)
|
|
5716
|
-
})).sort(
|
|
5710
|
+
})).sort((a, b) => b.value - a.value);
|
|
5717
5711
|
if (othersThreshold && allCategories.length > othersThreshold) {
|
|
5718
5712
|
const otherValue = allCategories.slice(othersThreshold).flatMap(({ name }) => groups.get(name));
|
|
5719
|
-
allCategories.push({
|
|
5720
|
-
name: OTHERS_CATEGORY_NAME,
|
|
5721
|
-
value: targetOperation(otherValue)
|
|
5722
|
-
});
|
|
5723
5713
|
return {
|
|
5724
5714
|
rows: allCategories,
|
|
5725
5715
|
metadata: {
|
|
@@ -5731,21 +5721,6 @@ function groupValuesByColumn({
|
|
|
5731
5721
|
rows: allCategories
|
|
5732
5722
|
};
|
|
5733
5723
|
}
|
|
5734
|
-
function getSorter(orderBy) {
|
|
5735
|
-
switch (orderBy) {
|
|
5736
|
-
case "frequency_asc":
|
|
5737
|
-
return (a, b) => a.value - b.value || localeCompare(a.name, b.name);
|
|
5738
|
-
case "frequency_desc":
|
|
5739
|
-
return (a, b) => b.value - a.value || localeCompare(a.name, b.name);
|
|
5740
|
-
case "alphabetical_asc":
|
|
5741
|
-
return (a, b) => localeCompare(a.name, b.name) || b.value - a.value;
|
|
5742
|
-
case "alphabetical_desc":
|
|
5743
|
-
return (a, b) => localeCompare(b.name, a.name) || b.value - a.value;
|
|
5744
|
-
}
|
|
5745
|
-
}
|
|
5746
|
-
function localeCompare(a, b) {
|
|
5747
|
-
return (a ?? "null").localeCompare(b ?? "null");
|
|
5748
|
-
}
|
|
5749
5724
|
|
|
5750
5725
|
// src/utils/dateUtils.ts
|
|
5751
5726
|
function getUTCMonday(date) {
|
|
@@ -6249,6 +6224,9 @@ function getApplicableFilters(owner, filters) {
|
|
|
6249
6224
|
return applicableFilters;
|
|
6250
6225
|
}
|
|
6251
6226
|
|
|
6227
|
+
// src/widget-sources/constants.ts
|
|
6228
|
+
var OTHERS_CATEGORY_NAME = "_carto_others";
|
|
6229
|
+
|
|
6252
6230
|
// src/widget-sources/widget-tileset-source-impl.ts
|
|
6253
6231
|
var WidgetTilesetSourceImpl = class extends WidgetSource {
|
|
6254
6232
|
constructor() {
|
|
@@ -6365,7 +6343,6 @@ var WidgetTilesetSourceImpl = class extends WidgetSource {
|
|
|
6365
6343
|
filterOwner,
|
|
6366
6344
|
spatialFilter,
|
|
6367
6345
|
othersThreshold,
|
|
6368
|
-
orderBy = "frequency_desc",
|
|
6369
6346
|
rawResult
|
|
6370
6347
|
}) {
|
|
6371
6348
|
const filteredFeatures = this._getFilteredFeatures(
|
|
@@ -6383,8 +6360,7 @@ var WidgetTilesetSourceImpl = class extends WidgetSource {
|
|
|
6383
6360
|
joinOperation,
|
|
6384
6361
|
keysColumn: column,
|
|
6385
6362
|
operation: operation2,
|
|
6386
|
-
othersThreshold
|
|
6387
|
-
orderBy
|
|
6363
|
+
othersThreshold
|
|
6388
6364
|
});
|
|
6389
6365
|
if (rawResult) {
|
|
6390
6366
|
return result;
|