org.hermit.geo
Class VincentyCalculator

java.lang.Object
  extended by org.hermit.geo.GeoCalculator
      extended by org.hermit.geo.VincentyCalculator
All Implemented Interfaces:
GeoConstants

public class VincentyCalculator
extends GeoCalculator

A geographic data calculator based on Vincenty's formulae.

The geodetic operations in this class are based on an ellipsoidal model of the Earth, using Vincenty's formulae; this is slow, but very accurate. Be aware, however, that accuracy is compromised in extreme cases, such as nearly-antipodal points.

The user needs to specify the ellipsoid to use for the geodetic calculations; this is done in the constructor. The Ellipsoid enum defines a range of reference ellipsoids. The default is the widely-used WGS-84 standard.

The code in this class was converted from the Fortran implementations developed by the National Geodetic Survey. No license is specified for this code, but I believe that it is public domain, since it was created by an agency of the US Government. References:

Author:
Ian Cameron Smith

Nested Class Summary
 
Nested classes/interfaces inherited from class org.hermit.geo.GeoCalculator
GeoCalculator.Algorithm
 
Nested classes/interfaces inherited from interface org.hermit.geo.GeoConstants
GeoConstants.Ellipsoid
 
Field Summary
 
Fields inherited from interface org.hermit.geo.GeoConstants
EQUATORIAL_RADIUS, MEAN_RADIUS, POLAR_RADIUS
 
Constructor Summary
VincentyCalculator()
          Create a calculator using the default ellipsoid.
VincentyCalculator(GeoConstants.Ellipsoid ellip)
          Create a calculator using a given ellipsoid.
 
Method Summary
 Azimuth azimuth(Position p1, Position p2)
          Calculate the azimuth (bearing) from a position to another.
 Distance distance(Position p1, Position p2)
          Calculate the distance between two positions.
 GeoCalculator.Algorithm getAlgorithm()
          Get the algorithm this calculator uses.
 Distance latDistance(Position p1, double lat)
          Calculate the distance between a position and a given latitude.
 Position offset(Position p1, Distance distance, Azimuth azimuth)
          Calculate a second position given its offset from a given position.
 Vector vector(Position p1, Position p2)
          Calculate the azimuth and distance from a position to another.
 
Methods inherited from class org.hermit.geo.GeoCalculator
getCalculator, getCurrentAlgorithm, setAlgorithm, setAlgorithm
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

VincentyCalculator

public VincentyCalculator()
Create a calculator using the default ellipsoid.


VincentyCalculator

public VincentyCalculator(GeoConstants.Ellipsoid ellip)
Create a calculator using a given ellipsoid.

Parameters:
ellip - The ellipsoid to use for geodetic calculations.
Method Detail

getAlgorithm

public GeoCalculator.Algorithm getAlgorithm()
Get the algorithm this calculator uses.

Specified by:
getAlgorithm in class GeoCalculator
Returns:
The algorithm this calculator uses.

distance

public Distance distance(Position p1,
                         Position p2)
Calculate the distance between two positions.

Specified by:
distance in class GeoCalculator
Parameters:
p1 - Position to calculate the distance from.
p2 - Position to calculate the distance to.
Returns:
The distance between p1 and p2.

latDistance

public Distance latDistance(Position p1,
                            double lat)
Calculate the distance between a position and a given latitude.

Specified by:
latDistance in class GeoCalculator
Parameters:
p1 - Position to calculate the distance from.
lat - Latitude in radians to calculate the distance to.
Returns:
The distance of this Position from lat.

azimuth

public Azimuth azimuth(Position p1,
                       Position p2)
Calculate the azimuth (bearing) from a position to another.

Specified by:
azimuth in class GeoCalculator
Parameters:
p1 - Position to calculate the distance from.
p2 - Position to calculate the distance to.
Returns:
The azimuth of pos from this Position.

vector

public Vector vector(Position p1,
                     Position p2)
Calculate the azimuth and distance from a position to another. This function is significantly faster than calling azimuth(p1, p2) and distance(p1, p2), if both parts are required.

Specified by:
vector in class GeoCalculator
Parameters:
p1 - Position to calculate the vector from.
p2 - Position to calculate the vector to.
Returns:
The Vector from p1 to p2.

offset

public Position offset(Position p1,
                       Distance distance,
                       Azimuth azimuth)
Calculate a second position given its offset from a given position.

Specified by:
offset in class GeoCalculator
Parameters:
p1 - Position to calculate from.
distance - The Distance to the desired position.
azimuth - The Azimuth to the desired position.
Returns:
The position given by the azimuth and distance from p1. Returns null if the result could not be computed.