@carto/api-client 0.5.7-alpha-optional-spatial-filter.0 → 0.5.7-alpha-optional-spatial-filter.1

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
@@ -4883,10 +4883,7 @@ import {
4883
4883
  cellToBoundary as quadbinCellToBoundary,
4884
4884
  geometryToCells as quadbinGeometryToCells
4885
4885
  } from "quadbin";
4886
- import {
4887
- cellToBoundary as h3CellToBoundary,
4888
- polygonToCells as h3PolygonToCells
4889
- } from "h3-js";
4886
+ import { polygonToCells as h3PolygonToCells } from "h3-js";
4890
4887
 
4891
4888
  // node_modules/@turf/bbox-clip/dist/esm/index.js
4892
4889
  function lineclip(points, bbox2, result) {
@@ -5042,27 +5039,18 @@ function intersectTileQuadbin(parent, cellResolution, spatialFilter) {
5042
5039
  }
5043
5040
  var BBOX_WEST = [-180, -90, 0, 90];
5044
5041
  var BBOX_EAST = [0, -90, 180, 90];
5045
- function intersectTileH3(parent, cellResolution, spatialFilter) {
5046
- const tilePolygon = {
5047
- type: "Polygon",
5048
- coordinates: [h3CellToBoundary(parent, true)]
5049
- };
5050
- if (!spatialFilter || turf_boolean_within_default(tilePolygon, spatialFilter)) {
5042
+ function intersectTileH3(cellResolution, spatialFilter) {
5043
+ if (!spatialFilter) {
5051
5044
  return true;
5052
5045
  }
5053
- const clippedSpatialFilter = turf_intersect_default(
5054
- featureCollection([feature(tilePolygon), feature(spatialFilter)])
5055
- );
5056
- if (!clippedSpatialFilter) {
5057
- return false;
5058
- }
5046
+ const spatialFilterFeature = feature(spatialFilter);
5059
5047
  const cellsWest = h3PolygonToCells(
5060
- turf_bbox_clip_default(clippedSpatialFilter, BBOX_WEST).geometry.coordinates,
5048
+ turf_bbox_clip_default(spatialFilterFeature, BBOX_WEST).geometry.coordinates,
5061
5049
  cellResolution,
5062
5050
  true
5063
5051
  );
5064
5052
  const cellsEast = h3PolygonToCells(
5065
- turf_bbox_clip_default(clippedSpatialFilter, BBOX_EAST).geometry.coordinates,
5053
+ turf_bbox_clip_default(spatialFilterFeature, BBOX_EAST).geometry.coordinates,
5066
5054
  cellResolution,
5067
5055
  true
5068
5056
  );
@@ -5366,20 +5354,22 @@ function tileFeaturesSpatialIndex({
5366
5354
  if (!cellResolution) {
5367
5355
  return [];
5368
5356
  }
5357
+ let intersection3;
5358
+ if (spatialIndex === "h3" /* H3 */) {
5359
+ intersection3 = intersectTileH3(cellResolution, spatialFilter);
5360
+ }
5369
5361
  for (const tile of tiles) {
5370
5362
  if (tile.isVisible === false || !tile.data) {
5371
5363
  continue;
5372
5364
  }
5373
- const parent = getTileIndex(tile, spatialIndex);
5374
- const intersection3 = spatialIndex === "quadbin" /* QUADBIN */ ? intersectTileQuadbin(
5375
- parent,
5376
- cellResolution,
5377
- spatialFilter
5378
- ) : intersectTileH3(
5379
- parent,
5380
- cellResolution,
5381
- spatialFilter
5382
- );
5365
+ if (spatialIndex === "quadbin" /* QUADBIN */) {
5366
+ const parent = getTileIndex(tile, spatialIndex);
5367
+ intersection3 = intersectTileQuadbin(
5368
+ parent,
5369
+ cellResolution,
5370
+ spatialFilter
5371
+ );
5372
+ }
5383
5373
  if (!intersection3) continue;
5384
5374
  tile.data.forEach((d) => {
5385
5375
  if (intersection3 === true || intersection3.has(d.id)) {