1

I am trying to find any solution that can calculate distance between point A and point B BUT including information about country's border.. I checked Google Maps and Bing Maps APIs - both of them don't provide such features..

Any suggestion? Thank you in advance

nKognito
  • 6,297
  • 17
  • 77
  • 138
  • What do borders have to do with calculating distance? I don't see how politics changes the Haversine formula: http://bigdatanerd.wordpress.com/2011/11/03/java-implementation-of-haversine-formula-for-distance-calculation-between-two-points/ – duffymo May 20 '14 at 11:35
  • It is not about politics.. I need this information in order to calculate the price of trip and price per km in one country might be different from price per km in other.. And I am not talking about VAT)) – nKognito May 20 '14 at 11:36
  • Now you'll have to figure out how to calculate the intersection between a border and your path and break the path integral/sum into two parts. I have nothing for you. – duffymo May 20 '14 at 11:44
  • 1
    This could help [Google Maps API - detect when crossing state lines and calculate distance travelled in each state](http://stackoverflow.com/questions/17660677/google-maps-api-detect-when-crossing-state-lines-and-calculate-distance-travel) – Anto Jurković May 20 '14 at 11:57

1 Answers1

0

First you can create a database of country boundaries. Country boundaries are easy to find online. Here is one source: http://www.diva-gis.org/Data

You can upload these into SQL 2008/2012 or Azure (express version is free) using the Shp2Sql tool here: http://www.sharpgis.net/page/Shape2SQL.aspx

Then using Bing Maps you can calculate a route and get the route point's. You can use the route points to create a LineString object and do an intersection test against the country data to get all the countries boundaries that line passes through. Then you can go through each resulting country and crop the line to the borders of the country. With the crop line you can then measure it's length. All of this can be done with the spatial tools in SQL. Here are some useful links.

http://msdn.microsoft.com/en-us/library/ff701713.aspx

http://technet.microsoft.com/en-us/library/bb933901.aspx

http://technet.microsoft.com/en-us/library/bb933962.aspx

http://technet.microsoft.com/en-us/library/bb933895.aspx

rbrundritt
  • 16,570
  • 2
  • 21
  • 46