public class GeoUtils extends Object
Modifier and Type | Field and Description |
---|---|
static char[] |
COMPASS_DIRECTIONS |
static char |
COMPASS_EAST |
static char |
COMPASS_NORTH |
static char |
COMPASS_SOUTH |
static char |
COMPASS_WEST |
static char |
DMS_SEPERATOR |
static char |
LAT_LNG_SEPERATOR |
static double |
LATITUDE_DEGREES_RANGE |
static double |
LONGITUDE_DEGREES_RANGE |
static char |
SYMBOL_DEGREES |
static char |
SYMBOL_MINUTES |
static char |
SYMBOL_SECONDS |
static char[] |
SYMBOLS |
Modifier and Type | Method and Description |
---|---|
static double |
getBearingTo(LatLng fromPoint,
LatLng toPoint)
Returns the (initial) bearing from pointFrom and toPoint.
|
static LatLng |
getDestinationPoint(LatLng fromPoint,
double bearing,
double distance)
Returns the destination point from 'this' point having travelled the given distance on the
given initial bearing (bearing normally varies around path followed).
|
static double |
getDistanceBetweenPoints(LatLng pointFrom,
LatLng pointTo)
Calculate the distance from pointFrom to destination point (using haversine formula).
|
static double |
getFinalBearingTo(LatLng fromPoint,
LatLng toPoint)
Returns final bearing arriving at toPoint and fromPoint; the final bearing
will differ from the initial bearing by varying degrees according to distance and latitude.
|
static LatLng |
getIntersection(LatLng firstPoint,
double firstIntialBearing,
LatLng secondPoint,
double secondIntialBearing)
Returns the point of intersection of two paths defined by point and bearing.
|
static LatLng |
getMidPointTo(LatLng fromPoint,
LatLng toPoint)
Returns the midpoint between fromPoint and toPoint.
|
static double |
getRHumbBearingTo(LatLng fromPoint,
LatLng toPoint)
Returns the bearing from source point to destination point along a rhumb line.
|
static LatLng |
getRHumbDestinationPoint(LatLng fromPoint,
double bearing,
double distance)
Returns the destination point having travelled along a rhumb line from 'this' point the given
distance on the given bearing.
|
static double |
getRHumbDistanceTo(LatLng fromPoint,
LatLng toPoint)
Returns the distance travelling from source point to destination point along a rhumb line.
|
static LatLng |
getRHumbMidpointTo(LatLng fromPoint,
LatLng toPoint)
Returns the loxodromic midpoint (along a rhumb line) between fromPoint and toPoint.
|
static double |
normalizeLatitudeDegrees(double latitudeDegrees)
Normalizes the latitude to inside a valid range.
|
static double |
normalizeLongitudeDegrees(double longitudeDegrees)
Normalizes the longitude to inside a valid range.
|
static double |
normalizeRange(double degrees,
double range)
This function normalizes the a value according to a range.
|
static Double |
parseDMS(String dms)
Parses string representing degrees/minutes/seconds into numeric degrees.
|
static LatLng |
parseLatLng(String latlngStr)
Parses a string to LatLng instance, it can parse many formats.
|
static String |
toBearing(Double degress,
LatLngFormat format)
Converts numeric degrees to deg/min/sec as a bearing (0°..360°), using format decimals.
|
static String |
toBearing(Double degress,
LatLngFormat format,
Integer dp)
Converts numeric degrees to deg/min/sec as a bearing (0°..360°)
|
static String |
toDMS(Double degrees,
LatLngFormat format)
Converts decimal degrees to deg/min/sec format.
|
static String |
toDMS(Double degrees,
LatLngFormat format,
Integer dp)
Converts decimal degrees to deg/min/sec format
- degree, prime, double-prime symbols are added, but sign is discarded, though no compass direction is added. |
static String |
toLatitude(Double degress,
LatLngFormat format)
Converts numeric latitude degrees to deg/min/sec latitude (3-digit degrees, suffixed with N/S).
|
static String |
toLatitude(Double degress,
LatLngFormat format,
Integer dp)
Converts numeric latitude degrees to deg/min/sec latitude (3-digit degrees, suffixed with N/S).
|
static String |
toLongitude(Double degress,
LatLngFormat format)
Converts numeric longitude degrees to deg/min/sec latitude (3-digit degrees, suffixed with E/W).
|
static String |
toLongitude(Double degress,
LatLngFormat format,
Integer dp)
Converts numeric longitude degrees to deg/min/sec latitude (3-digit degrees, suffixed with E/W).
|
static String |
toString(LatLng point)
Returns a string representation of point, formatted as degrees+minutes+seconds.
|
static String |
toString(LatLng point,
LatLngFormat format)
Returns a string representation of point, formatted as degrees, degrees+minutes, or degrees+minutes+seconds.
|
static String |
toString(LatLng point,
LatLngFormat format,
Integer dp)
Returns a string representation of point, formatted as degrees, degrees+minutes, or degrees+minutes+seconds.
|
public static final char SYMBOL_DEGREES
public static final char SYMBOL_MINUTES
public static final char SYMBOL_SECONDS
public static final char COMPASS_NORTH
public static final char COMPASS_SOUTH
public static final char COMPASS_EAST
public static final char COMPASS_WEST
public static final char DMS_SEPERATOR
public static final char LAT_LNG_SEPERATOR
public static final char[] SYMBOLS
public static final char[] COMPASS_DIRECTIONS
public static final double LATITUDE_DEGREES_RANGE
public static final double LONGITUDE_DEGREES_RANGE
public static double getDistanceBetweenPoints(LatLng pointFrom, LatLng pointTo)
pointFrom
- - Latitude/longitude of source point.pointTo
- - Latitude/longitude of destination point.public static double getBearingTo(LatLng fromPoint, LatLng toPoint)
fromPoint
- - Latitude/longitude of source point.toPoint
- - Latitude/longitude of destination point.public static double getFinalBearingTo(LatLng fromPoint, LatLng toPoint)
fromPoint
- - Latitude/longitude of source point.toPoint
- - Latitude/longitude of destination point.public static LatLng getMidPointTo(LatLng fromPoint, LatLng toPoint)
fromPoint
- - Latitude/longitude of source point.toPoint
- - Latitude/longitude of destination point.public static LatLng getDestinationPoint(LatLng fromPoint, double bearing, double distance)
fromPoint
- the source point.bearing
- Initial bearing in degrees.distance
- Distance in km (on sphere of 'this' radius).public static LatLng getIntersection(LatLng firstPoint, double firstIntialBearing, LatLng secondPoint, double secondIntialBearing)
firstPoint
- - First point.firstIntialBearing
- - Initial bearing from first point.secondPoint
- - Second point.secondIntialBearing
- - Initial bearing from second point.public static double getRHumbDistanceTo(LatLng fromPoint, LatLng toPoint)
fromPoint
- Latitude/longitude of source point.toPoint
- Latitude/longitude of destination point.public static double getRHumbBearingTo(LatLng fromPoint, LatLng toPoint)
fromPoint
- - Latitude/longitude of source point.toPoint
- - Latitude/longitude of destination point.public static LatLng getRHumbDestinationPoint(LatLng fromPoint, double bearing, double distance)
fromPoint
- - Latitude/longitude of source point.bearing
- - Bearing in degrees from north.distance
- - Distance in km (on sphere of 'this' radius).public static LatLng getRHumbMidpointTo(LatLng fromPoint, LatLng toPoint)
fromPoint
- - Latitude/longitude of source point.toPoint
- - Latitude/longitude of second point.public static String toString(LatLng point, LatLngFormat format, Integer dp)
point
- the LatLng pointformat
- the LatLngFormatdp
- number of decimals.public static String toString(LatLng point, LatLngFormat format)
point
- the LatLng pointformat
- the LatLngFormatpublic static String toString(LatLng point)
point
- the LatLng pointpublic static String toLatitude(Double degress, LatLngFormat format, Integer dp)
degress
- - Degrees to be formatted as specified.format
- the LatLngFormatdp
- - Number of decimal places to use – default 0 for dms, 3 for dm, 6 for d.public static String toLatitude(Double degress, LatLngFormat format)
degress
- - Degrees to be formatted as specified.format
- the LatLngFormatpublic static String toLongitude(Double degress, LatLngFormat format, Integer dp)
degress
- - Degrees to be formatted as specified.format
- the LatLngFormatdp
- - Number of decimal places to use – default 0 for dms, 3 for dm, 6 for d.public static String toLongitude(Double degress, LatLngFormat format)
degress
- - Degrees to be formatted as specified.format
- the LatLngFormatpublic static String toDMS(Double degrees, LatLngFormat format, Integer dp)
degrees
- - Degrees to be formatted as specified.format
- the LatLngFormatdp
- - Number of decimal places to use – default 0 for dms, 3 for dm, 6 for d.public static String toDMS(Double degrees, LatLngFormat format)
degrees
- - Degrees to be formatted as specified.format
- the LatLngFormatpublic static String toBearing(Double degress, LatLngFormat format, Integer dp)
degress
- Degrees to be formatted as specified.format
- the LatLngFormatdp
- - Number of decimal places to use – default 0 for dms, 3 for dm, 6 for d.public static String toBearing(Double degress, LatLngFormat format)
degress
- Degrees to be formatted as specified.format
- the LatLngFormatpublic static Double parseDMS(String dms) throws ParseException
dms
- - Degrees or deg/min/sec in variety of formats.ParseException
public static LatLng parseLatLng(String latlngStr) throws ParseException
latlngStr
- the latLng String.ParseException
- if failed to parse String.parseDMS(String)
,
LAT_LNG_SEPERATOR
public static final double normalizeLatitudeDegrees(double latitudeDegrees)
latitudeDegrees
- the latitude degrees.-LATITUDE_DEGREES_RANGE
and LATITUDE_DEGREES_RANGE
. (-90 to 90).public static final double normalizeLongitudeDegrees(double longitudeDegrees)
longitudeDegrees
- the latitude degrees.-LONGITUDE_DEGREES_RANGE
and LONGITUDE_DEGREES_RANGE
. (-180 to 180).public static final double normalizeRange(double degrees, double range)
degrees
- The value that needs adjustingrange
- -range = < value < range