Formula 1.0.0

Class Distance

  extended by hirondelle.formula.function.builtin.Distance
All Implemented Interfaces:

public final class Distance
extends Object
implements Function

distance(φ1, λ1, φ2, λ2): the distance in kilometres from one place to another.

Constructor Summary
Method Summary
 Decimal calculate(Decimal... aArgs)
          Returns the distance between two points on the Earth's surface, in kilometers.
Methods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

Constructor Detail


public Distance()
Method Detail


public Decimal calculate(Decimal... aArgs)
Returns the distance between two points on the Earth's surface, in kilometers.

This method takes 4 parameters, in the following order:

Latitude is positive north of the equator, and negative south of the equator. Longitude is positive to the east of Greenwich meridian (Asia, for example), and negative to the west of the Greenwich meridian (America, for example).

The return value usually has a large number of decimal places. That precision is spurious and without physical significance, since the underlying implementation makes the approximation that the Earth is spherical.

The caller should round the result to a reasonable number of decimal places.

This implementation uses two underlying formulas - one appropriate for large distances, and one appropriate for small distances.

Specified by:
calculate in interface Function
aArgs - 0 or more arguments to the function.

Formula 1.0.0

Copyright Hirondelle Systems. Published January 31, 2013