Question

I want to calculate shortest paths on some kind of already existing map API routes and then draw them.

That being said, I need to be able to extract/get as more more data as possible (i.e. routes' coordinates) in order to be able to manipulate with it.

My first thought was using Google Maps but as far as I understand, Google Maps API provides very little necessary data for my problem thus I won't be able to make any kind of accurate calculations. Also, existing Google Maps API's algorithms does not concern me because I want to implement my own and test them.

Then I looked to Openstreetmaps but it's documentation also talks very little on the subject and I still don't know if it is possible to do such calculations.

So, still not ruling out Google Maps and Openstreetmaps, my question would be - what existing map API would be best for me not only to calculate shortest paths but also to represent them on it?

Was it helpful?

Solution

Yes, you can do such things with OpenStreetMap.

OpenStreetMap offers various data downloads ranging from the whole Planet down to Country and area extracts and even small cities or self-chosen areas.

If you want to calculate routes from OSM data you have to learn about elements, tags, the OSM XML format and many more things described in the OSM wiki. There you can also find a page about routing listing several already existing routing libraries as well as online routers and offline routers. Many of them are open source and they might be helpful if you get stuck at some point.

OTHER TIPS

If you want to have a lot of freedom with the information in the map, then you can use OpenStreetMap. You can get the source map info with all the streets and POI's from the raw data format by parsing it yourself and saving it into the data format you need. Using that data, you can do your calculations and visualise the result.

That's how I did it and it worked out pretty nice. There're a few OSM-parsers available to get you started in the language you want (I used this java code). For visualisation, you can also use OSM (I used JXMapviewer) but you can also just use the google API to plot a route by specifying the coordinates of the intermediate points.

If you want to add your own routing algorithms in c++ , a pgrouting may be a good place to start. To add your own algorithm you just need to create your own algo in the src directory and add it to cmake.

Follow http://workshop.pgrouting.org/index.html to get started , it also shows how to create the representation with openlayers.

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