Class LatLonBoundingBox
java.lang.Object
org.apache.lucene.document.Field
org.apache.lucene.sandbox.document.LatLonBoundingBox
- All Implemented Interfaces:
IndexableField
An indexed 2-Dimension Bounding Box field for the Geospatial Lat/Lon Coordinate system
This field indexes 2-dimension Latitude, Longitude based Geospatial Bounding Boxes. The
bounding boxes are defined as minLat, minLon, maxLat, maxLon
where min/max lat,lon pairs
using double floating point precision.
Multiple values for the same field in one document is supported.
This field defines the following static factory methods for common search operations over double ranges:
newIntersectsQuery()
matches bounding boxes that intersect the defined search bounding box.newWithinQuery()
matches bounding boxes that are within the defined search bounding box.newContainsQuery()
matches bounding boxes that contain the defined search bounding box.newCrosses()
matches bounding boxes that cross the defined search bounding box.
The following Field limitations and restrictions apply:
- Dateline wrapping is not supported.
- Due to an encoding limitation Eastern and Western Hemisphere Bounding Boxes that share the dateline are not supported.
-
Nested Class Summary
Nested classes/interfaces inherited from class org.apache.lucene.document.Field
Field.Store
-
Field Summary
Modifier and TypeFieldDescriptionstatic final int
uses same encoding asLatLonPoint
so numBytes is the sameFields inherited from class org.apache.lucene.document.Field
fieldsData, name, tokenStream, type
-
Constructor Summary
ConstructorDescriptionLatLonBoundingBox
(String name, double minLat, double minLon, double maxLat, double maxLon) Create a new 2D GeoBoundingBoxField representing a 2 dimensional geospatial bounding box -
Method Summary
Modifier and TypeMethodDescriptionstatic Query
newContainsQuery
(String field, double minLat, double minLon, double maxLat, double maxLon) Create a new 2d query that finds all indexed 2d GeoBoundingBoxField values that contain the defined 2d bounding boxstatic Query
newCrossesQuery
(String field, double minLat, double minLon, double maxLat, double maxLon) Create a new 2d query that finds all indexed 2d GeoBoundingBoxField values that cross the defined 3d bounding boxstatic Query
newIntersectsQuery
(String field, double minLat, double minLon, double maxLat, double maxLon) Create a new 2d query that finds all indexed 2d GeoBoundingBoxField values that intersect the defined 3d bounding rangesstatic Query
newWithinQuery
(String field, double minLat, double minLon, double maxLat, double maxLon) Create a new 2d query that finds all indexed 2d GeoBoundingBoxField values that are within the defined 2d bounding boxvoid
setRangeValues
(double minLat, double minLon, double maxLat, double maxLon) Changes the values of the fieldtoString()
Methods inherited from class org.apache.lucene.document.Field
binaryValue, fieldType, getCharSequenceValue, invertableType, name, numericValue, readerValue, setBytesValue, setBytesValue, setByteValue, setDoubleValue, setFloatValue, setIntValue, setLongValue, setReaderValue, setShortValue, setStringValue, setTokenStream, storedValue, stringValue, tokenStream, tokenStreamValue
-
Field Details
-
BYTES
public static final int BYTESuses same encoding asLatLonPoint
so numBytes is the same- See Also:
-
-
Constructor Details
-
LatLonBoundingBox
Create a new 2D GeoBoundingBoxField representing a 2 dimensional geospatial bounding box- Parameters:
name
- field name. must not be nullminLat
- minimum latitude value (in degrees); valid in [-90.0 : 90.0]minLon
- minimum longitude value (in degrees); valid in [-180.0 : 180.0]maxLat
- maximum latitude value (in degrees); valid in [minLat : 90.0]maxLon
- maximum longitude value (in degrees); valid in [minLon : 180.0]
-
-
Method Details
-
setRangeValues
public void setRangeValues(double minLat, double minLon, double maxLat, double maxLon) Changes the values of the field- Parameters:
minLat
- minimum latitude value (in degrees); valid in [-90.0 : 90.0]minLon
- minimum longitude value (in degrees); valid in [-180.0 : 180.0]maxLat
- maximum latitude value (in degrees); valid in [minLat : 90.0]maxLon
- maximum longitude value (in degrees); valid in [minLon : 180.0]- Throws:
IllegalArgumentException
- ifmin
ormax
is invalid
-
newIntersectsQuery
public static Query newIntersectsQuery(String field, double minLat, double minLon, double maxLat, double maxLon) Create a new 2d query that finds all indexed 2d GeoBoundingBoxField values that intersect the defined 3d bounding ranges- Parameters:
field
- field name. must not be nullminLat
- minimum latitude value (in degrees); valid in [-90.0 : 90.0]minLon
- minimum longitude value (in degrees); valid in [-180.0 : 180.0]maxLat
- maximum latitude value (in degrees); valid in [minLat : 90.0]maxLon
- maximum longitude value (in degrees); valid in [minLon : 180.0]- Returns:
- query for matching intersecting 2d bounding boxes
-
newWithinQuery
public static Query newWithinQuery(String field, double minLat, double minLon, double maxLat, double maxLon) Create a new 2d query that finds all indexed 2d GeoBoundingBoxField values that are within the defined 2d bounding box- Parameters:
field
- field name. must not be nullminLat
- minimum latitude value (in degrees); valid in [-90.0 : 90.0]minLon
- minimum longitude value (in degrees); valid in [-180.0 : 180.0]maxLat
- maximum latitude value (in degrees); valid in [minLat : 90.0]maxLon
- maximum longitude value (in degrees); valid in [minLon : 180.0]- Returns:
- query for matching 3d bounding boxes that are within the defined bounding box
-
newContainsQuery
public static Query newContainsQuery(String field, double minLat, double minLon, double maxLat, double maxLon) Create a new 2d query that finds all indexed 2d GeoBoundingBoxField values that contain the defined 2d bounding box- Parameters:
field
- field name. must not be nullminLat
- minimum latitude value (in degrees); valid in [-90.0 : 90.0]minLon
- minimum longitude value (in degrees); valid in [-180.0 : 180.0]maxLat
- maximum latitude value (in degrees); valid in [minLat : 90.0]maxLon
- maximum longitude value (in degrees); valid in [minLon : 180.0]- Returns:
- query for matching 2d bounding boxes that contain the defined bounding box
-
newCrossesQuery
public static Query newCrossesQuery(String field, double minLat, double minLon, double maxLat, double maxLon) Create a new 2d query that finds all indexed 2d GeoBoundingBoxField values that cross the defined 3d bounding box- Parameters:
field
- field name. must not be nullminLat
- minimum latitude value (in degrees); valid in [-90.0 : 90.0]minLon
- minimum longitude value (in degrees); valid in [-180.0 : 180.0]maxLat
- maximum latitude value (in degrees); valid in [minLat : 90.0]maxLon
- maximum longitude value (in degrees); valid in [minLon : 180.0]- Returns:
- query for matching 2d bounding boxes that cross the defined bounding box
-
toString
-