You are here

protected function GPX::parseRoutes in geoPHP 7

Same name and namespace in other branches
  1. 8 geoPHP/lib/adapters/GPX.class.php \GPX::parseRoutes()
1 call to GPX::parseRoutes()
GPX::geomFromXML in geoPHP/lib/adapters/GPX.class.php

File

geoPHP/lib/adapters/GPX.class.php, line 120

Class

GPX
PHP Geometry/GPX encoder/decoder

Code

protected function parseRoutes() {
  $lines = array();
  $rte_elements = $this->xmlobj
    ->getElementsByTagName('rte');
  foreach ($rte_elements as $rte) {
    $components = array();
    foreach ($this
      ->childElements($rte, 'rtept') as $rtept) {
      $lat = $rtept->attributes
        ->getNamedItem("lat")->nodeValue;
      $lon = $rtept->attributes
        ->getNamedItem("lon")->nodeValue;
      $components[] = new Point($lon, $lat);
    }
    $lines[] = new LineString($components);
  }
  return $lines;
}