use std::fmt;

#[derive(Clone, Debug, PartialEq)]
pub struct Latitude(f32);

impl From<f32> for Latitude {
    fn from(val: f32) -> Self {
        if !(-90.0..=90.0).contains(&val) {
            panic!("Latitude is outside of range");
        }
        Self(val)
    }
}

impl fmt::Display for Latitude {
    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
        write!(f, "{}", self.0)
    }
}

#[derive(Clone, Debug, PartialEq)]
pub struct Longitude(f32);

impl From<f32> for Longitude {
    fn from(val: f32) -> Self {
        if !(-180.0..=180.0).contains(&val) {
            panic!("Longitude is outside fo range");
        }
        Self(val)
    }
}

impl fmt::Display for Longitude {
    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
        write!(f, "{}", self.0)
    }
}
