Tying up all the different parts that came up in our discussion.
1. The main issue - giving 0 travel distance.
Current documentation for the API can be found here (for >V4.x). Note under "Requests" that coordinates are supplied in lon,lat
order:
String of format
{longitude},{latitude};{longitude},{latitude}[;{longitude},{latitude}
...] or polyline({polyline}) or polyline6({polyline6})
The current coordinates you are giving put both locations in the sea, assuming that they were in lon,lat
pairing. Therefore, it is likely that you are instead supplying coordinates in the more natural lat,lon
ordering. The web interface expects lat,lon
so produces the output you expect. I honestly don't know why the API insists on lon,lat
.
2. Other routing services
A list of the current routing software built on top of OSM data is found in their Wiki here. Of those, I've used Graphhopper and OSRM extensively, but none of the others. A few things I can say about the ones I've used:
- OSRM is significantly faster than Graphhoper for large queries
because it supports matrix calls while Graphhopper does not (in
opensource format). For less than 300 queries/sec between location
pairs, there is no difference.
- Graphhopper comes with a front-end built in. OSRM front-end is a
separate entity that requires JavaScript effort to integrate.
- Graphhopper provides a cheap API service if you don't want to
self-host.
3. Self-hosting.
The current API you are using for OSRM is subject to a fair-use policy. It's not meant for any significant work, just infrequent calls. You're also concerned that it isn't updated often enough. Both issues can be solved by self-hosting your own version of the software (Windows support was dropped for OSRM but you can build on a virtual machine and then bridge port 5000 so you can call the API from Windows, which is what I did).
- Building OSRM instructions can be found here.
- Instructions for extracting the map files can be found here
Geofabrik makes daily updates to the map files. You can download new map files whenever you want from here in .osm.pbf
format.
Side note for OSRM matrix calls. There is a debate here that I don't fully appreciate regarding the matrix API returning both the distance and time. If you need that functionality, you should load the table-distances
branch of the forked project by niemeier-PSI here. I have never loaded a global map file, only on a per-country basis, so any memory concerns about this approach have been moot for me.