protected function ThemeService::formatWind in Weather 2.0.x
Same name and namespace in other branches
- 8 src/Service/ThemeService.php \Drupal\weather\Service\ThemeService::formatWind()
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, ...).
mixed $abbreviated: Whether or not to show abbreviated directions (E, NE, SSW).
mixed $exact_degree: Whether or not to show exact compass bearings.
Return value
string Formatted representation in the desired unit.
1 call to ThemeService::formatWind()
- ThemeService::setForecastsVariables in src/
Service/ ThemeService.php - Adds variables related to weather forecast.
File
- src/
Service/ ThemeService.php, line 613
Class
- ThemeService
- Prepare forecast data for displaying.
Namespace
Drupal\weather\ServiceCode
protected function formatWind($wind_direction, $wind_speed, $unit, $abbreviated, $exact_degree) {
$direction = $this
->bearingToText($wind_direction, $abbreviated);
$beaufort = $this
->calculateBeaufort($wind_speed);
// Set up the wind speed.
$speed = $this
->formatWindSpeed($wind_speed, $unit);
if ($exact_degree) {
$result = $this
->t('@description, <span style="white-space:nowrap;">@speed</span> from @direction (@degree°)', [
'@description' => $beaufort['description'],
'@speed' => $speed,
'@direction' => $direction,
'@degree' => $wind_direction,
]);
}
else {
$result = $this
->t('@description, @speed from @direction', [
'@description' => $beaufort['description'],
'@speed' => $speed,
'@direction' => $direction,
]);
}
return $result;
}