Geodesy is the scientific discipline that deals with the measurement and representation of the earth. Many mathematical models have been proposed to approximate the shape of the earth, ranging from flat-earth models to spherical approximations, ellipsoids, and geoids. Spherical and ellipsoidal approximations are used because of their mathematical simplicity. A more accurate approximation is the earth’s geoid, a hypothetical surface that coincides with the earth’s mean sea level. Although the earth’s geoid is considerably smoother than the actual surface of the earth, it is still highly irregular and therefore more difficult to represent and to use in computations. Note that there are many ellipsoid models (for example WGS84 and NAD83) and geoid models (for example EGM2008 and NAVD88) in use around the world.

The following sections describe what geodetic datums and geoids are and how they are supported in LuciadLightspeed.

## What is a geodetic datum?

A geodetic datum is a reference from which position measurements are made. A horizontal datum is a known and constant surface on which the positions of points can be precisely expressed. Because of their relative simplicity, ellipsoids are often used as the basis for horizontal datums. A vertical datum is an additional vertical reference for expressing the elevation of points. It is typically based on geoid or ellipsoid models.

Geodetic datums provide a basis for coordinate reference systems as described in LuciadLightspeed reference systems. For example, a geodetic datum based on an ellipsoid model of the earth’s surface allows to define geodetic lon-lat-height coordinates. The height coordinate may for example be computed with respect to the ellipsoid on which the lon-lat coordinates are defined (ellipsoidal height), or with respect to a geoid model (orthometric height), as shown in Figure 1, “Ellipsoidal versus orthometric heights”. Geodetic datums and the coordinate system based on them are widely used in surveying, mapping, and navigation. Refer to Projections for more information on map projections. Figure 1. Ellipsoidal versus orthometric heights

There are many datums in use today, as the basis for even more coordinate reference systems. Because referencing geodetic coordinates to the wrong datum can result in position errors of hundreds of meters, you need to be careful when conversing between coordinates defined with respect to different datums. You can find more information on coordinate transformations in Transformations between coordinate systems.

Using an ILcdGeodeticDatum describes how geodetic datums are supported in LuciadLightspeed. The API reference provides all the necessary details in the package `geodesy`. There is a vast literature on geodesy for the interested reader. Literature on geodesy provides a few references.

## Using an ILcdGeodeticDatum

LuciadLightspeed provides the interface `ILcdGeodeticDatum` to represent geodetic datums and support geodetic datum conversions. In this representation, a geodetic datum encompasses both a horizontal datum and a vertical datum. The horizontal datum is based on an ellipsoid of the type `ILcdEllipsoid` as described in Using an ILcdEllipsoid. A vertical datum is represented as a height function above this reference ellipsoid (see method `getHeight`). Most instances, like WGS84, reference height values to their ellipsoid (their method `getHeight` always returns zero).

`TLcdGeodeticDatum` is an implementation of `ILcdGeodeticDatum` which is based on an eight-parameter transformation to a global reference datum. The transformation defines a rotation, a translation, a scaling and a shift of the prime meridian. This transformation is applied to convert (lon, lat, height) coordinates from one geodetic datum to the reference datum.

Program: Transforming coordinates to reference geodetic datum (from `samples/gxy/transformation/geodeticToGrid/GridCalculation`)
``````fTransformation.setSourceReference(fReference);
fTransformation.setDestinationReference(fChosenGeodeticReference);
fTransformation.destinationPoint2sourceSFCT(fLonLatCoordinate,
fReferenceLonLatHeightPoint);``````

Program: Transforming coordinates to reference geodetic datum shows how to transform lon-lat-height coordinates from one `ILcdGeodeticDatum` (called `fChosenGeodeticDatum`) to the reference `ILcdGeodeticDatum`. The second argument of the method `datum2refLLHSFCT` is of the type `ILcd3DEditablePoint`, of which the coordinates are set to the result of the method.

 In LuciadLightspeed this is called a side-effect method. Side-effect methods are used for performance reasons. In LuciadLightspeed, the names of side-effect methods end in SFCT.
Program: Transforming coordinates from reference geodetic datum (from `samples/gxy/transformation/geodeticToGrid/GridCalculation`)
``````fTransformation.setDestinationReference(fChosenGeodeticReference);
fTransformation.sourcePoint2destinationSFCT(fReferenceLonLatHeightPoint,
fLonLatCoordinate);``````

Program: Transforming coordinates from reference geodetic datum shows the inverse transformation: from the reference `ILcdGeodeticDatum` back to the coordinates of the `fChosenGeodeticDatum`.

By means of these two transformations, it is possible to transform coordinates from any `ILcdGeodeticDatum` to any other `ILcdGeodeticDatum` using the reference datum. The reference datum is an internally chosen `ILcdGeodeticDatum`.

LuciadLightspeed has implementations of most geodetic datums used in the world. These implementations are grouped together in an `ILcdGeodeticDatumFactory`. LuciadLightspeed has five implementations of `ILcdGeodeticDatumFactory`:

All factories use WGS-84 as the reference datum.

Program: Create a geodetic datum from a name (from `samples/gxy/transformation/geodeticToGrid/GridCalculation`)
``````int id = fGeodeticDatumFactory.getAliasNames().findID(datum_name);
ILcdGeodeticDatum chosen_datum = fGeodeticDatumFactory.createGeodeticDatum(id);
fChosenGeodeticReference = new TLcdGeodeticReference(chosen_datum);``````

Program: Create a geodetic datum from a name shows how the particular instance `fGeodeticDatumFactory` of the class `TLcdNIMA8350GeodeticDatumFactory` returns a list of alias names of the class `TLcdAliasNames`. By means of the method `findID` on this `TLcdAliasNames`, the `id` of the `ILcdGeodeticDatum` with name `datum_name` is retrieved. Using this `id`, an `ILcdGeodeticDatum` called `fChosenGeodeticDatum` is created by `fGeodeticDatumFactory`.

In general, the creation of an `ILcdGeodeticDatum` using an `ILcdGeodeticDatumFactory` is done by giving the `ILcdGeodeticDatumFactory` a `java.util.Properties` object. For the specific `ILcdGeodeticDatumFactory` properties, see `ILcdGeodeticDatumFactory` and its implementations in the API reference.

## Using an ILcdEllipsoid

An `ILcdGeodeticDatum` is based on an `ILcdEllipsoid`. The interface `ILcdEllipsoid` provides geometrical calculations on an ellipsoid. LuciadLightspeed has a single implementation of the interface `ILcdEllipsoid`: `TLcdEllipsoid`.

LuciadLightspeed also provides a utility class `TLcdSphereUtil`. This class implements the methods of the interface `ILcdEllipsoid` as static methods. In this implementation the geometrical calculations are done on a sphere. Spherical calculations approximate the calculations on the ellipsoid, but are more efficient.

The main methods of the interface `ILcdEllipsoid` are:

• `geodesicDistance` to return the shortest distance between two `ILcdPoint` objects

• `forwardAzimuth2D` to return the azimuth direction of the shortest distance path between two `ILcdPoint` objects

• `geodesicPointSFCT` to return the geodetic coordinate of an `ILcdPoint` at a given distance in a given azimuth direction

LuciadLightspeed groups together instances of `ILcdEllipsoid` in an interface `ILcdEllipsoidFactory`. It has two factories that define most ellipsoids used in the world: