/** * @param \Runalyze\Data\Laps\Lap $Lap * @param array $AdditionalData */ protected function addVDOTToDataFrom(Lap $Lap, array &$AdditionalData) { $VDOT = new Calculation\JD\VDOT(); $VDOT->fromPaceAndHR($Lap->distance()->kilometer(), $Lap->duration()->seconds(), $Lap->HRavg()->inPercent() / 100); if ($VDOT->value() > 0) { $AdditionalData[Activity\Entity::VDOT] = $VDOT->value(); } }
/** * Calculate VDOT by heart rate * @param float $distance [optional] * @return float */ public function calculateVDOTbyHeartRate($distance = null) { if (is_null($distance)) { $distance = $this->Activity->distance(); } $VDOT = new JD\VDOT(); $VDOT->fromPaceAndHR($distance, $this->Activity->duration(), $this->Activity->hrAvg() / Configuration::Data()->HRmax()); return $VDOT->value(); }
/** * Get fieldset for VDOT * @return \FormularFieldset */ public function getFieldsetVDOT() { $Table = '<table class="fullwidth zebra-style"> <thead> <tr> <th colspan="10">' . sprintf(__('VDOT values of the last %s days'), Configuration::Vdot()->days()) . '</th> </tr> </thead> <tbody class="top-and-bottom-border">'; $Tooltip = new Tooltip(''); $VDOT = new VDOT(0, new VDOTCorrector(Configuration::Data()->vdotFactor())); $VDOTs = DB::getInstance()->query('SELECT `id`,`time`,`distance`,IF(`vdot_with_elevation`>0,`vdot_with_elevation`,`vdot`) as `vdot` FROM `' . PREFIX . 'training` WHERE time>=' . (time() - Configuration::Vdot()->days() * DAY_IN_S) . ' AND vdot>0 AND use_vdot=1 AND accountid = ' . SessionAccountHandler::getId() . ' ORDER BY time ASC')->fetchAll(); foreach ($VDOTs as $i => $Data) { if ($i % 10 == 0) { $Table .= '<tr>'; } $Tooltip->setText(date('d.m.Y', $Data['time']) . ': ' . Distance::format($Data['distance'])); $VDOT->setValue($Data['vdot']); $Table .= '<td ' . $Tooltip->attributes() . '>' . Ajax::trainingLink($Data['id'], $VDOT->value()) . '</td>'; if ($i % 10 == 9) { $Table .= '</tr>'; } } if (count($VDOTs) % 10 != 0) { $Table .= HTML::emptyTD(10 - count($VDOTs) % 10); } $Table .= '</tbody></table>'; $Fieldset = new FormularFieldset(__('VDOT')); $Fieldset->addBlock(sprintf(__('The VDOT value is the average, weighted by the time, of the VDOT of your activities in the last %s days.'), Configuration::Vdot()->days())); $Fieldset->addBlock(sprintf(__('Your current VDOT shape: <strong>%s</strong><br> '), Configuration::Data()->vdot())); $Fieldset->addBlock($Table); $Fieldset->addInfo(__('Jack Daniels uses VDOT as a fixed value and not based on the training progress.<br>' . 'We do instead predict the VDOT from all activities based on the heart rate. ' . 'These formulas are derived from Jack Daniels\' tables as well.')); return $Fieldset; }
/** * 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 . ' m</span> </div> <div class="w50 double-height-right"> <label>⇒ ' . __('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(); }