Skip to content

Instantly share code, notes, and snippets.

@fillerwriter
Created October 16, 2012 17:53
Show Gist options
  • Save fillerwriter/3900874 to your computer and use it in GitHub Desktop.
Save fillerwriter/3900874 to your computer and use it in GitHub Desktop.
function crcna_geocode_church_excecute($result){
$count = 0;
foreach ($result as $data) {
$node = (object) NULL;
$node = node_load($data->nid);
//format the address
$final_address = theme('addressfield_formatter__linear', array('address' => $node->field_church_address[$node->language][0]));
//geocode it
if($final_address) {
$geocoded_location = geocoder('google', $final_address);
if($geocoded_location){
// BRANDONIAN CHANGES
$node->field_church_geolocation[$node->language][0] = array(
'geom' => $geocoded_location->out('wkt'),
'input_format' => GEOFIELD_INPUT_WKT,
);
// END BRANDONIAN CHANGES
node_save($node);
dpm($node);
$count++;
} else {
drupal_set_message(l($node->title, 'node/' . $node->nid) . ' not geocoded');
}
} else {
drupal_set_message('No address found for node ' . l($node->title, 'node/' . $node->nid));
}
}
drupal_set_message($count . ' churches geocoded');
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment