function weather_format_nearest_station in Weather 7
Same name and namespace in other branches
- 7.3 weather_theme.inc \weather_format_nearest_station()
- 7.2 weather_theme.inc \weather_format_nearest_station()
Format information about nearest METAR station.
Parameters
object $location: Location object.
string $unit: Unit to be returned (for example, UK miles, km).
array $settings: Settings for displaying (abbreviated directions, with compass bearing)
Return value
string Formatted representation.
1 call to weather_format_nearest_station()
- theme_weather_theming in ./
weather_theme.inc - Custom theme function for preprocessing the weather display.
File
- ./
weather_theme.inc, line 609 - Prepare themed weather output.
Code
function weather_format_nearest_station($location, $unit, $settings) {
if (!empty($settings['show_abbreviated_directions'])) {
$bearing = weather_bearing_to_text($location->bearing, TRUE);
}
else {
$bearing = weather_bearing_to_text($location->bearing);
}
$exact_degree = FALSE;
if (!empty($settings['show_directions_degree'])) {
$exact_degree = TRUE;
}
if ($unit == 'miles') {
$distance = round($location->distance / 1.609344, 1);
if ($exact_degree) {
$result = t('!distance mi !bearing (!degree°)', array(
'!distance' => $distance,
'!bearing' => $bearing,
'!degree' => $location->bearing,
));
}
else {
$result = t('!distance mi !bearing', array(
'!distance' => $distance,
'!bearing' => $bearing,
));
}
}
else {
// Default to metric units.
$distance = $location->distance;
if ($exact_degree) {
$result = t('!distance km !bearing (!degree°)', array(
'!distance' => $distance,
'!bearing' => $bearing,
'!degree' => $location->bearing,
));
}
else {
$result = t('!distance km !bearing', array(
'!distance' => $distance,
'!bearing' => $bearing,
));
}
}
return preg_replace("/([^ ]*) ([^ ]*)/", '<span style="white-space:nowrap;">\\1 \\2</span>', $result);
}