Package org.ka2ddo.yaac.util
Class LatLongDistance
java.lang.Object
org.ka2ddo.yaac.util.LatLongDistance
This class defines a static method that implements the WGS84
cartesian distance formula.
-
Field Summary
Modifier and TypeFieldDescriptionstatic final double
Mean radius of the Earth (at sea level) in meters. -
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic double
computeDirection
(double lat1, double long1, double lat2, double long2) Compute the initial compass bearing of the vector between one point and a second point, relative to True North.static double
computeDistance
(double lat1, double long1, double lat2, double long2) Compute the distance between two points on the surface of the Earth, using the WGS84 model.
-
Field Details
-
R_EARTH_M
public static final double R_EARTH_MMean radius of the Earth (at sea level) in meters.- See Also:
-
-
Constructor Details
-
LatLongDistance
public LatLongDistance()
-
-
Method Details
-
computeDistance
public static double computeDistance(double lat1, double long1, double lat2, double long2) Compute the distance between two points on the surface of the Earth, using the WGS84 model.- Parameters:
lat1
- latitude of the first point in degrees Northlong1
- longitude of the first point in degrees East (negative means West)lat2
- latitude of the second point in degrees Northlong2
- longitude of the second point in degrees East (negative means West)- Returns:
- distance between the points in meters
-
computeDirection
public static double computeDirection(double lat1, double long1, double lat2, double long2) Compute the initial compass bearing of the vector between one point and a second point, relative to True North. This is a rectangular approximation, only good for short distances. For long distances, use OpenMap's classes for great circle and rhumb line calculations.- Parameters:
lat1
- latitude of the first point in degrees Northlong1
- longitude of the first point in degrees East (negative means West)lat2
- latitude of the second point in degrees Northlong2
- longitude of the second point in degrees East (negative means West)- Returns:
- compass bearing departing from first point to second point in clockwise degrees from True North
-