File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Web Services and the fly likes Common solutions for finding the distance between two addresses Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCM Java EE 6 Enterprise Architect Exam Guide this week in the OCMJEA forum!
JavaRanch » Java Forums » Java » Web Services
Bookmark "Common solutions for finding the distance between two addresses" Watch "Common solutions for finding the distance between two addresses" New topic
Author

Common solutions for finding the distance between two addresses

Alec Swan
Ranch Hand

Joined: Feb 03, 2005
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
Bartender

Joined: Oct 14, 2005
Posts: 18541
    
    8

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

Joined: Nov 17, 2006
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

Joined: Feb 03, 2005
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
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Common solutions for finding the distance between two addresses