How to prevent graphhopper from finding a route that it can't take

Hi everyone,
I’m facing a situation where graphhopper’s algorithm chooses to take the waterway, but in reality you want to take that route so you have to start from a far away stop. Is there a way to configure the algorithm so that the algorithm does not choose that waterway but chooses the road?
Current:

And I want it like this:


Thank you so much!

Yes, you can specify “snap_preventions”:[“ferry”] (or snap_prevention=ferry for the GET request) to avoid this:

1 Like

Can you explain in more detail? As I understand, this config will make the algorithm skip the route search with type ferry. How can I configure the POST api?

Many thanks,

Snapping refers to the selection of start/end points. Your routing happens to select the ferry route as a startpoint. From there it can only follow it which yields this “strange” route.

2 Likes

Snapping refers to the selection of start/end points. Your routing happens to select the ferry route as a startpoint. From there it can only follow it which yields this “strange” route.

:+1:

As I wrote: "snap_preventions":["ferry"]

1 Like

Can I configure it in the config file?

No, this is not possible.

What you could do is the exclude ferries for routing in general using a custom profile: https://github.com/graphhopper/graphhopper/blob/master/docs/core/profiles.md#custom-profiles

using the following custom_model:

{
 "priority": [{
   "if": "road_environment == FERRY",
   "multiply_by": "0.0"
 }]
}

You can copy and paste this custom_model directly in the config.yml like this (make sure the starting bracket is on the line of the custom_model):

profiles:
  - name: my_custom_profile
    vehicle: car
    weighting: custom
    custom_model: {
     "priority": [{
       "if": "road_environment == FERRY",
       "multiply_by": "0.0"
     }]
    }

or the “pure” yml:

profiles:
  - name: my_custom_profile
    vehicle: car
    weighting: custom
    custom_model:
     priority:
       - "if": "road_environment == FERRY"
         "multiply_by": "0.0"   

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.