From 61c0058b12c1bb65d6c4b7b4070abcd38d9db6bf Mon Sep 17 00:00:00 2001 From: Emile Date: Mon, 19 Aug 2019 15:52:49 +0200 Subject: NewTLE function --- convert.go | 53 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 53 insertions(+) create mode 100644 convert.go (limited to 'convert.go') diff --git a/convert.go b/convert.go new file mode 100644 index 0000000..c0515d8 --- /dev/null +++ b/convert.go @@ -0,0 +1,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 +} -- cgit 1.4.1