/** * @param \Runalyze\Model\Activity\Entity $activity * @param \Runalyze\Model\Route\Entity $route * @param int $offset * @return \Runalyze\Calculation\NightDetector $this-reference */ public function setFromEntities(Activity\Entity $activity, Route\Entity $route, $offset = 0) { if ($route->hasGeohashes() && $route->get(Route\Entity::STARTPOINT) != '') { $timestamp = $activity->timestamp() + 0.5 * $activity->duration(); $coordinate = (new Geohash())->decode($route->get(Route\Entity::STARTPOINT))->getCoordinate(); $this->setFrom($timestamp, $coordinate, $offset); } else { $this->Value = null; } return $this; }
/** * 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()); } }
/** * 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()); } }