libdrmconf 0.12.1
A library to program DMR radios.
Loading...
Searching...
No Matches
orbitalelementsdatabase.hh
1#ifndef ORBITALELEMENTSDATABASE_HH
2#define ORBITALELEMENTSDATABASE_HH
3
4#include <QAbstractTableModel>
5#include <QNetworkAccessManager>
6
7
9{
10public:
11 struct Epoch {
12 unsigned int year;
13 unsigned int month;
14 unsigned int day;
15 unsigned int hour;
16 unsigned int minute;
17 unsigned int second;
18 unsigned int microsecond;
19
21 Epoch();
23 Epoch(unsigned int year, unsigned int month, unsigned int day,
24 unsigned int hour, unsigned int minute, unsigned int second, unsigned int microsecond);
26 Epoch(const Epoch &other) = default;
28 Epoch &operator =(const Epoch &other) = default;
29
30 static Epoch parse(const QString &datetime);
31 double toEpoch() const;
32 QString toString() const;
33 };
34
35public:
39 OrbitalElement(unsigned int id);
41 OrbitalElement(const OrbitalElement &other) = default;
43 OrbitalElement &operator=(const OrbitalElement &other) = default;
44
46 bool isValid() const;
48 unsigned int id() const;
50 const QString &name() const;
51
53 const Epoch &epoch() const;
55 double meanMotion() const;
57 double meanMotionDerivative() const;
59 double inclination() const;
61 double ascension() const;
63 double eccentricity() const;
65 double perigee() const;
67 double meanAnomaly() const;
69 unsigned int revolutionNumber() const;
70
71public:
72 static OrbitalElement fromCelesTrak(const QJsonObject &obj);
73
74protected:
75 unsigned int _id;
76 QString _name;
77 Epoch _epoch;
78 double _meanMotion;
79 double _meanMotionDerivative;
80 double _inclination;
81 double _ascension;
82 double _eccentricity;
83 double _perigee;
84 double _meanAnomaly;
85 unsigned int _revolutionNumber;
86};
87
88
89
90class OrbitalElementsDatabase: public QAbstractTableModel
91{
92 Q_OBJECT
93
94public:
95 explicit OrbitalElementsDatabase(bool autoLoad, unsigned int updatePeriodDays=7, QObject *parent=nullptr);
96
97 bool contains(unsigned int id) const;
98 OrbitalElement getById(unsigned int id) const;
99 const OrbitalElement &getAt(unsigned int idx) const;
100 OrbitalElement &getAt(unsigned int idx);
101
102 unsigned int dbAge() const;
103 void load();
104
105 int rowCount(const QModelIndex &parent = QModelIndex()) const;
106 int columnCount(const QModelIndex &parent = QModelIndex()) const;
107 QVariant data(const QModelIndex &index, int role) const;
108
109signals:
111 void loaded();
113 void error(const QString &msg);
114
115public slots:
117 void download();
118
119private slots:
121 void downloadFinished(QNetworkReply *reply);
122
123protected:
124 bool load(const QString &filename);
125
126private:
128 unsigned int _updatePeriod;
130 QVector<OrbitalElement> _elements;
132 QHash<unsigned int, unsigned int> _idIndexMap;
134 QNetworkAccessManager _network;
135};
136
137#endif // ORBITALELEMENTSDATABASE_HH
Definition orbitalelementsdatabase.hh:9
const Epoch & epoch() const
Epoch of the orbital elements.
Definition orbitalelementsdatabase.cc:110
const QString & name() const
Retunrs the name of the satellite.
Definition orbitalelementsdatabase.cc:105
unsigned int revolutionNumber() const
Returns the revolution number.
Definition orbitalelementsdatabase.cc:150
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
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
OrbitalElement(const OrbitalElement &other)=default
Copy constructor.
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
bool isValid() const
Returns true, if this represents a valid satellite information.
Definition orbitalelementsdatabase.cc:95
OrbitalElement & operator=(const OrbitalElement &other)=default
Copy assignemnt.
double perigee() const
Returns the argument of perigee.
Definition orbitalelementsdatabase.cc:140
Definition orbitalelementsdatabase.hh:91
void loaded()
Gets emitted once the satellite orbitals has been loaded.
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:318
Definition orbitalelementsdatabase.hh:11
Epoch()
Default constructor.
Definition orbitalelementsdatabase.cc:16
Epoch & operator=(const Epoch &other)=default
Copy assignment.
Epoch(const Epoch &other)=default
Copy constructor.