Skip to content

Commit

Permalink
block[weather]: nws convert wind speed from km/s to m/s
Browse files Browse the repository at this point in the history
  • Loading branch information
bim9262 committed Jul 11, 2024
1 parent 07bf5bc commit 0aa8dd3
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions src/blocks/weather/nws.rs
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,14 @@ impl ApiForecast {
.to_string()
}

fn wind_speed(&self) -> f64 {
if self.wind_speed.unit_code.ends_with("km_h-1") {
self.wind_speed.value / 3.6
} else {
self.wind_speed.value
}
}

fn wind_kmh(&self) -> f64 {
if self.wind_speed.unit_code.ends_with("km_h-1") {
self.wind_speed.value
Expand Down Expand Up @@ -196,7 +204,7 @@ impl ApiForecast {
temp: self.temperature.value,
apparent: self.apparent_temp(),
humidity: self.relative_humidity.value,
wind: self.wind_speed.value,
wind: self.wind_speed(),
wind_kmh: self.wind_kmh(),
wind_direction: self.wind_direction(),
}
Expand All @@ -207,7 +215,7 @@ impl ApiForecast {
temp: self.temperature.value,
apparent: self.apparent_temp(),
humidity: self.relative_humidity.value,
wind: self.wind_speed.value,
wind: self.wind_speed(),
wind_kmh: self.wind_kmh(),
wind_direction: self.wind_direction(),
}
Expand Down

0 comments on commit 0aa8dd3

Please sign in to comment.