예제 #1
0
 /**
  * Create series
  * @var \Runalyze\View\Activity\Context $context
  */
 public function __construct(Activity\Context $context)
 {
     $this->initOptions();
     $this->initData($context->trackdata());
     $this->manipulateData();
     $this->setManualAverage($context->activity()->strideLength());
 }
예제 #2
0
 /**
  * Create series
  * @var \Runalyze\View\Activity\Context $context
  */
 public function __construct(Activity\Context $context)
 {
     $this->initOptions();
     $this->initData($context->trackdata(), Trackdata::GROUNDCONTACT_BALANCE);
     $this->setManualAverage($context->activity()->groundContactBalance() / 100);
     $this->manipulateData();
 }
예제 #3
0
 /**
  * Create series
  * @var \Runalyze\View\Activity\Context $context
  */
 public function __construct(Activity\Context $context)
 {
     $this->setManipulationFactor();
     $this->initOptions();
     $this->initData($context->trackdata(), Trackdata::HEARTRATE, true);
     $this->manipulateData();
 }
예제 #4
0
 /**
  * Create series
  * @var \Runalyze\View\Activity\Context $context
  */
 public function __construct(Activity\Context $context)
 {
     $this->initOptions();
     $this->initData($context->trackdata(), Trackdata::VERTICAL_OSCILLATION);
     $this->manipulateData();
     $this->setManualAverage($context->activity()->verticalOscillation() * 0.1);
 }
예제 #5
0
 /**
  * Constructor
  * @param \Runalyze\View\Activity\Context $context
  */
 public function __construct(Context $context)
 {
     $this->Context = $context;
     if ($this->Context->trackdata()->has(Runalyze\Model\Trackdata\Entity::TIME)) {
         $this->initData();
         $this->convertData();
     }
 }
예제 #6
0
파일: Heartrate.php 프로젝트: 9x/Runalyze
 /**
  * Create series
  * @var \Runalyze\View\Activity\Context $context
  */
 public function __construct(Activity\Context $context)
 {
     $this->setManipulationFactor();
     $this->initOptions();
     $this->initData($context->trackdata(), Trackdata::HEARTRATE, true);
     $this->manipulateData();
     $this->setManualAverage(round(100 * $context->activity()->hrAvg() / $this->HRmax));
 }
예제 #7
0
 /**
  * @param \Runalyze\View\Activity\Context $context
  * @param int $offset
  * @return \Runalyze\Calculation\NightDetector $this-reference
  */
 public function setFromContext(Context $context, $offset = 0)
 {
     if (!$context->hasRoute()) {
         $this->Value = null;
         return $this;
     }
     return $this->setFromEntities($context->activity(), $context->route(), $offset);
 }
예제 #8
0
 /**
  * Create series
  * @var \Runalyze\View\Activity\Context $context
  */
 public function __construct(Activity\Context $context)
 {
     $this->isRunning = $context->activity()->sportid() == Configuration::General()->runningSport();
     $cadence = $this->isRunning ? new CadenceUnitRunning(0) : new CadenceUnit(0);
     $this->initOptions();
     $this->initData($context->trackdata(), Trackdata::CADENCE);
     $this->initStrings($cadence);
     $this->manipulateData($cadence);
 }
예제 #9
0
파일: Pace.php 프로젝트: guancio/Runalyze
 /**
  * Create series
  * @var \Runalyze\View\Activity\Context $context
  */
 public function __construct(Activity\Context $context)
 {
     $this->paceUnit = $context->sport()->paceUnit();
     $this->paceUnitEnum = $context->sport()->paceUnitEnum();
     $this->isRunning = $context->sport()->id() == Configuration::General()->runningSport();
     $this->initOptions();
     $this->initData($context->trackdata(), Trackdata::PACE);
     $this->manipulateData();
 }
