Class BBoxStrategy

  • public class BBoxStrategy
    extends SpatialStrategy
    A SpatialStrategy for indexing and searching Rectangles by storing its coordinates in numeric fields. It supports all SpatialOperations and has a custom overlap relevancy. It is based on GeoPortal's SpatialClauseAdapter.


    • Only indexes Rectangles; just one per field value. Other shapes can be provided and the bounding box will be used.
    • Can query only by a Rectangle. Providing other shapes is an error.
    • Supports most SpatialOperations but not Overlaps.
    • Uses the DocValues API for any sorting / relevancy.


    This uses 4 double fields for minX, maxX, minY, maxY and a boolean to mark a dateline cross. Depending on the particular SpatialOperations, there are a variety of range queries on DoublePoints to be done. The #makeOverlapRatioValueSource(org.locationtech.spatial4j.shape.Rectangle, double) works by calculating the query bbox overlap percentage against the indexed shape overlap percentage. The indexed shape's coordinates are retrieved from LeafReader.getNumericDocValues(java.lang.String).