pub use celestia::xb::Identifier as XbId;
use std::cmp::PartialEq;
use std::fmt;
#[allow(non_snake_case)]
#[derive(Copy, Clone, Debug, PartialEq)]
pub enum Frame {
Celestial {
axb_id: i32,
exb_id: i32,
gm: f64,
parent_axb_id: Option<i32>,
parent_exb_id: Option<i32>,
},
Geoid {
axb_id: i32,
exb_id: i32,
gm: f64,
parent_axb_id: Option<i32>,
parent_exb_id: Option<i32>,
flattening: f64,
equatorial_radius: f64,
semi_major_radius: f64,
},
VNC,
RCN,
RIC,
}
impl Frame {
pub fn is_geoid(&self) -> bool {
match self {
Frame::Geoid { .. } => true,
_ => false,
}
}
pub fn is_celestial(&self) -> bool {
match self {
Frame::Celestial { .. } => true,
_ => false,
}
}
pub fn gm(&self) -> f64 {
match self {
Frame::Celestial { gm, .. } | Frame::Geoid { gm, .. } => *gm,
_ => panic!("Frame is not Celestial or Geoid in kind"),
}
}
pub fn axb_id(&self) -> i32 {
match self {
Frame::Geoid { axb_id, .. } | Frame::Celestial { axb_id, .. } => *axb_id,
_ => panic!("Frame is not Celestial or Geoid in kind"),
}
}
pub fn exb_id(&self) -> i32 {
match self {
Frame::Geoid { exb_id, .. } | Frame::Celestial { exb_id, .. } => *exb_id,
_ => panic!("Frame is not Celestial or Geoid in kind"),
}
}
pub fn parent_axb_id(&self) -> Option<i32> {
match self {
Frame::Geoid { parent_axb_id, .. } | Frame::Celestial { parent_axb_id, .. } => {
*parent_axb_id
}
_ => panic!("Frame is not Celestial or Geoid in kind"),
}
}
pub fn parent_exb_id(&self) -> Option<i32> {
match self {
Frame::Geoid { parent_exb_id, .. } | Frame::Celestial { parent_exb_id, .. } => {
*parent_exb_id
}
_ => panic!("Frame is not Celestial or Geoid in kind"),
}
}
pub fn equatorial_radius(&self) -> f64 {
match self {
Frame::Geoid {
equatorial_radius, ..
} => *equatorial_radius,
_ => panic!("Frame is not Geoid in kind"),
}
}
pub fn flattening(&self) -> f64 {
match self {
Frame::Geoid { flattening, .. } => *flattening,
_ => panic!("Frame is not Geoid in kind"),
}
}
pub fn semi_major_radius(&self) -> f64 {
match self {
Frame::Geoid {
semi_major_radius, ..
} => *semi_major_radius,
_ => panic!("Frame is not Geoid in kind"),
}
}
}
impl fmt::Display for Frame {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
match *self {
Frame::Celestial { axb_id, exb_id, .. } | Frame::Geoid { axb_id, exb_id, .. } => {
write!(f, "{:3} ({:3})", exb_id, axb_id)
}
othframe => write!(f, "{:?}", othframe),
}
}
}