Class LatLongDistance

java.lang.Object
org.ka2ddo.yaac.util.LatLongDistance

public class LatLongDistance extends Object
This class defines a static method that implements the WGS84 cartesian distance formula.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final double
    Mean radius of the Earth (at sea level) in meters.
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    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.
    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.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • R_EARTH_M

      public static final double R_EARTH_M
      Mean 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 North
      long1 - longitude of the first point in degrees East (negative means West)
      lat2 - latitude of the second point in degrees North
      long2 - 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 North
      long1 - longitude of the first point in degrees East (negative means West)
      lat2 - latitude of the second point in degrees North
      long2 - 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