/** * Add track to xml */ protected function setTrack() { $Starttime = $this->Context->activity()->timestamp(); $Trackdata = new Trackdata\Loop($this->Context->trackdata()); $Route = new Route\Loop($this->Context->route()); $hasElevation = $this->Context->route()->hasOriginalElevations(); $hasHeartrate = $this->Context->trackdata()->has(Trackdata\Entity::HEARTRATE); do { $Trackpoint = $this->Track->addChild('trkpt'); $Trackpoint->addAttribute('lat', $Route->latitude()); $Trackpoint->addAttribute('lon', $Route->longitude()); $Trackpoint->addChild('time', $this->timeToString($Starttime + $Trackdata->time())); if ($hasElevation) { $Trackpoint->addChild('ele', $Route->current(Route\Entity::ELEVATIONS_ORIGINAL)); } if ($hasHeartrate) { $ext = $Trackpoint->addChild('extensions'); $tpe = $ext->addChild('gpxtpx:TrackPointExtension', '', 'http://www.garmin.com/xmlschemas/TrackPointExtension/v1'); $tpe->addChild('gpxtpx:hr', $Trackdata->current(Trackdata\Entity::HEARTRATE)); } } while ($Trackdata->nextStep() && $Route->nextStep()); }
/** * @param \SimpleXMLElement $trackpoint * @param \Runalyze\Model\Route\Loop $routeLoop */ protected function addRouteDetailsTo(\SimpleXMLElement $trackpoint, Route\Loop $routeLoop) { if ($this->RouteHas[Route\Entity::GEOHASHES]) { $Position = $trackpoint->addChild('Position'); $Position->addChild('LatitudeDegrees', $routeLoop->latitude()); $Position->addChild('LongitudeDegrees', $routeLoop->longitude()); } if ($this->RouteHas[Route\Entity::ELEVATIONS_ORIGINAL]) { $trackpoint->addChild('AltitudeMeters', $routeLoop->current(Route\Entity::ELEVATIONS_ORIGINAL)); } }
/** * Add track to all laps to xml */ protected function setTrack() { $Starttime = $this->Context->activity()->timestamp(); $Trackdata = new Trackdata\Loop($this->Context->trackdata()); $Route = new Route\Loop($this->Context->route()); $hasElevation = $this->Context->route()->hasOriginalElevations(); $hasHeartrate = $this->Context->trackdata()->has(Trackdata\Object::HEARTRATE); while ($Trackdata->nextStep()) { $Route->nextStep(); if ($this->Activity->Lap[(int) floor($Trackdata->distance())]) { $Trackpoint = $this->Activity->Lap[(int) floor($Trackdata->distance())]->Track->addChild('Trackpoint'); $Trackpoint->addChild('Time', $this->timeToString($Starttime + $Trackdata->time())); $Position = $Trackpoint->addChild('Position'); $Position->addChild('LatitudeDegrees', $Route->latitude()); $Position->addChild('LongitudeDegrees', $Route->longitude()); if ($hasElevation) { $Trackpoint->addChild('AltitudeMeters', $Route->current(Route\Object::ELEVATIONS_ORIGINAL)); } $Trackpoint->addChild('DistanceMeters', 1000 * $Trackdata->distance()); if ($hasHeartrate) { $Heartrate = $Trackpoint->addChild('HeartRateBpm'); $Heartrate->addChild('Value', $Trackdata->current(Trackdata\Object::HEARTRATE)); } } } }