private function WKT::parsePolygon in geoPHP 8
Same name and namespace in other branches
- 7 geoPHP/lib/adapters/WKT.class.php \WKT::parsePolygon()
1 call to WKT::parsePolygon()
- WKT::parseMultiPolygon in geoPHP/
lib/ adapters/ WKT.class.php
File
- geoPHP/
lib/ adapters/ WKT.class.php, line 84
Class
- WKT
- WKT (Well Known Text) Adapter
Code
private function parsePolygon($data_string) {
$data_string = $this
->trimParens($data_string);
// If it's marked as empty, then return an empty polygon
if ($data_string == 'EMPTY') {
return new Polygon();
}
$parts = explode('),(', $data_string);
$lines = array();
foreach ($parts as $part) {
if (!$this
->beginsWith($part, '(')) {
$part = '(' . $part;
}
if (!$this
->endsWith($part, ')')) {
$part = $part . ')';
}
$lines[] = $this
->parseLineString($part);
}
return new Polygon($lines);
}