public class Geo3DDocValuesField extends Field
Sorting by distance is efficient. Multiple values for the same field in one document is allowed.
This field defines static factory methods for common operations:
If you also need query operations, you should add a separate Geo3DPoint
instance.
WARNING: 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).
Geo3DPoint
Field.Store
Modifier and Type | Field and Description |
---|---|
static FieldType |
TYPE
Type for a Geo3DDocValuesField
|
fieldsData, name, tokenStream, type
Constructor and Description |
---|
Geo3DDocValuesField(String name,
double x,
double y,
double z)
Creates a new Geo3DDocValuesField with the specified x, y, and z
|
Geo3DDocValuesField(String name,
GeoPoint point)
Creates a new Geo3DDocValuesField with the specified x, y, and z
|
Modifier and Type | Method and Description |
---|---|
static GeoPoint |
decodePoint(long docValue)
Decode GeoPoint value from long docvalues value.
|
static double |
decodeXValue(long docValue)
Decode X value from long docvalues value.
|
static double |
decodeYValue(long docValue)
Decode Y value from long docvalues value.
|
static double |
decodeZValue(long docValue)
Decode Z value from long docvalues value.
|
static long |
encodePoint(double x,
double y,
double z)
Encode a point.
|
static long |
encodePoint(GeoPoint point)
Encode a point.
|
static SortField |
newDistanceSort(String field,
double latitude,
double longitude,
double maxRadiusMeters)
Creates a SortField for sorting by distance within a circle.
|
static SortField |
newOutsideBoxSort(String field,
double minLatitude,
double maxLatitude,
double minLongitude,
double maxLongitude)
Creates a SortField for sorting by outside distance from a box.
|
static SortField |
newOutsideDistanceSort(String field,
double latitude,
double longitude,
double maxRadiusMeters)
Creates a SortField for sorting by outside distance from a circle.
|
static SortField |
newOutsideLargePolygonSort(String field,
Polygon... polygons)
Creates a SortField for sorting by outside distance from a large polygon.
|
static SortField |
newOutsidePathSort(String field,
double[] pathLatitudes,
double[] pathLongitudes,
double pathWidthMeters)
Creates a SortField for sorting by outside distance from a path.
|
static SortField |
newOutsidePolygonSort(String field,
Polygon... polygons)
Creates a SortField for sorting by outside distance from a polygon.
|
static SortField |
newPathSort(String field,
double[] pathLatitudes,
double[] pathLongitudes,
double pathWidthMeters)
Creates a SortField for sorting by distance along a path.
|
static double |
roundDownX(double startValue)
Round the provided X value down, by encoding it, decrementing it, and unencoding it.
|
static double |
roundDownY(double startValue)
Round the provided Y value down, by encoding it, decrementing it, and unencoding it.
|
static double |
roundDownZ(double startValue)
Round the provided Z value down, by encoding it, decrementing it, and unencoding it.
|
static double |
roundUpX(double startValue)
Round the provided X value up, by encoding it, incrementing it, and unencoding it.
|
static double |
roundUpY(double startValue)
Round the provided Y value up, by encoding it, incrementing it, and unencoding it.
|
static double |
roundUpZ(double startValue)
Round the provided Z value up, by encoding it, incrementing it, and unencoding it.
|
void |
setLocationValue(double x,
double y,
double z)
Change the values of this field
|
void |
setLocationValue(GeoPoint point)
Change the values of this field
|
String |
toString() |
binaryValue, fieldType, getCharSequenceValue, name, numericValue, readerValue, setBytesValue, setBytesValue, setByteValue, setDoubleValue, setFloatValue, setIntValue, setLongValue, setReaderValue, setShortValue, setStringValue, setTokenStream, stringValue, tokenStream, tokenStreamValue
public static final FieldType TYPE
Each value stores a 64-bit long where the three values (x, y, and z) are given 21 bits each. Each 21-bit value represents the maximum extent in that dimension for the WGS84 planet model.
public Geo3DDocValuesField(String name, GeoPoint point)
name
- field namepoint
- is the point.IllegalArgumentException
- if the field name is null or the point is out of boundspublic Geo3DDocValuesField(String name, double x, double y, double z)
name
- field namex
- is the x value for the point.y
- is the y value for the point.z
- is the z value for the point.IllegalArgumentException
- if the field name is null or x, y, or z are out of boundspublic void setLocationValue(GeoPoint point)
point
- is the point.IllegalArgumentException
- if the point is out of boundspublic void setLocationValue(double x, double y, double z)
x
- is the x value for the point.y
- is the y value for the point.z
- is the z value for the point.IllegalArgumentException
- if x, y, or z are out of boundspublic static long encodePoint(GeoPoint point)
point
- is the pointpublic static long encodePoint(double x, double y, double z)
x
- is the x valuey
- is the y valuez
- is the z valuepublic static GeoPoint decodePoint(long docValue)
docValue
- is the doc values value.public static double decodeXValue(long docValue)
docValue
- is the doc values value.public static double decodeYValue(long docValue)
docValue
- is the doc values value.public static double decodeZValue(long docValue)
docValue
- is the doc values value.public static double roundDownX(double startValue)
startValue
- is the starting value.public static double roundUpX(double startValue)
startValue
- is the starting value.public static double roundDownY(double startValue)
startValue
- is the starting value.public static double roundUpY(double startValue)
startValue
- is the starting value.public static double roundDownZ(double startValue)
startValue
- is the starting value.public static double roundUpZ(double startValue)
startValue
- is the starting value.public static SortField newDistanceSort(String field, double latitude, double longitude, double maxRadiusMeters)
This sort orders documents by ascending distance from the location. The value returned in FieldDoc
for
the hits contains a Double instance with the distance in meters.
If a document is missing the field, then by default it is treated as having Double.POSITIVE_INFINITY
distance
(missing values sort last).
If a document contains multiple values for the field, the closest distance from the circle center is used.
field
- field name. must not be null.latitude
- latitude at the center: must be within standard +/-90 coordinate bounds.longitude
- longitude at the center: must be within standard +/-180 coordinate bounds.maxRadiusMeters
- is the maximum radius in meters.IllegalArgumentException
- if field
is null or circle has invalid coordinates.public static SortField newPathSort(String field, double[] pathLatitudes, double[] pathLongitudes, double pathWidthMeters)
This sort orders documents by ascending distance along the described path. The value returned in FieldDoc
for
the hits contains a Double instance with the distance in meters.
If a document is missing the field, then by default it is treated as having Double.POSITIVE_INFINITY
distance
(missing values sort last).
If a document contains multiple values for the field, the closest distance along the path is used.
field
- field name. must not be null.pathLatitudes
- latitude values for points of the path: must be within standard +/-90 coordinate bounds.pathLongitudes
- longitude values for points of the path: must be within standard +/-180 coordinate bounds.pathWidthMeters
- width of the path in meters.IllegalArgumentException
- if field
is null or path has invalid coordinates.public static SortField newOutsideDistanceSort(String field, double latitude, double longitude, double maxRadiusMeters)
This sort orders documents by ascending outside distance from the circle. Points within the circle have distance 0.0.
The value returned in FieldDoc
for
the hits contains a Double instance with the distance in meters.
If a document is missing the field, then by default it is treated as having Double.POSITIVE_INFINITY
distance
(missing values sort last).
If a document contains multiple values for the field, the closest distance to the circle is used.
field
- field name. must not be null.latitude
- latitude at the center: must be within standard +/-90 coordinate bounds.longitude
- longitude at the center: must be within standard +/-180 coordinate bounds.maxRadiusMeters
- is the maximum radius in meters.IllegalArgumentException
- if field
is null or location has invalid coordinates.public static SortField newOutsideBoxSort(String field, double minLatitude, double maxLatitude, double minLongitude, double maxLongitude)
This sort orders documents by ascending outside distance from the box. Points within the box have distance 0.0.
The value returned in FieldDoc
for
the hits contains a Double instance with the distance in meters.
If a document is missing the field, then by default it is treated as having Double.POSITIVE_INFINITY
distance
(missing values sort last).
If a document contains multiple values for the field, the closest distance to the box is used.
field
- field name. must not be null.minLatitude
- latitude lower bound: must be within standard +/-90 coordinate bounds.maxLatitude
- latitude upper bound: must be within standard +/-90 coordinate bounds.minLongitude
- longitude lower bound: must be within standard +/-180 coordinate bounds.maxLongitude
- longitude upper bound: must be within standard +/-180 coordinate bounds.IllegalArgumentException
- if field
is null or box has invalid coordinates.public static SortField newOutsidePolygonSort(String field, Polygon... polygons)
This sort orders documents by ascending outside distance from the polygon. Points within the polygon have distance 0.0.
The value returned in FieldDoc
for
the hits contains a Double instance with the distance in meters.
If a document is missing the field, then by default it is treated as having Double.POSITIVE_INFINITY
distance
(missing values sort last).
If a document contains multiple values for the field, the closest distance to the polygon is used.
field
- field name. must not be null.polygons
- is the list of polygons to use to construct the query; must be at least one.IllegalArgumentException
- if field
is null or polygon has invalid coordinates.public static SortField newOutsideLargePolygonSort(String field, Polygon... polygons)
This sort orders documents by ascending outside distance from the polygon. Points within the polygon have distance 0.0.
The value returned in FieldDoc
for
the hits contains a Double instance with the distance in meters.
If a document is missing the field, then by default it is treated as having Double.POSITIVE_INFINITY
distance
(missing values sort last).
If a document contains multiple values for the field, the closest distance to the polygon is used.
field
- field name. must not be null.polygons
- is the list of polygons to use to construct the query; must be at least one.IllegalArgumentException
- if field
is null or polygon has invalid coordinates.public static SortField newOutsidePathSort(String field, double[] pathLatitudes, double[] pathLongitudes, double pathWidthMeters)
This sort orders documents by ascending outside distance from the described path. Points within the path
are given the distance of 0.0. The value returned in FieldDoc
for
the hits contains a Double instance with the distance in meters.
If a document is missing the field, then by default it is treated as having Double.POSITIVE_INFINITY
distance
(missing values sort last).
If a document contains multiple values for the field, the closest distance from the path is used.
field
- field name. must not be null.pathLatitudes
- latitude values for points of the path: must be within standard +/-90 coordinate bounds.pathLongitudes
- longitude values for points of the path: must be within standard +/-180 coordinate bounds.pathWidthMeters
- width of the path in meters.IllegalArgumentException
- if field
is null or path has invalid coordinates.Copyright © 2000-2019 Apache Software Foundation. All Rights Reserved.