예제 #10
0
파일: Pace.php 프로젝트: n0rthface/Runalyze
 /**
  * Create series
  * @var \Runalyze\View\Activity\Context $context
  */
 public function __construct(Activity\Context $context)
 {
     $this->paceUnit = $context->sport()->paceUnit();
     $this->paceInTime = $this->paceUnit == \Runalyze\Activity\Pace::MIN_PER_KM || $this->paceUnit == \Runalyze\Activity\Pace::MIN_PER_100M || $this->paceUnit == \Runalyze\Activity\Pace::MIN_PER_500M;
     $this->isRunning = $context->sport()->id() == Configuration::General()->runningSport();
     $this->initOptions();
     $this->initData($context->trackdata(), Trackdata::PACE);
     $this->manipulateData();
 }
예제 #11
0
 /**
  * Constructor
  * @param \Runalyze\View\Activity\Context $Context
  */
 public function __construct(\Runalyze\View\Activity\Context $Context)
 {
     $Pace = clone $Context->dataview()->pace();
     if (Configuration::General()->distanceUnitSystem()->isImperial()) {
         $Pace->setUnit(new PaceUnit\MinPerMile());
     } else {
         $Pace->setUnit(new PaceUnit\MinPerKilometer());
     }
     parent::__construct($Pace->value(), $Pace->appendix(), 'ø ' . __('Pace'));
 }
예제 #12
0
 /**
  * Create series
  * @var \Runalyze\View\Activity\Context $context
  */
 public function __construct(Activity\Context $context)
 {
     $this->isRunning = $context->activity()->sportid() == Configuration::General()->runningSport();
     $cadence = $this->isRunning ? new Data\Cadence\Running() : new Data\Cadence\General(0);
     $this->initOptions();
     $this->initData($context->trackdata(), Trackdata::CADENCE);
     $this->initStrings($cadence);
     $this->manipulateData($cadence);
     $this->setManualAverage($cadence->useFactor($context->activity()->cadence()));
 }
예제 #13
0
 /**
  * Construct
  * @param \Runalyze\View\Activity\Context $context
  */
 public function __construct(Activity\Context $context)
 {
     $this->setKey();
     $this->setID($context->activity()->id());
     $this->initPlot();
     $this->initData($context);
     if (!$this->dataIsAvailable()) {
         $this->Plot->raiseError(__('No plot available.'));
     }
 }
예제 #14
0
 /**
  * @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;
 }
예제 #15
0
파일: Laps.php 프로젝트: n0rthface/Runalyze
 /**
  * Splits are not complete
  * "Complete" means: all laps are active and fill total distance
  *
  * @param \Runalyze\View\Activity\Context $context
  * @return boolean
  */
 protected function splitsAreNotComplete(Activity\Context $context)
 {
     if ($context->activity()->splits()->isEmpty() || $context->activity()->splits()->totalDistance() <= 0) {
         return false;
     }
     if ($context->activity()->splits()->hasActiveAndInactiveLaps()) {
         return true;
     }
     if (abs($context->activity()->splits()->totalDistance() - $context->activity()->distance()) > 0.02 * $context->activity()->distance()) {
         return true;
     }
     return false;
 }
예제 #16
0
파일: LapsManual.php 프로젝트: 9x/Runalyze
 /**
  * Load data
  * @param \Runalyze\View\Activity\Context $context
  */
 protected function loadData(Activity\Context $context)
 {
     $Splits = $context->activity()->splits();
     if ($Splits->isEmpty() || $Splits->totalDistance() <= 0) {
         $this->Plot->raiseError(__('There are no manual laps.'));
         return;
     }
     $this->readDataFromSplits($Splits, !$Splits->hasActiveLaps(2));
     $num = count($this->Data);
     $Reader = new StringReader($context->activity()->comment());
     $this->demandedPace = $Reader->findDemandedPace();
     $this->achievedPace = array_sum($this->Data) / $num;
     $this->manipulateData($num);
 }
