You are here

public static function LiveWeather::windDirection in Live Weather 8

Same name and namespace in other branches
  1. 8.2 src/LiveWeather.php \Drupal\live_weather\LiveWeather::windDirection()

Get Wind Direction.

Overrides LiveWeatherInterface::windDirection

File

src/LiveWeather.php, line 105
Contains \Drupal\live_weather\LiveWeather.

Class

LiveWeather
Live weather.

Namespace

Drupal\live_weather

Code

public static function windDirection($direction) {
  if ($direction >= 348.75 && $direction <= 360) {
    $direction = "N";
  }
  elseif ($direction >= 0 && $direction < 11.25) {
    $direction = "N";
  }
  elseif ($direction >= 11.25 && $direction < 33.75) {
    $direction = "NNE";
  }
  elseif ($direction >= 33.75 && $direction < 56.25) {
    $direction = "NE";
  }
  elseif ($direction >= 56.25 && $direction < 78.75) {
    $direction = "ENE";
  }
  elseif ($direction >= 78.75 && $direction < 101.25) {
    $direction = "E";
  }
  elseif ($direction >= 101.25 && $direction < 123.75) {
    $direction = "ESE";
  }
  elseif ($direction >= 123.75 && $direction < 146.25) {
    $direction = "SE";
  }
  elseif ($direction >= 146.25 && $direction < 168.75) {
    $direction = "SSE";
  }
  elseif ($direction >= 168.75 && $direction < 191.25) {
    $direction = "S";
  }
  elseif ($direction >= 191.25 && $direction < 213.75) {
    $direction = "SSW";
  }
  elseif ($direction >= 213.75 && $direction < 236.25) {
    $direction = "SW";
  }
  elseif ($direction >= 236.25 && $direction < 258.75) {
    $direction = "WSW";
  }
  elseif ($direction >= 258.75 && $direction < 281.25) {
    $direction = "W";
  }
  elseif ($direction >= 281.25 && $direction < 303.75) {
    $direction = "WNW";
  }
  elseif ($direction >= 303.75 && $direction < 326.25) {
    $direction = "NW";
  }
  elseif ($direction >= 326.25 && $direction < 348.75) {
    $direction = "NNW";
  }
  return $direction;
}