Orbis.Format.TLE (Orbis v0.7.0)

Copy Markdown View Source

Parse and encode Two-Line Element sets.

TLE is the legacy fixed-width format for satellite orbital elements, designed for 80-column punch cards in the 1960s. Despite its age, it remains the most widely used format for distributing orbital data.

Parsing

The parser is liberal in what it accepts:

  • Trailing whitespace and extra characters are trimmed
  • Leading dots in floats (.1230.123)
  • Spaces in numeric fields

Checksum validation is performed and reported but does not prevent parsing.

Examples

{:ok, elements} = Orbis.Format.TLE.parse(line1, line2)
{line1, line2} = Orbis.Format.TLE.encode(elements)

Summary

Functions

Encode an %Orbis.Elements{} struct as TLE-format strings.

Parse a two-line element set into an %Orbis.Elements{} struct.

Functions

encode(el)

@spec encode(Orbis.Elements.t()) :: {String.t(), String.t()}

Encode an %Orbis.Elements{} struct as TLE-format strings.

Returns {line1, line2} — two 69-character strings with valid checksums. Round-trips are character-exact for standard TLEs.

Examples

iex> l1 = "1 25544U 98067A   18184.80969102  .00001614  00000-0  31745-4 0  9993"
iex> l2 = "2 25544  51.6414 295.8524 0003435 262.6267 204.2868 15.54005638121106"
iex> {:ok, el} = Orbis.Format.TLE.parse(l1, l2)
iex> {gen_l1, gen_l2} = Orbis.Format.TLE.encode(el)
iex> gen_l1 == l1
true
iex> gen_l2 == l2
true

parse(longstr1, longstr2)

@spec parse(String.t(), String.t()) ::
  {:ok, Orbis.Elements.t()} | {:error, String.t()}

Parse a two-line element set into an %Orbis.Elements{} struct.

Returns {:ok, elements} or {:error, reason}. Logs a warning if checksums are invalid but still parses.

Examples

iex> {:ok, el} = Orbis.Format.TLE.parse(
...>   "1 25544U 98067A   18184.80969102  .00001614  00000-0  31745-4 0  9993",
...>   "2 25544  51.6414 295.8524 0003435 262.6267 204.2868 15.54005638121106"
...> )
iex> el.catalog_number
"25544"
iex> el.inclination_deg
51.6414