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:
## Routing Web API Docs
In order to communicate with your or [our](http://graphhopper.com/#enterprise) hosted GraphHopper
server you need to understand how to use it. There is a separate [JavaScript](https://github.com/graphhopper/directions-api-js-client) and [Java](https://github.com/graphhopper/directions-api-java-client) client for this API or use the plain JSON response for your language.
To find out how to use the hosted GraphHopper Directions API you should refer to the online documentation [here](https://docs.graphhopper.com/). This file describes the web API of the open source routing server.
### A simple example
[http://localhost:8989/route?point=52.5300591%2C13.3565022&point=52.5060440%2C13.4378107](http://localhost:8989/route?point=52.5300591%2C13.3565022&point=52.5060440%2C13.4378107)
The URL path of the local instance is [http://localhost:8989](http://localhost:8989)
The endpoint to obtain the route is `/route` via GET.
## HTTP POST
The GET request has an URL length limitation, so it won't work for many locations per request. In those cases use a HTTP POST request with JSON data as input. The POST request is identical except that all singular parameter names are named as their plural for a POST request. All effected parameters are: `points`, `snap_preventions`, `curbsides` and `point_hints`. (`details` stays `details`)
Please note that unlike to the GET endpoint, points are specified in `[longitude, latitude]` order. For example `point=10,11&point=20,22` will be the following JSON:
```json
This file has been truncated. show original
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,
otbutz
August 25, 2022, 9:08am
4
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.
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"
system
Closed
November 23, 2022, 9:36am
8
This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.