You are here

function _weather_format_closest_station in Weather 5.6

Same name and namespace in other branches
  1. 6.5 weather.module \_weather_format_closest_station()

Convert information about nearest METAR station in the location block

1 call to _weather_format_closest_station()
theme_weather in ./weather.module
Custom theme function for the weather block output

File

./weather.module, line 1290
Display <acronym title="METeorological Aerodrome Report">METAR</acronym> weather data from anywhere in the world

Code

function _weather_format_closest_station($distance, $unit, $settings) {
  while ($distance['direction'] < 0) {
    $distance['direction'] += 360;
  }
  while ($distance['direction'] >= 360) {
    $distance['direction'] -= 360;
  }
  if ($settings['show_abbreviated_directions']) {
    $direction = weather_bearing_to_text($distance['direction'], TRUE);
  }
  else {
    $direction = weather_bearing_to_text($distance['direction']);
  }
  if ($unit['visibility'] == 'miles') {
    if ($settings['show_directions_degree']) {
      return t('!distance miles !direction (!degree°)', array(
        '!distance' => $distance['miles'],
        '!direction' => $direction,
        '!degree' => $distance['direction'],
      ));
    }
    else {
      return t('!distance miles !direction', array(
        '!distance' => $distance['miles'],
        '!direction' => $direction,
      ));
    }
  }
  else {

    // default to metric units
    if ($settings['show_directions_degree']) {
      return t('!distance kilometers !direction (!degree°)', array(
        '!distance' => $distance['kilometers'],
        '!direction' => $direction,
        '!degree' => $distance['direction'],
      ));
    }
    else {
      return t('!distance kilometers !direction', array(
        '!distance' => $distance['kilometers'],
        '!direction' => $direction,
      ));
    }
  }
}