Package org.apache.lucene.document

# Class LatLonShape

java.lang.Object
org.apache.lucene.document.LatLonShape

public class LatLonShape extends Object
An geo shape utility class for indexing and searching gis geometries whose vertices are latitude, longitude values (in decimal degrees).

This class defines seven static factory methods for common indexing and search operations:

- `createIndexableFields(String, Polygon)` for indexing a geo polygon.
- `createDocValueField(String, Polygon)` for indexing a geo polygon doc value field.
- `createIndexableFields(String, Polygon, boolean)` for indexing a geo polygon with the possibility of checking for self-intersections.
- `createIndexableFields(String, Polygon, boolean)` for indexing a geo polygon doc value field with the possibility of checking for self-intersections.
- `createIndexableFields(String, Line)` for indexing a geo linestring.
- `createDocValueField(String, Line)` for indexing a geo linestring doc value.
- `createIndexableFields(String, double, double)` for indexing a lat, lon geo point.
- `createDocValueField(String, double, double)` for indexing a lat, lon geo point doc value.
- `createDocValueField(String, BytesRef)` for indexing a cartesian doc value from existing encoding.
- `newBoxQuery()` for matching geo shapes that have some `ShapeField.QueryRelation` with a bounding box.
- `newLineQuery()` for matching geo shapes that have some `ShapeField.QueryRelation` with a linestring.
- `newPolygonQuery()` for matching geo shapes that have some `ShapeField.QueryRelation` with a polygon.
- `newGeometryQuery()` for matching geo shapes that have some `ShapeField.QueryRelation` with one or more `LatLonGeometry`.
- `createLatLonShapeDocValues(BytesRef)` for creating the `LatLonShapeDocValues`

WARNING: Like `LatLonPoint`, vertex values are indexed with some loss of precision from the original `double` values (4.190951585769653E-8 for the latitude component and 8.381903171539307E-8 for longitude).

See Also:
  - `PointValues`
  - `LatLonDocValuesField`

