/** * Display * @return string */ public function code() { if ($this->WindSpeed->isUnknown() && $this->WindDegree->isUnknown()) { return ''; } $code = '<span class="' . self::BASE_CLASS . '"' . $this->tooltipAttributes() . '>'; if (!$this->WindDegree->isUnknown()) { $code .= '<span class="' . self::DIRECTION_CLASS . '" style="transform:rotate(' . $this->WindDegree->value() . 'deg);"></span> '; } $code .= $this->WindSpeed->isUnknown() ? '?' : $this->WindSpeed->string(false); $code .= '</span>'; return $code; }
/** * Calculate and set adjusted temperature * @param \Runalyze\Data\Weather\WindSpeed $windSpeed * @param \Runalyze\Activity\Temperature $temperature * @param \Runalyze\Activity\Pace $activitySpeed * @param null|\Runalyze\Activity\Pace $activitySpeed * @throws \InvalidArgumentException * @see https://en.wikipedia.org/wiki/Wind_chill#North_American_and_United_Kingdom_wind_chill_index */ public function setFrom(WindSpeed $windSpeed, ActivityTemperature $temperature, Pace $activitySpeed = null) { if ($windSpeed->isUnknown() || $temperature->isEmpty()) { throw new \InvalidArgumentException('Wind speed and temperature must be known. Null value(s) given.'); } $kmh = $windSpeed->inKilometerPerHour(); $calc = $temperature->celsius(); if (null !== $activitySpeed) { $kmh = $windSpeed->inKilometerPerHour() + $activitySpeed->asKmPerHour(); } if ($kmh >= 5) { $calc = 13.12 + 0.6215000000000001 * $temperature->celsius() - 11.37 * pow($kmh, 0.16) + 0.3965 * $temperature->celsius() * pow($kmh, 0.16); } $this->AdjustedTemperature = clone $temperature; $this->AdjustedTemperature->set($calc); }
/** * Clear weather */ public function clear() { $this->Temperature->setTemperature(null); $this->Condition->set(Condition::UNKNOWN); $this->WindSpeed->set(null); $this->WindDegree->set(null); $this->Humidity->set(null); $this->Pressure->set(null); }
/** * Is the weather-data empty? * @return bool */ public function isEmpty() { return $this->Temperature->isUnknown() && $this->Condition->isUnknown() && $this->WindSpeed->isUnknown() && $this->WindDegree->isUnknown() && $this->Humidity->isUnknown() && $this->Pressure->isUnknown(); }
/** * Temperature * @return \Runalyze\Data\Weather\WindSpeed */ public function windSpeed() { $WindSpeed = new WindSpeed(); if (isset($this->Result['wind']) && isset($this->Result['wind']['speed'])) { $WindSpeed->setMilesPerHour($this->Result['wind']['speed']); } return $WindSpeed; }