about summary refs log tree commit diff
path: root/TLE.go
blob: cf66d11713b43e843f64c3d801f06dd87413764d (plain)
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
/*
Implementing the "Two-line element set (TLE)", a data format encoding orbital elements of Earth-orbiting objects.

More information can be found here:
- https://en.wikipedia.org/wiki/Two-line_element_set
- https://spaceflight.nasa.gov/realdata/sightings/SSapplications/Post/JavaSSOP/SSOP_Help/tle_def.html

*/

package TLE

// TLE defines the lines contained in a Two-Line-Element
type TLE struct {
	TitleLine TitleLine `json:"titleline"`
	LineOne   LineOne   `json:"lineone"`
	LineTwo   LineTwo   `json:"linetwo"`
}

// NewTLE returns a pointer to a TLE struct filled with the given Lines
func NewTLE(titleLine TitleLine, lineOne LineOne, lineTwo LineTwo) *TLE {
	return &TLE{TitleLine: titleLine, LineOne: lineOne, LineTwo: lineTwo}
}

// TitleLine defines the first line in the the TLE
// It contains the name of the satellite
type TitleLine struct {
	Satname string `json:"satname"`
}

// LineOne defines the first line in the TLE
type LineOne struct {
	Linenumber int8 `json:"linenumber"`

	// Catalog number defined by USSPACECOM
	// A "U" indicates an unclassified object
	SatelliteNumber int  `json:"satellitenumber"`
	Classification  rune `json:"classification"`

	// International  Designator containing information about the launch
	InternationalDesignator InternationalDesignator `json:"internationaldesignator"`

	// Epoch defining from when the TLE is
	Epoch Epoch `json:"epoch"`

	// First Time Derivative of the Mean Motion divided by two
	// Unit: revs / day
	// "catch all" drag term used in SGP4 USSPACECOM predictor
	Firstderiv float64 `json:"firstderiv"`

	// Second Time Derivative of Mean Motion divided by six (decimal point assumed)
	// second order drag term in the SGP4
	// Unit: revs / day^3
	// A leading decimal must be applied to this value
	// The last two characters define an applicable power of 10 (12345-5 = 0.0000012345)
	Secondderiv float64 `json:"secondderiv"`

	// Drag Term
	// (67960-4 = 0.000067960)
	// Unit: earth radii^-1
	// The last two characters define an applicable power of 10
	BSTAR float64 `json:"BSTAR"`

	// The number 0 (originally this should have been "Ephemeris type")
	Numberzero int8 `json:"numberzero"`

	// Element set number. Incremented when a new TLE is generated for this object.
	ElementSetNumber int `json:"elementesetnumber"`

	// Checksum (modulo 10)
	Checksum int8 `json:"checksum"`
}

// InternationalDesignator stores information about the satellite such as when it launched
type InternationalDesignator struct {

	// Last two digits of launch year
	Launchyear int8 `json:"launchyear"`

	// Launch number of the year
	Launchnumber int `json:"launchnumber"`

	// Piece of the launch
	Launchpiece rune `json:"launchpiece"`
}

// Epoch defines a moment in time
type Epoch struct {

	// Last two digits of the year
	Year int8 `json:"year"`

	// day of the year and fractional portion of the day
	Dayfraction float64 `json:"dayfraction"`
}

type LineTwo struct {
	Linenumber                       int8    `json:"linenumber"`
	Satellitenumber                  int     `json:"satellitenumber"`
	Inclination                      float64 `json:"inclination"`
	RightAscensionOfTheAscendingNode float64 `json:"rightascensionoftheascendingnode"`
	Eccentricity                     float64 `json:"eccentricity"`
	ArgumentOfPerigee                float64 `json:"argumentofperigee"`
	MeanAnomaly                      float64 `json:"meananomaly"`
	MeanMotion                       float64 `json:"meanmotion"`
	RevolutionNumberAtEpoch          int     `json:"revolutionnumberatepoch"`
	Checksum                         int8    `json:"checksum"`
}