Skip to content

fix: support Barrier Nodes for NavigateResponse - #2975

Merged
karussell merged 3 commits into
graphhopper:masterfrom
OlafFlebbeBosch:barrier
Apr 18, 2024
Merged

karussell merged 3 commits into
graphhopper:masterfrom
OlafFlebbeBosch:barrier

Conversation

@OlafFlebbeBosch

Copy link
Copy Markdown
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
Copy Markdown
Contributor Author

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

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
Copy Markdown
Contributor Author

Fixed rebaseing issue

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

Copy link
Copy Markdown
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
Copy Markdown
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
Copy Markdown
Contributor Author

@boldtrn

boldtrn commented Apr 17, 2024

Copy link
Copy Markdown
Member

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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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).

@boldtrn boldtrn left a comment

Copy link
Copy Markdown
Member

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
Copy Markdown
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.

@OlafFlebbeBosch OlafFlebbeBosch Apr 17, 2024 •

Copy link
Copy Markdown
Contributor Author

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

Copy link
Copy Markdown
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

@boldtrn boldtrn left a comment

Copy link
Copy Markdown
Member

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
@OlafFlebbeBosch
OlafFlebbeBosch deleted the barrier branch June 10, 2025 11:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants