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
latitudeLatitude 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.
longitudeLongitude 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.
altitudeAltitude 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
latitudeLatitude 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.
longitudeLongitude 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) -> DoubleParameters
pointCoordinates 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]where0.0identifies thisGeoCoordinatesand1.0indicates 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;
nilotherwise.Declaration
Swift
public func interpolate(toward towardCoords: GeoCoordinates, by factor: Double) -> GeoCoordinatesParameters
towardCoordsCoordinates of the point to which the interpolation is directed.
factorThe 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"E50d4m17.698N 14d24m2.826E49.9991522N, 150.8063858E40°26′47″N 79°58′36″WDeclaration
Swift
public static func fromString(input: String) -> GeoCoordinates?Parameters
inputString 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