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

Add rotary and use lane types #93

Merged
merged 6 commits into from Nov 15, 2016
Merged

Add rotary and use lane types #93

merged 6 commits into from Nov 15, 2016

Conversation

freenerd
Copy link
Contributor

@freenerd freenerd commented Nov 9, 2016

These two types were not present yet.

@1ec5 What other changes are required to bring these types in?

@1ec5
Copy link
Contributor

1ec5 commented Nov 9, 2016

This fixes #79.

@1ec5
Copy link
Contributor

1ec5 commented Nov 9, 2016

We’ll need to add support for the rotary_name type as well. Let’s land #91 first; then we can either add a junctionNames property on RouteStep or add a heuristic for rotaries that puts name in the destinations property and rotary_name in the names property, for consistency with ramps.

@freenerd
Copy link
Contributor Author

freenerd commented Nov 9, 2016

we can either add a junctionNames property on RouteStep
add a heuristic for rotaries that puts name in the destinations property and rotary_name in the names property, for consistency with ramps.

For integrating osrm-text-instructions it will be more useful to have direct access to the rotary_name property. I'd rather not have heuristics that mangle with properties, but instead retain the original response structure in the object and add helper functions that return heuristically-derived results

@1ec5
Copy link
Contributor

1ec5 commented Nov 9, 2016

For integrating osrm-text-instructions it will be more useful to have direct access to the rotary_name property.

Direct equivalence to JSON properties is a non-goal for this library, but #60 would keep the original serialized JSON around for anyone who finds it useful. The tradeoff in that case is higher memory usage.

Once #91 lands, the logic I’m proposing for RouteStep would look something like this:

if maneuverType == .rotary {
    destinations = road.names ?? road.destinations
    names = road.rotaryNames
} else {
    destinations = road.destinations
    names = road.rotaryNames
}

I don’t consider this to be “mangling”, since you can easily reverse this logic:

if maneuverType == .rotary {
    rotaryName = step.names.componentsJoined(by: ";")
    name = step.destinations.componentsJoined(by: ";")
} else {
    destination = step.destinations.componentsJoined(by: ";")
    name = step.names.componentsJoined(by: ";")
}

The only problematic case would be for a rotary tagged with destination, but the destination tag seems ill-suited to rotaries anyways.

You’ll probably have a lot more difficulty reversing the logic in #91 that deals with ref, but again, the point was never to match the Directions API response one-for-one.

@freenerd
Copy link
Contributor Author

destinations = road.names ?? road.destinations

This will be problematic for instructions, since we loose semantic if destinations is names or destinations. For the difference, see this example:

                   "name": "Enter {rotary_name} and exit onto {way_name}",
                    "destination": "Enter {rotary_name} and exit towards {destination}"

Take this example:

{
  "rotary_name": "Dupont Circle",
  "name":  "6th Avenue",
}

If we only expose destination then the correct instruction Enter Dupont Circle and exit onto 6th Avenue would become Enter Dupont Circle and exit towards 6th Avenue.

@1ec5
Copy link
Contributor

1ec5 commented Nov 10, 2016

If we only expose destination then the correct instruction Enter Dupont Circle and exit onto 6th Avenue would become Enter Dupont Circle and exit towards 6th Avenue.

As I pointed out in #93 (comment), I think you can safely ignore the destination for rotary instructions and interpret the destinations property as the exit name instead.

@1ec5
Copy link
Contributor

1ec5 commented Nov 10, 2016

An alternative would be to put rotary_name into the name property and name into a new exitName property (so named for consistency with exitIndex). If we go that route, we should consider putting name into exitName and leaving name empty for roundabout instructions.

@freenerd
Copy link
Contributor Author

freenerd commented Nov 10, 2016

@1ec5 This sounds good to me, since all information is carried through and no semantics are lost. To paraphrase:

if type == .rotary || type == .roundabout {
  step.name = json.rotary_name
  step.destinations = json.destinations
  step.exitName = json.name // empty on .roundabout
}

@1ec5
Copy link
Contributor

1ec5 commented Nov 10, 2016

Yes, that’s the idea. My only reservation is that there’s already a proliferation of road attribute properties on RouteStep. Ideally we’d shunt them all into a struct, but that won’t bridge to Objective-C; meanwhile, an Objective-C class would be overkill. But if it helps us rationalize our naming logic, then so be it.

I’m assuming we don’t want this behavior for TurnAtRoundabout since it’s supposed to be similar to an ordinary intersection.

freenerd added a commit that referenced this pull request Nov 10, 2016
freenerd added a commit that referenced this pull request Nov 11, 2016
@1ec5 1ec5 self-assigned this Nov 15, 2016
@1ec5
Copy link
Contributor

1ec5 commented Nov 15, 2016

bcca7e0 implements the approach described in #93 (comment). Ready for review.

Copy link
Contributor Author

@freenerd freenerd left a comment

Choose a reason for hiding this comment

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

🎉 i can't approve my own PR, but let's get this out

*/
case TakeRoundabout

/**
The step requires the user to enter, traverse, and exit a large, named roundabout (traffic circle or rotary).

The step’s name is the name of the road to take after exiting the roundabout. The exit index indicates the number of rotary exits up to and including the exit that the user must take.
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think this is different now with exitNames.

The step's name is the name of the rotary itself. The exit name is the name of the road to take after exiting the roundabout.

It isn’t just one of your holiday games;
You may think at first I’m as mad as a hatter
When I tell you, a roundabout maneuver must have two different names.
@1ec5 1ec5 merged commit a241f3a into master Nov 15, 2016
@1ec5 1ec5 deleted the rotary-use-lane-types branch November 15, 2016 20:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants