Win a copy of Think Java: How to Think Like a Computer Scientist this week in the Java in General forum!

# calculate distance between 2 post code

jim li
Ranch Hand
Posts: 180
hi

guys i am trying to create a application web allows to calculate the distance between 2 post code. how can i do it. please give me some hit

Hauke Ingmar Schmidt
Rancher
Posts: 436
2
What distance? Air line? Or something like finding a route for some sort of transport?

Air line is a two step process: Find the geo coordinates for the address (geocoding) and calculate the great circle distance. For route planning it depends if the service you use does this for you.

That said: Look into e.g. Google Maps Api. They have a geocoding API... and methods for getting the distance, even with nice map displays, so you don't need to do any manual calculation. But there are other vendors, if the Google API restrictions are too much for you.

jim li
Ranch Hand
Posts: 180
by walking or driving distance...

but i do not need that much details, all i need is how many kilometers between 2 post code, (this will be only used in canada)

Hauke Ingmar Schmidt
Rancher
Posts: 436
2
Walking or driving can give vastly different results (think pedestrian bridges). Google Maps API will be all you need, I think.

Ulf Dittmer
Rancher
Posts: 42967
73
Post codes are not points, but areas. The "difference" between random points in two postcodes can be about zero (if they adjoin) or many miles. So what is your definition of "distance"?

Paul Clapham
Sheriff
Posts: 21107
32
In Canada a postal code is a very small area, unlike the US zip code. For example the postal code where I live consists of about 15 houses on one side of a city block. So in most cases the "location" of a postal code is quite precise.

ken jun
Ranch Hand
Posts: 46
Hauke Ingmar Schmidt wrote:Walking or driving can give vastly different results (think pedestrian bridges). Google Maps API will be all you need, I think.

could you tell me more about Google Maps API? or could you give me a website? thank you

Rob Spoor
Sheriff
Posts: 20526
54