Postcode frustrations and a little help from Geonames
As you all hopefully know by now, ParkatmyHouse is available in 7 different countries. We can hardly believe it either. Cultural differences aside, the differences in the way we write addresses and postal codes can be a frustrating problem when catering for multiple audiences.
US Zipcodes are easy to remember and recognise, especially 90210 (for Beverley Hills) - which we can check for by looking for 5 consecutive numbers.
UK Postcodes have a slightly more complex structure. A typical postcode will look something like this `SE1 4BN` but to check that a postcode has been entered correctly we have to use something ugly looking like `/^[A-Z][A-Z]?[0-9][A-Z0-9]?(?:\s*[0-9][ABDEFGHJLNPQRSTUWXYZ]{2})?$/i`
You can probably work out what the above jargon is doing if you look at it closely.
Canada have something just as ugly `/^[ABCEGHJKLMNPRSTVXY][0-9][A-Z](?:\s*[0-9][A-Z][0-9])?$/i`
Fortunately, Australia, New Zealand and the Netherlands have simple 4 digit postal code systems. Curiously though, Ireland is yet to adopt a post code system which begs the question `How do the postman know where to take the mail?`
In addition to checking the accuracy of an entered postcode we also need to know the exact coordinates of each postcode in these countries. A problem solved thanks to a fantastic service called Geonames who have provided us with nearly all the postal code data we could ask for.
The idea of the GeoNames project is to aggregate national and local data and combine it into one global open source project. Their main goal is to provide useful data and web services.
If you have a map based project or require any geographic data including population statistics, head over to www.geonames.org and take a look around.





