Skip to content
Sergei Fundaev edited this page Apr 30, 2015 · 1 revision

QuickTle provides three classes for operating with TLE data: Node, Stream and DataSet. All of them are available in the quicktle namespace.

An object of quicktle::Node type stores the data about satellite position at some time moment. This data is provided by two lines (or three lines if the first one contains the satellite name) of TLE format. One can manipulate with this data with setters and getters of quicktle::Node class as it is presented bellow:

#include <quicktle/node.h>

int main(int argc, char** argv)
{
    quicktle::Node node;
    node.set_e(0.2); // eccentricity
    node.set_M(M_PI); // mean anomaly
    node.set_n(15 * 2 * M_PI / 86400); // mean motion is equal to 15 revolutions per day
    
    std::cout() << "x: " << node.x() << std::endl; // print X-coordinate
    std::cout() << "y: " << node.y() << std::endl; // print Y-coordinate
    std::cout() << "z: " << node.z() << std::endl; // print Z-coordinate
    
    std::cout << node; // print node data in TLE format
    
    return 0;
}

One can also assign satellite position via data, stored in the TLE-formated strings:

quicktle::Node node1("1 16609U 86017A   86053.30522506  .00057349  00000-0  31166-3 0   112",
                     "2 16609  51.6129 108.0599 0012107 160.8295 196.0076 15.79438158   394");
quicktle::Node node2("Mir                     ",
                     "1 16609U 86017A   86053.30522506  .00057349  00000-0  31166-3 0   112",
                     "2 16609  51.6129 108.0599 0012107 160.8295 196.0076 15.79438158   394");

It can be done also with assign method:

quicktle::Node node1;
node1.assign("1 16609U 86017A   86053.30522506  .00057349  00000-0  31166-3 0   112",
             "2 16609  51.6129 108.0599 0012107 160.8295 196.0076 15.79438158   394");

quicktle::Node node2;
node2.assign("Mir                     ",
             "1 16609U 86017A   86053.30522506  .00057349  00000-0  31166-3 0   112",
             "2 16609  51.6129 108.0599 0012107 160.8295 196.0076 15.79438158   394");

quicktle::Node class realizes lazy initialization behavior: it tries to parse TLE strings to obtain the value of some orbit element only when the value of this element is requested. So when the TLE strings are assigned into object of quicktle::Node type, this object checks their length and validates checksums only. It allows to load big TLE files fast.

2 quicktle::Stream

The quicktle::Stream class is developed to simplify the reading TLE files. It provides the wrapper for std::istream class. The example bellow demonstrates how to use it.

#include <iostream>
#include <fstream>
#include <quicktle/node.h>
#include <quicktle/stream.h>

using namespace std;

int main(int argc, char** argv)
{
    fstream f("mir.tle");
    quicktle::Stream tle(f, quicktle::TwoLines);
    while (tle)
    {
        quicktle::Node node;
        tle >> node;
        cout << node;
    }
    f.close();
    return 0;
}

3 quicktle::DataSet

If it is necessary to store the big volume of data about satellite positions and to search for the position, nearest to the given moment of time, it is convenient to use quicktle::DataSet class.

Clone this wiki locally