@carto/api-client 0.5.0-alpha.11 → 0.5.0-alpha.14

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.
@@ -45,326 +45,6 @@ var init_cjs_shims = __esm({
45
45
  }
46
46
  });
47
47
 
48
- // node_modules/tilebelt/index.js
49
- var require_tilebelt = __commonJS({
50
- "node_modules/tilebelt/index.js"(exports2, module2) {
51
- "use strict";
52
- init_cjs_shims();
53
- var d2r = Math.PI / 180;
54
- var r2d = 180 / Math.PI;
55
- function tileToBBOX(tile) {
56
- var e = tile2lon(tile[0] + 1, tile[2]);
57
- var w = tile2lon(tile[0], tile[2]);
58
- var s = tile2lat(tile[1] + 1, tile[2]);
59
- var n = tile2lat(tile[1], tile[2]);
60
- return [w, s, e, n];
61
- }
62
- function tileToGeoJSON(tile) {
63
- var bbox = tileToBBOX(tile);
64
- var poly = {
65
- type: "Polygon",
66
- coordinates: [
67
- [
68
- [bbox[0], bbox[1]],
69
- [bbox[0], bbox[3]],
70
- [bbox[2], bbox[3]],
71
- [bbox[2], bbox[1]],
72
- [bbox[0], bbox[1]]
73
- ]
74
- ]
75
- };
76
- return poly;
77
- }
78
- function tile2lon(x, z) {
79
- return x / Math.pow(2, z) * 360 - 180;
80
- }
81
- function tile2lat(y, z) {
82
- var n = Math.PI - 2 * Math.PI * y / Math.pow(2, z);
83
- return r2d * Math.atan(0.5 * (Math.exp(n) - Math.exp(-n)));
84
- }
85
- function pointToTile(lon, lat, z) {
86
- var tile = pointToTileFraction(lon, lat, z);
87
- tile[0] = Math.floor(tile[0]);
88
- tile[1] = Math.floor(tile[1]);
89
- return tile;
90
- }
91
- function getChildren(tile) {
92
- return [
93
- [tile[0] * 2, tile[1] * 2, tile[2] + 1],
94
- [tile[0] * 2 + 1, tile[1] * 2, tile[2] + 1],
95
- [tile[0] * 2 + 1, tile[1] * 2 + 1, tile[2] + 1],
96
- [tile[0] * 2, tile[1] * 2 + 1, tile[2] + 1]
97
- ];
98
- }
99
- function getParent(tile) {
100
- if (tile[0] % 2 === 0 && tile[1] % 2 === 0) {
101
- return [tile[0] / 2, tile[1] / 2, tile[2] - 1];
102
- } else if (tile[0] % 2 === 0 && !tile[1] % 2 === 0) {
103
- return [tile[0] / 2, (tile[1] - 1) / 2, tile[2] - 1];
104
- } else if (!tile[0] % 2 === 0 && tile[1] % 2 === 0) {
105
- return [(tile[0] - 1) / 2, tile[1] / 2, tile[2] - 1];
106
- } else {
107
- return [(tile[0] - 1) / 2, (tile[1] - 1) / 2, tile[2] - 1];
108
- }
109
- }
110
- function getSiblings(tile) {
111
- return getChildren(getParent(tile));
112
- }
113
- function hasSiblings(tile, tiles2) {
114
- var siblings = getSiblings(tile);
115
- for (var i = 0; i < siblings.length; i++) {
116
- if (!hasTile(tiles2, siblings[i])) return false;
117
- }
118
- return true;
119
- }
120
- function hasTile(tiles2, tile) {
121
- for (var i = 0; i < tiles2.length; i++) {
122
- if (tilesEqual(tiles2[i], tile)) return true;
123
- }
124
- return false;
125
- }
126
- function tilesEqual(tile1, tile2) {
127
- return tile1[0] === tile2[0] && tile1[1] === tile2[1] && tile1[2] === tile2[2];
128
- }
129
- function tileToQuadkey(tile) {
130
- var index = "";
131
- for (var z = tile[2]; z > 0; z--) {
132
- var b = 0;
133
- var mask = 1 << z - 1;
134
- if ((tile[0] & mask) !== 0) b++;
135
- if ((tile[1] & mask) !== 0) b += 2;
136
- index += b.toString();
137
- }
138
- return index;
139
- }
140
- function quadkeyToTile(quadkey) {
141
- var x = 0;
142
- var y = 0;
143
- var z = quadkey.length;
144
- for (var i = z; i > 0; i--) {
145
- var mask = 1 << i - 1;
146
- switch (quadkey[z - i]) {
147
- case "0":
148
- break;
149
- case "1":
150
- x |= mask;
151
- break;
152
- case "2":
153
- y |= mask;
154
- break;
155
- case "3":
156
- x |= mask;
157
- y |= mask;
158
- break;
159
- }
160
- }
161
- return [x, y, z];
162
- }
163
- function bboxToTile(bboxCoords) {
164
- var min2 = pointToTile(bboxCoords[0], bboxCoords[1], 32);
165
- var max2 = pointToTile(bboxCoords[2], bboxCoords[3], 32);
166
- var bbox = [min2[0], min2[1], max2[0], max2[1]];
167
- var z = getBboxZoom(bbox);
168
- if (z === 0) return [0, 0, 0];
169
- var x = bbox[0] >>> 32 - z;
170
- var y = bbox[1] >>> 32 - z;
171
- return [x, y, z];
172
- }
173
- function getBboxZoom(bbox) {
174
- var MAX_ZOOM = 28;
175
- for (var z = 0; z < MAX_ZOOM; z++) {
176
- var mask = 1 << 32 - (z + 1);
177
- if ((bbox[0] & mask) != (bbox[2] & mask) || (bbox[1] & mask) != (bbox[3] & mask)) {
178
- return z;
179
- }
180
- }
181
- return MAX_ZOOM;
182
- }
183
- function pointToTileFraction(lon, lat, z) {
184
- var sin2 = Math.sin(lat * d2r), z2 = Math.pow(2, z), x = z2 * (lon / 360 + 0.5), y = z2 * (0.5 - 0.25 * Math.log((1 + sin2) / (1 - sin2)) / Math.PI);
185
- return [x, y, z];
186
- }
187
- module2.exports = {
188
- tileToGeoJSON,
189
- tileToBBOX,
190
- getChildren,
191
- getParent,
192
- getSiblings,
193
- hasTile,
194
- hasSiblings,
195
- tilesEqual,
196
- tileToQuadkey,
197
- quadkeyToTile,
198
- pointToTile,
199
- bboxToTile,
200
- pointToTileFraction
201
- };
202
- }
203
- });
204
-
205
- // node_modules/@mapbox/tile-cover/index.js
206
- var require_tile_cover = __commonJS({
207
- "node_modules/@mapbox/tile-cover/index.js"(exports2) {
208
- "use strict";
209
- init_cjs_shims();
210
- var tilebelt = require_tilebelt();
211
- exports2.geojson = function(geom, limits) {
212
- return {
213
- type: "FeatureCollection",
214
- features: getTiles(geom, limits).map(tileToFeature)
215
- };
216
- };
217
- function tileToFeature(t) {
218
- return {
219
- type: "Feature",
220
- geometry: tilebelt.tileToGeoJSON(t),
221
- properties: {}
222
- };
223
- }
224
- exports2.tiles = getTiles;
225
- exports2.indexes = function(geom, limits) {
226
- return getTiles(geom, limits).map(tilebelt.tileToQuadkey);
227
- };
228
- function getTiles(geom, limits) {
229
- var i, tile, coords = geom.coordinates, maxZoom = limits.max_zoom, tileHash = {}, tiles2 = [];
230
- if (geom.type === "Point") {
231
- return [tilebelt.pointToTile(coords[0], coords[1], maxZoom)];
232
- } else if (geom.type === "MultiPoint") {
233
- for (i = 0; i < coords.length; i++) {
234
- tile = tilebelt.pointToTile(coords[i][0], coords[i][1], maxZoom);
235
- tileHash[toID(tile[0], tile[1], tile[2])] = true;
236
- }
237
- } else if (geom.type === "LineString") {
238
- lineCover(tileHash, coords, maxZoom);
239
- } else if (geom.type === "MultiLineString") {
240
- for (i = 0; i < coords.length; i++) {
241
- lineCover(tileHash, coords[i], maxZoom);
242
- }
243
- } else if (geom.type === "Polygon") {
244
- polygonCover(tileHash, tiles2, coords, maxZoom);
245
- } else if (geom.type === "MultiPolygon") {
246
- for (i = 0; i < coords.length; i++) {
247
- polygonCover(tileHash, tiles2, coords[i], maxZoom);
248
- }
249
- } else {
250
- throw new Error("Geometry type not implemented");
251
- }
252
- if (limits.min_zoom !== maxZoom) {
253
- var len = tiles2.length;
254
- appendHashTiles(tileHash, tiles2);
255
- for (i = 0; i < len; i++) {
256
- var t = tiles2[i];
257
- tileHash[toID(t[0], t[1], t[2])] = true;
258
- }
259
- return mergeTiles(tileHash, tiles2, limits);
260
- }
261
- appendHashTiles(tileHash, tiles2);
262
- return tiles2;
263
- }
264
- function mergeTiles(tileHash, tiles2, limits) {
265
- var mergedTiles = [];
266
- for (var z = limits.max_zoom; z > limits.min_zoom; z--) {
267
- var parentTileHash = {};
268
- var parentTiles = [];
269
- for (var i = 0; i < tiles2.length; i++) {
270
- var t = tiles2[i];
271
- if (t[0] % 2 === 0 && t[1] % 2 === 0) {
272
- var id2 = toID(t[0] + 1, t[1], z), id3 = toID(t[0], t[1] + 1, z), id4 = toID(t[0] + 1, t[1] + 1, z);
273
- if (tileHash[id2] && tileHash[id3] && tileHash[id4]) {
274
- tileHash[toID(t[0], t[1], t[2])] = false;
275
- tileHash[id2] = false;
276
- tileHash[id3] = false;
277
- tileHash[id4] = false;
278
- var parentTile = [t[0] / 2, t[1] / 2, z - 1];
279
- if (z - 1 === limits.min_zoom) mergedTiles.push(parentTile);
280
- else {
281
- parentTileHash[toID(t[0] / 2, t[1] / 2, z - 1)] = true;
282
- parentTiles.push(parentTile);
283
- }
284
- }
285
- }
286
- }
287
- for (i = 0; i < tiles2.length; i++) {
288
- t = tiles2[i];
289
- if (tileHash[toID(t[0], t[1], t[2])]) mergedTiles.push(t);
290
- }
291
- tileHash = parentTileHash;
292
- tiles2 = parentTiles;
293
- }
294
- return mergedTiles;
295
- }
296
- function polygonCover(tileHash, tileArray, geom, zoom) {
297
- var intersections = [];
298
- for (var i = 0; i < geom.length; i++) {
299
- var ring = [];
300
- lineCover(tileHash, geom[i], zoom, ring);
301
- for (var j = 0, len = ring.length, k = len - 1; j < len; k = j++) {
302
- var m = (j + 1) % len;
303
- var y = ring[j][1];
304
- if ((y > ring[k][1] || y > ring[m][1]) && // not local minimum
305
- (y < ring[k][1] || y < ring[m][1]) && // not local maximum
306
- y !== ring[m][1]) intersections.push(ring[j]);
307
- }
308
- }
309
- intersections.sort(compareTiles);
310
- for (i = 0; i < intersections.length; i += 2) {
311
- y = intersections[i][1];
312
- for (var x = intersections[i][0] + 1; x < intersections[i + 1][0]; x++) {
313
- var id = toID(x, y, zoom);
314
- if (!tileHash[id]) {
315
- tileArray.push([x, y, zoom]);
316
- }
317
- }
318
- }
319
- }
320
- function compareTiles(a, b) {
321
- return a[1] - b[1] || a[0] - b[0];
322
- }
323
- function lineCover(tileHash, coords, maxZoom, ring) {
324
- var prevX, prevY;
325
- for (var i = 0; i < coords.length - 1; i++) {
326
- var start = tilebelt.pointToTileFraction(coords[i][0], coords[i][1], maxZoom), stop = tilebelt.pointToTileFraction(coords[i + 1][0], coords[i + 1][1], maxZoom), x0 = start[0], y0 = start[1], x1 = stop[0], y1 = stop[1], dx = x1 - x0, dy = y1 - y0;
327
- if (dy === 0 && dx === 0) continue;
328
- var sx = dx > 0 ? 1 : -1, sy = dy > 0 ? 1 : -1, x = Math.floor(x0), y = Math.floor(y0), tMaxX = dx === 0 ? Infinity : Math.abs(((dx > 0 ? 1 : 0) + x - x0) / dx), tMaxY = dy === 0 ? Infinity : Math.abs(((dy > 0 ? 1 : 0) + y - y0) / dy), tdx = Math.abs(sx / dx), tdy = Math.abs(sy / dy);
329
- if (x !== prevX || y !== prevY) {
330
- tileHash[toID(x, y, maxZoom)] = true;
331
- if (ring && y !== prevY) ring.push([x, y]);
332
- prevX = x;
333
- prevY = y;
334
- }
335
- while (tMaxX < 1 || tMaxY < 1) {
336
- if (tMaxX < tMaxY) {
337
- tMaxX += tdx;
338
- x += sx;
339
- } else {
340
- tMaxY += tdy;
341
- y += sy;
342
- }
343
- tileHash[toID(x, y, maxZoom)] = true;
344
- if (ring && y !== prevY) ring.push([x, y]);
345
- prevX = x;
346
- prevY = y;
347
- }
348
- }
349
- if (ring && y === ring[0][1]) ring.pop();
350
- }
351
- function appendHashTiles(hash, tiles2) {
352
- var keys = Object.keys(hash);
353
- for (var i = 0; i < keys.length; i++) {
354
- tiles2.push(fromID(+keys[i]));
355
- }
356
- }
357
- function toID(x, y, z) {
358
- var dim = 2 * (1 << z);
359
- return (dim * y + x) * 32 + z;
360
- }
361
- function fromID(id) {
362
- var z = id % 32, dim = 2 * (1 << z), xy = (id - z) / 32, x = xy % dim, y = (xy - x) / dim % dim;
363
- return [x, y, z];
364
- }
365
- }
366
- });
367
-
368
48
  // node_modules/thenby/thenBy.module.js
