Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update MapboxDirections, Maps, and SDWebImage #1040

Merged
merged 3 commits into from Jan 19, 2018
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion Cartfile
@@ -1,5 +1,5 @@
binary "https://www.mapbox.com/ios-sdk/Mapbox-iOS-SDK.json" ~> 3.7
github "mapbox/MapboxDirections.swift" ~> 0.15
github "mapbox/MapboxDirections.swift" ~> 0.16.0
github "mapbox/turf-swift" ~> 0.0.3
github "rs/SDWebImage" ~> 4.1
github "frederoni/aws-sdk-ios" ~> 2.6
Expand Down
6 changes: 3 additions & 3 deletions Cartfile.resolved
@@ -1,9 +1,9 @@
binary "https://www.mapbox.com/ios-sdk/Mapbox-iOS-SDK.json" "3.7.1"
binary "https://www.mapbox.com/ios-sdk/Mapbox-iOS-SDK.json" "3.7.3"
github "ceeK/Solar" "2.1.0"
github "facebook/ios-snapshot-test-case" "2.1.4"
github "frederoni/aws-sdk-ios" "2.6.5"
github "mapbox/MapboxDirections.swift" "v0.15.1"
github "mapbox/MapboxDirections.swift" "v0.16.0"
github "mapbox/mapbox-telemetry-ios" "v0.2.11"
github "mapbox/turf-swift" "v0.0.4"
github "raphaelmor/Polyline" "v4.2.0"
github "rs/SDWebImage" "4.2.2"
github "rs/SDWebImage" "4.2.3"
29 changes: 14 additions & 15 deletions Examples/Swift/CustomViewController.swift
Expand Up @@ -96,22 +96,21 @@ class CustomViewController: UIViewController, MGLMapViewDelegate, AVSpeechSynthe
func updateRouteProgress(routeProgress: RouteProgress) {
guard let step = routeProgress.currentLegProgress.upComingStep else { return }

if let direction = step.maneuverDirection {
switch direction {
case .slightRight:
self.arrowView.text = "↗️"
case .sharpRight, .right:
self.arrowView.text = "➡️"
case .slightLeft:
self.arrowView.text = "↖️"
case .sharpLeft, .left:
self.arrowView.text = "⬅️"
case .uTurn:
self.arrowView.text = "⤵️"
default:
self.arrowView.text = "⬆️"
}
switch step.maneuverDirection {
case .slightRight:
self.arrowView.text = "↗️"
case .sharpRight, .right:
self.arrowView.text = "➡️"
case .slightLeft:
self.arrowView.text = "↖️"
case .sharpLeft, .left:
self.arrowView.text = "⬅️"
case .uTurn:
self.arrowView.text = "⤵️"
default:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There's a subtle edge-case behavioral change here -- if step.maneuverDirection = nil, the arrow text becomes "⬆️".

That may be desirable, I just thought i should point this out.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, I think that’s fine. Our other option is ⏹. 😉

self.arrowView.text = "⬆️"
}

self.instructionLabel.text = routeProgress.currentLegProgress.currentStepProgress.step.instructionsDisplayedAlongStep?.first?.primaryText
let distance = routeProgress.currentLegProgress.currentStepProgress.distanceRemaining
self.distanceLabel.text = textDistanceFormatter.string(fromMeters: distance)
Expand Down
2 changes: 1 addition & 1 deletion MapboxCoreNavigation.podspec
Expand Up @@ -40,7 +40,7 @@ Pod::Spec.new do |s|
s.requires_arc = true
s.module_name = "MapboxCoreNavigation"

s.dependency "MapboxDirections.swift", "~> 0.15"
s.dependency "MapboxDirections.swift", "~> 0.16.0"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was the problem: we were specifying only the minor version, so the tadpole operator would float until the next major version (1.0). By contrast, Carthage intentionally violates semver by being more strict pre-1.0.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe worth changing now?

s.dependency "MapboxMobileEvents", "~> 0.2"
s.dependency "Turf", "~> 0.0.4"

Expand Down
8 changes: 4 additions & 4 deletions MapboxCoreNavigation/MMEEventsManager.swift
Expand Up @@ -332,12 +332,12 @@ extension RouteLegProgress {
get {
return [
"upcomingInstruction": upComingStep?.instructions ?? NSNull(),
"upcomingType": upComingStep?.maneuverType?.description ?? NSNull(),
"upcomingModifier": upComingStep?.maneuverDirection?.description ?? NSNull(),
"upcomingType": upComingStep?.maneuverType.description ?? NSNull(),
"upcomingModifier": upComingStep?.maneuverDirection.description ?? NSNull(),
"upcomingName": upComingStep?.names?.joined(separator: ";") ?? NSNull(),
"previousInstruction": currentStep.instructions,
"previousType": currentStep.maneuverType?.description ?? NSNull(),
"previousModifier": currentStep.maneuverDirection?.description ?? NSNull(),
"previousType": currentStep.maneuverType.description,
"previousModifier": currentStep.maneuverDirection.description,
"previousName": currentStep.names?.joined(separator: ";") ?? NSNull(),
"distance": Int(currentStep.distance),
"duration": Int(currentStep.expectedTravelTime),
Expand Down
7 changes: 1 addition & 6 deletions MapboxCoreNavigation/RouteStep.swift
Expand Up @@ -8,15 +8,10 @@ extension RouteStep {
finalHeading = leftFinalHeading == rightFinalHeading
}

var maneuverType = false
if let leftType = left.maneuverType, let rightType = right.maneuverType {
maneuverType = leftType == rightType
}

let maneuverType = left.maneuverType == right.maneuverType
let maneuverLocation = left.maneuverLocation == right.maneuverLocation

return maneuverLocation && maneuverType && finalHeading

}

/**
Expand Down
9 changes: 2 additions & 7 deletions MapboxCoreNavigationTests/MapboxCoreNavigationTests.swift
Expand Up @@ -107,16 +107,11 @@ class MapboxCoreNavigationTests: XCTestCase {
}

func testArrive() {
let bundle = Bundle(for: MapboxCoreNavigationTests.self)
let filePath = bundle.path(forResource: "tunnel", ofType: "json")!

let locations = Array<CLLocation>.locations(from: filePath)!
route.accessToken = "foo"
let locations: [CLLocation] = route.coordinates!.map { CLLocation(latitude: $0.latitude, longitude: $0.longitude) }
let locationManager = ReplayLocationManager(locations: locations)
locationManager.speedMultiplier = 20

let routeFilePath = bundle.path(forResource: "tunnel", ofType: "route")!
let route = NSKeyedUnarchiver.unarchiveObject(withFile: routeFilePath) as! Route
route.accessToken = "foo"
let navigation = RouteController(along: route, directions: directions, locationManager: locationManager)

expectation(forNotification: .routeControllerProgressDidChange, object: navigation) { (notification) -> Bool in
Expand Down
2 changes: 1 addition & 1 deletion MapboxCoreNavigationTests/routeWithInstructions.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion MapboxNavigation/InstructionsBannerView.swift
Expand Up @@ -88,7 +88,7 @@ open class BaseInstructionsBannerView: UIControl {
super.prepareForInterfaceBuilder()
maneuverView.isStart = true

primaryLabel.instruction = [VisualInstructionComponent(text: "Primary text label", imageURL: nil)]
primaryLabel.instruction = [VisualInstructionComponent(type: .destination, text: "Primary text label", imageURL: nil)]

distance = 100
}
Expand Down
4 changes: 2 additions & 2 deletions MapboxNavigation/ManeuverView.swift
Expand Up @@ -67,9 +67,9 @@ public class ManeuverView: UIView {
}

var flip: Bool = false
let type: ManeuverType = step.maneuverType ?? .turn
let type: ManeuverType = step.maneuverType != .none ? step.maneuverType : .turn
let angle = ((step.finalHeading ?? 0) - (step.initialHeading ?? 0)).wrap(min: -180, max: 180)
let direction: ManeuverDirection = step.maneuverDirection ?? ManeuverDirection(angle: Int(angle))
let direction: ManeuverDirection = step.maneuverDirection != .none ? step.maneuverDirection : ManeuverDirection(angle: Int(angle))

switch type {
case .merge:
Expand Down
2 changes: 1 addition & 1 deletion MapboxNavigation/NextBannerView.swift
Expand Up @@ -52,7 +52,7 @@ open class NextBannerView: UIView {
override open func prepareForInterfaceBuilder() {
super.prepareForInterfaceBuilder()
maneuverView.isEnd = true
instructionLabel.instruction = [VisualInstructionComponent(text: "Next step", imageURL: nil)]
instructionLabel.instruction = [VisualInstructionComponent(type: .destination, text: "Next step", imageURL: nil)]
}

func setupLayout() {
Expand Down
6 changes: 3 additions & 3 deletions MapboxNavigation/StepsViewController.swift
Expand Up @@ -207,22 +207,22 @@ extension StepsViewController: UITableViewDataSource {
let leg = routeProgress.route.legs[indexPath.section-1]
let stepBefore = leg.steps[leg.steps.count-1]
if let instructions = stepBefore.instructionsDisplayedAlongStep?.last {
let secondaryInstruction = step.maneuverType == .arrive && arrivalSecondaryInstruction != nil ? [VisualInstructionComponent(text: arrivalSecondaryInstruction, imageURL: nil)] : instructions.secondaryTextComponents
let secondaryInstruction = step.maneuverType == .arrive && arrivalSecondaryInstruction != nil ? [VisualInstructionComponent(type: .destination, text: arrivalSecondaryInstruction, imageURL: nil)] : instructions.secondaryTextComponents
cell.instructionsView.set(instructions.primaryTextComponents, secondaryInstruction: secondaryInstruction)
}
cell.instructionsView.distance = stepBefore.distance
} else {
let leg = routeProgress.route.legs[indexPath.section]
if let stepBefore = leg.steps.stepBefore(step) {
if let instructions = stepBefore.instructionsDisplayedAlongStep?.last {
let secondaryInstruction = step.maneuverType == .arrive && arrivalSecondaryInstruction != nil ? [VisualInstructionComponent(text: arrivalSecondaryInstruction, imageURL: nil)] : instructions.secondaryTextComponents
let secondaryInstruction = step.maneuverType == .arrive && arrivalSecondaryInstruction != nil ? [VisualInstructionComponent(type: .destination, text: arrivalSecondaryInstruction, imageURL: nil)] : instructions.secondaryTextComponents
cell.instructionsView.set(instructions.primaryTextComponents, secondaryInstruction: secondaryInstruction)
}
cell.instructionsView.distance = stepBefore.distance
} else {
cell.instructionsView.distance = nil
if let instructions = step.instructionsDisplayedAlongStep?.last {
let secondaryInstruction = step.maneuverType == .arrive && arrivalSecondaryInstruction != nil ? [VisualInstructionComponent(text: arrivalSecondaryInstruction, imageURL: nil)] : instructions.secondaryTextComponents
let secondaryInstruction = step.maneuverType == .arrive && arrivalSecondaryInstruction != nil ? [VisualInstructionComponent(type: .destination, text: arrivalSecondaryInstruction, imageURL: nil)] : instructions.secondaryTextComponents
cell.instructionsView.set(instructions.primaryTextComponents, secondaryInstruction: secondaryInstruction)
}
}
Expand Down