Skip to content

Commit

Permalink
Merge pull request #21 from flitsmeister/testings
Browse files Browse the repository at this point in the history
Modified rerouting logic so we also apply a similar slower route for when a trafficjam occurs
  • Loading branch information
Svantulden authored Nov 1, 2022
2 parents c3a3ed2 + edd2edb commit 16d4acd
Show file tree
Hide file tree
Showing 41 changed files with 29,238 additions and 805 deletions.
2 changes: 1 addition & 1 deletion Cartfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ github "mapbox/mapbox-events-ios" "v0.10.2"
github "mapbox/MapboxDirections.swift" ~> 0.23.0
github "mapbox/turf-swift" ~> 0.2
github "ceeK/Solar" ~> 2.1.0
github "mapbox/mapbox-voice-swift" ~> 0.0.1
github "mapbox/mapbox-voice-swift" ~> 0.0.1
3 changes: 2 additions & 1 deletion Cartfile.private
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
github "uber/ios-snapshot-test-case" ~> 4.0.0
github "Quick/Quick" ~> 2.2.0
github "Quick/Quick" ~> 3.0.0
github "Quick/Nimble" ~> 9.0.0
3 changes: 2 additions & 1 deletion Cartfile.resolved
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
github "Quick/Quick" "v2.2.1"
github "Quick/Nimble" "v9.2.1"
github "Quick/Quick" "v3.1.2"
github "ceeK/Solar" "2.2.0"
github "mapbox/MapboxDirections.swift" "v0.23.0"
github "mapbox/MapboxGeocoder.swift" "v0.10.2"
Expand Down
3 changes: 1 addition & 2 deletions Examples/Objective-C/ViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -127,8 +127,7 @@ - (void)startNavigation:(MBRoute *)route {
styles:nil
routeController:nil
locationManager:locationManager
voiceController:nil
eventsManager:nil];
voiceController:nil];
[self presentViewController:controller animated:YES completion:nil];

// Suspend notifications and let `MBNavigationViewController` handle all progress and voice updates.
Expand Down
5 changes: 0 additions & 5 deletions MapboxCoreNavigation/Constants.swift
Original file line number Diff line number Diff line change
Expand Up @@ -73,11 +73,6 @@ public var RouteControllerMinimumNumberLocationUpdatesBackwards = 3
*/
public var RouteControllerNumberOfSecondsForRerouteFeedback: TimeInterval = 10

/**
The number of seconds between attempts to automatically calculate a more optimal route while traveling.
*/
public var RouteControllerProactiveReroutingInterval: TimeInterval = 120

let FasterRouteFoundEvent = "navigation.fasterRoute"

//MARK: - Route Snapping (CLLocation)
Expand Down
19 changes: 19 additions & 0 deletions MapboxCoreNavigation/Route.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
//
// Route.swift
// MapboxCoreNavigation
//
// Created by Sander van Tulden on 28/10/2022.
// Copyright © 2022 Mapbox. All rights reserved.
//
import MapboxDirections

extension Route {
convenience init(jsonFileName: String, waypoints: [CLLocationCoordinate2D], polylineShapeFormat: RouteShapeFormat = .polyline6, bundle: Bundle = .main, accessToken: String) {
let convertedWaypoints = waypoints.compactMap { waypoint in
Waypoint(coordinate: waypoint)
}
let routeOptions = NavigationRouteOptions(waypoints: convertedWaypoints)
routeOptions.shapeFormat = polylineShapeFormat
self.init(json: Fixture.JSONFromFileNamed(name: jsonFileName, bundle: bundle), waypoints: convertedWaypoints, options: routeOptions)
}
}
252 changes: 211 additions & 41 deletions MapboxCoreNavigation/RouteController.swift

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions MapboxCoreNavigation/RouteControllerDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -50,10 +50,10 @@ public protocol RouteControllerDelegate: AnyObject {
- parameter routeController: The route controller that has calculated a new route.
- parameter route: The new route.
- parameter reroutingBecauseOfFasterRoute: If the reroute is because a faster route was found.
- parameter reason: Describes the reason of the reroute. Could be due to a faster route / updating ETA or when the user diverted from the suggested route
*/
@objc(routeController:didRerouteAlongRoute:reroutingBecauseOfFasterRoute:)
optional func routeController(_ routeController: RouteController, didRerouteAlong route: Route, reroutingBecauseOfFasterRoute: Bool)
@objc(routeController:didRerouteAlongRoute:reason:)
optional func routeController(_ routeController: RouteController, didRerouteAlong route: Route, reason: RouteController.RerouteReason)

/**
Called when the route controller fails to receive a new route.
Expand Down
5 changes: 4 additions & 1 deletion MapboxCoreNavigation/RouteProgress.swift
Original file line number Diff line number Diff line change
Expand Up @@ -512,7 +512,10 @@ open class RouteStepProgress: NSObject {
An `Array` of remaining `SpokenInstruction` for a step.
*/
@objc public var remainingSpokenInstructions: [SpokenInstruction]? {
guard let instructions = step.instructionsSpokenAlongStep else { return nil }
guard
let instructions = step.instructionsSpokenAlongStep,
spokenInstructionIndex <= instructions.endIndex
else { return nil }
return Array(instructions.suffix(from: spokenInstructionIndex))
}

Expand Down
Loading

0 comments on commit 16d4acd

Please sign in to comment.