Added in API level 34

AltitudeConverter


class AltitudeConverter
kotlin.Any
   ↳ android.location.altitude.AltitudeConverter

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 constructors

Creates an instance that manages an independent cache to optimized conversions of locations in proximity to one another.

Public methods
Unit

Adds a Mean Sea Level altitude to the location.

Public constructors

AltitudeConverter

Added in API level 34
AltitudeConverter()

Creates an instance that manages an independent cache to optimized conversions of locations in proximity to one another.

Public methods

addMslAltitudeToLocation

Added in API level 34
fun addMslAltitudeToLocation(
    context: Context,
    location: Location
): Unit

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.
This method may take several seconds to complete, so it should only be called from a worker thread.

Parameters
context Context: This value cannot be null.
location Location: This value cannot be null.
Exceptions
java.io.IOException if an I/O error occurs when loading data from raw assets.
java.lang.IllegalArgumentException 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.