/**
  * Display data
  */
 protected function setDataToCode()
 {
     $this->Code .= '<table class="fullwidth zebra-style">';
     $this->Code .= '<thead><tr>';
     $this->Code .= '<th></th>';
     $this->Code .= '<th>' . __('Distance') . '</th>';
     $this->Code .= '<th>' . __('Time') . '</th>';
     $this->Code .= '<th>' . __('Swolf') . '</th>';
     $this->Code .= '<th>' . __('Strokes') . '</th>';
     $this->Code .= '<th>' . __('Type') . '</th>';
     $this->Code .= '</tr></thead>';
     $this->Code .= '<tbody>';
     $Loop = new Swimdata\Loop($this->Context->swimdata());
     $TrackLoop = new Trackdata\Loop($this->Context->trackdata());
     $Stroketype = new Stroketype(Stroketype::FREESTYLE);
     $Distance = new Distance(0);
     $max = $Loop->num();
     for ($i = 1; $i <= $max; ++$i) {
         $Stroketype->set($Loop->stroketype());
         $Distance->set($TrackLoop->distance());
         $this->Code .= '<tr class="r">';
         $this->Code .= '<td>' . $i . '.</td>';
         $this->Code .= '<td>' . $Distance->stringMeter() . '</td>';
         $this->Code .= '<td>' . Duration::format($TrackLoop->difference(Trackdata\Object::TIME)) . '</td>';
         $this->Code .= '<td>' . $Loop->swolf() . '</td>';
         $this->Code .= '<td>' . $Loop->stroke() . '</td>';
         $this->Code .= '<td>' . $Stroketype->shortstring() . '</td>';
         $this->Code .= '</tr>';
         $TrackLoop->nextStep();
         $Loop->nextStep();
     }
     $this->Code .= '</tbody>';
     $this->Code .= '</table>';
 }
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
 /**
  * @param \SimpleXMLElement $trackpoint
  * @param \Runalyze\Model\Trackdata\Loop $trackdataLoop
  */
 protected function addTrackdataDetailsTo(\SimpleXMLElement $trackpoint, Trackdata\Loop $trackdataLoop)
 {
     if ($this->TrackdataHas[Trackdata\Entity::CADENCE]) {
         $trackpoint->addChild('Cadence', $trackdataLoop->current(Trackdata\Entity::CADENCE));
     }
     if ($this->TrackdataHas[Trackdata\Entity::DISTANCE]) {
         $trackpoint->addChild('DistanceMeters', 1000 * $trackdataLoop->distance());
     }
     if ($this->TrackdataHas[Trackdata\Entity::HEARTRATE]) {
         $trackpoint->addChild('HeartRateBpm')->addChild('Value', $trackdataLoop->current(Trackdata\Entity::HEARTRATE));
     }
     if ($this->TrackdataHas[Trackdata\Entity::POWER] || $this->TrackdataHas[Trackdata\Entity::PACE]) {
         $TPX = $trackpoint->addChild('Extensions')->addChild('TPX', '', 'http://www.garmin.com/xmlschemas/ActivityExtension/v2');
         if ($this->TrackdataHas[Trackdata\Entity::PACE]) {
             $TPX->addChild('Speed', $this->convertPaceToSpeed($trackdataLoop->current(Trackdata\Entity::PACE)));
         }
         if ($this->TrackdataHas[Trackdata\Entity::POWER]) {
             $TPX->addChild('Watts', $trackdataLoop->current(Trackdata\Entity::POWER));
         }
     }
 }
 /**
  * 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));
             }
         }
     }
 }