You are here

function weather_format_wind in Weather 7.2

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

Convert wind.

Parameters

string $wind_direction: Wind direction (Compass bearings, for example, '080')

int $wind_speed: Wind speed in m/s.

string $unit: Unit to be returned (km/h, knots, meter/s, ...).

array $abbreviated: Whether or not to show abbreviated directions (E, NE, SSW).

array $exact_degree: Whether or not to show exact compass bearings.

Return value

string Formatted representation in the desired unit.

2 calls to weather_format_wind()
theme_weather_forecast_preprocess in ./weather_theme.inc
Custom theme function for preprocessing the weather display.
weather_handler_wind::render in views_handlers/weather_handler_wind.inc
Render wind information with selected unit.

File

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

Code

function weather_format_wind($wind_direction, $wind_speed, $unit, $abbreviated, $exact_degree) {
  $direction = weather_bearing_to_text($wind_direction, $abbreviated);
  $beaufort = weather_calculate_beaufort($wind_speed);

  // Set up the wind speed.
  $speed = weather_format_wind_speed($wind_speed, $unit);
  if ($exact_degree) {
    $result = t('!description, !speed from !direction (!degree°)', array(
      '!description' => $beaufort['description'],
      '!speed' => $speed,
      '!direction' => $direction,
      '!degree' => $wind_direction,
    ));
  }
  else {
    $result = t('!description, !speed from !direction', array(
      '!description' => $beaufort['description'],
      '!speed' => $speed,
      '!direction' => $direction,
    ));
  }
  return $result;
}