4#ifndef ORBITALELEMENTSDATABASE_HH
5#define ORBITALELEMENTSDATABASE_HH
7#include <QAbstractTableModel>
8#include <QNetworkAccessManager>
65 unsigned int id()
const;
67 const QString &
name()
const;
133 bool contains(
unsigned int id)
const;
142 unsigned int dbAge()
const;
147 int rowCount(
const QModelIndex &parent = QModelIndex())
const;
149 int columnCount(
const QModelIndex &parent = QModelIndex())
const;
151 QVariant
data(
const QModelIndex &index,
int role)
const;
153 QVariant
headerData(
int section, Qt::Orientation orientation,
int role)
const;
167 void downloadFinished(QNetworkReply *reply);
171 bool load(
const QString &filename);
175 unsigned int _updatePeriod;
177 QVector<OrbitalElement> _elements;
179 QHash<unsigned int, unsigned int> _idIndexMap;
181 QNetworkAccessManager _network;
Defines a single orbital element, enabling the tracking of a single satellite.
Definition orbitalelementsdatabase.hh:15
Epoch _epoch
The epoch.
Definition orbitalelementsdatabase.hh:98
double _eccentricity
Eccentricity.
Definition orbitalelementsdatabase.hh:108
double _perigee
Argument of perigee.
Definition orbitalelementsdatabase.hh:110
const Epoch & epoch() const
Epoch of the orbital elements.
Definition orbitalelementsdatabase.cc:110
const QString & name() const
Returns the name of the satellite.
Definition orbitalelementsdatabase.cc:105
double _meanAnomaly
Mean anomaly.
Definition orbitalelementsdatabase.hh:112
unsigned int revolutionNumber() const
Returns the revolution number.
Definition orbitalelementsdatabase.cc:150
double _ascension
Right ascension of the ascending node.
Definition orbitalelementsdatabase.hh:106
double meanMotionDerivative() const
Returns the first derivative of the mean motion.
Definition orbitalelementsdatabase.cc:120
double eccentricity() const
Returns the eccentricity.
Definition orbitalelementsdatabase.cc:135
double _meanMotion
Mean motion.
Definition orbitalelementsdatabase.hh:100
unsigned int id() const
Returns the NORAD catalog id.
Definition orbitalelementsdatabase.cc:100
double ascension() const
Returns the right ascension of the ascending node.
Definition orbitalelementsdatabase.cc:130
unsigned int _revolutionNumber
The revolution number.
Definition orbitalelementsdatabase.hh:114
unsigned int _id
NORAD id of the satellite.
Definition orbitalelementsdatabase.hh:94
OrbitalElement(const OrbitalElement &other)=default
Copy constructor.
static OrbitalElement fromCelesTrak(const QJsonObject &obj)
Constructs a orbital element from a CelesTrak JSON object.
Definition orbitalelementsdatabase.cc:156
double meanMotion() const
Returns the mean motion.
Definition orbitalelementsdatabase.cc:115
double meanAnomaly() const
Returns the mean anomaly.
Definition orbitalelementsdatabase.cc:145
OrbitalElement()
Default constructor.
Definition orbitalelementsdatabase.cc:77
double inclination() const
Returns the inclination.
Definition orbitalelementsdatabase.cc:125
QString _name
Descriptive name of the satellite.
Definition orbitalelementsdatabase.hh:96
bool isValid() const
Returns true, if this represents a valid satellite information.
Definition orbitalelementsdatabase.cc:95
double _inclination
Inclination.
Definition orbitalelementsdatabase.hh:104
OrbitalElement & operator=(const OrbitalElement &other)=default
Copy assignment.
double _meanMotionDerivative
First derivative of the mean motion.
Definition orbitalelementsdatabase.hh:102
double perigee() const
Returns the argument of perigee.
Definition orbitalelementsdatabase.cc:140
OrbitalElementsDatabase(bool autoLoad, unsigned int updatePeriodDays=7, QObject *parent=nullptr)
Constructs a orbital element database.
Definition orbitalelementsdatabase.cc:180
QVariant headerData(int section, Qt::Orientation orientation, int role) const
Returns a single header of the database table.
Definition orbitalelementsdatabase.cc:241
void load()
If needed, downloads the database and loads all received orbital elements.
Definition orbitalelementsdatabase.cc:266
OrbitalElement getById(unsigned int id) const
Returns the orbital elements for the satellite with the given NORAD id.
Definition orbitalelementsdatabase.cc:196
unsigned int dbAge() const
Returns the current age of the cache.
Definition orbitalelementsdatabase.cc:256
void loaded()
Gets emitted once the satellite orbitals has been loaded.
const OrbitalElement & getAt(unsigned int idx) const
Returns the i-th orbital element.
Definition orbitalelementsdatabase.cc:201
QVariant data(const QModelIndex &index, int role) const
Returns a single cell of the database table.
Definition orbitalelementsdatabase.cc:224
bool contains(unsigned int id) const
returns true if the database contains a satellite with the given NORAD id.
Definition orbitalelementsdatabase.cc:191
int columnCount(const QModelIndex &parent=QModelIndex()) const
Returns the number of columns of the database table.
Definition orbitalelementsdatabase.cc:218
int rowCount(const QModelIndex &parent=QModelIndex()) const
Returns the number of elements in the database.
Definition orbitalelementsdatabase.cc:212
void error(const QString &msg)
Gets emitted if the loading one of the sources fails.
void download()
Starts the download of the orbital elements.
Definition orbitalelementsdatabase.cc:332
Represents a Julien day epoch since a specified year.
Definition orbitalelementsdatabase.hh:18
unsigned int second
The second.
Definition orbitalelementsdatabase.hh:30
unsigned int year
The year of the epoch.
Definition orbitalelementsdatabase.hh:20
double toEpoch() const
Computes the decimal epoch as the day of year a.
Definition orbitalelementsdatabase.cc:50
unsigned int microsecond
The microsecond.
Definition orbitalelementsdatabase.hh:32
QString toString() const
Encodes the Epoch as YYYY-MM-DDThh:mm:ss.uuuuuu.
Definition orbitalelementsdatabase.cc:61
unsigned int hour
The hour.
Definition orbitalelementsdatabase.hh:26
Epoch()
Default constructor.
Definition orbitalelementsdatabase.cc:16
unsigned int month
The month.
Definition orbitalelementsdatabase.hh:22
static Epoch parse(const QString &datetime)
Parses a date-time string into the epoch.
Definition orbitalelementsdatabase.cc:33
unsigned int minute
The minute.
Definition orbitalelementsdatabase.hh:28
unsigned int day
The day.
Definition orbitalelementsdatabase.hh:24
Epoch & operator=(const Epoch &other)=default
Copy assignment.
Epoch(const Epoch &other)=default
Copy constructor.