private function createPoints(array $elevations) { $points = array(); foreach ($elevations as $index => $elevation) { $point = new Point(); $point->setTime(new \DateTime('+' . $index * 5 . ' seconds')); $point->setElevation($elevation); $points[] = $point; } return $points; }
protected function parseTrackpoint(\SimpleXMLElement $trackpointNode) { // Skip the point if lat/lng not found if (!isset($trackpointNode->Position->LatitudeDegrees) || !isset($trackpointNode->Position->LongitudeDegrees)) { return; } $point = new Point(); $point->setElevation((double) $trackpointNode->AltitudeMeters); $point->setDistance((double) $trackpointNode->DistanceMeters); $point->setLatitude((double) $trackpointNode->Position->LatitudeDegrees); $point->setLongitude((double) $trackpointNode->Position->LongitudeDegrees); $point->getTime()->modify((string) $trackpointNode->Time); if (isset($trackpointNode->HeartRateBpm->Value)) { $point->setHeartRate((int) $trackpointNode->HeartRateBpm->Value); } if (isset($trackpointNode->Extensions->TPX->Speed)) { $point->setSpeed($this->convertSpeed((double) $trackpointNode->Extensions->TPX->Speed)); } return $point; }