diff options
author | Emile <hanemile@protonmail.com> | 2019-09-25 16:53:39 +0200 |
---|---|---|
committer | Emile <hanemile@protonmail.com> | 2019-09-25 16:53:39 +0200 |
commit | af44bb03954019d358ae5da7fac4647e2f35d04e (patch) | |
tree | c25d7ccc1d74829cb1255fc81b1af036a27e8339 /convert.go | |
parent | e4a9b7da09325c84fc738f713f790c22a39d3341 (diff) |
added support for an enmpty international designator
Diffstat (limited to 'convert.go')
-rw-r--r-- | convert.go | 37 |
1 files changed, 24 insertions, 13 deletions
diff --git a/convert.go b/convert.go index 15c3962..8e9f88a 100644 --- a/convert.go +++ b/convert.go @@ -48,21 +48,32 @@ func parseLineOne(SplitTLE []string) (LineOne, error) { return LineOne{}, fmt.Errorf("%s: %#v\n%v", "Could not parse the Satellite Number", SplitTLE[1][2:7], err) } - // Parse the launch year - LaunchYear, err := strconv.Atoi(SplitTLE[1][9:11]) - if err != nil { - return LineOne{}, fmt.Errorf("%s: %#v\n%v", "Could not parse the Launch Year", SplitTLE[1][9:11], err) + var LaunchYear int + var LaunchNumber int + var LaunchPiece string + + if SplitTLE[1][9:16] == " " { + LaunchYear = -1 + LaunchNumber = -1 + LaunchPiece = "" + + } else { + // Parse the launch year + LaunchYear, err = strconv.Atoi(SplitTLE[1][9:11]) + if err != nil { + return LineOne{}, fmt.Errorf("%s: %#v\n%v", "Could not parse the Launch Year", SplitTLE[1][9:11], err) + } + + // Parse the launch number + LaunchNumber, err = strconv.Atoi(SplitTLE[1][11:14]) + if err != nil { + return LineOne{}, fmt.Errorf("%s: %#v\n%v", "Could not parse the Launch Number", SplitTLE[1][11:14], err) + } + + // Parse the launch number + LaunchPiece = strings.TrimSpace(SplitTLE[1][14:16]) } - // Parse the launch number - LaunchNumber, err := strconv.Atoi(SplitTLE[1][11:14]) - if err != nil { - return LineOne{}, fmt.Errorf("%s: %#v\n%v", "Could not parse the Launch Number", SplitTLE[1][11:14], err) - } - - // Parse the launch number - LaunchPiece := strings.TrimSpace(SplitTLE[1][14:16]) - // Parse the epoch year EpochYear, err := strconv.Atoi(SplitTLE[1][18:20]) if err != nil { |