use std::borrow::Cow;
use crate::query::AsApiStr;
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
#[non_exhaustive]
pub enum MarineHourlyVar {
WaveHeight,
WaveDirection,
WavePeriod,
WavePeakPeriod,
WindWaveHeight,
WindWaveDirection,
WindWavePeriod,
WindWavePeakPeriod,
SwellWaveHeight,
SwellWaveDirection,
SwellWavePeriod,
SwellWavePeakPeriod,
SecondarySwellWaveHeight,
SecondarySwellWaveDirection,
SecondarySwellWavePeriod,
TertiarySwellWaveHeight,
TertiarySwellWaveDirection,
TertiarySwellWavePeriod,
SeaLevelHeightMsl,
SeaSurfaceTemperature,
OceanCurrentVelocity,
OceanCurrentDirection,
InvertBarometerHeight,
Other(Cow<'static, str>),
}
impl MarineHourlyVar {
pub fn other(token: impl Into<Cow<'static, str>>) -> Self {
Self::Other(token.into())
}
}
impl AsApiStr for MarineHourlyVar {
fn as_api_str(&self) -> Cow<'static, str> {
match self {
Self::WaveHeight => Cow::Borrowed("wave_height"),
Self::WaveDirection => Cow::Borrowed("wave_direction"),
Self::WavePeriod => Cow::Borrowed("wave_period"),
Self::WavePeakPeriod => Cow::Borrowed("wave_peak_period"),
Self::WindWaveHeight => Cow::Borrowed("wind_wave_height"),
Self::WindWaveDirection => Cow::Borrowed("wind_wave_direction"),
Self::WindWavePeriod => Cow::Borrowed("wind_wave_period"),
Self::WindWavePeakPeriod => Cow::Borrowed("wind_wave_peak_period"),
Self::SwellWaveHeight => Cow::Borrowed("swell_wave_height"),
Self::SwellWaveDirection => Cow::Borrowed("swell_wave_direction"),
Self::SwellWavePeriod => Cow::Borrowed("swell_wave_period"),
Self::SwellWavePeakPeriod => Cow::Borrowed("swell_wave_peak_period"),
Self::SecondarySwellWaveHeight => Cow::Borrowed("secondary_swell_wave_height"),
Self::SecondarySwellWaveDirection => Cow::Borrowed("secondary_swell_wave_direction"),
Self::SecondarySwellWavePeriod => Cow::Borrowed("secondary_swell_wave_period"),
Self::TertiarySwellWaveHeight => Cow::Borrowed("tertiary_swell_wave_height"),
Self::TertiarySwellWaveDirection => Cow::Borrowed("tertiary_swell_wave_direction"),
Self::TertiarySwellWavePeriod => Cow::Borrowed("tertiary_swell_wave_period"),
Self::SeaLevelHeightMsl => Cow::Borrowed("sea_level_height_msl"),
Self::SeaSurfaceTemperature => Cow::Borrowed("sea_surface_temperature"),
Self::OceanCurrentVelocity => Cow::Borrowed("ocean_current_velocity"),
Self::OceanCurrentDirection => Cow::Borrowed("ocean_current_direction"),
Self::InvertBarometerHeight => Cow::Borrowed("invert_barometer_height"),
Self::Other(token) => token.clone(),
}
}
}
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
#[non_exhaustive]
pub enum MarineCurrentVar {
WaveHeight,
WaveDirection,
WavePeriod,
WavePeakPeriod,
WindWaveHeight,
WindWaveDirection,
WindWavePeriod,
WindWavePeakPeriod,
SwellWaveHeight,
SwellWaveDirection,
SwellWavePeriod,
SwellWavePeakPeriod,
SecondarySwellWaveHeight,
SecondarySwellWaveDirection,
SecondarySwellWavePeriod,
TertiarySwellWaveHeight,
TertiarySwellWaveDirection,
TertiarySwellWavePeriod,
SeaLevelHeightMsl,
SeaSurfaceTemperature,
OceanCurrentVelocity,
OceanCurrentDirection,
Other(Cow<'static, str>),
}
impl MarineCurrentVar {
pub fn other(token: impl Into<Cow<'static, str>>) -> Self {
Self::Other(token.into())
}
}
impl AsApiStr for MarineCurrentVar {
fn as_api_str(&self) -> Cow<'static, str> {
match self {
Self::WaveHeight => Cow::Borrowed("wave_height"),
Self::WaveDirection => Cow::Borrowed("wave_direction"),
Self::WavePeriod => Cow::Borrowed("wave_period"),
Self::WavePeakPeriod => Cow::Borrowed("wave_peak_period"),
Self::WindWaveHeight => Cow::Borrowed("wind_wave_height"),
Self::WindWaveDirection => Cow::Borrowed("wind_wave_direction"),
Self::WindWavePeriod => Cow::Borrowed("wind_wave_period"),
Self::WindWavePeakPeriod => Cow::Borrowed("wind_wave_peak_period"),
Self::SwellWaveHeight => Cow::Borrowed("swell_wave_height"),
Self::SwellWaveDirection => Cow::Borrowed("swell_wave_direction"),
Self::SwellWavePeriod => Cow::Borrowed("swell_wave_period"),
Self::SwellWavePeakPeriod => Cow::Borrowed("swell_wave_peak_period"),
Self::SecondarySwellWaveHeight => Cow::Borrowed("secondary_swell_wave_height"),
Self::SecondarySwellWaveDirection => Cow::Borrowed("secondary_swell_wave_direction"),
Self::SecondarySwellWavePeriod => Cow::Borrowed("secondary_swell_wave_period"),
Self::TertiarySwellWaveHeight => Cow::Borrowed("tertiary_swell_wave_height"),
Self::TertiarySwellWaveDirection => Cow::Borrowed("tertiary_swell_wave_direction"),
Self::TertiarySwellWavePeriod => Cow::Borrowed("tertiary_swell_wave_period"),
Self::SeaLevelHeightMsl => Cow::Borrowed("sea_level_height_msl"),
Self::SeaSurfaceTemperature => Cow::Borrowed("sea_surface_temperature"),
Self::OceanCurrentVelocity => Cow::Borrowed("ocean_current_velocity"),
Self::OceanCurrentDirection => Cow::Borrowed("ocean_current_direction"),
Self::Other(token) => token.clone(),
}
}
}
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
#[non_exhaustive]
pub enum MarineMinutely15Var {
OceanCurrentVelocity,
OceanCurrentDirection,
SeaLevelHeightMsl,
Other(Cow<'static, str>),
}
impl MarineMinutely15Var {
pub fn other(token: impl Into<Cow<'static, str>>) -> Self {
Self::Other(token.into())
}
}
impl AsApiStr for MarineMinutely15Var {
fn as_api_str(&self) -> Cow<'static, str> {
match self {
Self::OceanCurrentVelocity => Cow::Borrowed("ocean_current_velocity"),
Self::OceanCurrentDirection => Cow::Borrowed("ocean_current_direction"),
Self::SeaLevelHeightMsl => Cow::Borrowed("sea_level_height_msl"),
Self::Other(token) => token.clone(),
}
}
}
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
#[non_exhaustive]
pub enum MarineDailyVar {
WaveHeightMax,
WaveDirectionDominant,
WavePeriodMax,
WindWaveHeightMax,
WindWaveDirectionDominant,
WindWavePeriodMax,
WindWavePeakPeriodMax,
SwellWaveHeightMax,
SwellWaveDirectionDominant,
SwellWavePeriodMax,
SwellWavePeakPeriodMax,
Other(Cow<'static, str>),
}
impl MarineDailyVar {
pub fn other(token: impl Into<Cow<'static, str>>) -> Self {
Self::Other(token.into())
}
}
impl AsApiStr for MarineDailyVar {
fn as_api_str(&self) -> Cow<'static, str> {
match self {
Self::WaveHeightMax => Cow::Borrowed("wave_height_max"),
Self::WaveDirectionDominant => Cow::Borrowed("wave_direction_dominant"),
Self::WavePeriodMax => Cow::Borrowed("wave_period_max"),
Self::WindWaveHeightMax => Cow::Borrowed("wind_wave_height_max"),
Self::WindWaveDirectionDominant => Cow::Borrowed("wind_wave_direction_dominant"),
Self::WindWavePeriodMax => Cow::Borrowed("wind_wave_period_max"),
Self::WindWavePeakPeriodMax => Cow::Borrowed("wind_wave_peak_period_max"),
Self::SwellWaveHeightMax => Cow::Borrowed("swell_wave_height_max"),
Self::SwellWaveDirectionDominant => Cow::Borrowed("swell_wave_direction_dominant"),
Self::SwellWavePeriodMax => Cow::Borrowed("swell_wave_period_max"),
Self::SwellWavePeakPeriodMax => Cow::Borrowed("swell_wave_peak_period_max"),
Self::Other(token) => token.clone(),
}
}
}
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
#[non_exhaustive]
pub enum MarineModel {
BestMatch,
MeteoFranceWave,
MeteoFranceCurrents,
DwdEwam,
DwdGwam,
EcmwfWam,
EcmwfWam025,
GfsWave025,
GfsWave016,
Era5Ocean,
Other(Cow<'static, str>),
}
impl MarineModel {
pub fn other(token: impl Into<Cow<'static, str>>) -> Self {
Self::Other(token.into())
}
}
impl AsApiStr for MarineModel {
fn as_api_str(&self) -> Cow<'static, str> {
match self {
Self::BestMatch => Cow::Borrowed("best_match"),
Self::MeteoFranceWave => Cow::Borrowed("meteofrance_wave"),
Self::MeteoFranceCurrents => Cow::Borrowed("meteofrance_currents"),
Self::DwdEwam => Cow::Borrowed("dwd_ewam"),
Self::DwdGwam => Cow::Borrowed("dwd_gwam"),
Self::EcmwfWam => Cow::Borrowed("ecmwf_wam"),
Self::EcmwfWam025 => Cow::Borrowed("ecmwf_wam025"),
Self::GfsWave025 => Cow::Borrowed("ncep_gfswave025"),
Self::GfsWave016 => Cow::Borrowed("ncep_gfswave016"),
Self::Era5Ocean => Cow::Borrowed("era5_ocean"),
Self::Other(token) => token.clone(),
}
}
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn custom_marine_variable_tokens_are_passed_through() {
assert_eq!(
MarineHourlyVar::other("new_hourly_metric").as_api_str(),
"new_hourly_metric"
);
assert_eq!(
MarineCurrentVar::other("new_current_metric").as_api_str(),
"new_current_metric"
);
assert_eq!(
MarineMinutely15Var::other("new_minutely_metric").as_api_str(),
"new_minutely_metric"
);
assert_eq!(
MarineDailyVar::other("new_daily_metric").as_api_str(),
"new_daily_metric"
);
}
}