You are here

function _dd_generate in Geofield 7

Helper to generate DD coordinates

7 calls to _dd_generate()
_geofield_devel_generate in ./geofield.devel_generate.inc
_random_point in ./geofield.devel_generate.inc
_wkt_generate_linestring in ./geofield.devel_generate.inc
_wkt_generate_multilinestring in ./geofield.devel_generate.inc
_wkt_generate_multipoint in ./geofield.devel_generate.inc

... See full list

File

./geofield.devel_generate.inc, line 54
Create random data to populate geofields.

Code

function _dd_generate($min, $max, $int = FALSE) {
  $func = 'rand';
  if (function_exists('mt_rand')) {
    $func = 'mt_rand';
  }
  $number = $func($min, $max);
  if ($int || abs($number) === 180) {
    return $number;
  }
  $decimals = $func(1, pow(10, 5)) / pow(10, 5);
  return round($number + $decimals, 5);
}