Repository navigation
Allows setting finite u-turn costs. - #1672
Conversation
…files are aligned.
# Conflicts: # core/files/changelog.txt
# Conflicts: # core/src/main/java/com/graphhopper/GraphHopper.java
# Conflicts: # core/files/changelog.txt # core/src/main/java/com/graphhopper/storage/CHGraphImpl.java # core/src/test/java/com/graphhopper/storage/GraphHopperStorageCHTest.java
# Conflicts: # core/files/changelog.txt # core/src/main/java/com/graphhopper/routing/ch/CHAlgoFactoryDecorator.java
# Conflicts: # core/files/changelog.txt # core/src/main/java/com/graphhopper/routing/ch/CHAlgoFactoryDecorator.java # reader-osm/src/test/java/com/graphhopper/GraphHopperIT.java
| throw new CHProfileSelectionException("Cannot find CH profile for weighting map " + weightingMap + " in entries: " + entriesStrs + "."); | ||
| } | ||
|
|
||
| if (edgeBased != null && uTurnCosts != null) { |
There was a problem hiding this comment.
This is again quite a bit of nesting (even though its spread over different methods), but I thought this way it is easier to be sure we cover all the possible cases ? wdyt ?
There was a problem hiding this comment.
Looks fine due to the named cases IMO
|
I think I am happy with forbidding u-turns at virtual nodes. I added a comment to the docs stating that the u-turn penalty is time-based and therefore only works with time-based weightings, like fastest here: 3fafe81. Is this sufficient or should there be a more prominent warning (maybe at the place where the Should this go into |
| try { | ||
| return CHProfileSelector.select(chProfiles, map, edgeBased, uTurnCosts); | ||
| } catch (CHProfileSelectionException e) { | ||
| throw new IllegalArgumentException(e.getMessage()); |
There was a problem hiding this comment.
Is the checked exception CHProfileSelectionException required? Couldn't we let it extend DetailedIllegalArgumentException and avoid this method here and the 'throws CHProfileSelectionException' in a few methods? Or do you want it to be explicit? (I try to avoid checked exception as they are not often very helpful IMO)
There was a problem hiding this comment.
Ok, I changed it to a runtime exception. I do not necessarily think checked exceptions are never helpful because they give you a compile time check that helps you remembering to handle the error cases (for example here I think this is more of an advantage than it is a disadvantage that some 'intermediate' methods need to declare the exception). Anyway, either way is fine for me 👍.
|
Is this sufficient or should there be a more prominent warning (maybe at the place where the u_turn_costs parameter is documented ? Should we document it already ? Yes. May in ch.md and in the config-example.yml?
Sure 👍 - Thanks! |
Its in turn-restrictions.md and config-example.yml now |
This PR is based on #1671
With this PR it is possible to allow u-turns at some cost (when edge-based routing is enabled). On the request we have to specify, e.g.,
u_turn_costs=40which means each u-turn that the route takes adds40sto the overall travelling time. This only really makes sense as long as the weighting is based on time, likeFastestWeighting. See also #1590.Maybe this needs a bit of further thought and the u-turn costs should only be possible to apply if the weighting is time-based. Maybe we should deal with #1590 first ? Or just add some documentation and declare this parameter as experimental ?
However the largest part of this PR is about CH with finite u-turn costs. As for CH the u-turn costs must be specified in advance. This is done via the new
CHProfilefrom #1671.In config.yml the new configuration looks like this:
Fixes #1652, also see discussion there.