Geocoding with php
Recently one of our customers asked us to pimp his project database. This database is a pool of european wide projects in non-formal learning and youth work. The customer wanted the projects to be shown on a map of europe to emphasize their extensiveness. Unless we wanted somebody to put each of the over 500 projects on the map manually, we had to find a way to use a geocoder, because we had nothing more than a description text including address information like "Athens, Greece".
A geocoder is a piece of software or a (web) service that helps with geocoding. Amongst others geocoding is the process of assigning street addresses to geographic coordinates, and vice versa. In other words a geocoder is a nice little helper that enables you to map an address from its simple string representation to its exact coordinates.
So what we really wanted was a kind of GClientGeocoder for PHP!
Thanks to Google there was nothing more easy than that! Google allows to access the Map API geocoder directly using server-side scripting. You just need to send a request to http://maps.google.com/maps/geo including the address and the preferred output type and Google answers in either xml, kml, csv, or json. Thanks to PEAR'S HTTP_Request and PHP's database and string handling we could filter the address out of the project description, send it to Google and save the responded coordinates into the project database within several minutes.
You can see the result here: Innovative Long-term Youth in Action Projects
Sometimes everything you need is just there! Only the right approach is missing to get things done easily.