GeoCoordinates

public struct GeoCoordinates : Hashable

Represents geographical coordinates in 3D space.

  • Latitude in degrees.

    Declaration

    Swift

    public let latitude: Double
  • Longitude in degrees.

    Declaration

    Swift

    public let longitude: Double
  • Optional altitude in meters. By convention, on iOS devices, altitude is set as meters relative to the mean sea level. On Android devices, altitude is set as meters relative to the WGS 84 reference ellipsoid.

    Declaration

    Swift

    public let altitude: Double?
  • Constructs a GeoCoordinates from the provided latitude, longitude and altitude values. Corrects values of lat and long if they exceed the ranges.

    Declaration

    Swift

    public init(latitude: Double, longitude: Double, altitude: Double)

    Parameters

    latitude

    Latitude in degrees. Positive value means Northern hemisphere. If the value is out of range of [-90.0, 90.0] it’s clamped to that range. NaN value is converted to 0.0.

    longitude

    Longitude in degrees. Positive value means Eastern hemisphere. If the value is out of range of [-180.0, 180.0] it’s replaced with a value within the range, representing effectively the same meridian. NaN value is converted to 0.0.

    altitude

    Altitude in meters. NaN value is converted to nil.

  • Constructs a GeoCoordinates from the provided latitude and longitude values. Corrects values of latitude and longitude if they exceed the ranges. Altitude set to nil.

    Declaration

    Swift

    public init(latitude: Double, longitude: Double)

    Parameters

    latitude

    Latitude in degrees. Positive value means Northern hemisphere. If the value is out of range of [-90.0, 90.0] it’s clamped to that range. NaN value is converted to 0.0.

    longitude

    Longitude in degrees. Positive value means Eastern hemisphere. If the value is out of range of [-180.0, 180.0] it’s replaced with a value within the range, representing effectively the same meridian. NaN value is converted to 0.0.

  • Computes distance (in meters) along the great circle between two coordinates. This method ignores altitude of both points.

    Declaration

    Swift

    public func distance(to point: GeoCoordinates) -> Double

    Parameters

    point

    Coordinates of the point to which the distance is computed.

    Return Value

    distance in meters.

  • Computes the coordinates of the interpolated location along the great circle between the two coordinates.

    The interpolation factor is clamped to the range [0.0, 1.0] where 0.0 identifies this GeoCoordinates and 1.0 indicates the other coordinates.

    The ratio between the distance to the interpolated coordinates and the distance to the other coordinates is approximately equal to the interpolation factor. When both coordinates have the altitude, then the altitude is interpolated as well; nil otherwise.

    Declaration

    Swift

    public func interpolate(toward towardCoords: GeoCoordinates, by factor: Double) -> GeoCoordinates

    Parameters

    towardCoords

    Coordinates of the point to which the interpolation is directed.

    factor

    The interpolation factor

    Return Value

    interpolated coordinates

  • Constructs GeoCoordinates from the provided string in specified format. Corrects values of lat and long if they exceed the ranges. If the latitude value is out of range of [-90.0, 90.0] it’s clamped to that range. If the longitude value is out of range of [-180.0, 180.0] it’s replaced with a value within the range, representing effectively the same meridian. Examples: 53.43762,-13.65468. 49°59'56.948"N, 15°48'22.989"E 50d4m17.698N 14d24m2.826E 49.9991522N, 150.8063858E 40°26′47″N 79°58′36″W

    Declaration

    Swift

    public static func fromString(input: String) -> GeoCoordinates?

    Parameters

    input

    String representing GeoCoordinates in one of supported formats.

    Return Value

    Created GeoCoordinates, or ‘null’ if string was not in appropriate format.

  • Undocumented

    Declaration

    Swift

    static func == (lhs: GeoCoordinates, rhs: GeoCoordinates) -> Bool