/earth-gravitational-model

A lightweight port of the GeoTools EarthGravitationalModel (http://docs.geotools.org/latest/javadocs/org/geotools/referencing/operation/transform/EarthGravitationalModel.html).

Primary LanguageJava

earth-gravitational-model Java CI with Gradle

A lightweight port of the GeoTools EarthGravitationalModel (source code) that can be used on Android without requiring the entire GeoTools suite.

From the original EarthGravitationalModel.java file:

This class transforms vertical coordinates using coefficients from the Earth Gravitational Model. This class is an adaption of Fortran code clenqt.for from the National Geospatial-Intelligence Agency and available in public domain. The normalized geopotential coefficients file bundled in this module is an adaptation of egm180.nor file, with some spaces trimmed.

The egm180.nor file is included in src/main/resources directory in this project, which appears to be the EGM84 model.

Requirements

You'll need JDK 8 or higher.

Usage

The below example shows how to use the EarthGravitationalModel.

EarthGravitationalModel gh = new EarthGravitationalModel();
gh.load("/egm180.nor");

// GPS lat, lon, and altitude
double lat = 45;
double lon = 45;
double altitudeWgs84 = 0;

// Calculate the offset between the ellipsoid and geoid
double offset = gh.heightOffset(lon, lat, altitudeWgs84);

// Add the offset to the GPS altitude to get the height above the geoid (in meters)
double altitudeMeanSeaLevel = altitudeWgs84 - offset;

Compiling the code yourself

Setting up your environment

This project was created in IntelliJ. You can also compile it from the command line using Gradle.

Getting the code

To get started with this project, use a Git client to clone this repository to your local computer. Then, in IntelliJ import the project as a Maven project.

Build the project

  • IntelliJ - Clean and build the project
  • Gradle - ./gradlew build