-
Notifications
You must be signed in to change notification settings - Fork 88
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
Add roadSide to RouteStep #219
Conversation
26c6dbd
to
9bc3d40
Compare
MapboxDirections/MBRouteStep.swift
Outdated
@objc(MBRoadSide) | ||
public enum RoadSide: Int, CustomStringConvertible { | ||
case left | ||
case right |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Although this is pretty self explanatory, can you document this class it's properties?
MapboxDirections/MBRouteStep.swift
Outdated
/** | ||
Indicates what side of a bidirectional road the driver must be driving on. Also referred to as the rule of the road. | ||
*/ | ||
open let roadSide: RoadSide? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This property is always returned, I think we can make this non-optional. Noting, it is in fact returned for biking/walking.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Making it optional will also allow it to bridge to Objective-C.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry, I meant non-optional. It should be non-optional.
MapboxDirections/MBRouteStep.swift
Outdated
@@ -557,6 +597,7 @@ open class RouteStep: NSObject, NSSecureCoding { | |||
let maneuverType = ManeuverType(description: maneuver["type"] as! String) | |||
let maneuverDirection = ManeuverDirection(description: maneuver["modifier"] as? String ?? "") | |||
let maneuverLocation = CLLocationCoordinate2D(geoJSON: maneuver["location"] as! [Double]) | |||
let roadSide = RoadSide(description: json["driving_side"] as! String) ?? .right |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unsure how to handle a nil
here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is it possible for any production profile to not provide a driving_side
property? If so, we would add an unknown
enumeration value. If not, we would assert or implicitly unwrap the optional.
Regarding the property’s name,
|
MapboxDirections/MBRouteStep.swift
Outdated
guard let roadSideDescription = decoder.decodeObject(of: NSString.self, forKey: "roadSide") as String?, let roadSide = RoadSide(description: roadSideDescription) else { | ||
return nil | ||
} | ||
self.roadSide = roadSide |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Will this be an issue for old routes that are encoded without a roadSide
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, let’s assume it’s right
if unspecified. That would match OSRM’s behavior prior to Project-OSRM/osrm-backend#4415.
/cc @danpat
|
@1ec5 I agree. To riff on this a little more, it's important to note that it might make sense to incorporate the word Maybe |
I think The more I think about this, the more comfortable I am with calling it In the end, I think developers will have to just read the documentation to understand this property, unless we call it something silly like |
👍 to |
@mapbox/navigation-ios this is ready for review. |
✅ LGTM but I can't approve. |
MapboxDirections/MBRouteStep.swift
Outdated
@@ -643,10 +643,10 @@ open class RouteStep: NSObject, NSSecureCoding { | |||
maneuverDirection = nil | |||
} | |||
|
|||
guard let roadSideDescription = decoder.decodeObject(of: NSString.self, forKey: "roadSide") as String?, let roadSide = RoadSide(description: roadSideDescription) else { | |||
guard let drivingSideDescription = decoder.decodeObject(of: NSString.self, forKey: "drivingSide") as String?, let drivingSide = DrivingSide(description: drivingSideDescription) else { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let’s default this value to right
if it’s unspecified, so that preexisting objects don’t suddenly fail to decode.
Fixes #212 - Add roadSide to RouteStep
Unblocks mapbox/mapbox-navigation-ios#909
@bsudekum @1ec5 👀