NASA World Wind

gov.nasa.worldwind.geom
Class LatLon

java.lang.Object
  extended by gov.nasa.worldwind.geom.LatLon

public class LatLon
extends Object

Represents a point on the two-dimensional surface of a globe. Latitude is the degrees North and ranges between [-90, 90], while longitude refers to degrees East, and ranges between (-180, 180].

Instances of LatLon are immutable.


Field Summary
static LatLon ZERO
           
 
Constructor Summary
LatLon(Angle latitude, Angle longitude)
          Contructs a new LatLon from two angles.
 
Method Summary
 LatLon add(LatLon that)
           
 LatLon add(Position that)
           
static double ellipsoidalDistance(LatLon p1, LatLon p2, double equatorialRadius, double polarRadius)
          Computes the distance between two points on an ellipsoid iteratively.
 Angle ellipsoidalForwardAzimuth(LatLon p1, LatLon p2, double equatorialRadius, double polarRadius)
          Compute the forward azimuth between two positions
 boolean equals(Object o)
           
static LatLon fromDegrees(double latitude, double longitude)
          Factory method for obtaining a new LatLon from two angles expressed in degrees.
static LatLon fromRadians(double latitude, double longitude)
          Factor method for obtaining a new LatLon from two angles expressed in radians.
 Angle getLatitude()
          Obtains the latitude of this LatLon.
 Angle getLongitude()
          Obtains the longitude of this LatLon.
static Angle greatCircleAzimuth(LatLon p1, LatLon p2)
          Computes the azimuth angle (clockwise from North) that points from the first location to the second location.
static Angle greatCircleDistance(LatLon p1, LatLon p2)
          Computes the great circle angular distance between two locations.
static LatLon greatCircleEndPosition(LatLon p, Angle greatCircleAzimuth, Angle pathLength)
          Computes the location on a great circle arc with the given starting location, azimuth, and arc distance.
static LatLon greatCircleEndPosition(LatLon p, double greatCircleAzimuthRadians, double pathLengthRadians)
          Computes the location on a great circle arc with the given starting location, azimuth, and arc distance.
 int hashCode()
           
static LatLon interpolate(double amount, LatLon value1, LatLon value2)
           
static boolean positionsCrossDateLine(Iterable<LatLon> positions)
           
static boolean positionsCrossLongitudeBoundary(LatLon p1, LatLon p2)
           
static Angle rhumbAzimuth(LatLon p1, LatLon p2)
          Computes the azimuth angle (clockwise from North) of a rhumb line (a line of constant heading) between two locations.
static Angle rhumbDistance(LatLon p1, LatLon p2)
          Computes the length of the rhumb line between two locations.
static LatLon rhumbEndPosition(LatLon p, Angle rhumbAzimuth, Angle pathLength)
          Computes the location on a rhumb line with the given starting location, rhumb azimuth, and arc distance along the line.
static LatLon rhumbEndPosition(LatLon p, double rhumbAzimuthRadians, double pathLengthRadians)
          Computes the location on a rhumb line with the given starting location, rhumb azimuth, and arc distance along the line.
 LatLon subtract(LatLon that)
           
 LatLon subtract(Position that)
           
 String toString()
           
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

ZERO

public static final LatLon ZERO
Constructor Detail

LatLon

public LatLon(Angle latitude,
              Angle longitude)
Contructs a new LatLon from two angles. Neither angle may be null.

Parameters:
latitude - latitude
longitude - longitude
Throws:
IllegalArgumentException - if latitude or longitude is null
Method Detail

add

public LatLon add(LatLon that)

add

public LatLon add(Position that)

ellipsoidalDistance

public static double ellipsoidalDistance(LatLon p1,
                                         LatLon p2,
                                         double equatorialRadius,
                                         double polarRadius)
Computes the distance between two points on an ellipsoid iteratively.

NOTE: This method was copied from the UniData NetCDF Java library. http://www.unidata.ucar.edu/software/netcdf-java/

Algorithm from U.S. National Geodetic Survey, FORTRAN program "inverse," subroutine "INVER1," by L. PFEIFER and JOHN G. GERGEN. See http://www.ngs.noaa.gov/TOOLS/Inv_Fwd/Inv_Fwd.html

Original documentation: SOLUTION OF THE GEODETIC INVERSE PROBLEM AFTER T.VINCENTY MODIFIED RAINSFORD'S METHOD WITH HELMERT'S ELLIPTICAL TERMS EFFECTIVE IN ANY AZIMUTH AND AT ANY DISTANCE SHORT OF ANTIPODAL STANDPOINT/FOREPOINT MUST NOT BE THE GEOGRAPHIC POLE

Requires close to 1.4 E-5 seconds wall clock time per call on a 550 MHz Pentium with Linux 7.2.

Parameters:
p1 - first position
p2 - second position
equatorialRadius - the equatorial radius of the globe in meters
polarRadius - the polar radius of the globe in meters
Returns:
distance in meters between the two points

ellipsoidalForwardAzimuth

public Angle ellipsoidalForwardAzimuth(LatLon p1,
                                       LatLon p2,
                                       double equatorialRadius,
                                       double polarRadius)
Compute the forward azimuth between two positions

