public final class LatLongUtils
extends java.lang.Object
Modifier and Type | Field and Description |
---|---|
static double |
EQUATORIAL_RADIUS
The equatorial radius as defined by the WGS84
ellipsoid.
|
static double |
INVERSE_FLATTENING
The flattening factor of the earth's ellipsoid is required for distance computation.
|
static double |
LATITUDE_MAX
Maximum possible latitude coordinate.
|
static double |
LATITUDE_MIN
Minimum possible latitude coordinate.
|
static double |
LONGITUDE_MAX
Maximum possible longitude coordinate.
|
static double |
LONGITUDE_MIN
Minimum possible longitude coordinate.
|
static double |
POLAR_RADIUS
Polar radius of earth is required for distance computation.
|
Modifier and Type | Method and Description |
---|---|
static boolean |
contains(LatLong[] latLongs,
LatLong latLong)
Find if the given point lies within this polygon.
|
static boolean |
contains(java.util.List<LatLong> latLongs,
LatLong latLong)
Find if the given point lies within this polygon.
|
static int |
degreesToMicrodegrees(double coordinate)
Converts a coordinate from degrees to microdegrees (degrees * 10^6).
|
static LatLong |
destinationPoint(LatLong start,
double distance,
float bearing)
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 |
distance(LatLong latLong1,
LatLong latLong2)
Calculate the Euclidean distance between two LatLongs in degrees using the Pythagorean
theorem.
|
static double |
distanceSegmentPoint(double startX,
double startY,
double endX,
double endY,
double pointX,
double pointY)
Returns the distance between the given segment and point.
|
static LatLong |
fromString(java.lang.String latLongString)
Creates a new LatLong from a comma-separated string of coordinates in the order latitude, longitude.
|
static boolean |
isClosedWay(LatLong[] latLongs)
Find if this way is closed.
|
static double |
latitudeDistance(int meters)
Calculates the amount of degrees of latitude for a given distance in meters.
|
static double |
longitudeDistance(int meters,
double latitude)
Calculates the amount of degrees of longitude for a given distance in meters.
|
static double |
microdegreesToDegrees(int coordinate)
Converts a coordinate from microdegrees (degrees * 10^6) to degrees.
|
static Point |
nearestSegmentPoint(double startX,
double startY,
double endX,
double endY,
double pointX,
double pointY)
Returns a point on the segment nearest to the specified point.
|
static double[] |
parseCoordinateString(java.lang.String coordinatesString,
int numberOfCoordinates)
Parses a given number of comma-separated coordinate values from the supplied string.
|
static double |
sphericalDistance(LatLong latLong1,
LatLong latLong2)
Calculate the spherical distance between two LatLongs in meters using the Haversine
formula.
|
static double |
validateLatitude(double latitude) |
static double |
validateLongitude(double longitude) |
static double |
vincentyDistance(LatLong latLong1,
LatLong latLong2)
Calculates geodetic distance between two LatLongs using Vincenty inverse formula
for ellipsoids.
|
static byte |
zoomForBounds(Dimension dimension,
BoundingBox boundingBox,
int tileSize)
Calculates the zoom level that allows to display the
BoundingBox on a view with the Dimension and
tile size. |
public static final double EQUATORIAL_RADIUS
public static final double INVERSE_FLATTENING
public static final double POLAR_RADIUS
public static final double LATITUDE_MAX
public static final double LATITUDE_MIN
public static final double LONGITUDE_MAX
public static final double LONGITUDE_MIN
public static boolean contains(LatLong[] latLongs, LatLong latLong)
http://www.ecse.rpi.edu/Homepages/wrf/Research/Short_Notes/pnpoly.html
public static boolean contains(java.util.List<LatLong> latLongs, LatLong latLong)
http://www.ecse.rpi.edu/Homepages/wrf/Research/Short_Notes/pnpoly.html
public static int degreesToMicrodegrees(double coordinate)
coordinate
- the coordinate in degrees.public static LatLong destinationPoint(LatLong start, double distance, float bearing)
start
- the start pointdistance
- the distance travelled, in same units as earth radius (default: meters)bearing
- the initial bearing in degrees from northpublic static double distance(LatLong latLong1, LatLong latLong2)
latLong1
- first LatLonglatLong2
- second LatLongpublic static double distanceSegmentPoint(double startX, double startY, double endX, double endY, double pointX, double pointY)
libGDX (Apache 2.0)
public static LatLong fromString(java.lang.String latLongString)
latLongString
- the string that describes the LatLong.java.lang.IllegalArgumentException
- if the string cannot be parsed or describes an invalid LatLong.public static boolean isClosedWay(LatLong[] latLongs)
public static double latitudeDistance(int meters)
meters
- distance in meterspublic static double longitudeDistance(int meters, double latitude)
meters
- distance in meterslatitude
- the latitude at which the calculation should be performedpublic static double microdegreesToDegrees(int coordinate)
coordinate
- the coordinate in microdegrees (degrees * 10^6).public static Point nearestSegmentPoint(double startX, double startY, double endX, double endY, double pointX, double pointY)
libGDX (Apache 2.0)
public static double[] parseCoordinateString(java.lang.String coordinatesString, int numberOfCoordinates)
coordinatesString
- a comma-separated string of coordinate values.numberOfCoordinates
- the expected number of coordinate values in the string.java.lang.IllegalArgumentException
- if the string is invalid or does not contain the given number of coordinate values.public static double sphericalDistance(LatLong latLong1, LatLong latLong2)
latLong1
- first LatLonglatLong2
- second LatLongpublic static double validateLatitude(double latitude)
latitude
- the latitude coordinate in degrees which should be validated.java.lang.IllegalArgumentException
- if the latitude coordinate is invalid or Double.NaN
.public static double validateLongitude(double longitude)
longitude
- the longitude coordinate in degrees which should be validated.java.lang.IllegalArgumentException
- if the longitude coordinate is invalid or Double.NaN
.public static double vincentyDistance(LatLong latLong1, LatLong latLong2)
latLong1
- first LatLonglatLong2
- second LatLongpublic static byte zoomForBounds(Dimension dimension, BoundingBox boundingBox, int tileSize)
BoundingBox
on a view with the Dimension
and
tile size.dimension
- the Dimension
of the view.boundingBox
- the BoundingBox
to display.tileSize
- the size of the tiles.BoundingBox
on a view with the Dimension
and
tile size.