A library of various geodetic utilities for handling positions, directions and distances over the surface of the Earth, with a choice of algorithms from the fast and simple Haversine formula, to the super-accurate Vincenty formula.

Usage is pretty simple. Two rules to remember:

For example, positions on the Earth are represented by the {@link org.hermit.geo.Position} class. You can create a Position in either of these ways:

    pos1 = new Position(latRadians, lonRadians);
    pos2 = Position.fromDegrees(latDegrees, lonDegrees);

You can then easily calculate the distance between Positions:

    Distance dist = pos1.distance(pos2);

Abstract representations are used to avoid issues of units, as, for example, with the {@link org.hermit.geo.Distance} class used above. Having got a Distance, you can, when you need to, get its value in whatever units you like using provided accessors.

Multiple algorithms for calculating distances etc. are supported. The simplest, the Haversine formula, assumes a spherical Earth; it is fast and easy to use, but has an error of about 0.5%. The class {@link org.hermit.geo.GeoCalculator} allows you to set what algorithm is in use. Note that the more complex calculators are based on an ellipsoidal Earth; since multiple ellipsoid approximations are (or have been) in use internationally, you need to say which one you want to use. For example:

    GeoCalculator.setAlgorithm(GeoCalculator.Algorithm.VINCENTY,
                               GeoConstants.Ellipsoid.AIRY1858);

You can, if you wish, use the individual calculator classes directly; this is not the canonical model, but may be useful if you wish to work with several different calculators.

The {@link org.hermit.geo.PointOfInterest} class provides (somewhat) interesting textual descriptions of points on the Earth's surface. For example:

    currentLocMsg = PointOfInterest.describePosition(currentPos);
      --> "The Southern Tropics, 3.9 nm north of The Tropic of Capricorn"

See the On Watch application for an example use of this package.