Been thinking again about the postcode search issue.
1. (Getting this out of the way first.) There's a module on CPAN called
Geo::Postcode which can provide the "centre of gravity" of a postcode
district (eg SW6) as OS co-ords or lat-long. The author posted on the
Class::DBI list and said that the data comes from jibble.org/ukpostcodes/
Now, jibble.org doesn't say where they got the data from and didn't reply
to my email asking. So although it would be lovely to use this data,
I don't want to rely on it and then everything falls down when someone
gets heavy on the author and makes them take it off CPAN (this has
happened - see Streetmap.pm).
2. The format of UK postcodes is fixed and is public domain - see
http://www.royalmail.com/portal/rm/content1?catId=400044&mediaId=9200078
So we could get a crude search going by stripping off the sector and
unit code and finding nodes whose postcode is "LIKE" that. In fact I
have just written such a thing. However I'm not convinced this is
"better than nothing" since if someone enters for example a postcode
in SW6 then despite OGL having several things in W6 which are quite
close to SW6 it won't return anything. I don't like the idea of a search
function which gives the impression that the guide doesn't have information
which it in fact does. (SEE BELOW for more on this.)
3. We could find everything in W6, find everything within 500m of everything
in W6, and return the lot. This is computationally expensive and the
500m-ness is arbitrary. Also doesn't work if we don't have anything in W6.
4. We could find all the locales of everything in W6, find everything in
those locales, and return them. This is cheaper, but someone adding a
locale of, say, "West London" to a single node can make a simple postcode
search return half the database. Also requires the guide to have data
in W6.
5. We could find the postcode that's most similar to the one entered,
find its locales, find everything in those locales, and return them.
This suffers from the same problems as 4, but the "West London"
problem will affect fewer searches.
6. We could make a formal mechanism for gathering data such as that in
http://london.openguides.org/?Postal_Districts
and redirect eg WC1 searches to locale searches on Euston and Bloomsbury.
I quite like this idea.
7. We could stop thinking about postcode searches as being a function of
distance and make them cater only for people who genuinely do want to
search for "all things whose postcode begins with W6". I am not sure
this kind of search would be useful.
8. We could forget about postcode searches altogether and have a locale
search instead. This would be trivial to implement, but requires people
to know exactly what we mean by locale, and to know what locale their
base point is in in the first place. Besides, I *want* a postcode
search. I want to be able to stick in my postcode and find all the
stuff near me.
That was just a brain dump since I was thinking about it and wanted to
note it down.
And here is the SEE BELOW. I'm fairly sure that at some point I found a
list of which postal districts are next to which other postal districts,
and I think it may even have been on the Royal Mail website. However I
can't find it now. I've emailed the Royal Mail to ask but I expect I
won't get a very quick or informed reply, if I get one at all, unless
their helpdesk is unusually competent. Does anyone recognise what I'm
talking about?
Kake