A new version of SGPKit, 3.1.0, has been released.
This new minor version introduces the conformance to Codable for the TLE type. This allows easy serialization and deserialization of TLE objects.
Encoding Link to heading
import SGPKit
let tle = try TLE(
title: "ISS (ZARYA)",
firstLine: "1 25544U 98067A 25312.54791667 .00016717 00000-0 10270-3 0 9006",
secondLine: "2 25544 51.6432 123.4567 0007417 234.5678 345.6789 15.50000012345678"
)
let encoder = TLEEncoder()
let data: Data = try encoder.encode(tle)
print("Encoded TLE data: \(data)")
Decoding Link to heading
Decoding a single TLE is quite simple.
- Begin by creating a
Dataobject that contains the serialized TLE. - Instantiate a TLEDecoder object.
- Call the
decode(_:)method to reconstruct the TLE object.
To decode a collection of TLEs, the method to call is decodeCollection(_:)
Below, you’ll find two example.
Decoding single TLE Link to heading
import SGPKit
let encodedData: Data = ... // Some previously encoded TLE data
let decoder = TLEDecoder()
let tle: TLE = try decoder.decode(encodedData)
print("Decoded TLE: \(tle)")
Decoding multiple TLE Link to heading
import SGPKit
let encodedCollection: Data = ... // Some previously encoded TLE data
let decoder = TLEDecoder()
let tle: [TLE] = try decoder.decodeCollection(encodedCollection)
print("Decoded collection of TLE: \(tle)")