Skip to content

Commit

Permalink
Merge pull request #2124 from mapbox/maxspeedAnnotationsCheckForSpeed…
Browse files Browse the repository at this point in the history
…LimitData

Guard against missing speed limit data when speed limit is queried for
  • Loading branch information
avi-c authored May 9, 2019
2 parents a3b7861 + 08fcc09 commit 4b35798
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 5 deletions.
7 changes: 3 additions & 4 deletions MapboxCoreNavigation/NavigationRouteOptions.swift
Original file line number Diff line number Diff line change
Expand Up @@ -83,10 +83,9 @@ open class NavigationMatchOptions: MatchOptions {
includesSteps = true
routeShapeResolution = .full
shapeFormat = .polyline6
if profileIdentifier == .walking {
attributeOptions = [.congestionLevel, .expectedTravelTime]
} else {
attributeOptions = [.congestionLevel, .expectedTravelTime, .maximumSpeedLimit]
attributeOptions = [.congestionLevel, .expectedTravelTime]
if profileIdentifier == .automobile || profileIdentifier == .automobileAvoidingTraffic {
attributeOptions.insert(.maximumSpeedLimit)
}
includesSpokenInstructions = true
locale = Locale.nationalizedCurrent
Expand Down
2 changes: 1 addition & 1 deletion MapboxCoreNavigation/RouteProgress.swift
Original file line number Diff line number Diff line change
Expand Up @@ -258,7 +258,7 @@ open class RouteProgress: NSObject {
Returns the SpeedLimit for the current position along the route. Returns SpeedLimit.invalid if the speed limit is unknown or missing.
*/
public var currentSpeedLimit: SpeedLimit {

guard legIndex < positionedSpeedLimitsByStep.count, currentLegProgress.stepIndex < positionedSpeedLimitsByStep[legIndex].count else { return .invalid }
let speedLimits = positionedSpeedLimitsByStep[legIndex][currentLegProgress.stepIndex]
let lastSpeedLimitTuple = speedLimits.last { $0.1 <= currentLegProgress.currentStepProgress.distanceTraveled }
if let lastSpeedLimitTuple = lastSpeedLimitTuple {
Expand Down

0 comments on commit 4b35798

Please sign in to comment.