use metfor::Meters;
use optional::Optioned;
#[derive(Debug, Clone, Copy, PartialEq, Default)]
pub struct StationInfo {
num: Optioned<i32>,
location: Option<(f64, f64)>,
elevation: Optioned<Meters>,
}
impl StationInfo {
#[inline]
pub fn new_with_values<T, U, V, W>(station_num: T, location: U, elevation: V) -> Self
where
T: Into<Optioned<i32>>,
U: Into<Option<(f64, f64)>>,
Optioned<W>: From<V>,
W: optional::Noned + metfor::Length,
Meters: From<W>,
{
let elev: Optioned<W> = Optioned::from(elevation);
let elev: Optioned<Meters> = elev.map_t(Meters::from);
StationInfo {
num: station_num.into(),
location: location.into(),
elevation: elev,
}
}
#[inline]
pub fn new() -> Self {
Self::default()
}
#[inline]
pub fn with_station<T>(mut self, number: T) -> Self
where
Optioned<i32>: From<T>,
{
self.num = Optioned::from(number);
self
}
#[inline]
pub fn with_lat_lon<T>(mut self, coords: T) -> Self
where
Option<(f64, f64)>: From<T>,
{
self.location = Option::from(coords);
self
}
#[inline]
pub fn with_elevation<T, U>(mut self, elev: T) -> Self
where
Optioned<U>: From<T>,
U: optional::Noned + metfor::Length,
Meters: From<U>,
{
let elevation: Optioned<U> = Optioned::from(elev);
let elevation: Optioned<Meters> = elevation.map_t(Meters::from);
self.elevation = elevation;
self
}
#[inline]
pub fn station_num(&self) -> Optioned<i32> {
self.num
}
#[inline]
pub fn location(&self) -> Option<(f64, f64)> {
self.location
}
#[inline]
pub fn elevation(&self) -> Optioned<Meters> {
self.elevation
}
}