Don’t hesitate to contact us:
Forum: discuss.graphhopper.com
Email: support@graphhopper.com
In a previous post we described how to get started with customizable routing of the open source GraphHopper Routing Engine version 1.0. Today we’ll describe actual custom profiles by real world examples.
Disclaimer: custom profiles are considered a beta feature in at least version 1.0 and 2.0. Using them should be working, but details about the weight formula and the meaning of the different parameters is still subject to change. Also this feature will strongly benefit from community feedback, so do not hesitate with sharing your experience, custom profiles or problems you are running into! To share YAML files with us we suggest using a Github gist.
The format we use is in YAML that is accepted in the UI and also for the import. To use custom profiles per-request, against the endpoint /route-custom
, you need to use JSON. (For import also JSON is accepted.)
Currently all examples are linked to our demo server with world wide coverage for car, bike and foot. Still the default route is shown and to see the effect of the customization you need to click on the “flex” icon near the “Search” button and enter the custom profile as YAML.
The basic structure of a custom profile is described in this documentation.
All examples are also available in this Jupyter Notebook for easy customization.
Let’s start with a simple example from the previous post – it shows how to avoid primary roads:
priority: road_class: primary: 0.1
Other possibilities are:
The normal bike profile allows routing over steps in extreme cases. But a bike used for deliveries or children cannot be carried and should never be routed over this and so you exclude it with the road_class encoded value:
priority: road_class: steps: 0.0
Further exclusions like ‘too narrow roads’ are possible:
There are many ways to save fuel. One is to drive slower and another is to prefer shorter routes. For v2.0 it is planned to include an influence from the elevation data. See how the custom profiles can look:
The distance_influence is independent of the road properties and does not influence the ETA. The default is 70 in seconds per 1km. Let’s assume a route that takes 1000sec and is 10km long, then a value of 30 means that I would like to drive maximum 11km to reduce the travel time to 970sec, or drive max 12km to reduce it to 940sec.
Now to another cool feature:
Use the following area definition. You can also use the areas in the speed_factor to reduce the speed instead of changing the priority.
priority: area_cottbus: 0 areas: cottbus: { "type": "Feature", "properties": {}, "geometry": { "type": "Polygon", "coordinates": [[ [ 14.31, 51.75 ], [ 14.34, 51.75 ], [ 14.34, 51.77 ], [ 14.31, 51.77 ], [ 14.31, 51.75 ] ]] } }
You can use custom profiles to give the car profile several “truck” attributes. First of all you should reduce the max_speed and the speed_factor and increase the distance_influence like we did for the “economically driving”.
Further changes to the car profile are required:
Now to the most interesting properties like toll, width or height limitations:
As already mentioned this feature will strongly benefit from your feedback. So do not hesitate to share your experience, custom profiles or problems you are running into!
Happy custom routing!