You are here

function geofield_geom_is_empty in Geofield 7.2

Check whether geometry is empty

Parameters

array $item: Geometry field submission

Return value

boolean If empty, return TRUE

1 call to geofield_geom_is_empty()
geofield_field_validate in ./geofield.module
Implements hook_field_validate().

File

./geofield.module, line 234

Code

function geofield_geom_is_empty($item) {
  if (!empty($item['input_format'])) {
    switch ($item['input_format']) {
      case 'wkt':
        if (empty($item['geom'])) {
          return TRUE;
        }
        break;
      case 'lat/lon':
        if (empty($item['geom']['lat']) || empty($item['geom']['lon'])) {
          return TRUE;
        }
        break;
      case 'bounds':
        if (empty($item['geom']['top']) || empty($item['geom']['right']) || empty($item['geom']['bottom']) || empty($item['geom']['left'])) {
          return TRUE;
        }
        break;
      case 'json':
        if (empty($item['geom'])) {
          return TRUE;
        }
        break;
    }
  }
  else {
    return empty($item['geom']);
  }
}