Hook up the Buienradar provider metric in the forecast
Also, sync up the Luchtmeetnet provider documentation a bit.
This commit is contained in:
parent
6279d379ab
commit
4232263a45
2 changed files with 13 additions and 3 deletions
|
@ -21,6 +21,7 @@ use rocket::tokio::{self, select};
|
||||||
use rocket::{get, routes, FromFormField, State};
|
use rocket::{get, routes, FromFormField, State};
|
||||||
|
|
||||||
use self::maps::{Maps, MapsHandle};
|
use self::maps::{Maps, MapsHandle};
|
||||||
|
use self::providers::buienradar::Item as BuienradarItem;
|
||||||
use self::providers::luchtmeetnet::Item as LuchtmeetnetItem;
|
use self::providers::luchtmeetnet::Item as LuchtmeetnetItem;
|
||||||
|
|
||||||
pub(crate) mod maps;
|
pub(crate) mod maps;
|
||||||
|
@ -69,7 +70,7 @@ struct Forecast {
|
||||||
|
|
||||||
/// The precipitation (when asked for).
|
/// The precipitation (when asked for).
|
||||||
#[serde(skip_serializing_if = "Option::is_none")]
|
#[serde(skip_serializing_if = "Option::is_none")]
|
||||||
precipitation: Option<()>,
|
precipitation: Option<Vec<BuienradarItem>>,
|
||||||
|
|
||||||
/// The UV index (when asked for).
|
/// The UV index (when asked for).
|
||||||
#[serde(rename = "UVI", skip_serializing_if = "Option::is_none")]
|
#[serde(rename = "UVI", skip_serializing_if = "Option::is_none")]
|
||||||
|
@ -154,7 +155,9 @@ async fn forecast(
|
||||||
Metric::PAQI => forecast.paqi = Some(()),
|
Metric::PAQI => forecast.paqi = Some(()),
|
||||||
Metric::PM10 => forecast.pm10 = providers::luchtmeetnet::get(lat, lon, metric).await,
|
Metric::PM10 => forecast.pm10 = providers::luchtmeetnet::get(lat, lon, metric).await,
|
||||||
Metric::Pollen => forecast.pollen = Some(()),
|
Metric::Pollen => forecast.pollen = Some(()),
|
||||||
Metric::Precipitation => forecast.precipitation = Some(()),
|
Metric::Precipitation => {
|
||||||
|
forecast.precipitation = providers::buienradar::get(lat, lon, metric).await
|
||||||
|
}
|
||||||
Metric::UVI => forecast.uvi = Some(()),
|
Metric::UVI => forecast.uvi = Some(()),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -25,12 +25,13 @@ struct Container {
|
||||||
#[derive(Debug, Deserialize, Serialize)]
|
#[derive(Debug, Deserialize, Serialize)]
|
||||||
#[serde(crate = "rocket::serde")]
|
#[serde(crate = "rocket::serde")]
|
||||||
pub(crate) struct Item {
|
pub(crate) struct Item {
|
||||||
/// The time for when the value is forecast.
|
/// The time(stamp) of the forecast.
|
||||||
#[serde(
|
#[serde(
|
||||||
rename(deserialize = "timestamp_measured"),
|
rename(deserialize = "timestamp_measured"),
|
||||||
serialize_with = "ts_seconds::serialize"
|
serialize_with = "ts_seconds::serialize"
|
||||||
)]
|
)]
|
||||||
time: DateTime<Utc>,
|
time: DateTime<Utc>,
|
||||||
|
|
||||||
/// The forecasted value.
|
/// The forecasted value.
|
||||||
///
|
///
|
||||||
/// The unit depends on the selected [metric](Metric).
|
/// The unit depends on the selected [metric](Metric).
|
||||||
|
@ -39,6 +40,12 @@ pub(crate) struct Item {
|
||||||
|
|
||||||
/// Retrieves the Luchtmeetnet forecasted items for the provided position and metric.
|
/// Retrieves the Luchtmeetnet forecasted items for the provided position and metric.
|
||||||
///
|
///
|
||||||
|
/// It supports the following metrics:
|
||||||
|
/// * [`Metric::AQI`]
|
||||||
|
/// * [`Metric::NO2`]
|
||||||
|
/// * [`Metric::O3`]
|
||||||
|
/// * [`Metric::PM10`]
|
||||||
|
///
|
||||||
/// Returns [`None`] if retrieval or deserialization fails, or if the metric is not supported by
|
/// Returns [`None`] if retrieval or deserialization fails, or if the metric is not supported by
|
||||||
/// this provider.
|
/// this provider.
|
||||||
pub(crate) async fn get(lat: f64, lon: f64, metric: Metric) -> Option<Vec<Item>> {
|
pub(crate) async fn get(lat: f64, lon: f64, metric: Metric) -> Option<Vec<Item>> {
|
||||||
|
|
Loading…
Reference in a new issue