You are here

function weather_calculate_beaufort in Weather 7

Same name and namespace in other branches
  1. 7.3 weather_theme.inc \weather_calculate_beaufort()
  2. 7.2 weather_theme.inc \weather_calculate_beaufort()

Calculate Beaufort wind scale for given wind speed.

@link http://en.wikipedia.org/wiki/Beaufort_scale

Parameters

int $wind_speed: Wind speed in km/h.

Return value

int Beaufort number.

1 call to weather_calculate_beaufort()
weather_format_wind in ./weather_theme.inc
Convert wind.

File

./weather_theme.inc, line 465
Prepare themed weather output.

Code

function weather_calculate_beaufort($wind_speed) {
  if ($wind_speed >= 120) {
    return 12;
  }
  if ($wind_speed >= 103) {
    return 11;
  }
  if ($wind_speed >= 88) {
    return 10;
  }
  if ($wind_speed >= 76) {
    return 9;
  }
  if ($wind_speed >= 63) {
    return 8;
  }
  if ($wind_speed >= 51) {
    return 7;
  }
  if ($wind_speed >= 40) {
    return 6;
  }
  if ($wind_speed >= 30) {
    return 5;
  }
  if ($wind_speed >= 20) {
    return 4;
  }
  if ($wind_speed >= 12) {
    return 3;
  }
  if ($wind_speed >= 7) {
    return 2;
  }
  if ($wind_speed >= 1) {
    return 1;
  }
  return 0;
}