Package org.oscim.core
Class GeoPoint
java.lang.Object
org.oscim.core.GeoPoint
- All Implemented Interfaces:
Serializable,Comparable<GeoPoint>
A GeoPoint represents an immutable pair of latitude and longitude
coordinates.
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionfinal intThe latitude value of this GeoPoint in microdegrees (degrees * 10^6).final intThe longitude value of this GeoPoint in microdegrees (degrees * 10^6). -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptiondoubleintdestinationPoint(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).doubleCalculate the Euclidean distance from this point to another using the Pythagorean theorem.booleandoubledoubleinthashCode()static doublelatitudeDistance(int meters) Calculates the amount of degrees of latitude for a given distance in meters.static doublelongitudeDistance(int meters, double latitude) Calculates the amount of degrees of longitude for a given distance in meters.voiddoublesphericalDistance(GeoPoint other) Calculate the spherical distance from this point to another using the Haversine formula.toString()doublevincentyDistance(GeoPoint other) Calculate the spherical distance from this point to another using Vincenty inverse formula for ellipsoids.
-
Field Details
-
latitudeE6
public final int latitudeE6The latitude value of this GeoPoint in microdegrees (degrees * 10^6). -
longitudeE6
public final int longitudeE6The longitude value of this GeoPoint in microdegrees (degrees * 10^6).
-
-
Constructor Details
-
GeoPoint
public GeoPoint(double lat, double lon) - Parameters:
lat- the latitude in degrees, will be limited to the possible latitude range.lon- the longitude in degrees, will be limited to the possible longitude range.
-
GeoPoint
public GeoPoint(int latitudeE6, int longitudeE6) - Parameters:
latitudeE6- the latitude in microdegrees (degrees * 10^6), will be limited to the possible latitude range.longitudeE6- the longitude in microdegrees (degrees * 10^6), will be limited to the possible longitude range.
-
-
Method Details
-
bearingTo
-
compareTo
- Specified by:
compareToin interfaceComparable<GeoPoint>
-
destinationPoint
Returns the destination point from this point having travelled the given distance on the given initial bearing (bearing normally varies around path followed).- Parameters:
distance- the distance travelled, in same units as earth radius (default: meters)bearing- the initial bearing in degrees from north- Returns:
- the destination point
- See Also:
-
distance
Calculate the Euclidean distance from this point to another using the Pythagorean theorem.- Parameters:
other- The point to calculate the distance to- Returns:
- the distance in degrees as a double
-
equals
-
getLatitude
public double getLatitude()- Returns:
- the latitude value of this GeoPoint in degrees.
-
getLongitude
public double getLongitude()- Returns:
- the longitude value of this GeoPoint in degrees.
-
hashCode
public int hashCode() -
latitudeDistance
public static double latitudeDistance(int meters) Calculates the amount of degrees of latitude for a given distance in meters.- Parameters:
meters- distance in meters- Returns:
- latitude degrees
-
longitudeDistance
public static double longitudeDistance(int meters, double latitude) Calculates the amount of degrees of longitude for a given distance in meters.- Parameters:
meters- distance in meterslatitude- the latitude at which the calculation should be performed- Returns:
- longitude degrees
-
project
-
sphericalDistance
Calculate the spherical distance from this point to another using the Haversine formula. This calculation is done using the assumption, that the earth is a sphere, it is not though. If you need a higher precision and can afford a longer execution time you might want to use vincentyDistance.- Parameters:
other- The point to calculate the distance to- Returns:
- the distance in meters as a double
-
toString
-
vincentyDistance
Calculate the spherical distance from this point to another using Vincenty inverse formula for ellipsoids. This is very accurate but consumes more resources and time than the sphericalDistance method. Adaptation of Chriss Veness' JavaScript Code on http://www.movable-type.co.uk/scripts/latlong-vincenty.html Paper: Vincenty inverse formula - T Vincenty, "Direct and Inverse Solutions of Geodesics on the Ellipsoid with application of nested equations", Survey Review, vol XXII no 176, 1975 (http://www.ngs.noaa.gov/PUBS_LIB/inverse.pdf)- Parameters:
other- The point to calculate the distance to- Returns:
- the distance in meters as a double
-