protected function GPX::parseTracks in geoPHP 7
Same name and namespace in other branches
- 8 geoPHP/lib/adapters/GPX.class.php \GPX::parseTracks()
1 call to GPX::parseTracks()
- GPX::geomFromXML in geoPHP/
lib/ adapters/ GPX.class.php
File
- geoPHP/
lib/ adapters/ GPX.class.php, line 103
Class
- GPX
- PHP Geometry/GPX encoder/decoder
Code
protected function parseTracks() {
$lines = array();
$trk_elements = $this->xmlobj
->getElementsByTagName('trk');
foreach ($trk_elements as $trk) {
$components = array();
foreach ($this
->childElements($trk, 'trkseg') as $trkseg) {
foreach ($this
->childElements($trkseg, 'trkpt') as $trkpt) {
$lat = $trkpt->attributes
->getNamedItem("lat")->nodeValue;
$lon = $trkpt->attributes
->getNamedItem("lon")->nodeValue;
$components[] = new Point($lon, $lat);
}
}
if ($components) {
$lines[] = new LineString($components);
}
}
return $lines;
}