Page 1 of 1

Foreign / International Addresses

Posted: Tue Apr 22, 2008 1:51 pm
by stndrdsnz
I have an application that I'm working with that was developed to store domestic (US) addresses. However, recently I've been contacted by some of the users that they have contacts on an international scale, but my application won't allow them to store these addresses because of my data validation on things like zipcode and phone number.

Has anyone seen any good solutions for storing addresses that are both foreign and domestic?

I'm at a loss right now trying to figure out what to do, as well as how to validate the vast variety of address formats. Any suggestions, or even application that handle this well would be appreciated. If there is an application that does this well, I could dissect it to figure out how it's done.

Re: Foreign / International Addresses

Posted: Tue Apr 22, 2008 2:13 pm
by Kieran Huggins
International addresses are tricky, since they all work somewhat differently. The Google maps standard is helpful, but not always complete outside the US. I find it useful though to use their API to clean up and validate a plaintext address, but I usually store the important fields separately for sorting.

Example: User inputs the following....

Code: Select all

123 Somestreet
Toronto, Canada
m5m 1a1
And Google will parse that to something like:

Code: Select all

street number: 123
Throughfare: Somestreet
Mmunicipality: Toronto
Region: Ontario
Country: Canada
Postal Code: m5m 1a1
Lat: 65.8783232
Lng: 126.979823
(or something similar)

I find it's important to keep (and use) the original plaintext address, using the parsed, geolocated values only for sorting and distance calculations. Especially if it's being kept for mailing data... people are less likely to input a bad mailing address then you are to parse it incorrectly in my experience.

check out http://code.google.com/apis/maps/documentation/ for the API usage, but it's best not to rely on it.

Re: Foreign / International Addresses

Posted: Tue Apr 22, 2008 2:19 pm
by stndrdsnz
Thanks for that information. I'll look at the API. I would be hesitant to rely on something outside of my code, simply because I don't want to have it break every time Google changes something, or quits supporting the API, etc...