Skip to content

Commit 4b35798

Browse files
authored
Merge pull request #2124 from mapbox/maxspeedAnnotationsCheckForSpeedLimitData
Guard against missing speed limit data when speed limit is queried for
2 parents a3b7861 + 08fcc09 commit 4b35798

File tree

2 files changed

+4
-5
lines changed

2 files changed

+4
-5
lines changed

MapboxCoreNavigation/NavigationRouteOptions.swift

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -83,10 +83,9 @@ open class NavigationMatchOptions: MatchOptions {
8383
includesSteps = true
8484
routeShapeResolution = .full
8585
shapeFormat = .polyline6
86-
if profileIdentifier == .walking {
87-
attributeOptions = [.congestionLevel, .expectedTravelTime]
88-
} else {
89-
attributeOptions = [.congestionLevel, .expectedTravelTime, .maximumSpeedLimit]
86+
attributeOptions = [.congestionLevel, .expectedTravelTime]
87+
if profileIdentifier == .automobile || profileIdentifier == .automobileAvoidingTraffic {
88+
attributeOptions.insert(.maximumSpeedLimit)
9089
}
9190
includesSpokenInstructions = true
9291
locale = Locale.nationalizedCurrent

MapboxCoreNavigation/RouteProgress.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -258,7 +258,7 @@ open class RouteProgress: NSObject {
258258
Returns the SpeedLimit for the current position along the route. Returns SpeedLimit.invalid if the speed limit is unknown or missing.
259259
*/
260260
public var currentSpeedLimit: SpeedLimit {
261-
261+
guard legIndex < positionedSpeedLimitsByStep.count, currentLegProgress.stepIndex < positionedSpeedLimitsByStep[legIndex].count else { return .invalid }
262262
let speedLimits = positionedSpeedLimitsByStep[legIndex][currentLegProgress.stepIndex]
263263
let lastSpeedLimitTuple = speedLimits.last { $0.1 <= currentLegProgress.currentStepProgress.distanceTraveled }
264264
if let lastSpeedLimitTuple = lastSpeedLimitTuple {

0 commit comments

Comments
 (0)