Search code examples
graphhopper

how to use road speed per request in graphhopper routing


As per the graphhopper 0.9 release, it says

A new graph change API to change road speed and access properties, #845. Can be applied before preprocessing or per-request.

how do i use it, can someone point me to the documentation with example ?

thanks for your support


Solution

  • Indeed there is no good documentation at the moment. Have a look into the tests:

    1. Disable speed mode - set prepare.ch.weightings=no in the config.properties
    2. Create a GeoJSON where e.g. you want to change the access properties to false (blocking):

      {
           "type": "FeatureCollection",
           "features": [{
             "type": "Feature",
             "geometry": {
               "type": "Point",
               "coordinates": [1.521692, 42.522969]
             },
             "properties": {
               "vehicles": ["car"],
               "access": false
              }
           }]
      }
      
    3. Then POST this as json to the /change endpoint.

    Please note that in 0.9.0

    • for geometry type only Point, MultiPoint and LineString are supported.
    • for the properties only access (Boolean) and speed (Double) are supported that can be applied to multiple vehicles (but only in both directions).

    You can also use the Java equivalent.

    Please see this issue to improve the documentation.