You are here

function _addressfield_autocomplete_widget_resolve_deltas in Addressfield Autocomplete 7

Address autocomplete resolve deltas for handling geofield.

Given a list of geometries, and user configuration on how to handle deltas, we created a list of items to be inserted into the fields.

1 call to _addressfield_autocomplete_widget_resolve_deltas()
_addressfield_autocomplete_widget_get_field_value in ./addressfield_autocomplete.module
Function to get the geofield information from the autocomplete.

File

./addressfield_autocomplete.module, line 677
The Addressfield Autocomplete module code.

Code

function _addressfield_autocomplete_widget_resolve_deltas($geometries, $field_type, $delta_handling = 'default') {
  $values = array();

  // Default delta handling: just pass one delta to the next
  if ($delta_handling == 'default') {
    foreach ($geometries as $geometry) {
      $values[] = _addressfield_autocomplete_widget_values_from_geometry($geometry, $field_type);
    }
  }

  // For multiple-to-single handling, run it though geometryReduce
  if ($delta_handling == 'm_to_s') {
    $reduced_geom = geoPHP::geometryReduce($geometries);
    $values[] = _addressfield_autocomplete_widget_values_from_geometry($reduced_geom, $field_type);
  }

  // Set the values - geofields do not support languages
  return array(
    LANGUAGE_NONE => $values,
  );
}