Source:
<code>protected SpatialSearch createCombinedSpatialSearch( final Queue<PointRadius> pointRadiusSearches, final Queue<Geometry> geometrySearches) { final boolean hasPointRadiusSearch = CollectionUtils.isNotEmpty(pointRadiusSearches); final boolean hasGeometrySearches = CollectionUtils.isNotEmpty(geometrySearches); Geometry geometrySearch = null; BoundingBox boundingBox = null; PointRadius pointRadius = null; SpatialSearch spatialSearch = null; if (hasGeometrySearches) { if (geometrySearches.size() == 1) { geometrySearch = geometrySearches.remove(); } else { geometrySearch = GEOMETRY_FACTORY.createGeometryCollection(geometrySearches.toArray(new Geometry[0])); } if (geometrySearch instanceof Polygon && shouldConvertToBBox) { boundingBox = BoundingBoxUtils.createBoundingBox((Polygon) geometrySearch); geometrySearch = null; } } <START> if (hasPointRadiusSearch) { <END> if (pointRadiusSearches.size() > 1) { LOGGER.debug("Cannot combine multiple point radii. Dropping all geospatial filters."); return spatialSearch; } else if (boundingBox != null && shouldConvertToBBox) { LOGGER.debug("Cannot combine multiple bounding box. Dropping all geospatial filters."); return spatialSearch; } else if (shouldConvertToBBox) { boundingBox = BoundingBoxUtils.createBoundingBox(pointRadiusSearches.remove()); } else { pointRadius = pointRadiusSearches.remove(); } } if (geometrySearch != null || boundingBox != null || pointRadius != null) { spatialSearch = new SpatialSearch(geometrySearch, boundingBox, null, pointRadius); } return spatialSearch; }</code><technical_language>able convert a bbox envelope for geospatial constraints. In case of multiple point/radius converting bbox overall, convert individual point radius envelope add polygons geometry collection approximation</technical_language>

Target:
protected SpatialSearch createCombinedSpatialSearch( final Queue<PointRadius> pointRadiusSearches, final Queue<Geometry> geometrySearches) { Geometry geometrySearch = null; BoundingBox boundingBox = null; PointRadius pointRadius = null; SpatialSearch spatialSearch = null; Set<Geometry> combinedGeometrySearches = new HashSet<>(geometrySearches); if (CollectionUtils.isNotEmpty(pointRadiusSearches)) { if (!shouldConvertToBBox && pointRadiusSearches.size() == 1) { pointRadius = pointRadiusSearches.remove(); } else { for (PointRadius search : pointRadiusSearches) { BoundingBox bbox = BoundingBoxUtils.createBoundingBox(search); List bboxCoordinate = BoundingBoxUtils.getBoundingBoxCoordinatesList(bbox); List<List> coordinates = new ArrayList<>(); coordinates.add(bboxCoordinate); combinedGeometrySearches.add(ddf.geo.formatter.Polygon.buildPolygon(coordinates)); LOGGER.debug( "Point radius searches are converts it to a (rough approximation) square using Vincenty's formula (direct)"); } } } if (CollectionUtils.isNotEmpty(combinedGeometrySearches)) { if (combinedGeometrySearches.size() > 1) { geometrySearch = GEOMETRY_FACTORY.createGeometryCollection( combinedGeometrySearches.toArray(new Geometry[0])); } else { geometrySearch = combinedGeometrySearches.iterator().next(); } if (shouldConvertToBBox) { if (combinedGeometrySearches.size() > 1) { LOGGER.debug( "An approximate envelope encompassing all the geometry is returned. Area between the geometries are also included in this spatial search. Hence widen the search area."); } boundingBox = BoundingBoxUtils.createBoundingBox((Polygon) geometrySearch.getEnvelope()); geometrySearch = null; } } if (geometrySearch != null || boundingBox != null || pointRadius != null) { spatialSearch = new SpatialSearch(geometrySearch, boundingBox, null, pointRadius); } return spatialSearch; }