Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to use OpenStreetMap to get distance between two points

I am working on a vehicle-routing program that needs to accurately get the driving distance between different locations for a vehicle using .NET. I could have used the Google API to get the distances, but the company isn't willing to commit at least USD11,000 per year for subscription fee subject to usage volume.

I tried using the Haversine formula to get the distances, but the correction factor for the route is overwhelmingly high for it to even get close to calculating the total travel time correctly. I have spent quite some time researching OpenStreetMap, but the documentation does not have any specific examples to suit my requirements. I do not need the actual "tiles" to display the maps, only text-response with the distance would suffice.

I was hoping there would be some free to use service I could invoke within OpenStreetMap or others similar, or maybe someone could point me in the right direction to get started.

like image 245
Purusartha Avatar asked Dec 20 '10 06:12

Purusartha


People also ask

Can you measure distance on OpenStreetMap?

To measure the distance between any two points, click on the symbol with the hand and the tape on the left side of josm.

Does OpenStreetMap have an API?

OpenStreetMap has an editing API for fetching and saving raw geodata from/to the OpenStreetMap database — this is the entry page for the documentation.


2 Answers

OpenStreetMap does not have their own routing algorithm.

On the OpenStreetMap wiki, there's a list of software libraries that perform routing. The Intermodal Transport Routing Information System is written in C#.

like image 173
Gilbert Le Blanc Avatar answered Oct 26 '22 00:10

Gilbert Le Blanc


OpenStreetMap.org website is not yet able to measure distance between points. But you can still get the distances. To do so there are numerous websites and software that let you draw a track on top of OpenStreetMap based maps, then get the distance:

  • List of websites at https://wiki.openstreetmap.org/wiki/Track_drawing_websites

    Note: Some of those websites include API. Such as “Umap”, “bikehike”, “Strava”.

  • Viking software at https://sourceforge.net/projects/viking/

    Note: This software is free, owned and supported by a friendly community. It is for advanced users though. Lots of features. Including API-Key.

like image 30
Francewhoa Avatar answered Oct 26 '22 01:10

Francewhoa