You are here

protected function WktGenerator::generateMultipolygon in Geofield 8

Generates a multipolygon coordinates.

Return value

string The structured multipolygon coordinates.

1 call to WktGenerator::generateMultipolygon()
WktGenerator::wktGenerateMultipolygon in src/WktGenerator.php
Returns a WKT format multipolygon feature.

File

src/WktGenerator.php, line 291

Class

WktGenerator
Helper class that generates WKT format geometries.

Namespace

Drupal\geofield

Code

protected function generateMultipolygon() {
  $start = $this
    ->randomPoint();
  $num = $this
    ->ddGenerate(1, 5, TRUE);
  $segments = $this
    ->ddGenerate(2, 3, TRUE);
  $poly[] = $this
    ->buildPolygon($this
    ->generatePolygon($start, $segments));
  for ($i = 0; $i < $num; $i += 1) {
    $diff = $this
      ->randomPoint();
    $start[0] += $diff[0] / 100;
    $start[1] += $diff[1] / 100;
    $poly[] = $this
      ->buildPolygon($this
      ->generatePolygon($start, $segments));
  }
  return $this
    ->buildMultiCoordinates($poly);
}