Sample Code



This package provides efficient and accurate geographic coordinate transformations in the Java language.

The currently supported coordinate systems are defined as follows:
Name Abbreviation
Geodetic Coordinate System GDC
GeoCentric Coordinate System GCC
Universal Transverse Mercator UTM
Mercator MER
Lambert Conformal Conic LCC
Ordinance Survey Great Britain OSGB

Direct conversions, and their inverses, are supplied for GDC to GCC, GDC to UTM, LCC to GDC, MER to GDC, and OSGB to GDC. Indirect conversions (via GDC) are supplied for UTM to GCC and GCC to UTM.

These classes are intended to provide a fast method for coordinate transformations in Java.  Some of the conversions (GCC <-> GDC, UTM <-> GDC, UTM <-> GCC) are based on mathematical approximations that eliminate many of the trigonometric calls used in the exact solutions.  These are accurate to within a one millimeter error ball of the exact solution, while being substantially faster. The remaining conversions are based on community contributions and may provide less accurate and efficient solutions.

Twenty Two Earth Reference Ellipsoids are supported, for more information see the SEDRIS GRM.


  • No bounds checking is done for valid coordinates, nor error codes returned, thus it is possible to enter invalid coordinates and receive either erroneous results or a runtime error.  The user is responsible for the surety of the source data.

  • Vertical datums relative to mean sea level (i.e. geoids) are not supported - all elevations are currently assumed to be from the ellipsoid.

  • GCC to GDC and GCC to UTM require an ellipsoid for initialization, as the routine is optimized based on a curve-fit of the 22 supported earth reference models.

Known Bugs:

  • The Init method initialises the static variables Origin_lat and Origin_lon in terms of themselves. If Init is called more than once, the variables are assigned incorrect values by being converted from degrees to radians each time. Calling Init more than once for Gdc_To_OSGB_Converter does not have this problem. [Reported by Ian MacColl]