function _geofield_devel_generate in Geofield 7
Same name and namespace in other branches
- 7.2 geofield.devel_generate.inc \_geofield_devel_generate()
1 call to _geofield_devel_generate()
- geofield_devel_generate in ./
geofield.devel_generate.inc - Implements hook_devel_generate().
1 string reference to '_geofield_devel_generate'
- geofield_devel_generate in ./
geofield.devel_generate.inc - Implements hook_devel_generate().
File
- ./
geofield.devel_generate.inc, line 19 - Create random data to populate geofields.
Code
function _geofield_devel_generate($object, $field, $instance, $bundle) {
$object_field = array();
$type = str_replace('geofield_', '', $instance['widget']['type']);
$val = array(
'wkt' => NULL,
'lat' => NULL,
'lon' => NULL,
'top' => NULL,
'bottom' => NULL,
'right' => NULL,
'left' => NULL,
);
if ($type == 'latlon' || $type == 'bounds') {
list($val['lon'], $val['lat']) = _random_point();
// don't actually need lat/lon but provide a center for our bounds
if ($type == 'bounds') {
$lat_diff = _dd_generate(2, 10) / 100;
$lon_diff = _dd_generate(2, 10) / 100;
$val['left'] = $val['lon'] - $lon_diff;
$val['right'] = $val['lon'] + $lon_diff;
$val['top'] = $val['lat'] - $lat_diff;
$val['bottom'] = $val['lat'] + $lat_diff;
}
}
else {
$type = 'wkt';
$val['wkt'] = _wkt_generate();
}
$values = geofield_compute_values($val, $type);
return $values;
}