Package org.apache.lucene.geo
Class GeoUtils
java.lang.Object
org.apache.lucene.geo.GeoUtils
Basic reusable geo-spatial utility methods
- WARNING: This API is experimental and might change in incompatible ways in the next release.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic enumused to define the orientation of 3 points -1 = Clockwise 0 = Colinear 1 = Counter-clockwise -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final doublemean earth axis in metersstatic final doubleMaximum latitude value.static final doublemax latitude value in radiansstatic final doubleMaximum longitude value.static final doublemax longitude value in radiansstatic final doubleMinimum latitude value.static final doublemin latitude value in radiansstatic final doubleMinimum longitude value.static final doublemin longitude value in radians -
Method Summary
Modifier and TypeMethodDescriptionstatic voidcheckLatitude(double latitude) validates latitude value is within standard +/-90 coordinate boundsstatic voidcheckLongitude(double longitude) validates longitude value is within standard +/-180 coordinate boundsstatic doubledistanceQuerySortKey(double radius) binary search to find the exact sortKey needed to match the specified radius any sort key lte this is a query match.static booleanlineCrossesLine(double a1x, double a1y, double b1x, double b1y, double a2x, double a2y, double b2x, double b2y) uses orient method to compute whether two line segments crossstatic booleanlineCrossesLineWithBoundary(double a1x, double a1y, double b1x, double b1y, double a2x, double a2y, double b2x, double b2y) uses orient method to compute whether two line segments cross; boundaries included - returning true for lines that terminate on each other.static booleanlineOverlapLine(double a1x, double a1y, double b1x, double b1y, double a2x, double a2y, double b2x, double b2y) uses orient method to compute whether two line overlap each otherstatic intorient(double ax, double ay, double bx, double by, double cx, double cy) Returns a positive value if points a, b, and c are arranged in counter-clockwise order, negative value if clockwise, zero if collinear.static PointValues.Relationrelate(double minLat, double maxLat, double minLon, double maxLon, double lat, double lon, double distanceSortKey, double axisLat) Compute the relation between the provided box and distance query.static doublesloppySin(double a) Returns the trigonometric sine of an angle converted as a cos operation.
-
Field Details
-
MIN_LON_INCL
public static final double MIN_LON_INCLMinimum longitude value.- See Also:
-
MAX_LON_INCL
public static final double MAX_LON_INCLMaximum longitude value.- See Also:
-
MIN_LAT_INCL
public static final double MIN_LAT_INCLMinimum latitude value.- See Also:
-
MAX_LAT_INCL
public static final double MAX_LAT_INCLMaximum latitude value.- See Also:
-
MIN_LON_RADIANS
public static final double MIN_LON_RADIANSmin longitude value in radians -
MIN_LAT_RADIANS
public static final double MIN_LAT_RADIANSmin latitude value in radians -
MAX_LON_RADIANS
public static final double MAX_LON_RADIANSmax longitude value in radians -
MAX_LAT_RADIANS
public static final double MAX_LAT_RADIANSmax latitude value in radians -
EARTH_MEAN_RADIUS_METERS
public static final double EARTH_MEAN_RADIUS_METERSmean earth axis in meters- See Also:
-
-
Method Details
-
checkLatitude
public static void checkLatitude(double latitude) validates latitude value is within standard +/-90 coordinate bounds -
checkLongitude
public static void checkLongitude(double longitude) validates longitude value is within standard +/-180 coordinate bounds -
sloppySin
public static double sloppySin(double a) Returns the trigonometric sine of an angle converted as a cos operation.Note that this is not quite right... e.g. sin(0) != 0
Special cases:
- If the argument is
NaNor an infinity, then the result isNaN.
- Parameters:
a- an angle, in radians.- Returns:
- the sine of the argument.
- See Also:
- If the argument is
-
distanceQuerySortKey
public static double distanceQuerySortKey(double radius) binary search to find the exact sortKey needed to match the specified radius any sort key lte this is a query match. -
relate
public static PointValues.Relation relate(double minLat, double maxLat, double minLon, double maxLon, double lat, double lon, double distanceSortKey, double axisLat) Compute the relation between the provided box and distance query. This only works for boxes that do not cross the dateline. -
orient
public static int orient(double ax, double ay, double bx, double by, double cx, double cy) Returns a positive value if points a, b, and c are arranged in counter-clockwise order, negative value if clockwise, zero if collinear. -
lineCrossesLine
public static boolean lineCrossesLine(double a1x, double a1y, double b1x, double b1y, double a2x, double a2y, double b2x, double b2y) uses orient method to compute whether two line segments cross -
lineOverlapLine
public static boolean lineOverlapLine(double a1x, double a1y, double b1x, double b1y, double a2x, double a2y, double b2x, double b2y) uses orient method to compute whether two line overlap each other -
lineCrossesLineWithBoundary
public static boolean lineCrossesLineWithBoundary(double a1x, double a1y, double b1x, double b1y, double a2x, double a2y, double b2x, double b2y) uses orient method to compute whether two line segments cross; boundaries included - returning true for lines that terminate on each other.e.g., (plus sign) + == true, and (capital 't') T == true
Use
lineCrossesLine(double, double, double, double, double, double, double, double)to exclude lines that terminate on each other from the truth table
-