use crate::prelude::*;
pub mod set;
pub mod tuple;
pub mod coor2d;
pub mod coor32;
pub mod coor3d;
pub mod coor4d;
pub trait AngularUnits {
fn to_radians(&self) -> Self;
fn to_degrees(&self) -> Self;
fn to_arcsec(&self) -> Self;
fn arcsec_to_radians(&self) -> Self;
fn to_geo(&self) -> Self;
}
impl<T> AngularUnits for T
where
T: CoordinateTuple + Copy,
{
fn to_degrees(&self) -> Self {
let (x, y) = self.xy();
let mut res = *self;
res.set_xy(x.to_degrees(), y.to_degrees());
res
}
fn to_arcsec(&self) -> Self {
let (x, y) = self.xy();
let mut res = *self;
res.set_xy(x.to_degrees() * 3600., y.to_degrees() * 3600.);
res
}
fn arcsec_to_radians(&self) -> Self {
let (x, y) = self.xy();
let mut res = *self;
res.set_xy((x / 3600.).to_radians(), (y / 3600.).to_radians());
res
}
fn to_radians(&self) -> Self {
let (x, y) = self.xy();
let mut res = *self;
res.set_xy(x.to_radians(), y.to_radians());
res
}
fn to_geo(&self) -> Self {
let (x, y) = self.xy();
let mut res = *self;
res.set_xy(y.to_degrees(), x.to_degrees());
res
}
}
#[allow(dead_code)]
type DirectPosition = Coor4D;
#[derive(Debug, Default, PartialEq, PartialOrd, Copy, Clone)]
pub struct DataEpoch(f64);
#[derive(Debug, PartialEq, Eq, PartialOrd, Ord, Copy, Clone)]
pub struct MdIdentifier(uuid::Uuid);
#[derive(Debug, Default, PartialEq, PartialOrd, Clone)]
pub enum Crs {
#[default]
Unknown,
RegisterItem(String, String),
}
pub trait CoordinateMetadata {
fn crs_id(&self) -> Option<MdIdentifier> {
None
}
fn crs(&self) -> Option<Crs> {
Some(Crs::Unknown)
}
fn coordinate_epoch(&self) -> Option<DataEpoch> {
None
}
fn is_valid(&self) -> bool {
if self.crs_id().is_none() && self.crs().is_none() {
return false;
}
true
}
}
impl<T> CoordinateMetadata for T where T: ?Sized {}