Originally published at
Kyle Boddy. You can comment here or
there.
I recently wrote a mass geolocation script in PHP since Google seems to be taking down all the websites that offer this vital service. Right now it:
- Checks a table for records without lat/long coordinates
- Sends those records' addresses to Google's geolocation API
- Updates your records with the lat/long coordinates
It checks for the "#" sign and handles it since Google has problems with translating "2020 Anywhere Place #200" as a real address, but there are probably other errors I haven't adequately checked for.
At the moment it updates records that are missing lat/long coordinates and writes zeroes into those fields if it can't geolocate the address correctly. As a result, if you run the script again, it will assume those records were updated correctly and will pass over them, since they are not null. This is a known issue and is one (of many) areas of improvement for the script.
I didn't want to spend a ton of hours on the script to make it a full-fledged awesome service, since Google doesn't seem to like that. It's just a basic script that handles common problems and works well enough.
You can get it over at my
GitHub repo page for GeoCode. Enjoy.