|
Posted by Toby Inkster on 11/28/06 13:55
Charles Sweeney wrote:
> Bloody good thread. Every reply on-topic and informative!
Replying to Charles post, as I couldn't find a more appropriate one to
reply to...
For what it's worth, I've written a PHP library that validates and
canonically formats (people in the UK will know how important that is!)
postcodes for the following countries:
- Argentina
- Australia
- Belgium
- Bermuda
- Canada
- China
- Cyprus
- Czech Rep
- Denmark
- France
- Germany
- Greece
- India
- Ireland
- Israel
- Italy
- Japan
- Luxembourg
- Malaysia
- Netherlands
- New Zealand
- Norway
- Portugal
- Singapore
- South Africa
- Spain
- Sweden
- Switzerland
- United Kingdom
- United States of America
In addition, it's capable of the following additional functions for
certain countries:
- can handle optional country-codes for those countries that
use them (e.g. Belgian postcode '1234' is often written
'B-1234'; French '12345' written 'F-12345'; etc)
- can break down postcode into parts (UK: area, district,
sector, unit; USA: ZIP, ZIP+4; Netherlands: '1234' versus
'1234 AB'; Canada: District, FSA, LDU)
- can look up town and county from postcode (UK only)
- can look up longitude and latitude of postcode (UK only,
resolution is postcode district)
- can find distance between two postcodes (UK only, resolution
is postcode district)
- can find list of postcode districts within X metres of a
particular postcode (UK only, resolution is postcode district)
- provides an AJAX function to neatly format a postcode text
input on an HTML form. (UK only)
- accepts certain odd postcodes for the UK, though doesn't
provide geo data for them.
GIR 0AA (Giro)
SAN TA1 (Santa)
ASCN 1ZZ (Ascension Is)
BBND 1ZZ (British Indian Ocean Territory)
BIQQ 1ZZ (British Antarctic Territory)
FIQQ 1ZZ (Falkland Is)
PCRN 1ZZ (Pitcairn Is)
SIQQ 1ZZ (South Georgia & South Sandwich Is)
STHL 1ZZ (St Helena)
TDCU 1ZZ (Tristan da Cunha)
TKCA 1ZZ (Turks and Caicos Islands)
BFPO xxxx (British Military)
Some of the data used by the library I have under licence, so I can't
redistribute it all, but the library and some of the data can be found
here:
http://examples.tobyinkster.co.uk/postcodes/
I hope people find this useful. If you have any ideas for improvement
(preferably in patch form!) then please let me know.
--
Toby A Inkster BSc (Hons) ARCS
Contact Me ~ http://tobyinkster.co.uk/contact
[Back to original message]
|