use super::base::Degrees;
#[derive(Clone, Copy, Default, Debug, PartialEq)]
pub struct LonLat {
pub longitude: Degrees,
pub latitude: Degrees,
}
impl LonLat {
pub fn new(longitude: f64, latitude: f64) -> Self {
Self {
longitude: Degrees::new(longitude),
latitude: Degrees::new(latitude),
}
}
pub const fn new_unchecked(longitude: Degrees, latitude: Degrees) -> Self {
Self {
longitude,
latitude,
}
}
pub const fn longitude(&self) -> f64 {
self.longitude.get()
}
pub const fn latitude(&self) -> f64 {
self.latitude.get()
}
pub fn from_degrees(longitude: f64, latitude: f64) -> Self {
Self::new(longitude, latitude)
}
pub const fn to_degrees(&self) -> (f64, f64) {
(self.longitude.get(), self.latitude.get())
}
}
impl From<(f64, f64)> for LonLat {
fn from((longitude, latitude): (f64, f64)) -> Self {
Self::new(longitude, latitude)
}
}
impl From<LonLat> for (f64, f64) {
fn from(lonlat: LonLat) -> Self {
lonlat.to_degrees()
}
}