diff --git a/src/WktGenerator.php b/src/WktGenerator.php index 3fc7e9d..e55d18d 100644 --- a/src/WktGenerator.php +++ b/src/WktGenerator.php @@ -309,4 +309,28 @@ class WktGenerator implements WktGeneratorInterface { return $this->buildWkt(GEOFIELD_TYPE_MULTIPOLYGON, $this->generateMultipolygon()); } + /** + * Builds a multipolygon coordinates. + * + * @param array $rings + * The array of polygon arrays. + * + * @return string + * The structured multipolygon coordinates. + */ + protected function buildMultipolygon(array $rings) { + $poly = []; + foreach ($rings as $ring) { + $poly[] = $this->buildPolygon($ring); + } + return $this->buildMultiCoordinates($poly); + } + + /** + * {@inheritdoc} + */ + public function wktBuildMultipolygon(array $rings) { + return $this->buildWkt(GEOFIELD_TYPE_MULTIPOLYGON, $this->buildMultipolygon($rings)); + } + } diff --git a/src/WktGeneratorInterface.php b/src/WktGeneratorInterface.php index 0f55883..1db23af 100644 --- a/src/WktGeneratorInterface.php +++ b/src/WktGeneratorInterface.php @@ -103,6 +103,17 @@ interface WktGeneratorInterface { */ public function wktGeneratePolygon(array $start = NULL, $segments = NULL); + /** + * Returns a WKT format multipolygon feature given an array of polygon points. + * + * @param array $rings + * The array of polygon arrays. + * + * @return string + * The WKT multipolygon feature. + */ + public function wktBuildMultipolygon(array $rings); + /** * Returns a WKT format multipolygon feature. *