You are here

function farm_map_geofield_populate in farmOS 7

Helper function for populating the geometry field of an entity.

Parameters

Entity $entity: The entity object.

array $geoms: An array of geometry strings in WKT format.

2 calls to farm_map_geofield_populate()
farm_log_populate_geometry in modules/farm/farm_log/farm_log.module
Helper function for populating a log's geometry from an area reference field.
farm_movement_populate_geometry in modules/farm/farm_movement/farm_movement.module
Helper function for populating a movement field collection geometry from the "move to" area reference field.

File

modules/farm/farm_map/farm_map.module, line 323

Code

function farm_map_geofield_populate(&$entity, $geoms = array()) {

  // If no geometries were found, bail.
  if (empty($geoms)) {
    return;
  }

  // Combine the WKT geometries into a single GeoPHP geometry.
  $geometry = farm_map_combine_geoms($geoms);

  // If that didn't work, bail.
  if (empty($geometry)) {
    return;
  }

  // Save the combined geometry to the movement log.
  if (!empty($geometry)) {
    $entity->field_farm_geofield[LANGUAGE_NONE][0] = geofield_get_values_from_geometry($geometry);
  }
}