protected function WktGenerator::generatePolygon in Geofield 8
Generates a polygon components array.
Parameters
array $start: The starting point. If not provided, will be randomly generated.
int $segments: Number of segments. If not provided, will be randomly generated.
Return value
array The polygon components coordinates.
2 calls to WktGenerator::generatePolygon()
- WktGenerator::generateMultipolygon in src/
WktGenerator.php - Generates a multipolygon coordinates.
- WktGenerator::wktGeneratePolygon in src/
WktGenerator.php - Returns a WKT format polygon feature.
File
- src/
WktGenerator.php, line 245
Class
- WktGenerator
- Helper class that generates WKT format geometries.
Namespace
Drupal\geofieldCode
protected function generatePolygon(array $start = NULL, $segments = NULL) {
$start = $start ? $start : $this
->randomPoint();
$segments = $segments ? $segments : $this
->ddGenerate(2, 4, TRUE);
$poly = $this
->generateLinestring($start, $segments);
// Close the polygon.
$poly[] = $start;
return $poly;
}