Support (offered by community volunteers) > Feature Requests and Suggestions
Batch geocoding script for Google API
(1/1)
Dennis Gray:
Has anyone developed a script that will look up longitude and latitude using the Google API taking into account the daily limits and throttling. It would also have to be able to update the database in place.
JonGold:
From your question, I'm not sure if you're aware that there's an existing batch geocoding update script. With Civi 4.1, the code is in your filesystem here:
/civicrm/CRM/Utils/Address/BatchUpdate.php
I also see /civicrm/bin/deprecated/UpdateAddress.php, which I'm pretty sure is the pre-4.1 command-line script you can run.
However, the daily limits aren't respected, though according to this page, the existing batch geocoding script has a throttle:
http://wiki.civicrm.org/confluence/display/CRMDOC41/Managing+Scheduled+Jobs
The relevant code is here, so you might want to:
* Change the "usleep" time - currently it sleeps for 5 seconds between requests.
* Change the first line to:
if ( $processGeocode && $totalGeocoded < 2500)
So it will respect daily limits. Though of course we wouldn't hardcode the magic number of 2500 into the code, but rather set it by a variable :)
if ( $processGeocode ) {
// loop through the address removing more information
// so we can get some geocode for a partial address
// i.e. city -> state -> country
$maxTries = 5; do {
if ( $this->throttle ) {
usleep( 50000 );
}
Dennis Gray:
This looks like what I am looking for. I haven't done much with the job scheduler except for CiviMail and missed this.
Navigation
[0] Message Index
Go to full version