Need world zip codes

A

Alan

They were designed to deliver mail, for goodness sake! So in New
Zealand where I live they can be 'dummy' destinations that can either
refer to a place or a delivery contractor, while others reflect the
internal work-flow of sorting offices. (The biggest group goes down the
first chute, for instance.) Also boxes, bags and street deliveries at
the same location require different codes. At best they are
pseudo-geographic with no necessary connection to geocoding.

I am guessing that also happens in other parts of the world.
 
D

dorayme

Toby Inkster said:
When the postman is delivering the mail, he doesn't do so
with a GPS device in his hand, saying, "0.5 degrees due North East".

And there was I not believing a friend who reckoned the device he
held was a dog zapper...
 
D

Dylan Parry

Richard said:
The Council also plot the dwellings and pass the map overlays to the OS.

Perhaps in the authority you (appear to) work for. Most local
authorities that I work with (and I work with a lot of them) don't have
a GIS department, but if they do it consists of maybe one or two people.

The majority of street gazetteers that I am supplied with are appalling
in terms of quality, quite often with coordinates that don't match up
with OS Mastermap or Landline data.

Local authorities may well be responsible for maintaining lists of
properties, in the form of a gazetteer, but none that I have come across
are responsible for creating the geographic base data in the first place.
The RM then adds the postcode, and adds the property to PAF. The
OS then uses that info to build ADDRESS-POINT, which is then SOLD back to
the local authority as part of the Mapping Services Agreement, and we are
charged for each time a query is performed on any database that may, some
time in the past, been matched against ADDRESS-POINT, on an internet
transaction.

Yes. This is one of the issues I have to deal with. Many councils will
"get around" this by supplying us with their own, internally managed,
yet inaccurate databases. The shear amount of documentation that we have
to sign each year just to get hold of the Mastermap data with which we
create their maps is a ridiculous waste of paper!

--
Dylan Parry
http://electricfreedom.org | http://webpageworkshop.co.uk

Programming, n: A pastime similar to banging one's head
against a wall, but with fewer opportunities for reward.
 
N

nemo

GreyWyvern said:
And lo, Toby Inkster didst speak in alt.html,alt.php,alt.www.webmaster:


Can it handle H0H 0H0 ?

Yes -- the parsing for non-UK postcodes is far more rudimentry than for UK
postcodes. For Canada it just uses the following regular expression on a
normalised (all uppercase, with whitespace collapsed) postcode to check
the format is OK:

/^[A-CEGHJ-NPRSTV-Z][0-9][A-CEGHJ-NPRSTV-Z]\s+[0-9][A-CEGHJ-NPRSTV-Z][0-9]$/

Regular expressions for non-UK countries are here:
http://examples.tobyinkster.co.uk/postcodes/data/intlpc.txt

Columns are:

- ISO 2-character country code, lower case
- PCRE for valid postcodes
- optional country prefix for certain European countries
(the PCRE should match the country-prefixed postcode)
Any chance of your divulging the expression to check for the validity
of format of UK postcodes, please?
 
D

Dylan Parry

Any chance of your divulging the expression to check for the validity
of format of UK postcodes, please?

I would maybe use something like:

/^[A-Z]{1,2}[1-9][0-9]? [0-9][A-Z]{2}$/

Although, I haven't tested it in the slightest, but basically it should
read something like: One or two uppercase letters, followed by a digit
between 1 and 9 and, optionally, another digit between 0 and 9. Then,
after a space, a single digit between 0 and 9, followed by two uppercase
letters. It doesn't take into account more complicated issues such as
whether that postcode is real though.

I'd be interested to see what Toby came up with :)

--
Dylan Parry
http://electricfreedom.org | http://webpageworkshop.co.uk

Programming, n: A pastime similar to banging one's head
against a wall, but with fewer opportunities for reward.
 
C

CJM

Harlan Messinger said:
They have to do that *anyway* to use the codes *themselves*. They don't
have to do it all over again just to post the list so the rest of us have
access to it.

So if they did need to use the data themselves, it would be wrong of them to
sell it at a profit to subsidize the cost of collection?? Next thing you
know we'll be asked to pay for postage for our letters!

It costs to collect the data and it costs to distribute the data.
Lots of other people want the data, and are prepared to pay for it.

....Not to sell it to them at a fair market price would constitute negligence
and mismanagement.

Anyone who thinks they should be able to buy Postcode data for £10 on a CD
is living in cloud-cuckoo-land... as they say in my neck of the woods
[sorry - don't have coordinates to hand!].

CJM
 
C

CJM

Toby Inkster said:
I needed to tidy up and verify hundreds of thousands of addresses, mostly
in the UK. (Why else?)

It's just unusual to have to handle addresses for some many different
countries.
 
N

nemo

nemo@nemo_spam.com said:
Any chance of your divulging the expression to check for the validity
of format of UK postcodes, please?

I would maybe use something like:

/^[A-Z]{1,2}[1-9][0-9]? [0-9][A-Z]{2}$/

Although, I haven't tested it in the slightest, but basically it should
read something like: One or two uppercase letters, followed by a digit
between 1 and 9 and, optionally, another digit between 0 and 9. Then,
after a space, a single digit between 0 and 9, followed by two uppercase
letters. It doesn't take into account more complicated issues such as
whether that postcode is real though.

I'd be interested to see what Toby came up with :)
I think that would fall foul of, say, Central London postcodes - many
years ago, I lived at London WC1B 4BB
 
D

Dylan Parry

/^[A-Z]{1,2}[1-9][0-9]? [0-9][A-Z]{2}$/
I think that would fall foul of, say, Central London postcodes - many
years ago, I lived at London WC1B 4BB

Thanks! I did say it was untested :) Anyway, a quick fix would produce:

