@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.
@@ -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;
@@ -20088,8 +20073,7 @@
20088
20073
  joinOperation,
20089
20074
  keysColumn,
20090
20075
  operation: operation2,
20091
- othersThreshold,
20092
- orderBy = "frequency_desc"
20076
+ othersThreshold
20093
20077
  }) {
20094
20078
  if (Array.isArray(data) && data.length === 0) {
20095
20079
  return { rows: null };
@@ -20113,7 +20097,7 @@
20113
20097
  const allCategories = Array.from(groups).map(([name, value]) => ({
20114
20098
  name,
20115
20099
  value: targetOperation(value)
20116
- })).sort(getSorter(orderBy));
20100
+ })).sort((a, b) => b.value - a.value);
20117
20101
  if (othersThreshold && allCategories.length > othersThreshold) {
20118
20102
  const otherValue = allCategories.slice(othersThreshold).flatMap(({ name }) => groups.get(name));
20119
20103
  return {
@@ -20127,21 +20111,6 @@
20127
20111
  rows: allCategories
20128
20112
  };
20129
20113
  }
20130
- function getSorter(orderBy) {
20131
- switch (orderBy) {
20132
- case "frequency_asc":
20133
- return (a, b) => a.value - b.value || localeCompare(a.name, b.name);
20134
- case "frequency_desc":
20135
- return (a, b) => b.value - a.value || localeCompare(a.name, b.name);
20136
- case "alphabetical_asc":
20137
- return (a, b) => localeCompare(a.name, b.name) || b.value - a.value;
20138
- case "alphabetical_desc":
20139
- return (a, b) => localeCompare(b.name, a.name) || b.value - a.value;
20140
- }
20141
- }
20142
- function localeCompare(a, b) {
20143
- return (a ?? "null").localeCompare(b ?? "null");
20144
- }
20145
20114
 
20146
20115
  // src/utils/dateUtils.ts
20147
20116
  function getUTCMonday(date) {
@@ -20764,7 +20733,6 @@
20764
20733
  filterOwner,
20765
20734
  spatialFilter,
20766
20735
  othersThreshold,
20767
- orderBy = "frequency_desc",
20768
20736
  rawResult
20769
20737
  }) {
20770
20738
  const filteredFeatures = this._getFilteredFeatures(
@@ -20782,8 +20750,7 @@
20782
20750
  joinOperation,
20783
20751
  keysColumn: column,
20784
20752
  operation: operation2,
20785
- othersThreshold,
20786
- orderBy
20753
+ othersThreshold
20787
20754
  });
20788
20755
  if (rawResult) {
20789
20756
  return result;