## What is geodesy?

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, ellipsoid, and geoid. 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 EGM96 and NAVD88) in use around the world. The following sections describe what references are supported in LuciadRIA and how they can be used.

## 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. 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 systems based on them are widely used in surveying, mapping, and navigation. 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 converting between coordinates defined with respect to different datums. You can find more information on coordinate transformations in Transforming coordinates between geographic references.

Geodetic datums are implicitly supported in LuciadRIA through the various coordinate reference systems that are supported. The API reference provides all the necessary details in the modules `reference`, `transformation` and `geodesy`. There is a vast literature on geodesy for the interested reader.

## Working with coordinate references

When you create a model, you need a `CoordinateReference`. A `CoordinateReference` specifies the coordinate reference system used for locating the model data on earth. It is necessary to link a model to a `CoordinateReference` to define the objects in the model in a uniform way.

The `reference` module provides a `ReferenceProvider` that you can use to obtain a suitable `CoordinateReference`, based on an EPSG code.

Program: Creating a reference illustrates how you obtain a WGS84 reference from the reference factory using its `EPSG:4326` code.

Program: Creating a reference (from `samples/common/LayerConfigUtil.js`)
``var EPSG4326 = getReference("EPSG:4326");``

`ReferenceProvider` supports a number of commonly used references by default. See the reference documentation of the `isValidReferenceIdentifier(referenceIdentifier)` method for a list of those references.

You can also parse a reference that is formatted in Well-Known Text (WKT). Use the `parseWellKnownText` method for that.

## Working with vertical references

As mentioned in What is a geodetic datum?, a `CoordinateReference` contains both a horizontal datum and a vertical datum.

The vertical datum in the `CoordinateReference` generated by Program: Creating a reference has a vertical reference that is defined relative to Above Mean Sea Level (AMSL). This has effect on the z-coordinate of the shapes in your model. A z-coordinate equal to 0 will place your shape on the Mean Sea Level reference plane.

The `ReferenceProvider` class also allows you to create references that with a vertical reference defined above the terrain contained in the view:

Program: Create a height above terrain `CoordinateReference` using the factory methods from the `ReferenceProvider` module
``const reference = getHeightAboveTerrainReference("EPSG:4326");``

Program: Create a height above terrain `CoordinateReference` shows you how to create a `CoordinateReference` that is defined above the terrain’s surface. This has an effect on the z-coordinates of the shapes in your model. In a height above terrain reference, a z-coordinate equal to 0 will place your shape on top of the terrain’s surface. Figure 2. Example of streets vector data being defined above terrain, with z-coordinate equal to 0

Choosing the right vertical reference is important for your application. Here are a few examples of situations in which one is preferred over the other:

• Above Mean Sea Level Reference, obtained with `ReferenceProvider.getReference`:

• Airplanes flying on a trajectory are typically defined at a height above mean sea level.

• Satellites in orbit are typically defined at a height above mean sea level.

• Marine vessels are typically define on the mean sea level.

• Height Above Terrain Reference, obtained with `ReferenceProvider.getHeightAboveTerrainReference`: