#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)]
pub enum DawnType {
Civil,
Nautical,
Astronomical,
}
impl DawnType {
pub(crate) fn positive_angle(&self) -> f64 {
f64::to_radians(match self {
DawnType::Civil => 6.,
DawnType::Nautical => 12.,
DawnType::Astronomical => 18.,
})
}
}
#[derive(Debug, Clone, Copy, PartialEq, PartialOrd)]
pub enum SolarEvent {
Sunrise,
Sunset,
Dawn(DawnType),
Dusk(DawnType),
Elevation {
elevation: f64,
morning: bool,
},
}
impl SolarEvent {
pub(crate) fn angle(&self) -> f64 {
match self {
SolarEvent::Sunrise | SolarEvent::Sunset => f64::to_radians(5.) / 6.,
SolarEvent::Dusk(t) | SolarEvent::Dawn(t) => t.positive_angle(),
SolarEvent::Elevation { elevation, .. } => *elevation,
}
}
pub(crate) fn is_morning(&self) -> bool {
matches!(
self,
SolarEvent::Sunrise | SolarEvent::Dawn(_) | SolarEvent::Elevation { morning: true, .. }
)
}
}