RLMDistance

Objective-C

@interface RLMDistance : NSObject

Swift

class RLMDistance : NSObject, @unchecked Sendable

This structure is a helper to represent/convert a distance. It can be used in geospatial queries like those represented by a RLMGeospatialCircle

Warning

This structure cannot be persisted and can only be used to build other geospatial shapes
  • The distance in radians.

    Declaration

    Objective-C

    @property (readonly) double radians;

    Swift

    var radians: Double { get }
  • Constructs a Distance.

    Returns nil if the value is lower than 0, because we cannot construct negative distances.

    Declaration

    Objective-C

    + (nullable instancetype)distanceFromKilometers:(double)kilometers;

    Swift

    class func kilometers(_ kilometers: Double) -> Self?

    Parameters

    kilometers

    Distance in kilometers. @returns A value that represents the provided distance in radians.

  • Constructs a Distance.

    Returns nil if the value is lower than 0, because we cannot construct negative distances.

    Declaration

    Objective-C

    + (nullable instancetype)distanceFromMiles:(double)miles;

    Swift

    class func miles(_ miles: Double) -> Self?

    Parameters

    miles

    Distance in miles.

    Return Value

    A value that represents the provided distance in radians.

  • Constructs a Distance.

    Returns nil if the value is lower than 0, because we cannot construct negative distances.

    Declaration

    Objective-C

    + (nullable instancetype)distanceFromDegrees:(double)degrees;

    Swift

    class func degrees(_ degrees: Double) -> Self?

    Parameters

    degrees

    Distance in degrees. @returns A value that represents the provided distance in radians.

  • Constructs a Distance.

    Returns nil if the value is lower than 0, because we cannot construct negative distances.

    Declaration

    Objective-C

    + (nullable instancetype)distanceFromRadians:(double)radians;

    Swift

    class func radians(_ radians: Double) -> Self?

    Parameters

    radians

    Distance in radians. @returns A value that represents the provided distance in radians.

  • Returns the current Distance value in kilometers.

    @returns The value un kilometers.

    Declaration

    Objective-C

    - (double)asKilometers;

    Swift

    func asKilometers() -> Double
  • Returns the current Distance value in miles.

    @returns The value un miles.

    Declaration

    Objective-C

    - (double)asMiles;

    Swift

    func asMiles() -> Double
  • Returns the current Distance value in degrees.

    @returns The value un degrees.

    Declaration

    Objective-C

    - (double)asDegrees;

    Swift

    func asDegrees() -> Double