function weather_format_nearest_station in Weather 7.2
Same name and namespace in other branches
- 7.3 weather_theme.inc \weather_format_nearest_station()
- 7 weather_theme.inc \weather_format_nearest_station()
Format information about nearest weather station.
Parameters
array $station: Information about distance and bearing of weather station.
object $display: Display configuration (for example, UK miles, km).
Return value
string Formatted representation.
1 call to weather_format_nearest_station()
- theme_weather_forecast_preprocess in ./
weather_theme.inc - Custom theme function for preprocessing the weather display.
File
- ./
weather_theme.inc, line 607 - Prepare themed weather output.
Code
function weather_format_nearest_station($station, $display) {
$bearing = weather_bearing_to_text($station['bearing'], $display->config['show_abbreviated_directions']);
if ($display->config['distance'] == 'miles') {
$distance = round($station['distance'] / 1.609344, 1);
if ($display->config['show_directions_degree']) {
$result = t('!distance mi !bearing (!degree°)', array(
'!distance' => $distance,
'!bearing' => $bearing,
'!degree' => $station['bearing'],
));
}
else {
$result = t('!distance mi !bearing', array(
'!distance' => $distance,
'!bearing' => $bearing,
));
}
}
else {
// Default to metric units.
$distance = $station['distance'];
if ($display->config['show_directions_degree']) {
$result = t('!distance km !bearing (!degree°)', array(
'!distance' => $distance,
'!bearing' => $bearing,
'!degree' => $station['bearing'],
));
}
else {
$result = t('!distance km !bearing', array(
'!distance' => $distance,
'!bearing' => $bearing,
));
}
}
return preg_replace("/([^ ]*) ([^ ]*)/", '<span style="white-space:nowrap;">\\1 \\2</span>', $result);
}