369
49
  var require_thenBy_module = __commonJS({
370
50
  "node_modules/thenby/thenBy.module.js"(exports2, module2) {
@@ -429,6 +109,7 @@ __export(src_exports, {
429
109
  SpatialIndex: () => SpatialIndex,
430
110
  TileFormat: () => TileFormat,
431
111
  WidgetQuerySource: () => WidgetQuerySource,
112
+ WidgetRasterSource: () => WidgetRasterSource,
432
113
  WidgetRemoteSource: () => WidgetRemoteSource,
433
114
  WidgetSource: () => WidgetSource,
434
115
  WidgetTableSource: () => WidgetTableSource,
@@ -937,14 +618,14 @@ function transformMultiPolygon2(multiPolygon2, bbox) {
937
618
  var import_helpers = require("@turf/helpers");
938
619
  var FEATURE_GEOM_PROPERTY = "__geomValue";
939
620
  function tileFeaturesGeometries({
940
- tiles: tiles2,
621
+ tiles,
941
622
  tileFormat,
942
623
  spatialFilter,
943
624
  uniqueIdProperty,
944
625
  options
945
626
  }) {
946
627
  const map = /* @__PURE__ */ new Map();
947
- for (const tile of tiles2) {
628
+ for (const tile of tiles) {
948
629
  if (tile.isVisible === false || !tile.data) {
949
630
  continue;
950
631
  }
@@ -1227,59 +908,18 @@ function createIndicesForPoints(data) {
1227
908
 
1228
909
  // src/filters/tileFeaturesSpatialIndex.ts
1229
910
  init_cjs_shims();
1230
-
1231
- // node_modules/quadbin/dist/esm/index.js
1232
- init_cjs_shims();
1233
- var import_tile_cover = __toESM(require_tile_cover(), 1);
1234
- var B = [
1235
- 0x5555555555555555n,
1236
- 0x3333333333333333n,
1237
- 0x0f0f0f0f0f0f0f0fn,
1238
- 0x00ff00ff00ff00ffn,
1239
- 0x0000ffff0000ffffn,
1240
- 0x00000000ffffffffn
1241
- ];
1242
- var S = [0n, 1n, 2n, 4n, 8n, 16n];
1243
- function tileToCell(tile) {
1244
- if (tile.z < 0 || tile.z > 26) {
1245
- throw new Error("Wrong zoom");
1246
- }
1247
- const z = BigInt(tile.z);
1248
- let x = BigInt(tile.x) << 32n - z;
1249
- let y = BigInt(tile.y) << 32n - z;
1250
- for (let i = 0; i < 5; i++) {
1251
- const s = S[5 - i];
1252
- const b = B[4 - i];
1253
- x = (x | x << s) & b;
1254
- y = (y | y << s) & b;
1255
- }
1256
- const quadbin = 0x4000000000000000n | 1n << 59n | // | (mode << 59) | (mode_dep << 57)
1257
- z << 52n | (x | y << 1n) >> 12n | 0xfffffffffffffn >> z * 2n;
1258
- return quadbin;
1259
- }
1260
- function getResolution(quadbin) {
1261
- return quadbin >> 52n & 0x1fn;
1262
- }
1263
- function geometryToCells(geometry, resolution) {
1264
- const zoom = Number(resolution);
1265
- return (0, import_tile_cover.tiles)(geometry, {
1266
- min_zoom: zoom,
1267
- max_zoom: zoom
1268
- }).map(([x, y, z]) => tileToCell({ x, y, z }));
1269
- }
1270
-
1271
- // src/filters/tileFeaturesSpatialIndex.ts
911
+ var import_quadbin = require("quadbin");
1272
912
  var import_bbox_clip = __toESM(require("@turf/bbox-clip"), 1);
1273
913
  var import_h3_js = require("h3-js");
1274
914
  function tileFeaturesSpatialIndex({
1275
- tiles: tiles2,
915
+ tiles,
1276
916
  spatialFilter,
1277
917
  spatialDataColumn,
1278
918
  spatialDataType
1279
919
  }) {
1280
920
  const map = /* @__PURE__ */ new Map();
1281
921
  const spatialIndex = getSpatialIndex(spatialDataType);
1282
- const resolution = getResolution2(tiles2, spatialIndex);
922
+ const resolution = getResolution(tiles, spatialIndex);
1283
923
  const spatialIndexIDName = spatialDataColumn ? spatialDataColumn : spatialIndex;
1284
924
  if (!resolution) {
1285
925
  return [];
@@ -1289,7 +929,7 @@ function tileFeaturesSpatialIndex({
1289
929
  return [];
1290
930
  }
1291
931
  const cellsSet = new Set(cells);
1292
- for (const tile of tiles2) {
932
+ for (const tile of tiles) {
1293
933
  if (tile.isVisible === false || !tile.data) {
1294
934
  continue;
1295
935
  }
@@ -1301,13 +941,13 @@ function tileFeaturesSpatialIndex({
1301
941
  }
1302
942
  return Array.from(map.values());
1303
943
  }
1304
- function getResolution2(tiles2, spatialIndex) {
1305
- const data = tiles2.find((tile) => tile.data?.length)?.data;
944
+ function getResolution(tiles, spatialIndex) {
945
+ const data = tiles.find((tile) => tile.data?.length)?.data;
1306
946
  if (!data) {
1307
947
  return;
1308
948
  }
1309
949
  if (spatialIndex === "quadbin" /* QUADBIN */) {
1310
- return Number(getResolution(data[0].id));
950
+ return Number((0, import_quadbin.getResolution)(data[0].id));
1311
951
  }
1312
952
  if (spatialIndex === "h3" /* H3 */) {
1313
953
  return (0, import_h3_js.getResolution)(data[0].id);
@@ -1317,7 +957,7 @@ var bboxWest = [-180, -90, 0, 90];
1317
957
  var bboxEast = [0, -90, 180, 90];
1318
958
  function getCellsCoverGeometry(geometry, spatialIndex, resolution) {
1319
959
  if (spatialIndex === "quadbin" /* QUADBIN */) {
1320
- return geometryToCells(geometry, resolution);
960
+ return (0, import_quadbin.geometryToCells)(geometry, resolution);
1321
961
  }
1322
962
  if (spatialIndex === "h3" /* H3 */) {
1323
963
  return (0, import_h3_js.polygonToCells)(
@@ -1353,39 +993,173 @@ var DEFAULT_TILE_RESOLUTION = 0.5;
1353
993
  var DEFAULT_AGGREGATION_RES_LEVEL_H3 = 4;
1354
994
  var DEFAULT_AGGREGATION_RES_LEVEL_QUADBIN = 6;
1355
995
 
996
+ // src/filters/tileFeaturesRaster.ts
997
+ init_cjs_shims();
998
+ var import_quadbin2 = require("quadbin");
999
+ function tileFeaturesRaster({
1000
+ tiles,
1001
+ ...options
1002
+ }) {
1003
+ const metadataByBand = {};
1004
+ for (const band of options.rasterMetadata.bands) {
1005
+ metadataByBand[band.name] = { ...band, nodata: Number(band.nodata) };
1006
+ }
1007
+ tiles = tiles.filter(isRasterTileVisible);
1008
+ if (tiles.length === 0) return [];
1009
+ const tileResolution = (0, import_quadbin2.getResolution)(tiles[0].index.q);
1010
+ const tileBlockSize = tiles[0].data.blockSize;
1011
+ const cellResolution = tileResolution + BigInt(Math.log2(tileBlockSize));
1012
+ const spatialFilterCells = new Set(
1013
+ (0, import_quadbin2.geometryToCells)(options.spatialFilter, cellResolution)
1014
+ );
1015
+ const data = /* @__PURE__ */ new Map();
1016
+ for (const tile of tiles) {
1017
+ const parent = tile.index.q;
1018
+ const children = cellToChildrenSorted(parent, cellResolution);
1019
+ for (let i = 0; i < children.length; i++) {
1020
+ if (!spatialFilterCells.has(children[i])) continue;
1021
+ const cellData = {};
1022
+ let cellDataExists = false;
1023
+ for (const band in tile.data.cells.numericProps) {
1024
+ const value = tile.data.cells.numericProps[band].value[i];
1025
+ const bandMetadata = metadataByBand[band];
1026
+ if (isValidBandValue(value, bandMetadata.nodata)) {
1027
+ cellData[band] = tile.data.cells.numericProps[band].value[i];
1028
+ cellDataExists = true;
1029
+ }
1030
+ }
1031
+ if (cellDataExists) {
1032
+ data.set(children[i], cellData);
1033
+ }
1034
+ }
1035
+ }
1036
+ return Array.from(data.values());
1037
+ }
1038
+ function isRasterTile(tile) {
1039
+ return !!tile.data?.cells;
1040
+ }
1041
+ function isRasterTileVisible(tile) {
1042
+ return !!(tile.isVisible && tile.data?.cells?.numericProps);
1043
+ }
1044
+ function cellToChildrenSorted(parent, resolution) {
1045
+ return (0, import_quadbin2.cellToChildren)(parent, resolution).sort(
1046
+ (cellA, cellB) => {
1047
+ const tileA = (0, import_quadbin2.cellToTile)(cellA);
1048
+ const tileB = (0, import_quadbin2.cellToTile)(cellB);
1049
+ if (tileA.y !== tileB.y) {
1050
+ return tileA.y > tileB.y ? 1 : -1;
1051
+ }
1052
+ return tileA.x > tileB.x ? 1 : -1;
1053
+ }
1054
+ );
1055
+ }
1056
+ function isValidBandValue(value, nodata) {
1057
+ return Number.isNaN(value) ? false : nodata !== value;
1058
+ }
1059
+
1060
+ // src/utils.ts
1061
+ init_cjs_shims();
1062
+ var FILTER_TYPES = new Set(Object.values(FilterType));
1063
+ var isFilterType = (type) => FILTER_TYPES.has(type);
1064
+ function getApplicableFilters(owner, filters) {
1065
+ if (!filters) return {};
1066
+ const applicableFilters = {};
1067
+ for (const column in filters) {
1068
+ for (const type in filters[column]) {
1069
+ if (!isFilterType(type)) continue;
1070
+ const filter = filters[column][type];
1071
+ const isApplicable = !owner || !filter?.owner || filter?.owner !== owner;
1072
+ if (filter && isApplicable) {
1073
+ applicableFilters[column] || (applicableFilters[column] = {});
1074
+ applicableFilters[column][type] = filter;
1075
+ }
1076
+ }
1077
+ }
1078
+ return applicableFilters;
1079
+ }
1080
+ function normalizeObjectKeys(el) {
1081
+ if (Array.isArray(el)) {
1082
+ return el.map((value) => normalizeObjectKeys(value));
1083
+ } else if (typeof el !== "object") {
1084
+ return el;
1085
+ }
1086
+ return Object.entries(el).reduce(
1087
+ (acc, [key, value]) => {
1088
+ acc[key.toLowerCase()] = typeof value === "object" && value ? normalizeObjectKeys(value) : value;
1089
+ return acc;
1090
+ },
1091
+ {}
1092
+ );
1093
+ }
1094
+ function assert2(condition, message) {
1095
+ if (!condition) {
1096
+ throw new Error(message);
1097
+ }
1098
+ }
1099
+ var _InvalidColumnError = class _InvalidColumnError extends Error {
1100
+ constructor(message) {
1101
+ super(`${_InvalidColumnError.NAME}: ${message}`);
1102
+ this.name = _InvalidColumnError.NAME;
1103
+ }
1104
+ static is(error) {
1105
+ return error instanceof _InvalidColumnError || error.message?.includes(_InvalidColumnError.NAME);
1106
+ }
1107
+ };
1108
+ __publicField(_InvalidColumnError, "NAME", "InvalidColumnError");
1109
+ var InvalidColumnError = _InvalidColumnError;
1110
+ function isEmptyObject(object) {
1111
+ for (const _ in object) {
1112
+ return false;
1113
+ }
1114
+ return true;
1115
+ }
1116
+ var isObject = (x) => x !== null && typeof x === "object";
1117
+ var isPureObject = (x) => isObject(x) && x.constructor === {}.constructor;
1118
+
1356
1119
  // src/filters/tileFeatures.ts
1357
1120
  function tileFeatures({
1358
- tiles: tiles2,
1121
+ tiles,
1359
1122
  spatialFilter,
1360
1123
  uniqueIdProperty,
1361
1124
  tileFormat,
1362
1125
  spatialDataColumn = DEFAULT_GEO_COLUMN,
1363
1126
  spatialDataType,
1127
+ rasterMetadata,
1364
1128
  options = {}
1365
1129
  }) {
1366
- if (spatialDataType !== "geo") {
1367
- return tileFeaturesSpatialIndex({
1368
- tiles: tiles2,
1130
+ if (spatialDataType === "geo") {
1131
+ return tileFeaturesGeometries({
1132
+ tiles,
1133
+ tileFormat,
1134
+ spatialFilter,
1135
+ uniqueIdProperty,
1136
+ options
1137
+ });
1138
+ }
1139
+ if (tiles.some(isRasterTile)) {
1140
+ assert2(rasterMetadata, "Missing raster metadata");
1141
+ return tileFeaturesRaster({
1142
+ tiles,
1369
1143
  spatialFilter,
1370
1144
  spatialDataColumn,
1371
- spatialDataType
1145
+ spatialDataType,
1146
+ rasterMetadata
1372
1147
  });
1373
1148
  }
1374
- return tileFeaturesGeometries({
1375
- tiles: tiles2,
1376
- tileFormat,
1149
+ return tileFeaturesSpatialIndex({
1150
+ tiles,
1377
1151
  spatialFilter,
1378
- uniqueIdProperty,
1379
- options
1152
+ spatialDataColumn,
1153
+ spatialDataType
1380
1154
  });
1381
1155
  }
1382
1156
 
1383
1157
  // src/deck/get-data-filter-extension-props.ts
1384
- function getDataFilterExtensionProps(filters, filtersLogicalOperator, filterSize) {
1385
- filterSize ?? (filterSize = 4);
1158
+ var DEFAULT_FILTER_SIZE = 4;
1159
+ function getDataFilterExtensionProps(filters, filtersLogicalOperator) {
1386
1160
  const { filtersWithoutTimeType, timeColumn, timeFilter } = getFiltersByType(filters);
1387
1161
  return {
1388
- filterRange: getFilterRange(timeFilter, filterSize),
1162
+ filterRange: getFilterRange(timeFilter, DEFAULT_FILTER_SIZE),
1389
1163
  updateTriggers: getUpdateTriggers(
1390
1164
  filtersWithoutTimeType,
1391
1165
  timeColumn,
@@ -1395,7 +1169,7 @@ function getDataFilterExtensionProps(filters, filtersLogicalOperator, filterSize
1395
1169
  filtersWithoutTimeType,
1396
1170
  timeColumn,
1397
1171
  timeFilter,
1398
- filterSize,
1172
+ DEFAULT_FILTER_SIZE,
1399
1173
  filtersLogicalOperator
1400
1174
  )
1401
1175
  };
@@ -1463,67 +1237,6 @@ function getFilterValue(filtersWithoutTimeType, timeColumn, timeFilter, filterSi
1463
1237
 
1464
1238
  // src/filters.ts
1465
1239
  init_cjs_shims();
1466
-
1467
- // src/utils.ts
1468
- init_cjs_shims();
1469
- var FILTER_TYPES = new Set(Object.values(FilterType));
1470
- var isFilterType = (type) => FILTER_TYPES.has(type);
1471
- function getApplicableFilters(owner, filters) {
1472
- if (!filters) return {};
1473
- const applicableFilters = {};
1474
- for (const column in filters) {
1475
- for (const type in filters[column]) {
1476
- if (!isFilterType(type)) continue;
1477
- const filter = filters[column][type];
1478
- const isApplicable = !owner || !filter?.owner || filter?.owner !== owner;
1479
- if (filter && isApplicable) {
1480
- applicableFilters[column] || (applicableFilters[column] = {});
1481
- applicableFilters[column][type] = filter;
1482
- }
1483
- }
1484
- }
1485
- return applicableFilters;
1486
- }
1487
- function normalizeObjectKeys(el) {
1488
- if (Array.isArray(el)) {
1489
- return el.map((value) => normalizeObjectKeys(value));
1490
- } else if (typeof el !== "object") {
1491
- return el;
1492
- }
1493
- return Object.entries(el).reduce(
1494
- (acc, [key, value]) => {
1495
- acc[key.toLowerCase()] = typeof value === "object" && value ? normalizeObjectKeys(value) : value;
1496
- return acc;
1497
- },
1498
- {}
1499
- );
1500
- }
1501
- function assert2(condition, message) {
1502
- if (!condition) {
1503
- throw new Error(message);
1504
- }
1505
- }
1506
- var _InvalidColumnError = class _InvalidColumnError extends Error {
1507
- constructor(message) {
1508
- super(`${_InvalidColumnError.NAME}: ${message}`);
1509
- this.name = _InvalidColumnError.NAME;
1510
- }
1511
- static is(error) {
1512
- return error instanceof _InvalidColumnError || error.message?.includes(_InvalidColumnError.NAME);
1513
- }
1514
- };
1515
- __publicField(_InvalidColumnError, "NAME", "InvalidColumnError");
1516
- var InvalidColumnError = _InvalidColumnError;
1517
- function isEmptyObject(object) {
1518
- for (const _ in object) {
1519
- return false;
1520
- }
1521
- return true;
1522
- }
1523
- var isObject = (x) => x !== null && typeof x === "object";
1524
- var isPureObject = (x) => isObject(x) && x.constructor === {}.constructor;
1525
-
1526
- // src/filters.ts
1527
1240
  function addFilter(filters, { column, type, values, owner }) {
1528
1241
  if (!filters[column]) {
1529
1242
  filters[column] = {};
@@ -2624,17 +2337,8 @@ var WidgetQuerySource = class extends WidgetRemoteSource {
2624
2337
  }
2625
2338
  };
2626
2339
 
2627
- // src/widget-sources/widget-table-source.ts
2340
+ // src/widget-sources/widget-raster-source.ts
2628
2341
  init_cjs_shims();
2629
- var WidgetTableSource = class extends WidgetRemoteSource {
2630
- getModelSource(filters, filterOwner) {
2631
- return {
2632
- ...super._getModelSource(filters, filterOwner),
2633
- type: "table",
2634
- data: this.props.tableName
2635
- };
2636
- }
2637
- };
2638
2342
 
2639
2343
  // src/widget-sources/widget-tileset-source.ts
2640
2344
  init_cjs_shims();
@@ -3005,8 +2709,8 @@ var WidgetTilesetSourceImpl = class extends WidgetSource {
3005
2709
  * After tiles are loaded, {@link extractTileFeatures} must be called
3006
2710
  * before computing statistics on the tiles.
3007
2711
  */
3008
- loadTiles(tiles2) {
3009
- this._tiles = tiles2;
2712
+ loadTiles(tiles) {
2713
+ this._tiles = tiles;
3010
2714
  this._features.length = 0;
3011
2715
  }
3012
2716
  /** Configures options used to extract features from tiles. */
@@ -3020,12 +2724,10 @@ var WidgetTilesetSourceImpl = class extends WidgetSource {
3020
2724
  return;
3021
2725
  }
3022
2726
  this._features = tileFeatures({
3023
- tiles: this._tiles,
3024
- tileFormat: this.props.tileFormat,
2727
+ ...this.props,
3025
2728
  ...this._tileFeatureExtractOptions,
3026
- spatialFilter,
3027
- spatialDataColumn: this.props.spatialDataColumn,
3028
- spatialDataType: this.props.spatialDataType
2729
+ tiles: this._tiles,
2730
+ spatialFilter
3029
2731
  });
3030
2732
  prevInputs.spatialFilter = spatialFilter;
3031
2733
  }
@@ -3056,12 +2758,6 @@ var WidgetTilesetSourceImpl = class extends WidgetSource {
3056
2758
  filterOwner,
3057
2759
  spatialFilter
3058
2760
  }) {
3059
- if (operation === "custom") {
3060
- throw new Error("Custom aggregation not supported for tilesets");
3061
- }
3062
- if (column && column !== "*" || operation !== "count") {
3063
- assertColumn(this._features, column);
3064
- }
3065
2761
  const filteredFeatures = this._getFilteredFeatures(
3066
2762
  spatialFilter,
3067
2763
  filters,
@@ -3070,6 +2766,12 @@ var WidgetTilesetSourceImpl = class extends WidgetSource {
3070
2766
  if (filteredFeatures.length === 0 && operation !== "count") {
3071
2767
  return { value: null };
3072
2768
  }
2769
+ if (operation === "custom") {
2770
+ throw new Error("Custom aggregation not supported for tilesets");
2771
+ }
2772
+ if (column && column !== "*" || operation !== "count") {
2773
+ assertColumn(this._features, column);
2774
+ }
3073
2775
  const targetOperation = aggregationFunctions[operation];
3074
2776
  return {
3075
2777
  value: targetOperation(filteredFeatures, column, joinOperation)
@@ -3234,7 +2936,6 @@ var WidgetTilesetSourceImpl = class extends WidgetSource {
3234
2936
  filterOwner,
3235
2937
  spatialFilter
3236
2938
  }) {
3237
- assertColumn(this._features, column);
3238
2939
  const filteredFeatures = this._getFilteredFeatures(
3239
2940
  spatialFilter,
3240
2941
  filters,
@@ -3243,6 +2944,7 @@ var WidgetTilesetSourceImpl = class extends WidgetSource {
3243
2944
  if (!this._features.length) {
3244
2945
  return null;
3245
2946
  }
2947
+ assertColumn(this._features, column);
3246
2948
  return {
3247
2949
  min: aggregationFunctions.min(filteredFeatures, column),
3248
2950
  max: aggregationFunctions.max(filteredFeatures, column)
@@ -3337,9 +3039,8 @@ var WidgetTilesetSource = class extends WidgetSource {
3337
3039
  function onMessage(e) {
3338
3040
  const response = e.data;
3339
3041
  if (response.requestId !== requestId) return;
3340
- if (signal?.aborted) {
3341
- reject(new Error(signal.reason));
3342
- } else if (response.ok) {
3042
+ if (signal?.aborted) return;
3043
+ if (response.ok) {
3343
3044
  resolve(response.result);
3344
3045
  } else {
3345
3046
  reject(new Error(response.error));
@@ -3372,19 +3073,26 @@ var WidgetTilesetSource = class extends WidgetSource {
3372
3073
  * After tiles are loaded, {@link extractTileFeatures} must be called
3373
3074
  * before computing statistics on the tiles.
3374
3075
  */
3375
- loadTiles(tiles2) {
3076
+ loadTiles(tiles) {
3376
3077
  if (!this._workerEnabled) {
3377
- return this._localImpl.loadTiles(tiles2);
3078
+ return this._localImpl.loadTiles(tiles);
3378
3079
  }
3379
3080
  const worker = this._getWorker();
3380
- tiles2 = tiles2.map(({ id, bbox, data }) => ({
3381
- id,
3382
- bbox,
3383
- data
3384
- }));
3081
+ tiles = tiles.map(
3082
+ ({ id, index, bbox, isVisible, data }) => {
3083
+ const tile = {
3084
+ id,
3085
+ index,
3086
+ isVisible,
3087
+ data,
3088
+ bbox
3089
+ };
3090
+ return tile;
3091
+ }
3092
+ );
3385
3093
  worker.postMessage({
3386
3094
  method: "loadTiles" /* LOAD_TILES */,
3387
- params: [tiles2]
3095
+ params: [tiles]
3388
3096
  });
3389
3097
  }
3390
3098
  /** Configures options used to extract features from tiles. */
@@ -3466,6 +3174,22 @@ var WidgetTilesetSource = class extends WidgetSource {
3466
3174
  }
3467
3175
  };
3468
3176
 
3177
+ // src/widget-sources/widget-raster-source.ts
3178
+ var WidgetRasterSource = class extends WidgetTilesetSource {
3179
+ };
3180
+
3181
+ // src/widget-sources/widget-table-source.ts
3182
+ init_cjs_shims();
3183
+ var WidgetTableSource = class extends WidgetRemoteSource {
3184
+ getModelSource(filters, filterOwner) {
3185
+ return {
3186
+ ...super._getModelSource(filters, filterOwner),
3187
+ type: "table",
3188
+ data: this.props.tableName
3189
+ };
3190
+ }
3191
+ };
3192
+
3469
3193
  // src/sources/h3-query-source.ts
3470
3194
  var h3QuerySource = async function(options) {
3471
3195
  const {
@@ -3576,10 +3300,17 @@ var rasterSource = async function(options) {
3576
3300
  if (filters) {
3577
3301
  urlParameters.filters = filters;
3578
3302
  }
3579
- return baseSource(
3580
- "raster",
3581
- options,
3582
- urlParameters
3303
+ return baseSource("raster", options, urlParameters).then(
3304
+ (result) => ({
3305
+ ...result,
3306
+ widgetSource: new WidgetRasterSource({
3307
+ ...options,
3308
+ tileFormat: getTileFormat(result),
3309
+ spatialDataColumn: "quadbin",
3310
+ spatialDataType: "quadbin",
3311
+ rasterMetadata: result.raster_metadata
3312
+ })
3313
+ })
3583
3314
  );
3584
3315
  };
3585
3316
 
@@ -3833,6 +3564,7 @@ var query = async function(options) {
3833
3564
  SpatialIndex,
3834
3565
  TileFormat,
3835
3566
  WidgetQuerySource,
3567
+ WidgetRasterSource,
3836
3568
  WidgetRemoteSource,
3837
3569
  WidgetSource,
3838
3570
  WidgetTableSource,