You are here

function _wkt_generate in Geofield 7

Helper to generate a random WKT string

Try to keeps values sane, no shape is more than 100km across

1 call to _wkt_generate()
_geofield_devel_generate in ./geofield.devel_generate.inc

File

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

Code

function _wkt_generate() {
  $types = array(
    'point',
    'linestring',
    'polygon',
    'multipoint',
    'multilinestring',
    'multipolygon',
  );

  // don't always generate the same type
  shuffle($types);
  $type = $types[0];
  $func = '_wkt_generate_' . $type;
  if (function_exists($func)) {
    $wkt = $func();
    return drupal_strtoupper($type) . ' (' . $wkt . ')';
  }
  return 'POINT (0 0)';
}