about summary refs log tree commit diff
path: root/convert.go
blob: c0515d87c7ee9a181c888646febdbd9c247668b0 (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
package TLE

import (
	"fmt"
	"strconv"
	"strings"
)

func NewTLE(RawTLE string) (TLE, error) {

	// split the TLE
	var SplitTLE []string = strings.Split(RawTLE, "\n")

	//fmt.Printf("%#v", SplitTLE)
	fmt.Printf("Line one, first char: %v", SplitTLE[1][0])

	// Line One

	// parse the line number
	LineOneLinenumber, err := strconv.Atoi(string(SplitTLE[1][0]))
	if err != nil {
		return TLE{}, fmt.Errorf("%s: %#v", "Could not parse the line number", SplitTLE[0][1])
	}

	var generatedTLE TLE = TLE{
		TitleLine: TitleLine{
			Satname: fmt.Sprintf("%-25s", SplitTLE[0][0:24]),
		},
		LineOne: LineOne{
			Linenumber:      int8(LineOneLinenumber),
			SatelliteNumber: 0,
			Classification:  0,
			InternationalDesignator: InternationalDesignator{
				Launchyear:   0,
				Launchnumber: 0,
				Launchpiece:  0,
			},
			Epoch: Epoch{
				Year:        0,
				Dayfraction: 0,
			},
			Firstderiv:       0,
			Secondderiv:      0,
			BSTAR:            0,
			Numberzero:       0,
			ElementSetNumber: 0,
			Checksum:         0,
		},
		LineTwo: LineTwo{},
	}

	return generatedTLE, nil
}