Enroute Flight Navigation
A navigation app for VFR pilots
Airspace.h
1/***************************************************************************
2 * Copyright (C) 2019-2025 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 <QGeoPolygon>
24#include <QJsonObject>
25
26#include "units/Distance.h"
27#include "units/Pressure.h"
28
29namespace GeoMaps {
30
32
33class Airspace {
34 Q_GADGET
35
37 friend auto operator==(const GeoMaps::Airspace&, const GeoMaps::Airspace&) -> bool;
38
39public:
41 Airspace() = default;
42
51 explicit Airspace(const QJsonObject &geoJSONObject);
52
89 [[nodiscard]] Units::Distance estimatedLowerBoundMSL(Units::Distance terrainElevation, Units::Pressure QNH, Units::Distance ownshipGeometricAltitude, Units::Distance ownshipBarometricAltitude) const;
90
127 [[nodiscard]] Units::Distance estimatedUpperBoundMSL(Units::Distance terrainElevation, Units::Pressure QNH, Units::Distance ownshipGeometricAltitude, Units::Distance ownshipBarometricAltitude) const;
128
130 Q_PROPERTY(bool isValid READ isValid CONSTANT)
131
132
136 [[nodiscard]] auto isValid() const -> bool { return !m_polygon.isEmpty(); }
137
144 Q_PROPERTY(QString lowerBound READ lowerBound CONSTANT)
145
146
150 [[nodiscard]] auto lowerBound() const -> QString { return m_lowerBound; }
151
156 Q_PROPERTY(QString lowerBoundMetric READ lowerBoundMetric CONSTANT)
157
158
162 [[nodiscard]] auto lowerBoundMetric() const -> QString { return makeMetric(m_lowerBound); }
163
164 /* \brief Name of the airspace, such as "ED-R 31" */
165 Q_PROPERTY(QString name READ name CONSTANT)
166
167
171 [[nodiscard]] auto name() const -> QString { return m_name; }
172
174 Q_PROPERTY(QGeoPolygon polygon READ polygon CONSTANT)
175
176
180 [[nodiscard]] auto polygon() const -> QGeoPolygon { return m_polygon; }
181
182 /* \brief Category of the airspace
183 *
184 * A string with the category of the airspace, as described in the GeoJSON
185 * file specification
186 * [here](https://github.com/Akaflieg-Freiburg/enrouteServer/wiki/GeoJSON-files-used-in-enroute-flight-navigation).
187 */
188 Q_PROPERTY(QString CAT READ CAT CONSTANT)
189
190
194 [[nodiscard]] auto CAT() const -> QString { return m_CAT; }
195
200 Q_PROPERTY(QString upperBound READ upperBound CONSTANT)
201
202
206 [[nodiscard]] auto upperBound() const -> QString { return m_upperBound; }
207
212 Q_PROPERTY(QString upperBoundMetric READ upperBoundMetric CONSTANT)
213
214
218 [[nodiscard]] auto upperBoundMetric() const -> QString { return makeMetric(m_upperBound); }
219
220private:
221 // Transforms a height string such as "4500", "1500 GND" or "FL 130" into a
222 // string that describes the height in meters. If the height string cannot
223 // be parsed, returns the original string
224 [[nodiscard]] static auto makeMetric(const QString& standard) -> QString;
225
226 // Function used by estimatedLowerBoundMSL() and estimatedUpperBoundMSL()
227 [[nodiscard]] static Units::Distance estimateBoundMSL(const QString& boundString, Units::Distance terrainElevation, Units::Pressure QNH, Units::Distance ownshipGeometricAltitude, Units::Distance ownshipBarometricAltitude);
228
229 QString m_name;
230 QString m_CAT;
231 QString m_upperBound;
232 QString m_lowerBound;
233 QGeoPolygon m_polygon;
234};
235
237auto operator==(const GeoMaps::Airspace&, const GeoMaps::Airspace&) -> bool;
238
245auto qHash(const GeoMaps::Airspace& as) -> size_t;
246
247} // namespace GeoMaps
248
249
250// Declare meta types
251Q_DECLARE_METATYPE(GeoMaps::Airspace)
A very simple class that describes an airspace.
Definition Airspace.h:33
auto CAT() const -> QString
Getter function for property with the same name.
Definition Airspace.h:194
bool isValid
Validity.
Definition Airspace.h:130
QString upperBoundMetric
Upper limit of the airspace.
Definition Airspace.h:212
auto lowerBound() const -> QString
Getter function for property with the same name.
Definition Airspace.h:150
auto lowerBoundMetric() const -> QString
Getter function for property with the same name.
Definition Airspace.h:162
Units::Distance estimatedLowerBoundMSL(Units::Distance terrainElevation, Units::Pressure QNH, Units::Distance ownshipGeometricAltitude, Units::Distance ownshipBarometricAltitude) const
Estimates the lower limit of the airspace, as a geometric altitude above MSL.
QString lowerBoundMetric
Lower limit of the airspace.
Definition Airspace.h:156
auto name() const -> QString
Getter function for property with the same name.
Definition Airspace.h:171
auto polygon() const -> QGeoPolygon
Getter function for property with the same name.
Definition Airspace.h:180
auto isValid() const -> bool
Getter function for property with the same name.
Definition Airspace.h:136
friend auto operator==(const GeoMaps::Airspace &, const GeoMaps::Airspace &) -> bool
Comparison.
QGeoPolygon polygon
QGeoPolygon that describes the lateral limits of the airspace.
Definition Airspace.h:174
QString upperBound
Upper limit of the airspace.
Definition Airspace.h:200
Units::Distance estimatedUpperBoundMSL(Units::Distance terrainElevation, Units::Pressure QNH, Units::Distance ownshipGeometricAltitude, Units::Distance ownshipBarometricAltitude) const
Estimates the upper limit of the airspace, as a geometric altitude above MSL.
QString lowerBound
Lower limit of the airspace.
Definition Airspace.h:144
Airspace()=default
Constructs an invalid airspace.
auto upperBound() const -> QString
Getter function for property with the same name.
Definition Airspace.h:206
auto upperBoundMetric() const -> QString
Getter function for property with the same name.
Definition Airspace.h:218
Airspace(const QJsonObject &geoJSONObject)
Constructs an airspace from a GeoJSON object.
Convenience class for distance computations.
Definition Distance.h:35
Convenience class for pressure computations.
Definition Pressure.h:35