You are here

private function WKT::parseMultiPolygon in geoPHP 8

Same name and namespace in other branches
  1. 7 geoPHP/lib/adapters/WKT.class.php \WKT::parseMultiPolygon()

File

geoPHP/lib/adapters/WKT.class.php, line 131

Class

WKT
WKT (Well Known Text) Adapter

Code

private function parseMultiPolygon($data_string) {
  $data_string = $this
    ->trimParens($data_string);

  // If it's marked as empty, then return an empty multi-polygon
  if ($data_string == 'EMPTY') {
    return new MultiPolygon();
  }
  $parts = explode(')),((', $data_string);
  $polys = array();
  foreach ($parts as $part) {

    // Repair the string if the explode broke it
    if (!$this
      ->beginsWith($part, '((')) {
      $part = '((' . $part;
    }
    if (!$this
      ->endsWith($part, '))')) {
      $part = $part . '))';
    }
    $polys[] = $this
      ->parsePolygon($part);
  }
  return new MultiPolygon($polys);
}