Route optimisation using ORSTools and a local openrouteservice instance

I am trying to use QGIS to optimise a delivery route for a large number of stops in a fairly small area.

I have been able to get route maps with a preserved stop order by creating a local instance of openrouteservice in docker and pointing ORSTools at localhost:8080/ors, but the travelling salesman options don’t work.

Reading around it seems that the optimisation elements were removed from the docker version of openrouteservice.

In theory I could create a local instance of VROOM Express and ask it to listen to say localhost:3000/optimisation and then point OSRTools at localhost:3000 just for travelling salesman queries - but before I try to learn how to use VROOM Express, does anyone know for certain if this will work or if there is a better solution?

Because so far VROOM is very good at telling me it is listening to port 3000 and very bad at explaining why it refuses to do anything when something tries to talk to it.

Hey,

yes, in theory that should work.
ORSTools does send an /optimization request, which goes directly to a VROOM instance.

I am not completely sure, however, whether the plugin currently allows talking to two separate instances - it might be that regular requests don’t work anymore as they might go to the same server. Not sure about that though.

However, depending on what you want to do with it, there has been a “Vroom for QGIS” plugin floating around lately:

I haven’t tested it, and cannot tell you whether it’s easy to use or whether it indeed works OOTB, but it is said to work with a local ors and VROOM instance.

Best regards

VROOM for QGIS certainly looks interesting, but far too complicated for what I am looking for. I just want to add 200-1500 points to QGIS and ask some routing algorithm to find the optimal stop order.

That is what I figured, I would need two providers - one pointing to localhost:8080/ors for normal queries, and another pointing to localhost:3000 for optimisations (assuming default ports). Trouble is, if I do that the human-readable part of the error message I get back in QGIS is:

Exception: Network error: Connection refused. Are your provider settings correct and the provider ready?

I have tried all the obvious stuff I can think of in VROOM’s config.yml - change the host to localhost or 127.0.0.1, try valhalla and see if the error changes, set the baseurl back to “/” and clear the endpoint in ORSTool’s provider setting, but nothing changes the error message and since I can’t find any useful log file in VROOM I have no idea if the issue is with ORSTools, VROOM, ORS/Valhalla, or even running Docker in Windows.

Hi @SRandall,

sadly it won’t work as simple as that, as the QGIS plugin currently hardcodes the optimization endpoint url.
You can specify endpoints in the provider but even setting to empty still sends to optimization.

I’ve just got it to work with a second provider (you can just leave the endpoints as is with the fix below)

and adjusted vroom express index.js:

app.post(args.baseurl, [
  sizeCheckCallback(args.maxlocations, args.maxvehicles),
  execCallback,
]);

// add this to /vroom-express/src/index.js and restart the container
app.post(args.baseurl + 'optimization', [
  sizeCheckCallback(args.maxlocations, args.maxvehicles),
  execCallback,
]);

now you just need vroom-docker to be able to communicate with your ors instance.

but for me it still shows the an error for the following request:

curl -X POST \
  'http://localhost:3000/optimization' \
  -H 'Content-Type: application/json; charset=utf-8' \
  -H 'Accept: application/json, application/geo+json, application/gpx+xml, img/png; charset=utf-8' \
  -d '{"jobs":[{"id":1,"service":300,"delivery":[1],"location":[1.98465,48.70329],"skills":[1],"time_windows":[[32400,36000]]},{"id":2,"service":300,"delivery":[1],"location":[2.03655,48.61128],"skills":[1]},{"id":3,"service":300,"delivery":[1],"location":[2.39719,49.07611],"skills":[2]},{"id":4,"service":300,"delivery":[1],"location":[2.41808,49.22619],"skills":[2]},{"id":5,"service":300,"delivery":[1],"location":[2.28325,48.5958],"skills":[14]},{"id":6,"service":300,"delivery":[1],"location":[2.89357,48.90736],"skills":[14]}],"vehicles":[{"id":1,"profile":"driving-car","start":[2.35044,48.71764],"end":[2.35044,48.71764],"capacity":[4],"skills":[1,14],"time_window":[28800,43200]},{"id":2,"profile":"driving-car","start":[2.35044,48.71764],"end":[2.35044,48.71764],"capacity":[4],"skills":[2,14],"time_window":[28800,43200]}]}'
{"code":2,"error":"Invalid profile: driving-car."}
{"code":3,"error":"Failed to connect to 0.0.0.0:8082"}
zsh: command not found: code:2,error:Invalid profile: driving-car.

Might work if they are in the same docker network though