use lat_long::Coordinate;
use rfham_core::Agency;
use std::{fmt::Display, str::FromStr};
pub trait GridIdentifier:
Clone + Display + FromStr + PartialEq + Eq + Into<String> + AsRef<str> + From<Coordinate>
{
fn is_valid(s: &str) -> bool;
fn as_str(&self) -> &str {
self.as_ref()
}
}
pub trait GridPolygon {
type Identifier: GridIdentifier;
fn id(&self) -> &Self::Identifier;
fn vertices(&self) -> Vec<Coordinate>;
}
pub trait GridSystem {
type Identifier: GridIdentifier;
type Poly: GridPolygon<Identifier = Self::Identifier>;
fn name(&self) -> &str;
fn defining_agency(&self) -> Agency;
fn lookup_id(&self, id: &Self::Identifier) -> Option<Self::Poly>;
fn lookup_point(&self, point: &Coordinate) -> Option<Self::Poly> {
self.lookup_id(&Self::Identifier::from(*point))
}
}
pub mod maidenhead;