예제 #17
0
 /**
  * Init data
  * @param \Runalyze\View\Activity\Context $context
  */
 protected function initData(Activity\Context $context)
 {
     $Collector = new PointcareCollector($context->hrv());
     $this->Data = $Collector->data();
     if (empty($this->Data)) {
         return;
     }
     $this->Plot->Data[] = array('label' => __('Pointcare plot'), 'color' => 'rgb(0,0,0)', 'data' => $Collector->data());
     // TODO: ensure symmetric x-/y-axis
     // TODO: provide better tooltips
     $this->Plot->addYUnit(0, 'ms');
     $this->Plot->setXUnit('ms');
     $this->Plot->smoothing(false);
     $this->Plot->showPoints();
 }
예제 #18
0
 /**
  * Init data
  * @var \Runalyze\View\Activity\Context $context
  * @var boolean $forceOriginal
  */
 protected function initDataWithSwimdata(Activity\Context $context)
 {
     if (!$context->hasSwimdata()) {
         $this->Data = array();
         return;
     }
     $key = Swimdata::SWOLFCYCLES;
     if (!$context->swimdata()->has($key)) {
         $this->Data = array();
         return;
     }
     $Collector = new DataCollectorWithSwimdata($context->trackdata(), $key, $context->swimdata());
     $this->Data = $Collector->data();
     $this->XAxis = $Collector->xAxis();
 }
예제 #19
0
 /**
  * Construct plot data
  * @param enum $algorithm
  * @param int $treshold
  * @return array
  */
 protected function constructPlotDataFor($algorithm, $treshold = false)
 {
     $Method = new ElevationMethod();
     $Method->set($algorithm);
     if ($treshold === false) {
         $treshold = Configuration::ActivityView()->elevationMinDiff();
     }
     $Calculator = new Data\Elevation\Calculation\Calculator($this->Context->route()->elevations());
     $Calculator->setMethod($Method);
     $Calculator->setThreshold($treshold);
     $Calculator->calculate();
     $i = 0;
     $Data = array();
     $Points = $Calculator->strategy()->smoothedData();
     $Indices = $Calculator->strategy()->smoothingIndices();
     $hasDistances = $this->Context->trackdata()->get(Trackdata\Entity::DISTANCE);
     $Distances = $this->Context->trackdata()->get(Trackdata\Entity::DISTANCE);
     $Times = $this->Context->trackdata()->get(Trackdata\Entity::TIME);
     $num = $this->Context->trackdata()->num();
     foreach ($Indices as $i => $index) {
         if ($index >= $num) {
             $index = $num - 1;
         }
         if ($hasDistances) {
             $Data[(string) $Distances[$index]] = $Points[$i];
         } else {
             $Data[(string) $Times[$index] . '000'] = $Points[$i];
         }
     }
     $this->manipulateData($Data);
     return $Data;
 }
