function _weather_format_closest_station in Weather 6.5
Same name and namespace in other branches
- 5.6 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_theming in ./
weather.module - Custom theme function for preprocessing the weather block output
File
- ./
weather.module, line 1795 - 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']) {
$result = t('!distance mi !direction (!degree°)', array(
'!distance' => $distance['miles'],
'!direction' => $direction,
'!degree' => $distance['direction'],
));
}
else {
$result = t('!distance mi !direction', array(
'!distance' => $distance['miles'],
'!direction' => $direction,
));
}
}
else {
// default to metric units
if ($settings['show_directions_degree']) {
$result = t('!distance km !direction (!degree°)', array(
'!distance' => $distance['kilometers'],
'!direction' => $direction,
'!degree' => $distance['direction'],
));
}
else {
$result = t('!distance km !direction', array(
'!distance' => $distance['kilometers'],
'!direction' => $direction,
));
}
}
return preg_replace("/([^ ]*) ([^ ]*)/", '<span style="white-space:nowrap;">\\1 \\2</span>', $result);
}