@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.
@@ -5240,23 +5240,6 @@
5240
5240
  function getResolution(quadbin) {
5241
5241
  return quadbin >> 52n & 0x1fn;
5242
5242
  }
5243
- function cellToChildren(quadbin, resolution) {
5244
- if (resolution < 0 || resolution > 26 || resolution < getResolution(quadbin)) {
5245
- throw new Error("Invalid resolution");
5246
- }
5247
- const zoomLevelMask = ~(0x1fn << 52n);
5248
- const blockRange = 1n << (resolution - (quadbin >> 52n & 0x1fn) << 1n);
5249
- const sqrtBlockRange = 1n << resolution - (quadbin >> 52n & 0x1fn);
5250
- const blockShift = 52n - (resolution << 1n);
5251
- const childBase = (quadbin & zoomLevelMask | resolution << 52n) & ~(blockRange - 1n << blockShift);
5252
- const children = [];
5253
- for (let blockRow = 0n; blockRow < sqrtBlockRange; blockRow++) {
5254
- for (let blockColumn = 0n; blockColumn < sqrtBlockRange; blockColumn++) {
5255
- children.push(childBase | blockRow * sqrtBlockRange + blockColumn << blockShift);
5256
- }
5257
- }
5258
- return children;
5259
- }
5260
5243
  function geometryToCells(geometry, resolution) {
5261
5244
  const zoom = Number(resolution);
5262
5245
  return tiles(geometry, {
@@ -19844,7 +19827,7 @@
19844
19827
  options.spatialFilter
19845
19828
  );
19846
19829
  if (intersection3 === false) continue;
19847
- const tileSortedCells = cellToChildrenSorted(parent, cellResolution);
19830
+ const tileSortedCells = cellToChildrenRaster(parent, cellResolution);
19848
19831
  for (let i = 0; i < tileSortedCells.length; i++) {
19849
19832
  if (intersection3 !== true && !intersection3.has(tileSortedCells[i])) {
19850
19833
  continue;
@@ -19872,17 +19855,19 @@
19872
19855
  function isRasterTileVisible(tile) {
19873
19856
  return !!(tile.isVisible && tile.data?.cells?.numericProps);
19874
19857
  }
19875
- function cellToChildrenSorted(parent, resolution) {
19876
- return cellToChildren(parent, resolution).sort(
19877
- (cellA, cellB) => {
19878
- const tileA = cellToTile(cellA);
19879
- const tileB = cellToTile(cellB);
19880
- if (tileA.y !== tileB.y) {
19881
- return tileA.y > tileB.y ? 1 : -1;
19882
- }
19883
- return tileA.x > tileB.x ? 1 : -1;
19884
- }
19885
- );
19858
+ function cellToChildrenRaster(parent, resolution) {
19859
+ const parentTile = cellToTile(parent);
19860
+ const childZ = Number(resolution);
19861
+ const blockSize = 2 ** (childZ - parentTile.z);
19862
+ const childBaseX = parentTile.x * blockSize;
19863
+ const childBaseY = parentTile.y * blockSize;
19864
+ const cells = [];
19865
+ for (let i = 0, il = blockSize ** 2; i < il; i++) {
19866
+ const x = childBaseX + i % blockSize;
19867
+ const y = childBaseY + Math.floor(i / blockSize);
19868
+ cells.push(tileToCell({ x, y, z: childZ }));
19869
+ }
19870
+ return cells;
19886
19871
  }
19887
19872
  function isValidBandValue(value, nodata) {
19888
19873
  return Number.isNaN(value) ? false : nodata !== value;
@@ -20081,9 +20066,6 @@
20081
20066
  });
20082
20067
  }
20083
20068
 
20084
- // src/widget-sources/constants.ts
20085
- var OTHERS_CATEGORY_NAME = "_carto_others";
20086
-
20087
20069
  // src/operations/groupBy.ts
20088
20070
  function groupValuesByColumn({
20089
20071
  data,
@@ -20091,8 +20073,7 @@
20091
20073
  joinOperation,
20092
20074
  keysColumn,
20093
20075
  operation: operation2,
20094
- othersThreshold,
20095
- orderBy = "frequency_desc"
20076
+ othersThreshold
20096
20077
  }) {
20097
20078
  if (Array.isArray(data) && data.length === 0) {
20098
20079
  return { rows: null };
@@ -20116,13 +20097,9 @@
20116
20097
  const allCategories = Array.from(groups).map(([name, value]) => ({
20117
20098
  name,
20118
20099
  value: targetOperation(value)
20119
- })).sort(getSorter(orderBy));
20100
+ })).sort((a, b) => b.value - a.value);
20120
20101
  if (othersThreshold && allCategories.length > othersThreshold) {
20121
20102
  const otherValue = allCategories.slice(othersThreshold).flatMap(({ name }) => groups.get(name));
20122
- allCategories.push({
20123
- name: OTHERS_CATEGORY_NAME,
20124
- value: targetOperation(otherValue)
20125
- });
20126
20103
  return {
20127
20104
  rows: allCategories,
20128
20105
  metadata: {
@@ -20134,21 +20111,6 @@
20134
20111
  rows: allCategories
20135
20112
  };
20136
20113
  }
20137
- function getSorter(orderBy) {
20138
- switch (orderBy) {
20139
- case "frequency_asc":
20140
- return (a, b) => a.value - b.value || localeCompare(a.name, b.name);
20141
- case "frequency_desc":
20142
- return (a, b) => b.value - a.value || localeCompare(a.name, b.name);
20143
- case "alphabetical_asc":
20144
- return (a, b) => localeCompare(a.name, b.name) || b.value - a.value;
20145
- case "alphabetical_desc":
20146
- return (a, b) => localeCompare(b.name, a.name) || b.value - a.value;
20147
- }
20148
- }
20149
- function localeCompare(a, b) {
20150
- return (a ?? "null").localeCompare(b ?? "null");
20151
- }
20152
20114
 
20153
20115
  // src/utils/dateUtils.ts
20154
20116
  function getUTCMonday(date) {
@@ -20652,6 +20614,9 @@
20652
20614
  return applicableFilters;
20653
20615
  }
20654
20616
 
20617
+ // src/widget-sources/constants.ts
20618
+ var OTHERS_CATEGORY_NAME = "_carto_others";
20619
+
20655
20620
  // src/widget-sources/widget-tileset-source-impl.ts
20656
20621
  var WidgetTilesetSourceImpl = class extends WidgetSource {
20657
20622
  constructor() {
@@ -20768,7 +20733,6 @@
20768
20733
  filterOwner,
20769
20734
  spatialFilter,
20770
20735
  othersThreshold,
20771
- orderBy = "frequency_desc",
20772
20736
  rawResult
20773
20737
  }) {
20774
20738
  const filteredFeatures = this._getFilteredFeatures(
@@ -20786,8 +20750,7 @@
20786
20750
  joinOperation,
20787
20751
  keysColumn: column,
20788
20752
  operation: operation2,
20789
- othersThreshold,
20790
- orderBy
20753
+ othersThreshold
20791
20754
  });
20792
20755
  if (rawResult) {
20793
20756
  return result;