1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
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),
}
}
}