org.apache.lucene.geo

## Class GeoUtils

• public final class GeoUtils
extends Object
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 Classes
Modifier and Type Class and Description
static class  GeoUtils.WindingOrder
used to define the orientation of 3 points -1 = Clockwise 0 = Colinear 1 = Counter-clockwise
• ### Method Summary

All Methods
Modifier and Type Method and Description
static void checkLatitude(double latitude)
validates latitude value is within standard +/-90 coordinate bounds
static void checkLongitude(double longitude)
validates longitude value is within standard +/-180 coordinate bounds
binary search to find the exact sortKey needed to match the specified radius any sort key lte this is a query match.
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
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.
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.
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.
static double sloppySin(double a)
Returns the trigonometric sine of an angle converted as a cos operation.
• ### Field Detail

• #### MIN_LON_INCL

public static final double MIN_LON_INCL
Minimum longitude value.
Constant Field Values
• #### MAX_LON_INCL

public static final double MAX_LON_INCL
Maximum longitude value.
Constant Field Values
• #### MIN_LAT_INCL

public static final double MIN_LAT_INCL
Minimum latitude value.
Constant Field Values
• #### MAX_LAT_INCL

public static final double MAX_LAT_INCL
Maximum latitude value.
Constant Field Values

Constant Field Values

Constant Field Values

Constant Field Values

Constant Field Values

mean earth axis in meters
Constant Field Values
• ### Method Detail

• #### 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 NaN or an infinity, then the result is NaN.
Parameters:
a - an angle, in radians.
Returns:
the sine of the argument.
Math.sin(double)
• #### distanceQuerySortKey

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
• #### 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