A geocoder is a system that takes a street address and converts it to an (approximate) latitude and longitude for use in GPS navigation, online cartography, and similar applications. MapQuest has a nice online tutorial for different geocoding algorithms, with illustrations.
A new, extremely simple geocoder has just come online for Canada, named (unsurprisingly) geocoder.ca. The app includes both an HTML interface and an XML (and HTTP) API. Here is an example of a GET URL for a simple API call to geocode 1 Lindbergh, Ottawa, Ontario:
Here’s the XML document returned in the HTTP response:
<?xml version="1.0" encoding="iso-8859-1" ?> <geodata> <latt>45.3358320000</latt> <longt>-75.6864510000</longt> </geodata>
It’s also possible to send your own transaction ID and have it returned in the XML. If I append “&id=foobar” to the above URL, I get this back:
<?xml version="1.0" encoding="iso-8859-1" ?> <geodata> <latt>45.3358320000</latt> <longt>-75.6864510000</longt> <id>foobar</id> </geodata>
Finally, like many REST applications, this one has its own ad-hoc error-reporting scheme:
<?xml version="1.0" encoding="iso-8859-1" ?> <geodata> <error> <code>004</code> <description>Specify a Canadian province two letter code.</description> </error> <latt> <longt>- </geodata>
This is another great example of how plain XML and HTTP make it easy to provide a public API.