Route optimization - Truck Vehicle type still going under low bridges

Hi there,

I’ve been using Graphhopper API for a while for route optimization and i am very happy with it.

My client now needs to integrate different type of vehicles such as truck/small truck.

I’ve updated the “vehicle_types” value to the value selected by users “small_truck” or “truck”. This leads to longer itineraries however truck are still routed under very low bridges (2m height max).

Is there anything else that should be done to avoid these kind of bridges ? Routes are in France

Thanks for your help

When the routing does not consider these low bridges it is likely that the data does not contain any limits. With ground truth information you can change this directly in the data we use - i.e. in OpenStreetMap:

https://learnosm.org/en/beginner/start-osm/

I.e. the street with this limit should get max_height: Key:maxheight - OpenStreetMap Wiki

Thanks for your quick answer @karussell

I am not very clear about what i should do to make it work.
I’ve found this page: OpenStreetMap Truck QA Map (created by mmd) that shows correct height data for the roads I am testing my solution on. However i don’t understand how i should tell my app to use those datas when using the route optimization API.

In general you don’t have to do any extra step.

But if something is wrong, then you go to openstreetmap.org and check if the maxheight limit exists there (click question mark and on that location). If it is already there something else is wrong. If it is not there, but in real world it exists, then you can add it to the data on openstreetmap.org

To help you further please send me a link of e.g. the route that should not go under this bridge. You can use our GraphHopper Maps.

Thanks, the route avoids the bridge when using GrapHopper Maps so I assume I am doing something wrong.

is there anything in addition to “vehicle_types” that should be added in order to have it work ?

Did you specify the profile in the used vehicle_type?

https://docs.graphhopper.com/#operation/solveVRP/body/application/json/vehicle_types/profile

Yes i did specify profile and it matches the vehicle_type

I’m unsure what you mean with “matches the vehicle_type”.

Can you go to the route editor and review the default example: Dashboard

There we specify car (you can use truck) as profile:

"vehicle_types": [{
      "type_id": "custom_vehicle_type",
      "profile": "car"
    }]

And this vehicle type then has to be used in the vehicle as type_id:

{
  "vehicles": [{
      "vehicle_id": "custom_vehicle",
      "type_id": "custom_vehicle_type",
...

Here is my code:

curl --location --request POST 'https://graphhopper.com/api/1/vrp?key=mykey' \
--header 'Content-Type: application/json' \
--data-raw '{
"vehicles": [{
"vehicle_id": "vehicle-1",
"type_id": "truck",
"start_address": {
"location_id": "Lyon, France Auvergne-Rhône-Alpes",
"lon": 4.8318,
"lat": 45.7577
},
"end_address": {
"location_id": "Lyon, France Auvergne-Rhône-Alpes",
"lon": 4.8318,
"lat": 45.7577
},
"earliest_start": 1664919000,
"max_jobs": 2
}
],
"vehicle_types": [{
"type_id": "truck",
"capacity": [2],
"profile": "truck"
}
],
"services": [{
"id": "s-1",
"name": "address",
"address": {
"location_id": "Rue Charles Péguy, ZAC Île de France, Laon, Aisne, Hauts-de-France, Metropolitan France, 02000, France",
"lon": 3.617,
"lat": 49.549
},
"duration": 720
}, {
"id": "s-2",
"name": "address",
"address": {
"location_id": "3, Rue le Coq, Leuilly, Laon, Aisne, Hauts-de-France, Metropolitan France, 02000, France",
"lon": 3.607,
"lat": 49.5401
},
"duration": 720
}
],
"objectives": [{
"type": "min",
"value": "vehicles"
}, {
"type": "min",
"value": "completion_time"
}
],
"configuration": {
"routing": {
"calc_points": true,
"snap_preventions": ["motorway", "trunk", "tunnel", "bridge", "ferry"]
}
}
}

Yes, this looks good. Where exactly in this long route is the problem you mentioned?

It’s between s-1 and s-2.
There is a bridge hightlighted in the screenshot attached below:


With GraphHopper map, the route is not going through it:
good|360x290

Can you share a link to GraphHopper Maps?

Here is the link

Thanks for your help

I think you mean this bridge: Way: 151406578 | OpenStreetMap
This contains indeed the maxheight=2 tag so that trucks are not sent through it (as GH Maps shows).

If I copy your JSON from above into the route editor then I do get the same expected detour for truck that you do on GraphHopper Maps:

And if I switch to profile=car it doesn’t have this detour. So everything seems fine to me :slight_smile:

Maybe can you elaborate what your problem is in more detail?

Thanks for your time, it seems that the issue is with the way the route is displayed on map. We are double checking our code.