- ## Method Summary

  Modifier and Type
  Method
  Description
  `static LatLonShapeDocValuesField`
  `createDocValueField(String fieldName, double lat, double lon)`
  create doc value field for lat lon line geometry without creating indexable fields.
  `static LatLonShapeDocValuesField`
  `createDocValueField(String fieldName, List<ShapeField.DecodedTriangle> tessellation)`
  create a `LatLonShapeDocValuesField` from an existing tessellation
  `static LatLonShapeDocValuesField`
  `createDocValueField(String fieldName, Field[] indexableFields)`
  create a shape docvalue field from indexable fields
  `static LatLonShapeDocValuesField`
  `createDocValueField(String fieldName, Line line)`
  create doc value field for lat lon line geometry without creating indexable fields.
  `static LatLonShapeDocValuesField`
  `createDocValueField(String fieldName, Polygon polygon)`
  create doc value field for lat lon polygon geometry without creating indexable fields
  `static LatLonShapeDocValuesField`
  `createDocValueField(String fieldName, Polygon polygon, boolean checkSelfIntersections)`
  create doc value field for lat lon polygon geometry without creating indexable fields.
  `static LatLonShapeDocValuesField`
  `createDocValueField(String fieldName, BytesRef binaryValue)`
  create a `LatLonShapeDocValuesField` from an existing encoded representation
  `static Field[]`
  `createIndexableFields(String fieldName, double lat, double lon)`
  create indexable fields for point geometry
  `static Field[]`
  `createIndexableFields(String fieldName, Line line)`
  create indexable fields for line geometry
  `static Field[]`
  `createIndexableFields(String fieldName, Polygon polygon)`
  create indexable fields for polygon geometry.
  `static Field[]`
  `createIndexableFields(String fieldName, Polygon polygon, boolean checkSelfIntersections)`
  create indexable fields for polygon geometry.
  `static LatLonShapeDocValues`
  `createLatLonShapeDocValues(BytesRef bytesRef)`
  Factory method for creating the `LatLonShapeDocValues`
  `static Query`
  `newBoxQuery(String field, ShapeField.QueryRelation queryRelation, double minLatitude, double maxLatitude, double minLongitude, double maxLongitude)`
  create a query to find all indexed geo shapes that intersect a defined bounding box *
  `static Query`
  `newDistanceQuery(String field, ShapeField.QueryRelation queryRelation, Circle... circle)`
  create a query to find all polygons that intersect a provided circle.
  `static Query`
  `newGeometryQuery(String field, ShapeField.QueryRelation queryRelation, LatLonGeometry... latLonGeometries)`
  create a query to find all indexed geo shapes that intersect a provided geometry (or array of geometries).
  `static Query`
  `newLineQuery(String field, ShapeField.QueryRelation queryRelation, Line... lines)`
  create a query to find all indexed geo shapes that intersect a provided linestring (or array of linestrings) note: does not support dateline crossing
  `static Query`
  `newPointQuery(String field, ShapeField.QueryRelation queryRelation, double[]... points)`
  create a query to find all indexed shapes that comply the `ShapeField.QueryRelation` with the provided points
  `static Query`
  `newPolygonQuery(String field, ShapeField.QueryRelation queryRelation, Polygon... polygons)`
  create a query to find all indexed geo shapes that intersect a provided polygon (or array of polygons) note: does not support dateline crossing
  `static Query`
  `newSlowDocValuesBoxQuery(String field, ShapeField.QueryRelation queryRelation, double minLatitude, double maxLatitude, double minLongitude, double maxLongitude)`
  create a docvalue query to find all geo shapes that intersect a defined bounding box *

  ### Methods inherited from class java.lang.Object

  `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- ## Method Details

  - ### createIndexableFields

    public static Field[] createIndexableFields(String fieldName, Polygon polygon)
    create indexable fields for polygon geometry.

  - ### createDocValueField

    public static LatLonShapeDocValuesField createDocValueField(String fieldName, Polygon polygon)
    create doc value field for lat lon polygon geometry without creating indexable fields

  - ### createIndexableFields

    public static Field[] createIndexableFields(String fieldName, Polygon polygon, boolean checkSelfIntersections)
    create indexable fields for polygon geometry. If `checkSelfIntersections` is set to true, the validity of the provided polygon is checked with a small performance penalty.

  - ### createDocValueField

    public static LatLonShapeDocValuesField createDocValueField(String fieldName, Polygon polygon, boolean checkSelfIntersections)
    create doc value field for lat lon polygon geometry without creating indexable fields.

  - ### createIndexableFields

    public static Field[] createIndexableFields(String fieldName, Line line)
    create indexable fields for line geometry

  - ### createDocValueField

    public static LatLonShapeDocValuesField createDocValueField(String fieldName, Line line)
    create doc value field for lat lon line geometry without creating indexable fields.

  - ### createIndexableFields

    public static Field[] createIndexableFields(String fieldName, double lat, double lon)
    create indexable fields for point geometry

  - ### createDocValueField

    public static LatLonShapeDocValuesField createDocValueField(String fieldName, double lat, double lon)
    create doc value field for lat lon line geometry without creating indexable fields.

  - ### createDocValueField

    public static LatLonShapeDocValuesField createDocValueField(String fieldName, BytesRef binaryValue)
    create a `LatLonShapeDocValuesField` from an existing encoded representation

  - ### createDocValueField

    public static LatLonShapeDocValuesField createDocValueField(String fieldName, List<ShapeField.DecodedTriangle> tessellation)
    create a `LatLonShapeDocValuesField` from an existing tessellation

  - ### createDocValueField

    public static LatLonShapeDocValuesField createDocValueField(String fieldName, Field[] indexableFields)
    create a shape docvalue field from indexable fields

  - ### newBoxQuery

    public static Query newBoxQuery(String field, ShapeField.QueryRelation queryRelation, double minLatitude, double maxLatitude, double minLongitude, double maxLongitude)
    create a query to find all indexed geo shapes that intersect a defined bounding box *

  - ### newSlowDocValuesBoxQuery

    public static Query newSlowDocValuesBoxQuery(String field, ShapeField.QueryRelation queryRelation, double minLatitude, double maxLatitude, double minLongitude, double maxLongitude)
    create a docvalue query to find all geo shapes that intersect a defined bounding box *

  - ### newLineQuery

    public static Query newLineQuery(String field, ShapeField.QueryRelation queryRelation, Line... lines)
    create a query to find all indexed geo shapes that intersect a provided linestring (or array of linestrings) note: does not support dateline crossing

  - ### newPolygonQuery

    public static Query newPolygonQuery(String field, ShapeField.QueryRelation queryRelation, Polygon... polygons)
    create a query to find all indexed geo shapes that intersect a provided polygon (or array of polygons) note: does not support dateline crossing

  - ### newPointQuery

    public static Query newPointQuery(String field, ShapeField.QueryRelation queryRelation, double[]... points)
    create a query to find all indexed shapes that comply the `ShapeField.QueryRelation` with the provided points

  - ### newDistanceQuery

    public static Query newDistanceQuery(String field, ShapeField.QueryRelation queryRelation, Circle... circle)
    create a query to find all polygons that intersect a provided circle.

  - ### newGeometryQuery

    public static Query newGeometryQuery(String field, ShapeField.QueryRelation queryRelation, LatLonGeometry... latLonGeometries)
    create a query to find all indexed geo shapes that intersect a provided geometry (or array of geometries).

  - ### createLatLonShapeDocValues

    public static LatLonShapeDocValues createLatLonShapeDocValues(BytesRef bytesRef)
    Factory method for creating the `LatLonShapeDocValues`
    Parameters:
      `bytesRef` - `BytesRef`
    Returns:
      `LatLonShapeDocValues`