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

Document that avoiding tunnels is unsupported #665

Closed
1ec5 opened this issue Mar 16, 2022 · 2 comments
Closed

Document that avoiding tunnels is unsupported #665

1ec5 opened this issue Mar 16, 2022 · 2 comments

Comments

@1ec5
Copy link
Contributor

1ec5 commented Mar 16, 2022

RouteOptions.roadClassesToAvoid accepts any value in RoadClass, including tunnel, but the Directions API doesn’t support excluding tunnels in its exclude parameter.

Originally, in #154, the assumption was that intersections.classes would only ever indicate classes that the request could exclude. Project-OSRM/osrm-backend#4812 broke this assumption, adding tunnel as a class but not an excludable class. #237 effectively added it as both.

We’ll eventually need to decouple the exclude parameter from the concept of road classes, due to changes like #662, but we can’t formally do that until v3.0.0 due to backwards compatibility concerns. For the time being, we’ll have to settle for updating this documentation comment to note that the option can only be used in the context of Intersection.outletRoadClasses, not RouteOptions.roadClassesToAllow or roadClassesToAvoid:

/**
The user must travel this segment of the route through a [tunnel](https://wiki.openstreetmap.org/wiki/Key:tunnel).
This option can only be used with `RouteOptions.roadClassesToAvoid`.
*/
public static let tunnel = RoadClasses(rawValue: 1 << 5)

We could also actively omit tunnel when converting RouteOptions to a request URL, but it doesn’t look like we do that for any other option that’s supported by only one of RouteOptions.roadClassesToAllow or roadClassesToAvoid. In general, we try to avoid client-side enforcement of server-side constraints, in case the Directions API relaxes those constraints in a future deployment or conditionally by user.

/ref mapbox/mapbox-java#709

@azarovalex
Copy link
Contributor

Will be fixed as part of this PR: #664

However, I decided to hardcode supported avoid and include road classes in the separate internal arrays, to filter omit unsupported road classes while creating a URL request.

@azarovalex
Copy link
Contributor

The PR with documentation update was merged

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants