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

fix: support Barrier Nodes for NavigateResponse #2975

Merged
merged 3 commits into from
Apr 18, 2024

Conversation

OlafFlebbeBosch
Copy link
Contributor

Supplying a route with Intersections located on the same spot, connected with a zero length edge seems to confuse Mapbox like APIs. This can happen if there are barriers on the route, which are split into two intersections connected by a zero length edge. The idea is to find these intersections and merge all the edges of both intersections and remove the out outgoing edge of the connecting edge from the first and the in edge of the incoming edge for the connection.

Patch is rather large unfortunately because of reformatting based on editorconfig.

@OlafFlebbeBosch OlafFlebbeBosch marked this pull request as draft April 16, 2024 14:18
@OlafFlebbeBosch
Copy link
Contributor Author

Converted to DRAFT. There seem to be errors due to rebasing

Verified

This commit was signed with the committer’s verified signature. The key has expired.
karussell Peter
Supplying a route with Intersections located on the same spot, connected with a zero length edge seems
to confuse Mapbox like APIs. This can happen if there are barriers on the route, which are split into
two intersections connected by a zero length edge.
The idea is to find these intersections and merge all the edges of both intersections and remove the
out outgoing edge of the connecting edge from the first and the in edge of the incoming edge.
@OlafFlebbeBosch
Copy link
Contributor Author

Fixed rebaseing issue

@OlafFlebbeBosch OlafFlebbeBosch marked this pull request as ready for review April 16, 2024 14:26
@karussell
Copy link
Member

From my side this looks good and can be merged. Do you have some examples where this currently happens?

@boldtrn any objections?

@OlafFlebbeBosch
Copy link
Contributor Author

The newly introduced unittest barrierTest in NavigateResponseConverterTest is triggering the issue while
commenting out lines 197 to end of (excluding return) of filterIntersectionDetails NavigateResponseConverter .

However I have to admit that I have issues to reproduce the issue ad hoc on routes like https://graphhopper.com/maps/?point=55.720661%2C13.213068&point=55.720375%2C13.213033&profile=bike&layer=Omniscale
where mapbox previously tripped over the kerbs https://www.openstreetmap.org/node/10233057887 and https://www.openstreetmap.org/node/10233057888 . Please let me investigate this again .

@OlafFlebbeBosch
Copy link
Contributor Author

Was tripping over my own feet :)

The issue can be seen in sweden:

https://graphhopper.com/api/1/navigate/directions/v5/gh/bike/13.2130268,55.7206509;13.2130345,55.7204650?geometries=polyline6&steps=true&roundabout_exits=true&voice_instructions=true&banner_instructions=true&key=xxx

The 2nd/3rd and 4th/5th are located on the same point . The PR fixes this.

@boldtrn
Copy link
Member

boldtrn commented Apr 17, 2024

Thanks a lot for providing this PR @OlafFlebbeBosch. I can also reproduce the issue at different places on GraphHopper.com 👍.

IMHO we should not have two intersections at the same coordinate with incorrect bearings, so this fix makes sense to me. While I also think that clients should not crash due to that, it is good if we can fix this issue here as well :).

Integer out = (Integer) intersectionMap.get("out");
List<Boolean> entry = (List<Boolean>) intersectionMap.get("entries");

if (bearings.size() != entry.size()) {
Copy link
Member

Choose a reason for hiding this comment

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

I am not sure about this case, so this is an error case, right? Should we return silent? Or should we at least log the error or even throw an IllegalStateException? This should never happen right?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

AFAIK this should never happen. Not sure what is an appropriate reaction on that. I wasn't aware that IllegalStateException is a RuntimeException, so we do not need to attribute each throw , which is good.
But I can create an Logger instance and Log it as well... Please advise me here.

Copy link
Member

Choose a reason for hiding this comment

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

Yes, this should result in a HTTP request with response code 400, as Dropwizard catches this. Since we believe this should never happen, I'd say let's throw an exception at least (and maybe even log the result).

Copy link
Member

@boldtrn boldtrn left a comment

Choose a reason for hiding this comment

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

Could you clarify the error case where the sizes don't match? Otherwise this change looks good to me 👍

Comment on lines +67 to +70
intersection.put("bearings",
list.stream().map(x -> x.bearing).collect(Collectors.toList()));
intersection.put("entries",
list.stream().map(x -> x.entry).collect(Collectors.toList()));
Copy link
Contributor

Choose a reason for hiding this comment

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

Not that it matters that much, but the old implementation is more efficient. This adds two more list iterations.

Copy link
Contributor Author

@OlafFlebbeBosch OlafFlebbeBosch Apr 17, 2024

Choose a reason for hiding this comment

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

Indeed. But I think the runtime costs it will be overshadowed by list allocation, which is needed anyway.

OlafFlebbeBosch and others added 2 commits April 17, 2024 17:11

Verified

This commit was signed with the committer’s verified signature. The key has expired.
karussell Peter
…lues.java

Co-authored-by: Robin <boldtrn@users.noreply.github.com>

Verified

This commit was signed with the committer’s verified signature. The key has expired.
karussell Peter
@OlafFlebbeBosch
Copy link
Contributor Author

Could you clarify the error case where the sizes don't match? Otherwise this change looks good to me 👍

Throwing now an IllegalstateException for this "should not happen" case

Copy link
Member

@boldtrn boldtrn left a comment

Choose a reason for hiding this comment

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

Thanks the PR looks good to me 👍

@karussell karussell merged commit 4c21dd6 into graphhopper:master Apr 18, 2024
@karussell karussell added this to the 9.0 milestone Apr 18, 2024
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

4 participants