diff --git a/CRM/Core/BAO/Address.php b/CRM/Core/BAO/Address.php index 139f0ea6a958..a0aa6a50191e 100644 --- a/CRM/Core/BAO/Address.php +++ b/CRM/Core/BAO/Address.php @@ -1297,6 +1297,8 @@ public static function addGeocoderData(&$params) { // ensure that if the geocoding provider (Google, OSM etc) has returned the string 'null' because they can't geocode, ensure that contacts are not placed on null island 0,0 if ($params[$geocode] !== 'null') { $params[$geocode] = (float) substr($params[$geocode], 0, 14); + //set manual_geo_code to 0 + $params['manual_geo_code'] = FALSE; } } } diff --git a/CRM/Utils/Address/BatchUpdate.php b/CRM/Utils/Address/BatchUpdate.php index e00460b9900f..044c44ceb66c 100644 --- a/CRM/Utils/Address/BatchUpdate.php +++ b/CRM/Utils/Address/BatchUpdate.php @@ -131,6 +131,8 @@ public function processContacts($processGeocode, $parseStreetAddress) { if ($processGeocode) { $clause[] = '( a.geo_code_1 is null OR a.geo_code_1 = 0 )'; $clause[] = '( a.geo_code_2 is null OR a.geo_code_2 = 0 )'; + // the scheduled job is ignoring trying to geocode addresses where manual_geocode is 1 + $clause[] = '( a.manual_geo_code = 0 )'; $clause[] = '( a.country_id is not null )'; } @@ -211,6 +213,11 @@ public function processContacts($processGeocode, $parseStreetAddress) { $totalGeocoded++; $addressParams = $params; } + else { + // If an address has failed in the geocoding scheduled job i.e. no lat/long is fetched, we will update the manual_geocode field to 1. + $addressParams['manual_geo_code'] = TRUE; + $addressParams['geo_code_1'] = $addressParams['geo_code_2'] = 0; + } } // parse street address