예제 #20
0
    /**
     * Display with corrector
     */
    protected function displayWithElevation()
    {
        if ($this->Context->hasRoute() && ($this->Context->route()->elevationUp() > 0 || $this->Context->route()->elevationDown())) {
            $up = $this->Context->route()->elevationUp();
            $down = $this->Context->route()->elevationDown();
        } else {
            $up = $this->Context->activity()->elevation();
            $down = $up;
        }
        $Modifier = new Elevation\DistanceModifier($this->Context->activity()->distance(), $up, $down, Configuration::Vdot());
        $VDOT = new JD\VDOT(0, new JD\VDOTCorrector(Configuration::Data()->vdotFactor()));
        $VDOT->fromPaceAndHR($Modifier->correctedDistance(), $this->Context->activity()->duration(), $this->Context->activity()->hrAvg() / Configuration::Data()->HRmax());
        $Fieldset = new FormularFieldset(__('Correction: considering elevation'));
        $Fieldset->setHtmlCode('
			<p class="warning small ' . (Configuration::Vdot()->useElevationCorrection() ? 'hide' : '') . '">
				' . __('This correction method is currently unused.') . '
			</p>

			<div class="w50">
				<label>' . __('Up/Down') . '</label>
				<span class="as-input">+' . $up . '/-' . $down . '&nbsp;m</span>
			</div>
			<div class="w50 double-height-right">
				<label>&rArr; ' . __('VDOT') . '</label>
				<span class="as-input ' . (!Configuration::Vdot()->useElevationCorrection() ? '' : 'highlight') . '">' . $VDOT->value() . '</span>
			</div>
			<div class="w50">
				<label>' . __('Influence') . '</label>
				<span class="as-input">' . sprintf("%+d", 1000 * $Modifier->additionalDistance()) . 'm = ' . Distance::format($Modifier->correctedDistance(), false, 3) . '</span>
			</div>
		');
        $Fieldset->display();
    }
예제 #21
0
 /**
  * Display shared menu
  */
 protected function displaySharedMenu()
 {
     $User = AccountHandler::getDataForId(SharedLinker::getUserId());
     $this->ToolbarLinks = array();
     $this->ToolbarLinks[] = SharedLinker::getStandardLinkTo($this->Context->activity()->id(), Icon::$ATTACH);
     $this->ToolbarLinks[] = '<a href="shared/' . $User['username'] . '/" target="_blank">' . Icon::$TABLE . '</a>';
     $this->displayHeaderMenu();
 }
예제 #22
0
파일: Window.php 프로젝트: guancio/Runalyze
 /**
  * Display rounds
  */
 protected function displayTable()
 {
     $this->DemandedPace->setUnit($this->Context->sport()->paceUnit());
     $Table = new Table($this->Laps, $this->DemandedTime, $this->DemandedPace, $this->Context->sport()->id() == Configuration::General()->runningSport());
     if ($this->LapDistance > 0) {
         $Table->setAverage($this->Context->dataview()->pace(), new Duration($this->Context->trackdata()->totalTime() / $this->Context->trackdata()->totalDistance() * $this->LapDistance));
     } else {
         $Table->setAverage($this->Context->dataview()->pace());
     }
     $Table->display();
 }
예제 #23
0
 /**
  * Constructor
  * @param \Runalyze\View\Activity\Context $Context
  */
 public function __construct(\Runalyze\View\Activity\Context $Context)
 {
     if ($Context->hasRoute()) {
         $upDown = '+' . ElevationBase::format($Context->route()->elevationUp(), false) . '/-' . ElevationBase::format($Context->route()->elevationDown(), false);
     } else {
         $upDown = '+' . ElevationBase::format($Context->activity()->elevation(), false) . '/-' . ElevationBase::format($Context->activity()->elevation(), false);
     }
     parent::__construct($upDown, Configuration::General()->distanceUnitSystem()->elevationUnit(), __('Elevation up/down'));
 }
예제 #24
0
 /**
  * Display prev/next navigation
  */
 protected function displayNavigation()
 {
     $prevId = Linker::prevId($this->Context->activity()->id(), $this->Context->activity()->timestamp());
     $nextId = Linker::nextId($this->Context->activity()->id(), $this->Context->activity()->timestamp());
     if ($prevId !== false) {
         echo Ajax::trainingLink($prevId, '<i class="fa fa-fw fa-chevron-left"></i>');
     } else {
         echo '<i class="transparent-70 fa-grey fa fa-fw fa-chevron-left"></i>';
     }
     if ($nextId !== false) {
         echo Ajax::trainingLink($nextId, '<i class="fa fa-fw fa-chevron-right"></i>');
     } else {
         echo '<i class="transparent-70 fa-grey fa fa-fw fa-chevron-right"></i>';
     }
 }
예제 #25
0
    /**
     * Display elevation correction
     */
    protected function displayElevationCorrection()
    {
        $Fieldset = new FormularFieldset(__('Elevation correction'));
        if ($this->Context->route()->elevationsCorrected()) {
            $Fieldset->addSmallInfo(__('Elevation data have been corrected.'));
        } else {
            $Linker = new Runalyze\View\Activity\Linker($this->Context->activity());
            // TODO: add link to "reload" if correction has been done via ajax
            $Fieldset->setHtmlCode('<p class="warning small block" id="gps-results">
					' . __('Elevation data has not been corrected.') . '<br>
					<br>
					<a class="ajax" target="gps-results" href="' . $Linker->urlToElevationCorrection() . '"><strong>&raquo; ' . __('correct now') . '</strong></a>
				</p>');
        }
        $Fieldset->display();
    }
예제 #26
0
    /**
     * 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">';
    }
예제 #27
0
파일: HRV.php 프로젝트: n0rthface/Runalyze
 /**
  * Determine correct x axis
  * @param \Runalyze\View\Activity\Context $context
  */
 protected function determineXAxis(Activity\Context $context)
 {
     if ($context->hasTrackdata()) {
         $totalTime = 1000 * $context->trackdata()->totalTime();
         if ($context->hrv()->num() == $context->trackdata()->num()) {
             $this->XAxisData = array_map(function ($value) {
                 return 1000 * $value;
             }, $context->trackdata()->time());
         } else {
             $correctTime = abs(array_sum($context->hrv()->data()) - $totalTime) > 0.005 * $totalTime;
             $time = 0;
             foreach ($context->hrv()->data() as $ms) {
                 $time += $correctTime && $ms < 1000 ? 1000 : $ms;
                 $this->XAxisData[] = $time;
             }
             if ($correctTime && abs($time - $totalTime) > 0.01 * $totalTime) {
                 $this->XAxisData = array();
             }
         }
     }
 }
예제 #28
0
    /**
     * Display elevation correction
     */
    protected function displayElevationCorrection()
    {
        $Url = (new Runalyze\View\Activity\Linker($this->Context->activity()))->urlToElevationCorrection();
        $Fieldset = new FormularFieldset(__('Elevation correction'));
        $Links = array();
        if ($this->Context->route()->elevationsCorrected()) {
            $textInfo = __('Elevation data has been corrected.') . ($this->Context->route()->elevationsSource() != '' ? ' (' . $this->Context->route()->elevationsSource() . ')' : '');
            $rawLinks = $this->getLinksForCorrectionStrategies();
        } else {
            $textInfo = __('Elevation data has not been corrected.');
            $rawLinks = array('' => __('correct now'));
        }
        foreach ($rawLinks as $urlAppendix => $text) {
            $Links[] = '<a class="ajax" target="gps-results" href="' . $Url . $urlAppendix . '"><strong>&raquo; ' . $text . '</strong></a>';
        }
        $Fieldset->setHtmlCode('<p class="info block" id="gps-results">' . $textInfo . '</p>
			<p class="info block">' . implode('<br>', $Links) . '</p>');
        $Fieldset->display();
    }
예제 #29
0
 /**
  * Init data
  * @var \Runalyze\View\Activity\Context $context
  * @var boolean $forceOriginal
  */
 protected function initDataWithRoute(Activity\Context $context, $forceOriginal)
 {
     if (!$context->hasRoute()) {
         $this->Data = array();
         return;
     }
     $key = $context->route()->hasCorrectedElevations() && !$forceOriginal ? Route::ELEVATIONS_CORRECTED : Route::ELEVATIONS_ORIGINAL;
     if (!$context->route()->has($key)) {
         $this->Data = array();
         return;
     }
     $Collector = new DataCollectorWithRoute($context->trackdata(), $key, $context->route());
     $this->Data = $Collector->data();
     $this->XAxis = $Collector->xAxis();
 }
예제 #30
0
 /**
  * Create series
  * @var \Runalyze\View\Activity\Context $context
  */
 public function __construct(Activity\Context $context)
 {
     $this->initOptions();
     $this->initData($context->trackdata());
     $this->manipulateData();
 }