org.hermit.geo
Class AndoyerCalculator

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

public class AndoyerCalculator
extends GeoCalculator

A geographic data calculator based on the Andoyer formula. This is a good algorithm which takes into account the flattening of the Earth. Accuracy should be around the flattening squared; however, some extreme cases can yield bad results.

Note that currently we only have the Andoyer algorithm for distance; other functions use simpler spherical methods. Hence, this class should be used for reasonably fast but fairly accurate distance calculations, where edge cases (e.g. near-antipodean points) are not encountered.

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
AndoyerCalculator()
          Create a calculator using the default ellipsoid.
AndoyerCalculator(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

AndoyerCalculator

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


AndoyerCalculator

public AndoyerCalculator(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.

NOTE: this is the Haversine version of this algorithm.

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 may be faster than calling azimuth(p1, p2) and distance(p1, p2), if both parts are required.

NOTE: this is the Haversine version of this algorithm.

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.

NOTE: this is the Haversine version of this algorithm.

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.