RSDDistanceRecord

public struct RSDDistanceRecord : RSDSampleRecord, RSDDelimiterSeparatedEncodable

A RSDDistanceRecord is a Codable implementation of RSDSampleRecord that can be used to record CoreLocation samples for use in determining distance travelled.

  • example:
    // Example json for a codable record.
    let json = """
               {
                "uptime" : 99652.677386361029,
                "relativeDistance" : 2.1164507282484935,
                "verticalAccuracy" : 3,
                "horizontalAccuracy" : 6,
                "stepPath" : "Cardio 12MT/run/runDistance",
                "course" : 76.873546882061802,
                "totalDistance" : 63.484948023273581,
                "speed" : 1.0289180278778076,
                "timestampDate" : "2018-01-04T23:49:34.135-08:00",
                "timestamp" : 210.47070598602295,
                "altitude" : 23.375564581136974
               }
               """.data(using: .utf8)! // our data in native (JSON) format
  • The absolute clock time.

    Declaration

    Swift

    public let uptime: TimeInterval?
  • Relative time to when the recorder was started.

    Declaration

    Swift

    public let timestamp: TimeInterval?
  • An identifier marking the current step.

    Declaration

    Swift

    public let stepPath: String
  • The date timestamp when the measurement was taken.

    Declaration

    Swift

    public let timestampDate: Date?
  • The Unix timestamp (seconds since 1970-01-01T00:00:00.000Z) when the measurement was taken.

    Declaration

    Swift

    public let timestampUnix: TimeInterval?
  • Returns the horizontal accuracy of the location in meters; nil if the lateral location is invalid.

    Declaration

    Swift

    public let horizontalAccuracy: Double?
  • Returns the lateral distance between the current location and the previous location in meters.

    Declaration

    Swift

    public let relativeDistance: Double?
  • Returns the latitude coordinate of the current location; nil if only relative distance should be recorded.

    Declaration

    Swift

    public let latitude: Double?
  • Returns the longitude coordinate of the current location; nil if only relative distance should be recorded.

    Declaration

    Swift

    public let longitude: Double?
  • Returns the vertical accuracy of the location in meters; nil if the altitude is invalid.

    Declaration

    Swift

    public let verticalAccuracy: Double?
  • Returns the altitude of the location in meters. Can be positive (above sea level) or negative (below sea level).

    Declaration

    Swift

    public let altitude: Double?
  • Sum of the relative distance measurements if the participant is supposed to be moving. Otherwise, this value will be nil.

    Declaration

    Swift

    public let totalDistance: Double?
  • Returns the course of the location in degrees true North; nil if course is invalid.

    • Range: 0.0 - 359.9 degrees, 0 being true North.

    Declaration

    Swift

    public let course: Double?
  • Returns the bearing to the location from the previous location in radians (clockwise from) true North.

    • Range: [0.0..2π), 0 being true North.

    Declaration

    Swift

    public let bearingRadians: Double?
  • Returns the speed of the location in meters/second; nil if speed is invalid.

    Declaration

    Swift

    public let speed: Double?
  • Returns the floor of the building where the location was recorded; nil if floor is not available.

    Declaration

    Swift

    public let floor: Int?
  • Default initializer.

    Declaration

    Swift

    public init(uptime: TimeInterval?, timestamp: TimeInterval?, stepPath: String, location: CLLocation, previousLocation: CLLocation?, totalDistance: Double?, relativeDistanceOnly: Bool = true)

    Parameters

    uptime

    The clock uptime.

    timestamp

    Relative time to when the recorder was started.

    stepPath

    An identifier marking the current step.

    location

    The CLLocation to record.

    previousLocation

    The previous CLLocation or nil if this is the first sample.

    totalDistance

    Sum of the relative distance measurements.

    relativeDistanceOnly

    Whether or not only relative distance should be recorded. Default = true

  • Declaration

    Swift

    public static func codingKeys() -> [CodingKey]