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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draw slight left/right lanes #1270

Merged
merged 5 commits into from
Apr 4, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@

## master

### User Interface

* Draws slight right and left turn icons for slight turns in the turn lane view. [#1270](https://github.com/mapbox/mapbox-navigation-ios/pull/1270)

### Core Navigation

* Fixed a crash that was caused by check the edit distance of an empty string. [#1281](https://github.com/mapbox/mapbox-navigation-ios/pull/1281/)
Expand Down
2 changes: 1 addition & 1 deletion Cartfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
binary "https://www.mapbox.com/ios-sdk/Mapbox-iOS-SDK.json" ~> 3.7
github "mapbox/MapboxDirections.swift" ~> 0.19.0
github "mapbox/MapboxDirections.swift" ~> 0.19.1
github "mapbox/turf-swift" ~> 0.0.3
github "mapbox/mapbox-events-ios" ~> 0.3
github "ceeK/Solar" ~> 2.1.0
Expand Down
2 changes: 1 addition & 1 deletion Cartfile.resolved
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
binary "https://www.mapbox.com/ios-sdk/Mapbox-iOS-SDK.json" "3.7.6"
github "ceeK/Solar" "2.1.0"
github "mapbox/MapboxDirections.swift" "v0.19.0"
github "mapbox/MapboxDirections.swift" "v0.19.1"
github "mapbox/mapbox-events-ios" "v0.3.1"
github "mapbox/mapbox-voice-swift" "v0.0.1"
github "mapbox/turf-swift" "v0.0.4"
Expand Down
2 changes: 1 addition & 1 deletion MapboxCoreNavigation.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ Pod::Spec.new do |s|
s.requires_arc = true
s.module_name = "MapboxCoreNavigation"

s.dependency "MapboxDirections.swift", "~> 0.19.0"
s.dependency "MapboxDirections.swift", "~> 0.19.1"
s.dependency "MapboxMobileEvents", "~> 0.3"
s.dependency "Turf", "~> 0.0.4"

Expand Down
2 changes: 1 addition & 1 deletion MapboxNavigation-Documentation.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ Pod::Spec.new do |s|
s.requires_arc = true
s.module_name = "MapboxNavigation"

s.dependency "MapboxDirections.swift", "~> 0.19.0"
s.dependency "MapboxDirections.swift", "~> 0.19.1"
s.dependency "Mapbox-iOS-SDK", "~> 3.6"
s.dependency "MapboxMobileEvents", "~> 0.3"
s.dependency "Solar", "~> 2.1"
Expand Down
53 changes: 44 additions & 9 deletions MapboxNavigation/LaneView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -39,26 +39,42 @@ open class LaneView: UIView {
if lane.indications.isSuperset(of: [.straightAhead, .sharpRight]) || lane.indications.isSuperset(of: [.straightAhead, .right]) || lane.indications.isSuperset(of: [.straightAhead, .slightRight]) {
flipLane = false
if !isValid {
LanesStyleKit.drawLane_straight_right(primaryColor: appropriatePrimaryColor)
if lane.indications == .slightRight {
LanesStyleKit.drawLane_slight_right(primaryColor: appropriatePrimaryColor)
} else {
LanesStyleKit.drawLane_straight_right(primaryColor: appropriatePrimaryColor)
}
alpha = invalidAlpha
} else if maneuverDirection == .straightAhead {
LanesStyleKit.drawLane_straight_only(primaryColor: appropriatePrimaryColor, secondaryColor: secondaryColor)
} else if maneuverDirection == .sharpLeft || maneuverDirection == .left || maneuverDirection == .slightLeft {
LanesStyleKit.drawLane_right_h(primaryColor: appropriatePrimaryColor)
if lane.indications == .slightLeft {
LanesStyleKit.drawLane_slight_right(primaryColor: appropriatePrimaryColor)
} else {
LanesStyleKit.drawLane_right_h(primaryColor: appropriatePrimaryColor)
}
flipLane = true
} else {
LanesStyleKit.drawLane_right_only(primaryColor: appropriatePrimaryColor, secondaryColor: secondaryColor)
}
} else if lane.indications.isSuperset(of: [.straightAhead, .sharpLeft]) || lane.indications.isSuperset(of: [.straightAhead, .left]) || lane.indications.isSuperset(of: [.straightAhead, .slightLeft]) {
flipLane = true
if !isValid {
LanesStyleKit.drawLane_straight_right(primaryColor: appropriatePrimaryColor)
if lane.indications == .slightLeft {
LanesStyleKit.drawLane_slight_right(primaryColor: appropriatePrimaryColor)
} else {
LanesStyleKit.drawLane_straight_right(primaryColor: appropriatePrimaryColor)
}

alpha = invalidAlpha
} else if maneuverDirection == .straightAhead {
LanesStyleKit.drawLane_straight_only(primaryColor: appropriatePrimaryColor, secondaryColor: secondaryColor)
} else if maneuverDirection == .sharpRight || maneuverDirection == .right || maneuverDirection == .slightRight {
} else if maneuverDirection == .sharpRight || maneuverDirection == .right {
LanesStyleKit.drawLane_right_h(primaryColor: appropriatePrimaryColor)
flipLane = false
} else if maneuverDirection == .slightRight {
LanesStyleKit.drawLane_slight_right(primaryColor: appropriatePrimaryColor)
flipLane = false
} else {
LanesStyleKit.drawLane_right_only(primaryColor: appropriatePrimaryColor, secondaryColor: secondaryColor)
}
Expand All @@ -67,20 +83,31 @@ open class LaneView: UIView {
// Account for a configuation where there is no straight lane
// but there are at least 2 indications.
// In this situation, just draw a left/right arrow
if maneuverDirection == .sharpRight || maneuverDirection == .right || maneuverDirection == .slightRight {
if maneuverDirection == .sharpRight || maneuverDirection == .right {
LanesStyleKit.drawLane_right_h(primaryColor: appropriatePrimaryColor)
flipLane = false
} else if maneuverDirection == .slightRight {
LanesStyleKit.drawLane_slight_right(primaryColor: appropriatePrimaryColor)
flipLane = false
} else {
LanesStyleKit.drawLane_right_h(primaryColor: appropriatePrimaryColor)
flipLane = true
}
alpha = isValid ? 1 : invalidAlpha
} else if lane.indications.isSuperset(of: [.sharpRight]) || lane.indications.isSuperset(of: [.right]) || lane.indications.isSuperset(of: [.slightRight]) {
LanesStyleKit.drawLane_right_h(primaryColor: appropriatePrimaryColor)
if lane.indications == .slightRight {
LanesStyleKit.drawLane_slight_right(primaryColor: appropriatePrimaryColor)
} else {
LanesStyleKit.drawLane_right_h(primaryColor: appropriatePrimaryColor)
}
flipLane = false
alpha = isValid ? 1 : invalidAlpha
} else if lane.indications.isSuperset(of: [.sharpLeft]) || lane.indications.isSuperset(of: [.left]) || lane.indications.isSuperset(of: [.slightLeft]) {
LanesStyleKit.drawLane_right_h(primaryColor: appropriatePrimaryColor)
if lane.indications == .slightLeft {
LanesStyleKit.drawLane_slight_right(primaryColor: appropriatePrimaryColor)
} else {
LanesStyleKit.drawLane_right_h(primaryColor: appropriatePrimaryColor)
}
flipLane = true
alpha = isValid ? 1 : invalidAlpha
} else if lane.indications.isSuperset(of: [.straightAhead]) {
Expand All @@ -95,10 +122,18 @@ open class LaneView: UIView {
// If the lane indication is `none` and the maneuver modifier has a turn in it,
// show the turn in the lane image.
if maneuverDirection == .sharpRight || maneuverDirection == .right || maneuverDirection == .slightRight {
LanesStyleKit.drawLane_right_h(primaryColor: appropriatePrimaryColor)
if maneuverDirection == .slightRight {
LanesStyleKit.drawLane_slight_right(primaryColor: appropriatePrimaryColor)
} else {
LanesStyleKit.drawLane_right_h(primaryColor: appropriatePrimaryColor)
}
flipLane = false
} else if maneuverDirection == .sharpLeft || maneuverDirection == .left || maneuverDirection == .slightLeft {
LanesStyleKit.drawLane_right_h(primaryColor: appropriatePrimaryColor)
if maneuverDirection == .slightLeft {
LanesStyleKit.drawLane_slight_right(primaryColor: appropriatePrimaryColor)
} else {
LanesStyleKit.drawLane_right_h(primaryColor: appropriatePrimaryColor)
}
flipLane = true
} else {
LanesStyleKit.drawLane_straight(primaryColor: appropriatePrimaryColor)
Expand Down
9 changes: 9 additions & 0 deletions MapboxNavigationTests/LaneTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -43,4 +43,13 @@ class LaneTests: FBSnapshotTestCase {
func testRightNone() {
assertLanes(step: steps[1])
}

func testSlightRight() {
let view = LaneView(frame: CGRect(origin: .zero, size: CGSize(width: 30, height: 30)))
view.backgroundColor = .white
view.lane = Lane(indications: [.slightRight])
view.maneuverDirection = .slightRight
view.isValid = true
FBSnapshotVerifyView(view)
}
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.