Exemple #1
0
 /**
  * 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;
 }
Exemple #2
0
 /**
  * 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);
 }
Exemple #3
0
 /**
  * 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);
 }
Exemple #4
0
 /**
  * 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();
 }
Exemple #5
0
 /**
  * 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;
 }