function _geofield_formatter_get_info in Geofield 7
Same name and namespace in other branches
- 7.2 geofield.formatters.inc \_geofield_formatter_get_info()
2 calls to _geofield_formatter_get_info()
File
- ./
geofield.formatters.inc, line 439 - Drupal field formatter hooks and helper functions.
Code
function _geofield_formatter_get_info($geometry, $centroid, $address = FALSE, $units = 'degrees') {
$info = array(
'latitude' => $centroid
->y(),
'longitude' => $centroid
->x(),
);
// Get the shape
if ($geometry
->geometryType() == 'Point') {
$info['shape'] = 'Point';
}
if ($geometry
->geometryType() == 'LineString') {
$info['shape'] = 'Line';
}
if ($geometry
->geometryType() == 'Polygon') {
//@@TODO: Get more useful information like 'Triangle', 'Square', 'Rectangle', 'Pentagon'
$info['shape'] = 'Polygon';
}
if ($address) {
$info['address'] = $centroid
->out('google_geocode');
}
//@@TODO, convert length and area to proper units
#if ($geometry->geometryType() == 'LineString') {
# $info['length'] = $geometry->length();
#}
#if ($geometry->geometryType() == 'Polygon') {
# $info['area'] = $geometry->area();
#}
return $info;
}