Beispiel #1
0
 /**
  * Set track
  */
 protected function setTrack()
 {
     $this->prepareLoop();
     while ($this->RouteLoop->nextStep()) {
         $this->TrackdataLoop->nextStep();
         if ($this->thereWasAPause()) {
             $this->setPauseToXml();
         }
         $this->addCoordinateToCurrentPath($this->RouteLoop->coordinate());
     }
     $this->addCurrentPathToXml();
 }
 /**
  * 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>';
 }
 /**
  * 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 #4
0
 /**
  * Next step
  * @return boolean
  */
 protected function nextStep()
 {
     if ($this->hasTrackdataLoop()) {
         $this->TrackdataLoop->nextStep();
     }
     return $this->RouteLoop->nextStep();
 }
 /**
  * Display course
  */
 public function displayCourse()
 {
     $this->Context = new Context(Request::sendId(), Request::param('account'));
     if (!$this->activityIsValid() || !$this->Context->hasRoute() || !$this->Context->route()->hasPositionData()) {
         die('Don\'t do that!');
     }
     $Linker = new Linker($this->Context->activity());
     echo '<meta property="og:type" content="metadata">' . NL;
     echo '<link rel="origin" href="' . $Linker->publicUrl() . '">' . NL;
     $this->RouteLoop = new Model\Route\Loop($this->Context->route());
     $this->RouteLoop->setStepSize(self::STEP_SIZE);
     $this->TrackdataLoop = new Model\Trackdata\Loop($this->Context->trackdata());
     $this->TrackdataLoop->setStepSize(self::STEP_SIZE);
     do {
         $this->displayActivityDataPoint();
     } while ($this->RouteLoop->nextStep() && $this->TrackdataLoop->nextStep());
 }
 /**
  * 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\Object::HEARTRATE);
     while ($Trackdata->nextStep()) {
         $Route->nextStep();
         $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\Object::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\Object::HEARTRATE));
         }
     }
 }
Beispiel #7
0
 public function fillSwolfArray(Trackdata\Entity &$trackdata)
 {
     if ($this->stroke() && $trackdata->has(Trackdata\Entity::TIME)) {
         $TrackLoop = new Trackdata\Loop($trackdata);
         $Loop = new Loop($this);
         $max = $Loop->num();
         $swolf = array();
         $swolfcycles = array();
         for ($i = 1; $i <= $max; ++$i) {
             $duration = $TrackLoop->difference(Trackdata\Entity::TIME);
             $swolf[] = $duration + $Loop->stroke();
             $swolfcycles[] = $duration + $Loop->stroke() / 2;
             $Loop->nextStep();
             $TrackLoop->nextStep();
         }
         $this->set(Entity::SWOLF, $swolf);
         $this->set(Entity::SWOLFCYCLES, $swolfcycles);
     }
 }
Beispiel #8
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));
             }
         }
     }
 }