function _wunderground_weather_speed_to_beaufort in Wunderground weather 7
Convert wind speed to beaufort.
Parameters
int $speed: Windspeed in kp/h or m/h.
string $unit: Windspeed unit.
Return value
int Windspeed in Bft.
2 calls to _wunderground_weather_speed_to_beaufort()
- theme_wunderground_weather_forecast in ./
wunderground_weather.module - Theme function to render weather forecast block.
- wunderground_weather_get_current in ./
wunderground_weather.module - Get current weather conditions and return them.
File
- ./
wunderground_weather.module, line 893 - Wunderground weather module to display weather forecasts and current weather conditions in blocks.
Code
function _wunderground_weather_speed_to_beaufort($speed, $unit) {
$speed = $unit == 'kph' ? $speed : $speed * 1.6;
switch (TRUE) {
case $speed < 1:
$bft = 0;
break;
case $speed < 5.6:
$bft = 1;
break;
case $speed < 12:
$bft = 2;
break;
case $speed < 20:
$bft = 3;
break;
case $speed < 29:
$bft = 4;
break;
case $speed < 39:
$bft = 5;
break;
case $speed < 50:
$bft = 6;
break;
case $speed < 62:
$bft = 7;
break;
case $speed < 75:
$bft = 8;
break;
case $speed < 89:
$bft = 9;
break;
case $speed < 103:
$bft = 10;
break;
case $speed < 118:
$bft = 11;
break;
case $speed >= 118:
$bft = 12;
break;
default:
$bft = 100;
break;
}
return $bft;
}