Win a copy of The Way of the Web Tester: A Beginner's Guide to Automating Tests this week in the Testing forum!

# Common solutions for finding the distance between two addresses

Alec Swan
Ranch Hand
Posts: 39
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 ]

Paul Clapham
Sheriff
Posts: 21443
33
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.

Jeevan Philip
Ranch Hand
Posts: 41
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: 39
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