Skip to content

Commit

Permalink
Apply suggestions from code review
Browse files Browse the repository at this point in the history
Co-authored-by: Ian Wagner <[email protected]>
  • Loading branch information
Archdoog and ianthetechie authored Oct 28, 2024
1 parent 0b62778 commit dd35901
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 11 deletions.
Original file line number Diff line number Diff line change
@@ -1,36 +1,39 @@
import Foundation

/// A Valhalla OSRM flavored annotations object.
public struct ValhallaOSRMAnnotation: Codable, Equatable, Hashable {
/// A Valhalla extended OSRM annotation object.
///
/// Describes attributes about a segment of an edge between two points
/// in a route step.
public struct ValhallaExtendedOSRMAnnotation: Codable, Equatable, Hashable {
enum CodingKeys: String, CodingKey {
case speedLimit = "maxspeed"
case speed
case distance
case duration
}

/// The speed limit for the current line segment.
/// The speed limit of the segment.
public let speedLimit: MaxSpeed?

/// The recommended travel speed in meters per second.
/// The estimated speed of travel for the segment, in meters per second.
public let speed: Double?

/// The distance in meters of the geometry line segment.
/// The distance in meters of the segment.
public let distance: Double?

/// The duration in seconds of the geometry line segment.
/// The estimated time to traverse the segment, in seconds.
public let duration: Double?
}

public extension AnnotationPublisher {
/// Create a Valhalla OSRM flavored annotation publisher
/// Create a Valhalla extended OSRM annotation publisher
///
/// - Parameter onError: An optional error closure (runs when a `DecoderError` occurs)
/// - Returns: The annotation publisher.
static func valhallaOSRM(
static func valhallaExtendedOSRM(
onError: @escaping (Error) -> Void = { _ in }
) -> AnnotationPublisher<ValhallaOSRMAnnotation> {
AnnotationPublisher<ValhallaOSRMAnnotation>(
) -> AnnotationPublisher<ValhallaExtendedOSRMAnnotation> {
AnnotationPublisher<ValhallaExtendedOSRMAnnotation>(
mapSpeedLimit: {
$0?.speedLimit?.measurementValue
},
Expand Down
2 changes: 1 addition & 1 deletion apple/Sources/FerrostarCore/Models/MaxSpeed.swift
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ public enum MaxSpeed: Codable, Equatable, Hashable {
}

/// There is no speed limit (it's unlimited, e.g. German Autobahn)
case none
case noLimit

/// The speed limit is not known.
case unknown
Expand Down

0 comments on commit dd35901

Please sign in to comment.