Coordinate

class Coordinate(point: Point, val levels: Levels = Levels.Outdoor, val altitude: Double? = null, val bearing: Double? = null, val horizontalAccuracy: Double = 0.0, val timestamp: Long = System.currentTimeMillis(), val heightFromFloor: Double? = null, val heightFromGround: Double? = null) : CompactStringConvertible

A geographic location — a 2D point plus indoor levels, altitude, bearing, horizontal accuracy and time.

An immutable value type. The horizontal position is held as a single 2D GeoJSON point (the analog of iOS CLLocationCoordinate2D), with latitude/longitude exposed as accessors over it; altitude is kept separately in altitude. Build one from a point or from raw latitude/longitude, bridge from an Android Location via the Location constructor, or let the SDK decode it from API responses. Use copy to derive a modified instance, and toLocation to bridge back to an Android Location.

Constructors

Link copied to clipboard
constructor(point: Point, levels: Levels = Levels.Outdoor, altitude: Double? = null, bearing: Double? = null, horizontalAccuracy: Double = 0.0, timestamp: Long = System.currentTimeMillis(), heightFromFloor: Double? = null, heightFromGround: Double? = null)
constructor(latitude: Double, longitude: Double, levels: Levels = Levels.Outdoor, altitude: Double? = null, bearing: Double? = null, horizontalAccuracy: Double = 0.0, timestamp: Long = System.currentTimeMillis(), heightFromFloor: Double? = null, heightFromGround: Double? = null)

Builds a coordinate from raw latitude/longitude with optional indoor levels and altitude.

constructor(latitude: Double, longitude: Double, level: Float, altitude: Double? = null)

Builds a coordinate from raw latitude/longitude placed on a single indoor level.

constructor(latitude: Double, longitude: Double, range: ClosedRange<Float>, altitude: Double? = null)

Builds a coordinate from raw latitude/longitude spanning a range of indoor levels.

constructor(location: Location, levels: Levels = Levels.Outdoor, heightFromFloor: Double? = null, heightFromGround: Double? = null)

Wraps an Android Location, keeping altitude and bearing only when Location reports them valid.

Types

Link copied to clipboard
object Companion

Properties

Link copied to clipboard

The altitude of this location in meters above the WGS84 reference ellipsoid.

Link copied to clipboard

The bearing — the horizontal direction of travel of this device, measured in degrees and relative to due north.

Link copied to clipboard

Height from the floor of the defined level. Must be null outdoor.

Link copied to clipboard

Height from the ground of the defined level. Must be null outdoor.

Link copied to clipboard

The radius of uncertainty for the location, measured in meters, at the 68th percentile confidence level.

Link copied to clipboard

true when the coordinate is inside a building — i.e. it has indoor levels.

Link copied to clipboard

true when the coordinate is outdoor — i.e. it has no indoor levels.

Link copied to clipboard

The latitude in degrees.

Link copied to clipboard

Get the latitude in radians.

Link copied to clipboard

The indoor levels this coordinate belongs to, or Levels.Outdoor when it is not inside a building.

Link copied to clipboard

The longitude in degrees.

Link copied to clipboard

Get the longitude in radians.

Link copied to clipboard
val point: Point

The horizontal position as a 2D GeoJSON Point (longitude/latitude).

Link copied to clipboard

The Unix epoch time of this location fix, in milliseconds since the start of the Unix epoch (00:00:00 January 1, 1970 UTC).

Functions

Link copied to clipboard

Returns the approximate initial bearing in degrees east of true north when traveling along the shortest path between this coordinate and the given coordinate. The shortest path is defined using the WGS84 ellipsoid. Coordinates that are (nearly) antipodal may produce meaningless results.

Link copied to clipboard
fun copy(point: Point = this.point, levels: Levels = this.levels, altitude: Double? = this.altitude, bearing: Double? = this.bearing, horizontalAccuracy: Double = this.horizontalAccuracy, timestamp: Long = this.timestamp, heightFromFloor: Double? = this.heightFromFloor, heightFromGround: Double? = this.heightFromGround): Coordinate

Returns a copy of this coordinate with the given fields replaced and every other field preserved.

Link copied to clipboard
fun destination(distance: Double, bearing: Double): Coordinate

Returns a coordinate a certain Haversine distance away in the given bearing, preserving every other field.

Link copied to clipboard

Calculates the distance (measured in meters) from the current object’s coordinate to the specified coordinate. This uses the Haversine formula to account for global curvature.

Link copied to clipboard

Calculates the distance (measured in meters) from the current object’s coordinate to the specified coordinate taking altitude into account. This uses the Haversine formula to account for global curvature.

Link copied to clipboard
fun distanceTo(other: Coordinate, formula: DistanceFormula = DistanceFormula.HAVERSINE_WITH_LEVELS): Double?

Calculates the distance (measured in meters) from the current object’s coordinate to the specified coordinate. This uses the Haversine formula to account for global curvature.

Link copied to clipboard
open operator override fun equals(other: Any?): Boolean
Link copied to clipboard

Adapted to Cartesian coordinates using Spherical model

Link copied to clipboard
open override fun hashCode(): Int
Link copied to clipboard
open override fun toCompactString(): String

Returns a compact, human-readable representation of this value.

Link copied to clipboard

Builds an Android Location representation of this coordinate from the stored values.

Link copied to clipboard
open override fun toString(): String