# AltitudeConverterCompat

Artifact: [androidx.core:core-location-altitude](https://developer.android.com/jetpack/androidx/releases/core) [View Source](https://cs.android.com/search?q=file:androidx/core/location/altitude/AltitudeConverterCompat.java+class:androidx.core.location.altitude.AltitudeConverterCompat) Added in [1.0.1](https://developer.android.com/jetpack/androidx/releases/core#1.0.1)

*** ** * ** ***


```
public final class AltitudeConverterCompat
```

<br />

*** ** * ** ***

Converts altitudes reported above the World Geodetic System 1984 (WGS84) reference ellipsoid into ones above Mean Sea Level.

Reference:

```
Brian Julian and Michael Angermann.
"Resource efficient and accurate altitude conversion to Mean Sea Level."
2023 IEEE/ION Position, Location and Navigation Symposium (PLANS).
```

## Summary

| ### Public methods |
|---|---|
| `static void` | `@https://developer.android.com/reference/androidx/annotation/WorkerThread https://developer.android.com/reference/androidx/core/location/altitude/AltitudeConverterCompat#addMslAltitudeToLocation(android.content.Context,android.location.Location)( @https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/android/content/Context.html context, @https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/android/location/Location.html location )` Adds a Mean Sea Level altitude to the `location`. |

## Public methods

### addMslAltitudeToLocation

Added in [1.0.1](https://developer.android.com/jetpack/androidx/releases/core#1.0.1)

```
@WorkerThread
public static void addMslAltitudeToLocation(
    @NonNull Context context,
    @NonNull Location location
)
```

Adds a Mean Sea Level altitude to the `location`. In addition, adds a Mean Sea Level altitude accuracy if the `location` has a finite and non-negative vertical accuracy; otherwise, does not add a corresponding accuracy.

Must be called off the main thread as data may be loaded from raw assets.

| Throws |
|---|---|
| `https://developer.android.com/reference/java/io/IOException.html` | if an I/O error occurs when loading data from raw assets. |
| `https://developer.android.com/reference/java/lang/IllegalArgumentException.html` | if the `location` has an invalid latitude, longitude, or altitude above WGS84. Specifically, the latitude must be between -90 and 90 (both inclusive), the longitude must be between -180 and 180 (both inclusive), and the altitude above WGS84 must be finite. |