[GIS] OSRM – trucks and cars routes should differ

open-source-routing-machinerouting

I am working on logistic software that includes building routes by points given. So I've got my local OSRM server and it's working fine.

But now I faced the problem of dividing vehicles into cars and trucks. Some areas are conditionally closed for the truck passage, so I need the truck route to be built bypassing that areas.
So I'm wondering how do I get this?

I must admit I'm new to OSRM and OSM data, so I'm thinking about following steps:

  1. If forbidden area is not in OSM data, should I add it to my own data (like in this question)?
  2. If an area exists or I've added it, can I set up OSRM profile to consider the area as "inaccessible for the trucks"? Should I re-extract map data after that?
  3. Can I pass the param "has acess to forbidden areas" when quering for a route?

Am I on the right way and is my goal reachable?

Best Answer

  1. Yes, if you have the data and you can legally add it to OSM, you should do so. This helps improve OSM for everyone else, and removes the need for you to maintain a complex workflow merging your data with OSM.
  2. You could adapt OSRM's Lua profiles (the logic for which roads are preferred) to avoid roads which aren't open to trucks. This will require some programming knowledge.
  3. No. OSRM's routing graph is pre-computed, so you can't pass query-time options to it. You would need to get OSRM to generate two routing graphs, one for cars, one for trucks, and run two separate instances of OSRM.