Henry
> --
> You received this message because you are subscribed to the Google Groups "VisibleGovernment Discuss" group.
> To post to this group, send email to visiblegover...@googlegroups.com.
> To unsubscribe from this group, send email to visiblegovernment-...@googlegroups.com.
> For more options, visit this group at http://groups.google.com/group/visiblegovernment-discuss?hl=en.
>
That's something that rings a bell from the last round of the copyfight. Russell McOrmond worked on it -- check it out at http://www.digital-copyright.ca/edid
The data might be stale, so see the links.
--
Michael Allan
Toronto, +1 416-699-9528
http://zelea.com/
As Henry posted, your best option is Cory Horner's howdtheyvote.ca
API. It has a simple postal-code-to-MP call. I and lots of other
people have been relying on the service for a while; it's incredibly
useful.
However, even this service -- which Cory bought data for out of his
own pocket! -- is imperfect because of how expensive much of our
public data is. The data it uses represents postal codes as
"centroids" -- a single representative point for a given postal code.
The consequence of this is that it'll occasionally give you the wrong
answer, for example when a postal code contains addresses in different
ridings (it does happen!).
If you're really worried about accuracy, you can pay several thousand
dollars to Statscan for their data. Or you can go through the
following laborious procedure for each postal code (this assumes
you're getting postal codes from users on an interactive website):
1) Use Daniel Haran's postal code webservice at
http://postal-code-to-edid-webservice.heroku.com/ to get the ID of the
riding. This is a web service interface to a caching scraper of the
Elections Canada site. For problematic postal codes which don't
resolve cleanly to a riding, it'll return an error code.
2) If you get an error code, get a street address from the user,
resolve that address to coordinates using a geocoder, and submit those
coordinates to the howdtheyvote.ca API. I wrote some sample code for
this at vote.ca/api/ (using an alternate API).
This is complicated and painful. People are surprised at how
complicated and painful it is for developers to answer a simple
question like "who's my MP?". It would be far less painful, of course,
if certain public data -- the statscan postal-code-to-riding file,
geospatial data on postal codes -- were publically available. This
used to be the case in the UK -- see http://www.freethepostcode.org/
-- but their data has now been freed. Here's hoping that happens here
too.