@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.
@@ -5308,27 +5308,18 @@ function intersectTileQuadbin(parent, cellResolution, spatialFilter) {
5308
5308
  }
5309
5309
  var BBOX_WEST = [-180, -90, 0, 90];
5310
5310
  var BBOX_EAST = [0, -90, 180, 90];
5311
- function intersectTileH3(parent, cellResolution, spatialFilter) {
5312
- const tilePolygon = {
5313
- type: "Polygon",
5314
- coordinates: [(0, import_h3_js.cellToBoundary)(parent, true)]
5315
- };
5316
- if (!spatialFilter || turf_boolean_within_default(tilePolygon, spatialFilter)) {
5311
+ function intersectTileH3(cellResolution, spatialFilter) {
5312
+ if (!spatialFilter) {
5317
5313
  return true;
5318
5314
  }
5319
- const clippedSpatialFilter = turf_intersect_default(
5320
- featureCollection([feature(tilePolygon), feature(spatialFilter)])
5321
- );
5322
- if (!clippedSpatialFilter) {
5323
- return false;
5324
- }
5315
+ const spatialFilterFeature = feature(spatialFilter);
5325
5316
  const cellsWest = (0, import_h3_js.polygonToCells)(
5326
- turf_bbox_clip_default(clippedSpatialFilter, BBOX_WEST).geometry.coordinates,
5317
+ turf_bbox_clip_default(spatialFilterFeature, BBOX_WEST).geometry.coordinates,
5327
5318
  cellResolution,
5328
5319
  true
5329
5320
  );
5330
5321
  const cellsEast = (0, import_h3_js.polygonToCells)(
5331
- turf_bbox_clip_default(clippedSpatialFilter, BBOX_EAST).geometry.coordinates,
5322
+ turf_bbox_clip_default(spatialFilterFeature, BBOX_EAST).geometry.coordinates,
5332
5323
  cellResolution,
5333
5324
  true
5334
5325
  );
@@ -5633,20 +5624,22 @@ function tileFeaturesSpatialIndex({
5633
5624
  if (!cellResolution) {
5634
5625
  return [];
5635
5626
  }
5627
+ let intersection3;
5628
+ if (spatialIndex === "h3" /* H3 */) {
5629
+ intersection3 = intersectTileH3(cellResolution, spatialFilter);
5630
+ }
5636
5631
  for (const tile of tiles) {
5637
5632
  if (tile.isVisible === false || !tile.data) {
5638
5633
  continue;
5639
5634
  }
5640
- const parent = getTileIndex(tile, spatialIndex);
5641
- const intersection3 = spatialIndex === "quadbin" /* QUADBIN */ ? intersectTileQuadbin(
5642
- parent,
5643
- cellResolution,
5644
- spatialFilter
5645
- ) : intersectTileH3(
5646
- parent,
5647
- cellResolution,
5648
- spatialFilter
5649
- );
5635
+ if (spatialIndex === "quadbin" /* QUADBIN */) {
5636
+ const parent = getTileIndex(tile, spatialIndex);
5637
+ intersection3 = intersectTileQuadbin(
5638
+ parent,
5639
+ cellResolution,
5640
+ spatialFilter
5641
+ );
5642
+ }
5650
5643
  if (!intersection3) continue;
5651
5644
  tile.data.forEach((d) => {
5652
5645
  if (intersection3 === true || intersection3.has(d.id)) {