Contents

csanfilippo/swift-sgp4

A Swift package to compute satellite positions from two-line elements (TLE).

Usage

import SGPKit

let title = "ISS (ZARYA)"
let firstLine = "1 25544U 98067A   13165.59097222  .00004759  00000-0  88814-4 0    47"
let secondLine = "2 25544  51.6478 121.2152 0011003  68.5125 263.9959 15.50783143834295"

let tle = try TLE(
    title: title,
    firstLine: firstLine,
    secondLine: secondLine
)

// Instantiate the interpreter (stateless and Sendable)
let interpreter = TLEInterpreter()

// Compute the satellite state at a given date
let now: Date = .now
let data = try interpreter.satelliteData(from: tle, date: now)

print(data.latitude)   // degrees
print(data.longitude)  // degrees
print(data.altitude)   // kilometers
print(data.speed)      // km/h

Swift Package Manager

If you want to use SGPKit in any other project that uses SwiftPM, add the package as a dependency in Package.swift:

dependencies: [
  .package(
    url: "https://github.com/csanfilippo/swift-sgp4",
    from: "3.1.0"
  ),
]

Package Metadata

Repository: csanfilippo/swift-sgp4

Homepage: https://calogerosanfilippo.it/libs/swift-spg4/

Stars: 9

Forks: 5

Open issues: 1

Default branch: main

Primary language: c++

License: MIT

Topics: satellite-prediction, satellite-tracking, sgp4, spm, swift, tle

README: README.md