Help coderanch get a
new server
by contributing to the fundraiser
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Common solutions for finding the distance between two addresses

 
Ranch Hand
Posts: 44
jQuery Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

I am not sure where to post this question, but I believe web service programmers had to deal with it a lot.

I am writing an application which collects user address information. I then need to be able to determine the distance between any two users. How do people normally solve this problem?

Thanks.

Alec
[ January 26, 2007: Message edited by: Alec Swan ]
 
Marshal
Posts: 28271
95
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Well, first you'd need to find the latitude and longitude of the two addresses. There are several sites on the Internet that will do this geocoding for you with a simple HTTP request, including Google. Then you just use simple spherical trigonometry to find the distance between those two sets of coordinates.

Okay, maybe not simple. But you can find the formula easily enough on the Internet, for example here.
 
Ranch Hand
Posts: 41
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You can use Google Maps API by providing it with Latitude and Longitude parameters of the start point and destination. I think you can also use Zip codes in case of US locations, not sure though...

Dont even think that you can do this using any other means if you intention is to find the actual surface/driving distance. However, if it is just straightline/flight path distance, then you need not use any external APIs, there will be some ready formulae available to do the same using Lat/Long o-ordinates.
[ January 27, 2007: Message edited by: Jeevan Philip ]
 
Alec Swan
Ranch Hand
Posts: 44
jQuery Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

I Googled around and found Tiger, the US Census geo database. I could use it to determine longitutes and latitudes of US addresses and then convert them to distances. Does anybody use Tiger for this kind of purposes or it would be an overkill?

Both of you mentioned Google web services. Are they free to use from a commercial web application?

Thank you.

Alec
 
I don't even know how to spell CIA. But this tiny ad does:
We need your help - Coderanch server fundraiser
https://coderanch.com/t/782867/Coderanch-server-fundraiser
reply
    Bookmark Topic Watch Topic
  • New Topic