You are here

private function WKT::parseMultiLineString in geoPHP 8

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

File

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

Class

WKT
WKT (Well Known Text) Adapter

Code

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

  // If it's marked as empty, then return an empty multi-linestring
  if ($data_string == 'EMPTY') {
    return new MultiLineString();
  }
  $parts = explode('),(', $data_string);
  $lines = 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 . ')';
    }
    $lines[] = $this
      ->parseLineString($part);
  }
  return new MultiLineString($lines);
}