/** * Remove single series from trackdata * @param enum $key */ public function removeFromTrackdata($key) { if (isset($this->ActivityKeysForTrackdataKeys[$key])) { $this->removeFromActivityIfValueIsEqualToAverage($key, $this->ActivityKeysForTrackdataKeys[$key]); } $this->Trackdata->set($key, array()); }
/** * Update power for trackdata * @param array $powerData */ protected function updatePowerForTrackdata(array $powerData) { if (null !== $this->Trackdata && (empty($powerData) && $this->Trackdata->has(Model\Trackdata\Entity::POWER) || !empty($powerData) && !$this->Trackdata->has(Model\Trackdata\Entity::POWER))) { $this->Trackdata->set(Model\Trackdata\Entity::POWER, $powerData); $TrackdataUpdater = new Model\Trackdata\Updater($this->PDO); $TrackdataUpdater->setAccountID($this->AccountID); $TrackdataUpdater->update($this->Trackdata, array(Model\Trackdata\Entity::POWER)); } }
/** * Calculate power */ protected function calculatePower() { if (\Runalyze\Context::Factory()->sport($this->Object->sportid())->hasPower() && Configuration::ActivityForm()->computePower() && null !== $this->Trackdata) { $Calculator = new \Runalyze\Calculation\Power\Calculator($this->Trackdata, $this->Route); $Calculator->calculate(); $this->Trackdata->set(Model\Trackdata\Entity::POWER, $Calculator->powerData()); $this->Object->set(Entity::POWER, $Calculator->average()); } }
/** * Init data * @param \Runalyze\Model\Trackdata\Entity $trackdata * @param string $key */ protected function fillGaps(Trackdata $trackdata, $key) { $data = $trackdata->get($key); $last = $data[0]; foreach ($data as &$val) { if ($val == 0) { $val = $last; } $last = $val; } $trackdata->set($key, $data); }
/** * Construct time series for trackdata object * @param \Runalyze\Model\Trackdata\Entity $trackdata * @param int $indexKey enum * @param int[] $sumDifferencesKeys enums * @param int[] $avgValuesKeys enums * @throws \InvalidArgumentException */ public function __construct(Trackdata\Entity $trackdata, $indexKey, $sumDifferencesKeys = array(), $avgValuesKeys = array()) { $this->Trackdata = $trackdata; $this->IndexKey = $indexKey; $this->SumDifferencesKeys = $sumDifferencesKeys; $this->AvgValuesKeys = $avgValuesKeys; foreach (array_merge($sumDifferencesKeys, $avgValuesKeys) as $key) { if (!$trackdata->has($key)) { $trackdata->set($key, array_fill(0, $trackdata->num(), 0)); } } parent::__construct($trackdata->get($indexKey), $trackdata->get(Trackdata\Entity::TIME)); $this->collectData(); }
public function fillDistanceArray(Trackdata\Entity &$trackdata) { if ($this->poollength() && !$trackdata->has(Trackdata\Entity::DISTANCE)) { $distance = range($this->poollength() / 100000, $this->num() * $this->poollength() / 100000, $this->poollength() / 100000); $trackdata->set(Trackdata\Entity::DISTANCE, $distance); } }