/** * Calculate swim values */ protected function calculateSwimValues() { if (null !== $this->Trackdata && null !== $this->Swimdata) { if ($this->Swimdata->stroke()) { $this->Object->set(Entity::TOTAL_STROKES, array_sum($this->Swimdata->stroke())); } if ($this->Object->totalStrokes() && $this->Trackdata->totalTime()) { $num = $this->Trackdata->num(); $totaltime = $this->Trackdata->totalTime(); $totalstrokes = $this->Object->totalStrokes(); if (!empty($totalstrokes) && !empty($totaltime) & !empty($num) && $totalstrokes != 0) { $this->Object->set(Entity::SWOLF, round(($totalstrokes + $totaltime) / $num)); } } } }
/** * Save changes for route */ protected function saveChangesForRoute() { if (null === $this->Route || $this->OldRoute->isEmpty()) { return; } $this->Route->synchronize(); if ($this->Route->isEmpty()) { $Deleter = new Model\Route\Deleter($this->PDO, $this->Route); $Deleter->setAccountID($this->AccountID); $Deleter->delete(); $this->Route = null; $this->Activity->set(Entity::ROUTEID, 0); $this->Activity->set(Entity::ELEVATION, 0); } else { $Updater = new Model\Route\Updater($this->PDO, $this->Route, $this->OldRoute); $Updater->setAccountID($this->AccountID); $Updater->update(); } }
/** * Update if activity was at night */ protected function updateIfActivityWasAtNight() { if (null !== $this->Route && $this->Route->hasGeohashes() && $this->hasChanged(Entity::TIMESTAMP)) { $this->NewObject->set(Entity::IS_NIGHT, (new NightDetector())->setFromEntities($this->NewObject, $this->Route)->value()); } }
/** * Update vertical ratio */ protected function updateVerticalRatio() { if ($this->hasChanged(Entity::SPORTID) || $this->hasChanged(Entity::VERTICAL_OSCILLATION) || $this->hasChanged(Entity::STRIDE_LENGTH)) { $this->NewObject->set(Entity::VERTICAL_RATIO, VerticalRatioCalculator::forActivity($this->NewObject)); } }
/** * Calculate if activity was at night */ protected function calculateIfActivityWasAtNight() { if (null !== $this->Route && $this->Route->hasGeohashes()) { $this->Object->set(Entity::IS_NIGHT, (new NightDetector())->setFromEntities($this->Object, $this->Route)->value()); } }