-
Notifications
You must be signed in to change notification settings - Fork 0
/
sgp4.wai
161 lines (134 loc) · 4.41 KB
/
sgp4.wai
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
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
// sgp4.wai
/// underlying structs and variants for errors
variant error-tle-what {
bad-checksum,
bad-length,
bad-first-character,
expected-float,
expected-float-with-assumed-decimal-point,
expected-integer,
expected-space,
expected-string,
float-with-assumed-decimal-point-too-long,
norad-id-mismatch,
unknown-classification,
from-yo-opt-failed,
from-num-seconds-from-midnight-failed,
}
variant error-tle-line {
line1,
line2,
both,
}
record out-of-range-epoch-eccentricity {
eccentricity: float64,
}
record out-of-range-eccentricity {
eccentricity: float64,
t: float64,
}
record out-of-range-perturbed-eccentricity {
eccentricity: float64,
t: float64,
}
record negative-semi-latus-rectum {
t: float64,
}
record tle {
what: error-tle-what,
line: error-tle-line,
start: u32,
end: u32,
}
/// main error variant
variant error {
out-of-range-epoch-eccentricity(out-of-range-epoch-eccentricity),
out-of-range-eccentricity(out-of-range-eccentricity),
out-of-range-perturbed-eccentricity(out-of-range-perturbed-eccentricity),
negative-brouwer-mean-motion,
negative-kozai-mean-motion,
negative-semi-latus-rectum(negative-semi-latus-rectum),
tle(tle),
json-parse(string)
}
record unix-timestamp {
secs: s64,
nsecs: u32
}
enum classification {
unclassified,
classified,
secret,
}
resource elements {
static from-tle: func(object-name: option<string>, line1: string, line2: string) -> expected<elements,error>
static from-json: func(json: string) -> expected<elements,error>
epoch: func() -> float64
epoch-afspc-compatibility-mode: func() -> float64
get-object-name: func() -> option<string>
get-international-designator: func() -> option<string>
get-norad-id: func() -> u64
get-classification: func() -> classification
get-datetime: func() -> unix-timestamp
get-mean-motion-dot: func() -> float64
get-mean-motion-ddot: func() -> float64
get-drag-term: func() -> float64
get-element-set-number: func() -> u64
get-inclination: func() -> float64
get-right-ascension: func() -> float64
get-eccentricity: func() -> float64
get-argument-of-perigee: func() -> float64
get-mean-anomaly: func() -> float64
get-mean-motion: func() -> float64
get-revolution-number: func() -> u64
get-ephemeris-type: func() -> u8
}
/// Geopotential Struct
record geopotential {
ae: float64,
ke: float64,
j2: float64,
j3: float64,
j4: float64,
}
/// Orbit Struct
record orbit {
inclination: float64,
right-ascension: float64,
eccentricity: float64,
argument-of-perigee: float64,
mean-anomaly: float64,
mean-motion: float64,
}
orbit-from-kozai-elements: func(geopotential: geopotential,inclination: float64, right-ascension: float64, eccentricity: float64, argument-of-perigee: float64, mean-anomaly: float64, kozai-mean-motion: float64) -> expected<orbit,error>
/// Prediction Struct
record prediction {
position: tuple<float64,float64,float64>,
velocity: tuple<float64,float64,float64>,
}
/// Constant WGS72
wgs72: func() -> geopotential
/// Constant WGS84
wgs84: func() -> geopotential
afspc-epoch-to-sidereal-time: func(epoch: float64) -> float64
iau-epoch-to-sidereal-time: func(epoch: float64) -> float64
parse2les: func(tles: string) -> expected<list<elements>,error>
parse3les: func(tles: string) -> expected<list<elements>,error>
// get the t from resonanceState as all the fields are private and doeesn't allow automatic initialization
resource resonance-state {
t: func()->float64
}
enum epoch-to-sidereal-time-algorithm {
afspc,
iau,
}
/// implmenetation for Constants
resource constants {
static new: func(geopotential: geopotential, epoch-to-sidereal-time: epoch-to-sidereal-time-algorithm, epoch: float64, drag-item: float64, orbit0: orbit) -> expected<constants, error>
static from-elements: func(elements: elements) -> expected<constants, error>
static from-elements-afspc-compatibility-mode: func(elements: elements) -> expected<constants, error>
initial-state: func() -> option<resonance-state>
propagate-from-state: func(t: float64, state: option<resonance-state>, afspc-compatibility-mode: bool) -> expected<prediction, error>
propagate: func(t: float64) -> expected<prediction, error>
propagate-afspc-compatibility-mode: func(t: float64) -> expected<prediction, error>
}