about summary refs log tree commit diff
path: root/convert.go
diff options
context:
space:
mode:
authorEmile <hanemile@protonmail.com>2019-08-19 15:52:49 +0200
committerEmile <hanemile@protonmail.com>2019-08-19 15:52:49 +0200
commit61c0058b12c1bb65d6c4b7b4070abcd38d9db6bf (patch)
treeecd2ff2cddb5dea348dff20944bfa03bea9fe4c7 /convert.go
parent2a9a38a4e143a24dbffb8625f7781d91238b7905 (diff)
NewTLE function
Diffstat (limited to 'convert.go')
-rw-r--r--convert.go53
1 files changed, 53 insertions, 0 deletions
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
+}