/** * 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)); } } }
/** * @param \Runalyze\View\Activity\Context $context * @return array */ protected function computeRounds(Activity\Context $context) { $Loop = new Trackdata\Loop($context->trackdata()); $Rounds = array(); do { $Loop->nextDistance(); $Rounds[] = array('km' => $Loop->difference(Trackdata\Object::DISTANCE), 's' => $Loop->difference(Trackdata\Object::TIME)); } while (!$Loop->isAtEnd()); return $Rounds; }
/** * Go to end and read last lap */ protected function finish() { $this->TrackdataLoop->goToEnd(); if (!is_null($this->RouteLoop)) { $this->RouteLoop->goToEnd(); } $this->readLap(); }
/** * Check for pause */ protected function checkForPause() { if (!is_null($this->Trackdata) && $this->Trackdata->hasPauses()) { if ($this->PauseIndex < $this->Trackdata->pauses()->num() && $this->Trackdata->pauses()->at($this->PauseIndex)->time() <= $this->Trackdata->at($this->TrackdataLoop->index(), Trackdata\Entity::TIME)) { $this->addCurrentPauseIcon(); $this->PathShouldBreak = true; $this->PauseIndex++; } } elseif (!Configuration::ActivityView()->routeBreak()->never() && $this->RouteLoop->calculatedStepDistance() > $this->PauseLimit) { $this->addCurrentSegment(); } }
/** * 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()); }
/** * 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">'; }
/** * @param string $key Object key to move */ protected function runFastSmoothingForKey($key) { $started = false; while (!$this->Loop->isAtEnd()) { $this->Loop->move($key, $this->StepSize); $dist = $this->Loop->difference(Trackdata\Object::DISTANCE); $pace = $dist > 0 ? round($this->Loop->difference(Trackdata\Object::TIME) / $dist) : 0; if ($this->KeepArraySize) { $steps = $this->Loop->currentStepSize(); if (!$started) { $steps += 1; $started = true; } for ($i = 0; $i < $steps; ++$i) { $this->Smoothed[] = $pace; } } else { $this->Smoothed[] = $pace; } } }
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); } }
/** * @param \Runalyze\Model\Trackdata\Loop $Loop * @return array */ protected function halfFromLoop(Trackdata\Loop $Loop) { return array('s' => $Loop->difference(Trackdata\Entity::TIME), 'km' => $Loop->difference(Trackdata\Entity::DISTANCE)); }
/** * @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)); } } } }
/** * @return bool */ protected function thereWasAPause() { return $this->CurrentPauseIndex < $this->NumPauses && $this->CurrentPauseTime < $this->TrackdataLoop->time(); }