Question

I'm developing a custom routing application using Openstreetmap. To do this I have to read (at least) the nodes and edges in a certain boundary box using an Openstreetmap API like Overpass. After that I will process the nodes and edges and apply my routing algorithm. My main problem is to determine the size of this boundary box.

One way is to read out a big boundary box including the origin and destination nodes and process all the nodes and edges in it, but this seems excessive and would take a long loading time from the API. Furthermore, this is no way to guarantee that we have all the roads needed.

Another way would be to read out a small boundary box around the origin node, start the routing algorithm (say Dijkstra) from there and read/process a new portion of the map when needed. This approach would have to make several calls to the API server and this could take time as well.

Do you know whether one of these two approaches is usual in OSM routing applications or if another approach is preferable?

Was it helpful?

Solution

Your approach is very unusual and not recommended. Usually you have a local copy of the OSM database. Either the whole planet or an extract, for example a country.

Fetching this data on-the-fly is a really bad idea and you will run into lots of problems. The APIs are not really prepared to support such heavy queries. And for long distances you will have to deal with hundreds of megabytes of data. Furthermore if you want to be able to calculate routes fast then it is necessary to pre-process the raw data.

If you decide to install a local database then I recommend you to read switch2osm. There is a guide about building a tile server which you can use, just skip installing Mapnik, mod_tile, renderd etc.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top