/** * Database key * @return string */ public function column() { if (\Runalyze\Configuration::Vdot()->useElevationCorrection()) { return 'vdot_with_elevation'; } return 'vdot'; }
public function testStaticMethod() { Configuration::General()->temperatureUnit()->set(TemperatureUnit::CELSIUS); $unit = ' ' . Configuration::General()->TemperatureUnit()->unit(); $this->assertEquals('10.0' . $unit, Temperature::format(10, true, 1)); $this->assertEquals('12.35' . $unit, Temperature::format(12.3456, true, 2)); }
/** * Init pointer to DB/Error-object */ protected function initInternalObjects() { parent::initInternalObjects(); if (!\Runalyze\Configuration::Privacy()->showPrivateActivitiesInList()) { $this->DatasetQuery->showOnlyPublicActivities(); } }
/** * Athlete * @return \Runalyze\Athlete */ public static function Athlete() { if (!isset(self::$Objects['athlete'])) { self::$Objects['athlete'] = new Athlete(Configuration::General()->gender(), Configuration::Data()->HRmax(), Configuration::Data()->HRrest(), null, null, Configuration::Data()->vdot()); } return self::$Objects['athlete']; }
/** * Add to plot * @param \Plot $Plot * @param int $yAxis * @param boolean $addAnnotations [optional] */ public function addTo(Plot &$Plot, $yAxis, $addAnnotations = true) { if (empty($this->Data)) { return; } parent::addTo($Plot, $yAxis, $addAnnotations); switch ($this->XAxis) { case DataCollector::X_AXIS_DISTANCE: $Plot->setXUnitFactor(Configuration::General()->distanceUnitSystem()->distanceToPreferredUnitFactor(), Configuration::General()->distanceUnitSystem()->distanceUnit()); $stepSize = Configuration::General()->distanceUnitSystem()->distanceToKmFactor(); if ($stepSize != round($stepSize)) { end($this->Data); $totalDistanceInKm = key($this->Data); while ($totalDistanceInKm / $stepSize > 15) { $stepSize *= 2; } while ($totalDistanceInKm / $stepSize < 4) { $stepSize /= 2; } $Plot->Options['xaxis']['tickSize'] = $stepSize; } break; case DataCollector::X_AXIS_TIME: $Plot->setXAxisAsTime(); $Plot->setXAxisTimeFormat("%h:%M:%S"); $Plot->Options['xaxis']['ticks'] = 5; break; case DataCollector::X_AXIS_INDEX: $Plot->hideXLabels(); } }
/** * Move Distance * @return bool */ public function nextDistance() { if (Configuration::General()->distanceUnitSystem()->isImperial()) { return $this->nextMile(); } return $this->nextKilometer(); }
/** * Parse general values */ protected function parseGeneralValues() { $this->TrainingObject->setTimestamp(strtotime((string) $this->XML['StartTime'])); if (!empty($this->XML['categoryName'])) { $this->guessSportID((string) $this->XML['categoryName']); } else { $this->TrainingObject->setSportid(Configuration::General()->mainSport()); } if (!empty($this->XML->Duration['TotalSeconds'])) { $this->TrainingObject->setTimeInSeconds(round((double) $this->XML->Duration['TotalSeconds'])); } if (!empty($this->XML->Distance['TotalMeters'])) { $this->TrainingObject->setDistance(round((double) $this->XML->Distance['TotalMeters']) / 1000); } if (!empty($this->XML->Calories['TotalCal'])) { $this->TrainingObject->setCalories((int) $this->XML->Calories['TotalCal']); } if (!empty($this->XML->Location['Name'])) { $this->TrainingObject->setRoute((string) $this->XML->Location['Name']); } if (!empty($this->XML->Weather['Temp'])) { $this->TrainingObject->setTemperature((int) $this->XML->Weather['Temp']); } if (!empty($this->XML->HeartRateMaximumBPM)) { $this->TrainingObject->setPulseMax((int) $this->XML->HeartRateMaximumBPM); } if (!empty($this->XML->HeartRateAverageBPM)) { $this->TrainingObject->setPulseAvg((int) $this->XML->HeartRateAverageBPM); } }
/** * Parse general values */ protected function parseGeneralValues() { $this->TrainingObject->setTimestamp(strtotime((string) $this->XML->GeneralInformation->startDate)); $this->TrainingObject->setCalories((int) $this->XML->GeneralInformation->calories); $this->TrainingObject->setSportid(Configuration::General()->mainSport()); $this->TrainingObject->setCreatorDetails($this->findCreator()); $this->TrainingObject->setComment((string) $this->XML->GeneralInformation->name); }
/** * Prepare summary */ protected function prepare() { $this->Title = __('All years'); $this->Timerange = 366 * DAY_IN_S; $this->TimeEnd = mktime(23, 59, 59, 12, 31, date('Y')); $this->TimeStart = mktime(0, 0, 1, 1, 1, date('Y', START_TIME)); $this->AdditionalColumns = 1 * ($this->Sportid == Configuration::General()->runningSport()); }
public function testStaticMethod() { Configuration::General()->weightUnit()->set(WeightUnit::KG); $unit = ' ' . Configuration::General()->weightUnit()->unit(); $this->assertEquals('10.0' . $unit, Weight::format(10, true, 1)); $this->assertEquals('12.346' . $unit, Weight::format(12.3456, true, 3)); $this->assertEquals('12.3', Weight::format(12.3456, false, 1)); }
/** * Parse general values */ protected function parseGeneralValues() { $this->TrainingObject->setTimestamp(strtotime((string) $this->XML->DeviceLog->Header->DateTime)); if (!empty($this->XML->DeviceLog->Header->Activity)) { $this->guessSportID((string) $this->XML->DeviceLog->Header->Activity); } else { $this->TrainingObject->setSportid(Configuration::General()->runningSport()); } }
/** * Tasks before insertion */ protected function before() { parent::before(); $Calculator = new Calculator($this->Object); if (Configuration::ActivityForm()->correctElevation() && !$this->Object->hasCorrectedElevations()) { $Calculator->tryToCorrectElevation(); } $Calculator->calculateElevation(); }
/** * Manipulate data */ protected function manipulateData() { $UnitSystem = Configuration::General()->distanceUnitSystem(); if ($UnitSystem->isImperial()) { $this->Data = array_map(function ($value) { return $value * DistanceUnitSystem::FEET_MULTIPLIER / 1000 / 100; }, $this->Data); } }
/** * 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); }
/** * Initialize internal sports-array from database */ private static function initAllSports() { self::$AllSports = array(); $sports = self::cacheAllSports(); foreach ($sports as $sport) { self::$AllSports[(string) $sport['id']] = $sport; } Configuration::ActivityForm()->orderSports()->sort(self::$AllSports); }
/** * 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')); }
public function testWeekstartAndWeekendForSundayBug() { Configuration::General()->weekStart()->set(WeekStart::SUNDAY); $today = mktime(0, 0, 0, 10, 25, 2015); $end = mktime(23, 59, 50, 10, 31, 2015); $this->assertEquals($today, Time::weekstart($today)); $this->assertEquals($today, Time::weekstart($end)); $this->assertEquals($end, Time::weekend($today)); $this->assertEquals($end, Time::weekend($end)); }
/** * Get link to shared list for current user * @param string $text [optional] * @return string */ public static function getListLinkForCurrentUser($text = null) { if (!Configuration::Privacy()->listIsPublic()) { return ''; } if (is_null($text)) { $text = Icon::$ATTACH; } return '<a href="shared/' . SessionAccountHandler::getUsername() . '/" target="_blank" ' . Ajax::tooltip('', __('Public list'), false, true) . '>' . $text . '</a>'; }
/** * 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')); }
public function testSetupFromDatabase() { DB::getInstance()->insert('training', array('sportid', 'vdot_by_time', 's', 'distance'), array(Configuration::General()->runningSport(), 60, 16 * 60 + 6, 5)); DB::getInstance()->insert('training', array('sportid', 'vdot_by_time', 's', 'distance'), array(Configuration::General()->runningSport(), 45, 90 * 60 + 0, 21.1)); $this->object->setupFromDatabase(); $this->assertEquals(9 * 60 + 20, $this->object->inSeconds(3), '', 1); $this->assertEquals(16 * 60 + 6, $this->object->inSeconds(5), '', 1); $this->assertEquals(33 * 60 + 12, $this->object->inSeconds(10), '', 1); DB::getInstance()->exec('DELETE FROM `runalyze_training`'); }
/** * 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())); }
/** * Get string to display this dataset value * @param \Runalyze\Dataset\Context $context * @return string */ public function stringFor(Context $context) { if (!$context->activity()->splits()->isEmpty()) { if ($context->activity()->splits()->hasActiveAndInactiveLaps() || round($context->activity()->splits()->totalDistance()) != round($context->activity()->distance()) || $context->hasType() && $context->type()->id() == Configuration::General()->competitionType()) { $Icon = new Icon(Icon::CLOCK); $Icon->setTooltip($this->stringForActiveLaps($context->activity()->splits())); return $Icon->code(); } } return ''; }
/** * Construct laps */ protected function constructLaps() { $singleDistance = Configuration::General()->distanceUnitSystem()->distanceToKmFactor(); if ($this->Context->trackdata()->totalDistance() < $singleDistance) { $Distances = array($singleDistance); } else { $Distances = range($singleDistance, floor($this->Context->trackdata()->totalDistance()), $singleDistance); } $this->Laps = new Laps(); $this->Laps->calculateFrom($Distances, $this->Context->trackdata(), $this->Context->route()); }
/** * Set code */ protected function setCode() { $Reader = new StringReader($this->Context->activity()->comment()); $Splits = $this->Context->activity()->splits(); $SplitsView = new Splits\Table($Splits, $this->Context->dataview()->pace()->unitEnum()); $SplitsView->setDemandedPace($Reader->findDemandedPace()); if ($this->Context->trackdata()->has(Trackdata\Entity::DISTANCE) && $this->Context->activity()->typeid() == Configuration::General()->competitionType()) { $SplitsView->setHalfsOfCompetition($this->computeHalfs()); } $this->Code = $SplitsView->code(); }
/** * Get the timestamp of the start of the week * @param int $time * @return int */ public static function weekstart($time) { $w = date("w", $time); if (Configuration::General()->weekStart()->isMonday()) { if ($w == 0) { $w = 6; } else { $w -= 1; } } return mktime(0, 0, 0, date('m', $time), date('d', $time) - $w, date('Y', $time)); }
/** * Construct collector * @param \Runalyze\Model\Trackdata\Entity $trackdata * @param int $key * @param \Runalyze\Model\Swimdata\Entity $swimdata * @throws \InvalidArgumentException */ public function __construct(Trackdata $trackdata, $key, Swimdata $swimdata) { if (!$swimdata->has($key)) { throw new \InvalidArgumentException('Swimdata has no data for "' . $key . '".'); } $this->Key = $key; $this->Precision = Configuration::ActivityView()->plotPrecision(); $this->KnowsDistance = $trackdata->has(Trackdata::DISTANCE); $this->init($trackdata); $this->LoopSwimdata = new Loop($swimdata); $this->collect(); }
public function testSetupFromDatabase() { DB::getInstance()->insert('training', array('sportid', 'vdot_by_time', 's', 'distance'), array(Configuration::General()->runningSport(), 60, 16 * 60 + 32, 5)); DB::getInstance()->insert('training', array('sportid', 'vdot_by_time', 's', 'distance'), array(Configuration::General()->runningSport(), 45, 90 * 60 + 0, 21.1)); $this->object->setupFromDatabase(); $this->assertEquals(9 * 60 + 33, $this->object->inSeconds(3), '', 1); $this->assertEquals(16 * 60 + 32, $this->object->inSeconds(5), '', 1); $this->assertEquals(34 * 60 + 26, $this->object->inSeconds(10), '', 1); $this->assertEquals(1 * 60 * 60 + 15 * 60 + 56, $this->object->inSeconds(21.1), '', 1); $this->assertEquals(2 * 60 * 60 + 41 * 60 + 22, $this->object->inSeconds(42.2), '', 1); DB::getInstance()->exec('TRUNCATE TABLE `runalyze_training`'); }
/** * Init options */ protected function initOptions() { $this->Label = __('Elevation'); $this->Color = self::COLOR; $this->UnitString = Configuration::General()->distanceUnitSystem()->elevationUnit(); $this->UnitDecimals = 0; $this->TickSize = 10; $this->TickDecimals = 0; $this->ShowAverage = false; $this->ShowMaximum = true; $this->ShowMinimum = true; }
/** * Tasks before insertion */ protected function before() { parent::before(); $Calculator = new Calculator($this->Object); if (Configuration::ActivityForm()->correctElevation() && !$this->Object->hasCorrectedElevations()) { try { $Calculator->tryToCorrectElevation(); } catch (NoValidStrategyException $e) { // Well, obviously that did not work. Probably all API limits have been reached. } } $Calculator->calculateElevation(); }
/** * Set manipulation facotr */ protected function setManipulationFactor() { $this->Factor = 1; $this->HRmax = Configuration::Data()->HRmax(); $this->HRrest = Configuration::Data()->HRrest(); if (\Runalyze\Context::Athlete()->knowsMaximalHeartRate() && !Configuration::General()->heartRateUnit()->isBPM()) { if (\Runalyze\Context::Athlete()->knowsRestingHeartRate() && Configuration::General()->heartRateUnit()->isHRreserve()) { $this->Factor = false; } else { $this->Factor = 100 / Configuration::Data()->HRmax(); } } }