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
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
|
package tle
import (
"encoding/json"
"fmt"
"os"
"reflect"
"testing"
)
func ExampleNewTLE() {
var RawTLE = `ISS (ZARYA)
1 25544U 98067A 19229.39083552 .00000228 00000-0 11917-4 0 9993
2 25544 51.6447 57.6210 0007373 294.0868 138.8050 15.50381554184754`
TLE, err := NewTLE(RawTLE)
if err != nil {
fmt.Println(err)
}
// convert the TLE to json
b, err := json.MarshalIndent(TLE, "", " ")
if err != nil {
fmt.Println("error: ", err)
}
_, err = os.Stdout.Write(b)
if err != nil {
fmt.Println("error: ", err)
}
// Output:
// {
// "titleline": {
// "satname": "ISS (ZARYA) "
// },
// "lineone": {
// "linenumber": 1,
// "satellitenumber": 25544,
// "classification": "U",
// "internationaldesignator": {
// "launchyear": 98,
// "launchnumber": 67,
// "launchpiece": "A"
// },
// "epoch": {
// "year": 19,
// "dayfraction": 229.39083552
// },
// "firstderiv": 0.00000228,
// "secondderiv": 0,
// "BSTAR": 0.000011917,
// "numberzero": 0,
// "elementesetnumber": 999,
// "checksum": 3
// },
// "linetwo": {
// "linenumber": 2,
// "satellitenumber": 25544,
// "inclination": 51.6447,
// "rightascensionoftheascendingnode": 57.621,
// "eccentricity": 7373,
// "argumentofperigee": 294.0868,
// "meananomaly": 138.805,
// "meanmotion": 15.50381554,
// "revolutionnumberatepoch": 18475,
// "checksum": 4
// }
//}
}
func TestNewTLE(t *testing.T) {
type args struct {
RawTLE string
}
tests := []struct {
name string
args args
want TLE
wantErr bool
}{
{
name: "ISS (ZARYA) ",
args: args{
RawTLE: `ISS (ZARYA)
1 25544U 98067A 19229.39083552 .00000228 00000-0 11917-4 0 9993
2 25544 51.6447 57.6210 0007373 294.0868 138.8050 15.50381554184754`,
},
want: TLE{
TitleLine: TitleLine{
Satname: "ISS (ZARYA) ",
},
LineOne: LineOne{
Linenumber: 1,
SatelliteNumber: 25544,
Classification: "U",
InternationalDesignator: InternationalDesignator{
Launchyear: 98,
Launchnumber: 67,
Launchpiece: "A",
},
Epoch: Epoch{
Year: 19,
Dayfraction: 229.39083552,
},
Firstderiv: 0.00000228,
Secondderiv: 0,
BSTAR: 0.000011917,
Numberzero: 0,
ElementSetNumber: 999,
Checksum: 3,
},
LineTwo: LineTwo{
Linenumber: 2,
SatelliteNumber: 25544,
Inclination: 51.6447,
RightAscensionOfTheAscendingNode: 57.621,
Eccentricity: 7373,
ArgumentOfPerigee: 294.0868,
MeanAnomaly: 138.805,
MeanMotion: 15.50381554,
RevolutionNumberAtEpoch: 18475,
Checksum: 4,
},
},
wantErr: false,
},
{
name: "ALTAIR PATHFINDER ",
args: args{
RawTLE: `ALTAIR PATHFINDER
1 42711U 98067LS 19228.69980992 .00034716 00000-0 14927-3 0 9996
2 42711 51.6342 342.8763 0003425 355.3059 4.7912 15.84686251128432`,
},
want: TLE{
TitleLine: TitleLine{
Satname: "ALTAIR PATHFINDER ",
},
LineOne: LineOne{
Linenumber: 1,
SatelliteNumber: 42711,
Classification: "U",
InternationalDesignator: InternationalDesignator{
Launchyear: 98,
Launchnumber: 67,
Launchpiece: "LS",
},
Epoch: Epoch{
Year: 19,
Dayfraction: 228.69980992,
},
Firstderiv: 0.00034716,
Secondderiv: 0,
BSTAR: 0.00014927,
Numberzero: 0,
ElementSetNumber: 999,
Checksum: 6,
},
LineTwo: LineTwo{
Linenumber: 2,
SatelliteNumber: 42711,
Inclination: 51.6342,
RightAscensionOfTheAscendingNode: 342.8763,
Eccentricity: 3425,
ArgumentOfPerigee: 355.3059,
MeanAnomaly: 4.7912,
MeanMotion: 15.84686251,
RevolutionNumberAtEpoch: 12843,
Checksum: 2,
},
},
wantErr: false,
},
{
name: "CALSPHERE 1 ",
args: args{
RawTLE: `CALSPHERE 1
1 00900U 64063C 19230.92310804 .00000183 00000-0 18763-3 0 9990
2 00900 90.1493 23.5442 0025413 246.1721 230.7950 13.73262737728795`,
},
want: TLE{
TitleLine: TitleLine{
Satname: "CALSPHERE 1 ",
},
LineOne: LineOne{
Linenumber: 1,
SatelliteNumber: 900,
Classification: "U",
InternationalDesignator: InternationalDesignator{
Launchyear: 64,
Launchnumber: 63,
Launchpiece: "C",
},
Epoch: Epoch{
Year: 19,
Dayfraction: 230.92310804,
},
Firstderiv: 0.00000183,
Secondderiv: 0,
BSTAR: 0.00018763,
Numberzero: 0,
ElementSetNumber: 999,
Checksum: 0,
},
LineTwo: LineTwo{
Linenumber: 2,
SatelliteNumber: 900,
Inclination: 90.1493,
RightAscensionOfTheAscendingNode: 23.5442,
Eccentricity: 25413,
ArgumentOfPerigee: 246.1721,
MeanAnomaly: 230.795,
MeanMotion: 13.73262737,
RevolutionNumberAtEpoch: 72879,
Checksum: 5,
},
},
wantErr: false,
},
{
name: "CALSPHERE 1 ",
args: args{
RawTLE: `NOAA 1 [-]
1 04793U 70106A 19240.84692470 -.00000044 00000-0 47034-5 0 9995
2 04793 101.6989 308.4654 0032091 148.0366 326.6117 12.53991010229282`,
},
want: TLE{
TitleLine: TitleLine{
Satname: "NOAA 1 [-] ",
},
LineOne: LineOne{
Linenumber: 1,
SatelliteNumber: 4793,
Classification: "U",
InternationalDesignator: InternationalDesignator{
Launchyear: 70,
Launchnumber: 106,
Launchpiece: "A",
},
Epoch: Epoch{
Year: 19,
Dayfraction: 240.8469247,
},
Firstderiv: -4.4e-07,
Secondderiv: 0,
BSTAR: 4.7034e-06,
Numberzero: 0,
ElementSetNumber: 999,
Checksum: 5,
},
LineTwo: LineTwo{
Linenumber: 2,
SatelliteNumber: 4793,
Inclination: 1.6989,
RightAscensionOfTheAscendingNode: 308.4654,
Eccentricity: 32091,
ArgumentOfPerigee: 148.0366,
MeanAnomaly: 326.6117,
MeanMotion: 12.5399101,
RevolutionNumberAtEpoch: 22928,
Checksum: 2,
},
},
wantErr: false,
},
{
name: "NewTLE parseLineOne err",
args: args{
RawTLE: `NOAA 1 [-]
a 04793U 70106A 19240.84692470 -.00000044 00000-0 47034-5 0 9995
2 04793 101.6989 308.4654 0032091 148.0366 326.6117 12.53991010229282`,
},
want: TLE{},
wantErr: true,
},
{
name: "NewTLE parseLineOne satellite number error",
args: args{
RawTLE: `NOAA 1 [-]
1 0aaa3U 70106A 19240.84692470 -.00000044 00000-0 47034-5 0 9995
a 04793 101.6989 308.4654 0032091 148.0366 326.6117 12.53991010229282`,
},
want: TLE{},
wantErr: true,
},
{
name: "NewTLE parseLineOne LaunchYear",
args: args{
RawTLE: `NOAA 1 [-]
1 04793U aa106A 19240.84692470 -.00000044 00000-0 47034-5 0 9995
2 04793 101.6989 308.4654 0032091 148.0366 326.6117 12.53991010229282`,
},
want: TLE{},
wantErr: true,
},
{
name: "NewTLE parseLineOne LaunchNumber",
args: args{
RawTLE: `NOAA 1 [-]
1 04793U 70aaaA 19240.84692470 -.00000044 00000-0 47034-5 0 9995
2 04793 101.6989 308.4654 0032091 148.0366 326.6117 12.53991010229282`,
},
want: TLE{},
wantErr: true,
},
{
name: "NewTLE parseLineOne Epoch Year",
args: args{
RawTLE: `NOAA 1 [-]
1 04793U 70106A aa240.84692470 -.00000044 00000-0 47034-5 0 9995
2 04793 101.6989 308.4654 0032091 148.0366 326.6117 12.53991010229282`,
},
want: TLE{},
wantErr: true,
},
{
name: "NewTLE parseLineOne Epoch Day Fraction",
args: args{
RawTLE: `NOAA 1 [-]
1 04793U 70106A 19aaaaaaaaa470 -.00000044 00000-0 47034-5 0 9995
2 04793 101.6989 308.4654 0032091 148.0366 326.6117 12.53991010229282`,
},
want: TLE{},
wantErr: true,
},
{
name: "NewTLE parseLineOne Raw First Deriv",
args: args{
RawTLE: `NOAA 1 [-]
1 04793U 70106A 19240.84692470 -.0aaaa044 00000-0 47034-5 0 9995
2 04793 101.6989 308.4654 0032091 148.0366 326.6117 12.53991010229282`,
},
want: TLE{},
wantErr: true,
},
{
name: "NewTLE parseLineOne Second Deriv Base",
args: args{
RawTLE: `NOAA 1 [-]
1 04793U 70106A 19240.84692470 -.00000044 00aaa-0 47034-5 0 9995
2 04793 101.6989 308.4654 0032091 148.0366 326.6117 12.53991010229282`,
},
want: TLE{},
wantErr: true,
},
{
name: "NewTLE parseLineOne Second Deriv Power",
args: args{
RawTLE: `NOAA 1 [-]
1 04793U 70106A 19240.84692470 -.00000044 00000-a 47034-5 0 9995
2 04793 101.6989 308.4654 0032091 148.0366 326.6117 12.53991010229282`,
},
want: TLE{},
wantErr: true,
},
{
name: "NewTLE parseLineOne BSTARBase",
args: args{
RawTLE: `NOAA 1 [-]
1 04793U 70106A 19240.84692470 -.00000044 00000-0 4aaa4-5 0 9995
2 04793 101.6989 308.4654 0032091 148.0366 326.6117 12.53991010229282`,
},
want: TLE{},
wantErr: true,
},
{
name: "NewTLE parseLineOne BSTARPower",
args: args{
RawTLE: `NOAA 1 [-]
1 04793U 70106A 19240.84692470 -.00000044 00000-0 47034-a 0 9995
2 04793 101.6989 308.4654 0032091 148.0366 326.6117 12.53991010229282`,
},
want: TLE{},
wantErr: true,
},
{
name: "NewTLE parseLineOne ElementSetNumber",
args: args{
RawTLE: `NOAA 1 [-]
1 04793U 70106A 19240.84692470 -.00000044 00000-0 47034-5 0 aa95
2 04793 101.6989 308.4654 0032091 148.0366 326.6117 12.53991010229282`,
},
want: TLE{},
wantErr: true,
},
{
name: "NewTLE parseLineOne Number Zero",
args: args{
RawTLE: `NOAA 1 [-]
1 04793U 70106A 19240.84692470 -.00000044 00000-0 47034-5 a 9995
2 04793 101.6989 308.4654 0032091 148.0366 326.6117 12.53991010229282`,
},
want: TLE{},
wantErr: true,
},
{
name: "NewTLE parseLineOne Checksum",
args: args{
RawTLE: `NOAA 1 [-]
1 04793U 70106A 19240.84692470 -.00000044 00000-0 47034-5 0 999a
2 04793 101.6989 308.4654 0032091 148.0366 326.6117 12.53991010229282`,
},
want: TLE{},
wantErr: true,
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
got, err := NewTLE(tt.args.RawTLE)
if (err != nil) != tt.wantErr {
t.Errorf("NewTLE() error = %v, wantErr %v", err, tt.wantErr)
return
}
if !reflect.DeepEqual(got, tt.want) {
t.Errorf("NewTLE() got = %v\n,......................... want %v", got, tt.want)
}
})
}
}
func BenchmarkNewTLE(b *testing.B) {
RawTLE := `CALSPHERE 1
1 00900U 64063C 19230.92310804 .00000183 00000-0 18763-3 0 9990
2 00900 90.1493 23.5442 0025413 246.1721 230.7950 13.73262737728795`
for i := 0; i < b.N; i++ {
_, _ = NewTLE(RawTLE)
}
}
|