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

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/build/worker.js CHANGED
@@ -86,6 +86,10 @@ var FilterType = /* @__PURE__ */ ((FilterType2) => {
86
86
  return FilterType2;
87
87
  })(FilterType || {});
88
88
  var DEFAULT_API_BASE_URL = "https://gcp-us-east1.api.carto.com";
89
+ var SpatialIndexColumn = Object.freeze({
90
+ ["h3" /* H3 */]: ["h3", "hex", "h3id", "hex_id", "h3hex"],
91
+ ["quadbin" /* QUADBIN */]: ["quadbin"]
92
+ });
89
93
 
90
94
  // src/utils.ts
91
95
  var FILTER_TYPES = new Set(Object.values(FilterType));
@@ -804,8 +808,8 @@ function getSpatialIndex(spatialDataType) {
804
808
 
805
809
  // src/constants-internal.ts
806
810
  var DEFAULT_GEO_COLUMN = "geom";
807
- var DEFAULT_AGGREGATION_RES_LEVEL_H3 = 4;
808
- var DEFAULT_AGGREGATION_RES_LEVEL_QUADBIN = 6;
811
+ var DEFAULT_AGGREGATION_EXP_ALIAS = "__aggregationValue";
812
+ var DEFAULT_AGGREGATION_EXP = `1 AS ${DEFAULT_AGGREGATION_EXP_ALIAS}`;
809
813
 
810
814
  // src/filters/tileFeaturesRaster.ts
811
815
  import {
@@ -1258,77 +1262,16 @@ function getClient() {
1258
1262
  return client;
1259
1263
  }
1260
1264
 
1261
- // src/spatial-index.ts
1262
- var DEFAULT_TILE_SIZE = 512;
1263
- var QUADBIN_ZOOM_MAX_OFFSET = 4;
1264
- function getSpatialFiltersResolution(source2, viewState) {
1265
- const dataResolution = source2.dataResolution ?? Number.MAX_VALUE;
1266
- const aggregationResLevel = source2.aggregationResLevel ?? (source2.spatialDataType === "h3" ? DEFAULT_AGGREGATION_RES_LEVEL_H3 : DEFAULT_AGGREGATION_RES_LEVEL_QUADBIN);
1267
- const aggregationResLevelOffset = Math.max(
1268
- 0,
1269
- Math.floor(aggregationResLevel)
1270
- );
1271
- const currentZoomInt = Math.ceil(viewState.zoom);
1272
- if (source2.spatialDataType === "h3") {
1273
- const tileSize = DEFAULT_TILE_SIZE;
1274
- const maxResolutionForZoom = maxH3SpatialFiltersResolutions.find(
1275
- ([zoom]) => zoom === currentZoomInt
1276
- )?.[1] ?? Math.max(0, currentZoomInt - 3);
1277
- const maxSpatialFiltersResolution = maxResolutionForZoom ? Math.min(dataResolution, maxResolutionForZoom) : dataResolution;
1278
- const hexagonResolution = _getHexagonResolution(viewState, tileSize) + aggregationResLevelOffset;
1279
- return Math.min(hexagonResolution, maxSpatialFiltersResolution);
1280
- }
1281
- if (source2.spatialDataType === "quadbin") {
1282
- const maxResolutionForZoom = currentZoomInt + QUADBIN_ZOOM_MAX_OFFSET;
1283
- const maxSpatialFiltersResolution = Math.min(
1284
- dataResolution,
1285
- maxResolutionForZoom
1286
- );
1287
- const quadsResolution = Math.floor(viewState.zoom) + aggregationResLevelOffset;
1288
- return Math.min(quadsResolution, maxSpatialFiltersResolution);
1289
- }
1290
- return void 0;
1291
- }
1292
- var maxH3SpatialFiltersResolutions = [
1293
- [20, 14],
1294
- [19, 13],
1295
- [18, 12],
1296
- [17, 11],
1297
- [16, 10],
1298
- [15, 9],
1299
- [14, 8],
1300
- [13, 7],
1301
- [12, 7],
1302
- [11, 7],
1303
- [10, 6],
1304
- [9, 6],
1305
- [8, 5],
1306
- [7, 4],
1307
- [6, 4],
1308
- [5, 3],
1309
- [4, 2],
1310
- [3, 1],
1311
- [2, 1],
1312
- [1, 0]
1313
- ];
1314
- var BIAS = 2;
1315
- function _getHexagonResolution(viewport, tileSize) {
1316
- const zoomOffset = Math.log2(tileSize / DEFAULT_TILE_SIZE);
1317
- const hexagonScaleFactor = 2 / 3 * (viewport.zoom - zoomOffset);
1318
- const latitudeScaleFactor = Math.log(
1319
- 1 / Math.cos(Math.PI * viewport.latitude / 180)
1320
- );
1321
- return Math.max(
1322
- 0,
1323
- Math.floor(hexagonScaleFactor + latitudeScaleFactor - BIAS)
1324
- );
1325
- }
1326
-
1327
1265
  // src/widget-sources/widget-source.ts
1328
1266
  var _WidgetSource = class _WidgetSource {
1329
1267
  constructor(props) {
1330
1268
  __publicField(this, "props");
1331
- this.props = { ..._WidgetSource.defaultProps, ...props };
1269
+ this.props = {
1270
+ ..._WidgetSource.defaultProps,
1271
+ clientId: getClient(),
1272
+ // Refresh clientId, default may have changed.
1273
+ ...props
1274
+ };
1332
1275
  }
1333
1276
  /**
1334
1277
  * Destroys the widget source and releases allocated resources.
@@ -1339,17 +1282,6 @@ var _WidgetSource = class _WidgetSource {
1339
1282
  */
1340
1283
  destroy() {
1341
1284
  }
1342
- _getSpatialFiltersResolution(source2, spatialFilter, referenceViewState) {
1343
- if (!spatialFilter || source2.spatialDataType === "geo") {
1344
- return;
1345
- }
1346
- if (!referenceViewState) {
1347
- throw new Error(
1348
- 'Missing required option, "spatialIndexReferenceViewState".'
1349
- );
1350
- }
1351
- return getSpatialFiltersResolution(source2, referenceViewState);
1352
- }
1353
1285
  };
1354
1286
  __publicField(_WidgetSource, "defaultProps", {
1355
1287
  apiVersion: "v3" /* V3 */,