You are here

function geofield_compute_values in Geofield 7.2

Same name and namespace in other branches
  1. 7 geofield.module \geofield_compute_values()

Geofield Compute Values

@todo: documentation Steps: 1. Load the geoPHP library 2. Load the Geometry object from the master-column 3. Get out all the computer values from the Geometry object 4. Set all the values

5 calls to geofield_compute_values()
geofield_feeds_combined_source in ./geofield.feeds.inc
Callback; Provides a source combining geo information from items.
geofield_field_presave in ./geofield.module
Implements hook_field_presave().
geofield_set_target_simple in ./geofield.feeds.inc
Example callback specified in hook_feeds_processor_targets_alter().
geofield_set_target_wkt in ./geofield.feeds.inc
Feeds processor target callback for WKT source.
geofield_validate_geom in ./geofield.module
Validates input data against the geometry processor

File

./geofield.module, line 409

Code

function geofield_compute_values($raw_data, $input_format = NULL) {

  // If raw_data is NULL, false, or otherwise empty, just return an empty array of values
  if (empty($raw_data)) {
    return array();
  }

  // Load up geoPHP to do the conversions
  $geophp = geophp_load();
  if (!$geophp) {
    drupal_set_message(t("Unable to load geoPHP library. Not all values will be calculated correctly"), 'error');
    return;
  }
  $geometry = geofield_geometry_from_values($raw_data, $input_format);

  // Get values from geometry
  if (!empty($geometry)) {
    $values = geofield_get_values_from_geometry($geometry);
  }
  else {
    $values = array();
  }
  return $values;
}