Repository navigation
Handle turn restrictions with multiple via ways and overlapping restrictions - #3030
Conversation
|
The concept is pretty simple, but covering all special cases is very tricky. If anyone is willing to do some testing this would be of huge help. By testing I mean checking out this branch, running an import and checking routes that are affected by different kinds of turn restrictions. Even collecting some of the more complicated working examples would be helpful. So far I used these profiles for testing car and hgv restrictions: profiles:
- name: car
weighting: custom
turn_costs:
vehicle_types: ["motor_vehicle", "motorcar"]
u_turn_costs: 160
custom_model:
priority:
- if: "!car_access"
multiply_by: "0"
speed:
- if: "true"
limit_to: "car_average_speed"
- name: car_hgv
weighting: custom
turn_costs:
vehicle_types: ["goods", "hgv", "motor_vehicle"]
u_turn_costs: 160
custom_model:
priority:
- if: "!car_access"
multiply_by: "0"
speed:
- if: "true"
limit_to: "car_average_speed"These overpass queries are useful to find turn relations: |
is there somewhere step-to-step guide? (AFAIK I have never compiled graphhopper) Looked at https://github.com/graphhopper/graphhopper/blob/master/CONTRIBUTING.md and it seems to have no such steps nor link to them https://github.com/graphhopper/graphhopper?tab=readme-ov-file#installation has for installation of released code (sorry if I missed it, I done quick check so far) |
With git, java and Maven installed it is just a matter of checking out the from the root directory. The binary will be created as # config.yml
graphhopper:
# download a map from Geofabrik or similar and set the path here
datareader.file: /path/to/your/map.osm.pbf
graph.location: your-map-gh
graph.encoded_values: car_access,car_average_speed
profiles:
- name: car
weighting: custom
turn_costs:
vehicle_types: ["motor_vehicle", "motorcar"]
u_turn_costs: 160
custom_model:
priority:
- if: "!car_access"
multiply_by: "0"
speed:
- if: "true"
limit_to: "car_average_speed"
- name: car_hgv
weighting: custom
turn_costs:
vehicle_types: ["goods", "hgv", "motor_vehicle"]
u_turn_costs: 160
custom_model:
priority:
- if: "!car_access"
multiply_by: "0"
speed:
- if: "true"
limit_to: "car_average_speed"
import.osm.ignored_highways: ''
prepare.min_network_size: 200
server:
register_default_exception_mappers: false
application_connectors:
- type: http
port: 8989
# for security reasons bind to localhost
bind_host: localhost
admin_connectors:
- type: http
port: 8988
bind_host: localhost
logging:
appenders:
- type: file
time_zone: UTC
current_log_filename: logs/graphhopper.log
log_format: "%d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n"
archive: true
archived_log_filename_pattern: ./logs/graphhopper%d.log.gz
archived_file_count: 30
never_block: true
- type: console
time_zone: UTC
log_format: "%d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n"
loggers:
"com.graphhopper.osm_warnings":
level: INFO
additive: false
appenders:
- type: file
currentLogFilename: logs/osm_warnings.log
archive: false
logFormat: '[%level] %msg%n'There are more detailed instructions here: https://github.com/graphhopper/graphhopper/blob/master/docs/core/quickstart-from-source.md but just let me know if the above instructions do not work. I can also upload the jar if needed. |
|
Thanks for keep working on this! I had a quick look over the changes as notices that
could you outline the concept in a few words or a sketch? In #2695 we thought about multiple artificial edges to support overlapping via way restrictions and multi via way restrictions. Is the approach now something completely different or close to multiple artificial edges? Here is the failing test I included to demonstrate the problem with multi via way restriction. Have you used this to test your new implementation?
|
No, it is still a very similar idea. The restrictions are implemented by adding artificial edges, but to handle multi-via and overlapping restrictions we do need to add multiple artificial copies of an edge, indeed. More precisely, there is now one artificial edge for every different incoming edge that is part of a restriction. This means there can be several paths leading to an edge that encode the different possible origins of the path. This way the routing algorithm 'knows' multiple previous steps only by looking at the previous edge and can apply the turn restrictions accordingly. The details become rather tricky, though (best seen in code).
I added a few tests, but not this one exactly. But if you don't mind I will pick some of your tests and explanations to this branch. |
so previously there was only one artificial
Of cause feel free to take anything you need from the previous PR :) |
There are two. One that the route is forced to use when coming from a, and one the route is forced to use when coming from e. The original edge would only be used for other incoming edges for which there are no restrictions. |
|
okay great and if there would be another restriction
|
Generally, yes, if we needed to distinguish whether the route is coming from |
This reverts commit 1f6205c.
# Conflicts: # core/src/main/java/com/graphhopper/reader/osm/OSMReader.java
This PR extends the turn restriction support to restrictions with multiple and/or overlapping via-edges. These include OSM turn relations with multiple via-ways, turn relations with a single via-way that are crossed by other ways (such that they must be split into multiple edges for routing) and turn relations that could not be handled so far because they share a common via-way.
Fixes
#446#3155Closes #2695
Here are some examples:
overlapping via-way restrictions, with via-ways pointing in the same restriction (ignored so far): rel1, rel2, route
overlapping no-straight-on and no-u-turn, via-ways pointing in the same direction (ignored so far): rel1, rel2, route
two via-ways (because via-way is split into two for some reason): rel route
straight-ahead-only with two via-ways: rel route
straight-ahead-only with three via-ways: rel route