public function WundergroundWeatherManager::windSpeedToBeaufort in Wunderground weather 8
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.
File
- src/
WundergroundWeatherManager.php, line 168 - Contains Drupal\wunderground_weather\WundergroundWeatherManager.
Class
- WundergroundWeatherManager
- Methods to make an API call and tool to handle the output.
Namespace
Drupal\wunderground_weatherCode
public function windSpeedToBeaufort($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;
}