You are here

protected function KML::_extractCoordinates in geoPHP 7

Same name and namespace in other branches
  1. 8 geoPHP/lib/adapters/KML.class.php \KML::_extractCoordinates()
2 calls to KML::_extractCoordinates()
KML::parseLineString in geoPHP/lib/adapters/KML.class.php
KML::parsePoint in geoPHP/lib/adapters/KML.class.php

File

geoPHP/lib/adapters/KML.class.php, line 175

Class

KML
PHP Geometry/KML encoder/decoder

Code

protected function _extractCoordinates($xml) {
  $coord_elements = $this
    ->childElements($xml, 'coordinates');
  $coordinates = array();
  if (count($coord_elements)) {
    $coord_sets = explode(' ', preg_replace('/[\\r\\n]+/', ' ', $coord_elements[0]->nodeValue));
    foreach ($coord_sets as $set_string) {
      $set_string = trim($set_string);
      if ($set_string) {
        $set_array = explode(',', $set_string);
        if (count($set_array) >= 2) {
          $coordinates[] = $set_array;
        }
      }
    }
  }
  return $coordinates;
}