Parameters:
p1 - first position
p2 - second position
equatorialRadius - the equatorial radius of the globe in meters
polarRadius - the polar radius of the globe in meters
Returns:
the azimuth

equals

public boolean equals(Object o)
Overrides:
equals in class Object

fromDegrees

public static LatLon fromDegrees(double latitude,
                                 double longitude)
Factory method for obtaining a new LatLon from two angles expressed in degrees.

Parameters:
latitude - in degrees
longitude - in degrees
Returns:
a new LatLon from the given angles, which are expressed as degrees

fromRadians

public static LatLon fromRadians(double latitude,
                                 double longitude)
Factor method for obtaining a new LatLon from two angles expressed in radians.

Parameters:
latitude - in radians
longitude - in radians
Returns:
a new LatLon from the given angles, which are expressed as radians

getLatitude

public final Angle getLatitude()
Obtains the latitude of this LatLon.

Returns:
this LatLon's latitude

getLongitude

public final Angle getLongitude()
Obtains the longitude of this LatLon.

Returns:
this LatLon's longitude

greatCircleAzimuth

public static Angle greatCircleAzimuth(LatLon p1,
                                       LatLon p2)
Computes the azimuth angle (clockwise from North) that points from the first location to the second location. This angle can be used as the starting azimuth for a great circle arc that begins at the first location, and passes through the second location.

Parameters:
p1 - LatLon of the first location
p2 - LatLon of the second location
Returns:
Angle that points from the first location to the second location.

greatCircleDistance

public static Angle greatCircleDistance(LatLon p1,
                                        LatLon p2)
Computes the great circle angular distance between two locations. The return value gives the distance as the angle between the two positions on the pi radius circle. In radians, this angle is also the arc length of the segment between the two positions on that circle. To compute a distance in meters from this value, multiply it by the radius of the globe.

Parameters:
p1 - LatLon of the first location
p2 - LatLon of the second location
Returns:
the angular distance between the two locations. In radians, this value is the arc length on the radius pi circle.

greatCircleEndPosition

public static LatLon greatCircleEndPosition(LatLon p,
                                            Angle greatCircleAzimuth,
                                            Angle pathLength)
Computes the location on a great circle arc with the given starting location, azimuth, and arc distance.

Parameters:
p - LatLon of the starting location
greatCircleAzimuth - great circle azimuth angle (clockwise from North)
pathLength - arc distance to travel
Returns:
LatLon location on the great circle arc.

greatCircleEndPosition

public static LatLon greatCircleEndPosition(LatLon p,
                                            double greatCircleAzimuthRadians,
                                            double pathLengthRadians)
Computes the location on a great circle arc with the given starting location, azimuth, and arc distance.

Parameters:
p - LatLon of the starting location
greatCircleAzimuthRadians - great circle azimuth angle (clockwise from North), in radians
pathLengthRadians - arc distance to travel, in radians
Returns:
LatLon location on the great circle arc.

hashCode

public int hashCode()
Overrides:
hashCode in class Object

interpolate

public static LatLon interpolate(double amount,
                                 LatLon value1,
                                 LatLon value2)

positionsCrossDateLine

public static boolean positionsCrossDateLine(Iterable<LatLon> positions)

positionsCrossLongitudeBoundary

public static boolean positionsCrossLongitudeBoundary(LatLon p1,
                                                      LatLon p2)

rhumbAzimuth

public static Angle rhumbAzimuth(LatLon p1,
                                 LatLon p2)
Computes the azimuth angle (clockwise from North) of a rhumb line (a line of constant heading) between two locations.

Parameters:
p1 - LatLon of the first location
p2 - LatLon of the second location
Returns:
azimuth Angle of a rhumb line between the two locations.

rhumbDistance

public static Angle rhumbDistance(LatLon p1,
                                  LatLon p2)
Computes the length of the rhumb line between two locations. The return value gives the distance as the angular distance between the two positions on the pi radius circle. In radians, this angle is also the arc length of the segment between the two positions on that circle. To compute a distance in meters from this value, multiply it by the radius of the globe.

Parameters:
p1 - LatLon of the first location
p2 - LatLon of the second location
Returns:
the arc length of the rhumb line between the two locations. In radians, this value is the arc length on the radius pi circle.

rhumbEndPosition

public static LatLon rhumbEndPosition(LatLon p,
                                      Angle rhumbAzimuth,
                                      Angle pathLength)
Computes the location on a rhumb line with the given starting location, rhumb azimuth, and arc distance along the line.

Parameters:
p - LatLon of the starting location
rhumbAzimuth - rhumb azimuth angle (clockwise from North)
pathLength - arc distance to travel
Returns:
LatLon location on the rhumb line.

rhumbEndPosition

public static LatLon rhumbEndPosition(LatLon p,
                                      double rhumbAzimuthRadians,
                                      double pathLengthRadians)
Computes the location on a rhumb line with the given starting location, rhumb azimuth, and arc distance along the line.

Parameters:
p - LatLon of the starting location
rhumbAzimuthRadians - rhumb azimuth angle (clockwise from North), in radians
pathLengthRadians - arc distance to travel, in radians
Returns:
LatLon location on the rhumb line.

subtract

public LatLon subtract(LatLon that)

subtract

public LatLon subtract(Position that)

toString

public String toString()
Overrides:
toString in class Object

NASA World Wind