Enroute Flight Navigation
A navigation app for VFR pilots
NOTAM.h
1/***************************************************************************
2 * Copyright (C) 2023-2024 by Stefan Kebekus *
3 * stefan.kebekus@gmail.com *
4 * *
5 * This program is free software; you can redistribute it and/or modify *
6 * it under the terms of the GNU General Public License as published by *
7 * the Free Software Foundation; either version 3 of the License, or *
8 * (at your option) any later version. *
9 * *
10 * This program is distributed in the hope that it will be useful, *
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
13 * GNU General Public License for more details. *
14 * *
15 * You should have received a copy of the GNU General Public License *
16 * along with this program; if not, write to the *
17 * Free Software Foundation, Inc., *
18 * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
19 ***************************************************************************/
20
21#pragma once
22
23#include <QDateTime>
24#include <QGeoCircle>
25#include <QQmlEngine>
26
27#include "units/Distance.h"
28
29namespace NOTAM {
30
32
33class NOTAM {
34 Q_GADGET
35 QML_VALUE_TYPE(notam)
36
37 friend QDataStream& operator<<(QDataStream& stream, const NOTAM& notam);
38 friend QDataStream& operator>>(QDataStream& stream, NOTAM& notam);
39
40public:
42 NOTAM() = default;
43
48 explicit NOTAM(const QJsonObject& jsonObject);
49
50
51 //
52 // Properties
53 //
54
56 Q_PROPERTY(QString affectedFIR READ affectedFIR CONSTANT)
57
64 Q_PROPERTY(QString cancels READ cancels CONSTANT)
65
67 Q_PROPERTY(QGeoCoordinate coordinate READ coordinate CONSTANT)
68
75 Q_PROPERTY(QDateTime effectiveEnd READ effectiveEnd CONSTANT)
76
83 Q_PROPERTY(QDateTime effectiveStart READ effectiveStart CONSTANT)
84
86 Q_PROPERTY(QJsonObject GeoJSON READ GeoJSON CONSTANT)
87
89 Q_PROPERTY(QString icaoLocation READ icaoLocation CONSTANT)
90
92 Q_PROPERTY(bool isValid READ isValid CONSTANT)
93
95 Q_PROPERTY(QString number READ number CONSTANT)
96
98 Q_PROPERTY(QGeoCircle region READ region CONSTANT)
99
105 Q_PROPERTY(QString sectionTitle MEMBER m_sectionTitle)
106
112 Q_PROPERTY(QString text READ text CONSTANT)
113
115 Q_PROPERTY(QString traffic READ traffic CONSTANT)
116
117
118 //
119 // Getter Methods
120 //
121
126 Q_REQUIRED_RESULT QString affectedFIR() const { return m_affectedFIR; }
127
132 Q_REQUIRED_RESULT QString cancels() const;
133
138 Q_REQUIRED_RESULT QGeoCoordinate coordinate() const { return m_coordinate; }
139
144 Q_REQUIRED_RESULT QDateTime effectiveEnd() const { return m_effectiveEnd; }
145
150 Q_REQUIRED_RESULT QDateTime effectiveStart() const { return m_effectiveStart; }
151
156 Q_REQUIRED_RESULT QJsonObject GeoJSON() const;
157
162 Q_REQUIRED_RESULT QString icaoLocation() const { return m_icaoLocation; }
163
168 Q_REQUIRED_RESULT bool isValid() const;
169
174 Q_REQUIRED_RESULT QString number() const { return m_number; }
175
180 Q_REQUIRED_RESULT QGeoCircle region() const { return m_region; }
181
186 Q_REQUIRED_RESULT QString text() const { return m_text; }
187
192 Q_REQUIRED_RESULT QString traffic() const { return m_traffic; }
193
194
195
196 //
197 // Methods
198 //
199
210 Q_REQUIRED_RESULT QString category() const;
211
218 Q_REQUIRED_RESULT [[nodiscard]] Q_INVOKABLE bool operator==(const NOTAM& rhs) const = default;
219
224 Q_REQUIRED_RESULT bool isOutdated() const
225 {
226 return m_effectiveEnd.isValid() && (m_effectiveEnd < QDateTime::currentDateTimeUtc());
227 }
228
236 Q_REQUIRED_RESULT Q_INVOKABLE QString richText() const;
237
245
246private:
247 /* NOTAM members, as described by the FAA */
248 QString m_affectedFIR;
249 QGeoCoordinate m_coordinate;
250 QString m_effectiveEndString;
251 QString m_effectiveStartString;
252 QString m_icaoLocation;
253 QString m_maximumFL;
254 QString m_minimumFL;
255 QString m_number;
256 Units::Distance m_radius;
257 QString m_sectionTitle;
258 QString m_schedule;
259 QString m_selectionCode;
260 QString m_text;
261 QString m_traffic;
262
263 /* Derivative data, obtained from the FAA notam members above */
264 QDateTime m_effectiveEnd;
265 QDateTime m_effectiveStart;
266 QGeoCircle m_region;
267};
268
269
290QGeoCoordinate interpretNOTAMCoordinates(const QString& string);
291
296QDataStream& operator<<(QDataStream& stream, const NOTAM& notam);
297
302QDataStream& operator>>(QDataStream& stream, NOTAM& notam);
303
304} // namespace NOTAM
305
306// Declare meta types
307Q_DECLARE_METATYPE(NOTAM::NOTAM)
This extremely simple class holds a the data item of a NOTAM.
Definition NOTAM.h:33
QString icaoLocation
ICAO location of this NOTAM.
Definition NOTAM.h:89
QString affectedFIR
Flight Information Region of this NOTAM.
Definition NOTAM.h:56
Q_REQUIRED_RESULT QJsonObject GeoJSON() const
Getter function for the property with the same name.
Q_REQUIRED_RESULT bool isValid() const
Getter function for the property with the same name.
Q_REQUIRED_RESULT QString traffic() const
Getter function for the property with the same name.
Definition NOTAM.h:192
QString cancels
Cancels other NOTAM.
Definition NOTAM.h:64
QDateTime effectiveStart
Effective start of the NOTAM, if date is given.
Definition NOTAM.h:83
QGeoCoordinate coordinate
Coordinates of the NOTAM.
Definition NOTAM.h:67
Q_REQUIRED_RESULT QString icaoLocation() const
Getter function for the property with the same name.
Definition NOTAM.h:162
Q_REQUIRED_RESULT QString cancels() const
Getter function for the property with the same name.
Q_REQUIRED_RESULT bool isOutdated() const
Check if effectiveEnd is valid and earlier than currentTime.
Definition NOTAM.h:224
QString number
Number of this NOTAM.
Definition NOTAM.h:95
Q_REQUIRED_RESULT Q_INVOKABLE QString richText() const
Rich text description of the NOTAM.
QString sectionTitle
Section title.
Definition NOTAM.h:105
Q_REQUIRED_RESULT QDateTime effectiveEnd() const
Getter function for the property with the same name.
Definition NOTAM.h:144
Q_REQUIRED_RESULT Q_INVOKABLE bool operator==(const NOTAM &rhs) const =default
Comparison.
NOTAM()=default
Constructs an invalid NOTAM.
QString text
Plain text of the NOTAM.
Definition NOTAM.h:112
QDateTime effectiveEnd
Effective end of the NOTAM, if date is given.
Definition NOTAM.h:75
Q_REQUIRED_RESULT QGeoCoordinate coordinate() const
Getter function for the property with the same name.
Definition NOTAM.h:138
bool isValid
Validity of this NOTAM.
Definition NOTAM.h:92
Q_REQUIRED_RESULT QDateTime effectiveStart() const
Getter function for the property with the same name.
Definition NOTAM.h:150
Q_REQUIRED_RESULT QGeoCircle region() const
Getter function for the property with the same name.
Definition NOTAM.h:180
QGeoCircle region
Region where this NOTAM is valid.
Definition NOTAM.h:98
Q_REQUIRED_RESULT QString text() const
Getter function for the property with the same name.
Definition NOTAM.h:186
Q_REQUIRED_RESULT QString category() const
Category of this NOTAM for map icon selection.
QJsonObject GeoJSON
Waypoint in GeoJSON format.
Definition NOTAM.h:86
Q_REQUIRED_RESULT QString number() const
Getter function for the property with the same name.
Definition NOTAM.h:174
void updateSectionTitle()
Update section title according to the current time.
QString traffic
Traffic entry of the NOTAM.
Definition NOTAM.h:115
Convenience class for distance computations.
Definition Distance.h:35