/**
  * Add track to xml 
  */
 protected function setTrack()
 {
     if (!$this->Context->hasTrackdata()) {
         return;
     }
     $Starttime = $this->Context->activity()->timestamp();
     $Trackdata = new Trackdata\Loop($this->Context->trackdata());
     $Route = $this->Context->hasRoute() && $this->Context->route()->hasPositionData() ? new Route\Loop($this->Context->route()) : null;
     $hasHeartrate = $this->Context->trackdata()->has(Trackdata\Object::HEARTRATE);
     $Track = $this->Activity->addChild('Track');
     $Track->addAttribute('StartTime', $this->timeToString($Starttime));
     while ($Trackdata->nextStep()) {
         $Point = $Track->addChild('pt');
         $Point->addAttribute('tm', $Trackdata->time());
         if (NULL !== $Route) {
             $Route->nextStep();
             $Point->addAttribute('lat', $Route->latitude());
             $Point->addAttribute('lon', $Route->longitude());
             $Point->addAttribute('ele', $Route->current(Route\Object::ELEVATIONS_ORIGINAL));
         }
         if ($hasHeartrate) {
             $Point->addAttribute('hr', $Trackdata->current(Trackdata\Object::HEARTRATE));
         }
     }
 }
Beispiel #2
0
 /**
  * Read lap
  */
 protected function readLap()
 {
     $Lap = new Lap($this->TrackdataLoop->difference(Trackdata\Object::TIME), $this->TrackdataLoop->difference(Trackdata\Object::DISTANCE));
     $Lap->setTrackDuration($this->TrackdataLoop->time());
     $Lap->setTrackDistance($this->TrackdataLoop->distance());
     $Lap->setHR($this->TrackdataLoop->average(Trackdata\Object::HEARTRATE), $this->TrackdataLoop->max(Trackdata\Object::HEARTRATE));
     $this->addElevationFor($Lap);
     $this->Laps->add($Lap);
 }
Beispiel #3
0
 /**
  * Add start and end icon
  */
 protected function addStartAndEndIcon()
 {
     if (!$this->addIconsAndInfo) {
         return;
     }
     $this->addMarker($this->Paths[0][0][0], $this->Paths[0][0][1], $this->startIcon(), __('Start'));
     if ($this->hasTrackdataLoop()) {
         $Tooltip = sprintf(__('<strong>Total:</strong> %s'), Distance::format($this->TrackdataLoop->distance()));
         $Tooltip .= '<br>' . sprintf(__('<strong>Time:</strong> %s'), Duration::format($this->TrackdataLoop->time()));
     } else {
         $Tooltip = '';
     }
     $this->addMarkerGeohash($this->RouteLoop->geohash(), $this->endIcon(), $Tooltip);
 }
    /**
     * Display activity data point
     */
    protected function displayActivityDataPoint()
    {
        // TODO: Elevation?
        //$elevation = ...
        $pace = $this->TrackdataLoop->average(Model\Trackdata\Entity::PACE);
        echo '
<meta property="fitness:metrics:location:latitude"  content="' . $this->RouteLoop->latitude() . '">
<meta property="fitness:metrics:location:longitude" content="' . $this->RouteLoop->longitude() . '">
<meta property="fitness:metrics:timestamp" content="' . date('Y-m-d\\TH:i', $this->Context->activity()->timestamp() + $this->TrackdataLoop->time()) . '">
<meta property="fitness:metrics:distance:value" content="' . $this->TrackdataLoop->distance() . '">
<meta property="fitness:metrics:distance:units" content="km">
<meta property="fitness:metrics:pace:value" content="' . $pace / 1000 . '">
<meta property="fitness:metrics:pace:units" content="s/m">
<meta property="fitness:metrics:speed:value" content="' . ($pace > 0 ? 1000 / $pace : 0) . '">
<meta property="fitness:metrics:speed:units" content="m/s">';
    }
Beispiel #5
0
 /**
  * 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());
 }
Beispiel #6
0
 /**
  * Add track to all laps to xml
  */
 protected function setTrack()
 {
     $Starttime = $this->Context->activity()->timestamp();
     $Trackdata = new Trackdata\Loop($this->Context->trackdata());
     if ($this->HasRoute) {
         $Route = new Route\Loop($this->Context->route());
     }
     while ($Trackdata->nextStep()) {
         if ($this->HasRoute) {
             $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()));
             if ($this->HasRoute) {
                 $this->addRouteDetailsTo($Trackpoint, $Route);
             }
             $this->addTrackdataDetailsTo($Trackpoint, $Trackdata);
         }
     }
 }
 /**
  * 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));
             }
         }
     }
 }
Beispiel #8
0
 /**
  * @return bool
  */
 protected function thereWasAPause()
 {
     return $this->CurrentPauseIndex < $this->NumPauses && $this->CurrentPauseTime < $this->TrackdataLoop->time();
 }