/^[A-Z]{1,2}[1-9][0-9A-Z]? [0-9][A-Z]{2}$/

Which would then allow a letter /or/ a number as the last character in
the first half of the postcode, but only if it's following a digit. That
should work now, I think.

--
Dylan Parry
http://electricfreedom.org | http://webpageworkshop.co.uk

Programming, n: A pastime similar to banging one's head
against a wall, but with fewer opportunities for reward.
 
S

Stuart Miller

GreyWyvern said:
And lo, Toby Inkster didst speak in alt.html,alt.php,alt.www.webmaster:


Can it handle H0H 0H0 ?
The Canadian postal code system has a lot of strange features.
The most obvious one is this code for the north pole and all the letters to
Santa.
However, the letter H is not a valid first letter for any other area.
V is the last code used, W X Y and Z are not valid addresses
Letters which may be confused for numbers are often omitted from the
sequence


Stuart
 
T

Toby Inkster

nemo said:
Any chance of your divulging the expression to check for the validity
of format of UK postcodes, please?

I did post the entire source code earlier, but if you'd like an all-in-one
regexp, then you could do a lot worse than...

/([A-PR-UWYZ][A-HK-Y]?([0-9]{1,2}|[1-9][A-HJKMNPR-Y])\s+[0-9][ABDEFGHJLN
P-UW-Z]{2})|(BFPO\s+(c..?o\s+)?([0-9]{1,4}))|(GIR\s+0AA)|(SAN\s+TA1)|((
(ASCN)|(BBND)|(BIQQ)|(FIQQ)|(PCRN)|(SIQQ)|(STHL)|(TDCU)|(TKCA))\s+1ZZ)/

You'll need to remove the line breaks -- this regexp should contain no
white space. Note that this allows any amount of white space between
outgoing and incoming parts of the postcode (e.g. 'AB10 1AB' and
'AB10 1AB' both pass the test. It's a fairly trivial matter to collapse
that down if required.

This is untested, but compiled from several that I do use.
 
N

nemo

nemo said:
Any chance of your divulging the expression to check for the validity
of format of UK postcodes, please?

I did post the entire source code earlier, but if you'd like an all-in-one
regexp, then you could do a lot worse than...

/([A-PR-UWYZ][A-HK-Y]?([0-9]{1,2}|[1-9][A-HJKMNPR-Y])\s+[0-9][ABDEFGHJLN
P-UW-Z]{2})|(BFPO\s+(c..?o\s+)?([0-9]{1,4}))|(GIR\s+0AA)|(SAN\s+TA1)|((
(ASCN)|(BBND)|(BIQQ)|(FIQQ)|(PCRN)|(SIQQ)|(STHL)|(TDCU)|(TKCA))\s+1ZZ)/

You'll need to remove the line breaks -- this regexp should contain no
white space. Note that this allows any amount of white space between
outgoing and incoming parts of the postcode (e.g. 'AB10 1AB' and
'AB10 1AB' both pass the test. It's a fairly trivial matter to collapse
that down if required.

This is untested, but compiled from several that I do use.

Thank you.
 
C

Charles Sweeney

Toby Inkster wrote
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:

I reckon Mr Inkster should get a mention in the New Year's Honours list.
 
C

Chris F.A. Johnson

GreyWyvern wrote


Isn't that what Santa Claus says?

That's Santa's postal code; the North Pole *is* in Canada!

There was a story going around shortly after the postal codes were
introduced (in the 1970s, IIRC) of someone whose mail had been
routed through Japan. His postal code was T0K 0Y0.
 
H

Harlan Messinger

Toby said:
The post office doesn't need to know longitude/latitude information to use
postcodes -- it only needs to know where a postcode is in terms of region,
town and street. When the postman is delivering the mail, he doesn't do so
with a GPS device in his hand, saying, "0.5 degrees due North East".

When did latitudes and longitudes enter the discussion? The OP asked
only for the codes (and presumably the corresponding countries, cities,
states, etc.) Of course I'd expect to pay for geocoding information. I
was talking about the codes themselves, which are public property and
should therefore be freely available.
 
H

Harlan Messinger

CJM said:
So if they did need to use the data themselves, it would be wrong of them to
sell it at a profit to subsidize the cost of collection??

I don't see the government as being in business to make a profit. I see
them as providing services at no more than cost. The cost of putting a
list of postal codes on the postal organization's web site is de
minimis. If they were to charge for cost, it would probably be under USD 1.
Next thing you
know we'll be asked to pay for postage for our letters!

The cost of delivering mail is not de minimis.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,780
Messages
2,569,607
Members
45,240
Latest member
pashute

Latest Threads

Top