Enroute Flight Navigation
A navigation app for VFR pilots
VAC.h
1/***************************************************************************
2 * Copyright (C) 2023-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 <QGeoCoordinate>
24#include <QGeoRectangle>
25#include <QQmlEngine>
26
27using namespace Qt::Literals::StringLiterals;
28
29
30namespace GeoMaps
31{
32
44class VAC
45{
46 Q_GADGET
47 QML_VALUE_TYPE(vac)
48
49 friend QDataStream& operator<<(QDataStream& stream, const GeoMaps::VAC& vac);
50 friend QDataStream& operator>>(QDataStream& stream, GeoMaps::VAC& vac);
51
52public:
54 VAC() = default;
55
76 VAC(const QString& fName, const QString& unmingledFName);
77
78 //
79 // Properties
80 //
81
86 Q_PROPERTY(QGeoCoordinate bottomLeft MEMBER bottomLeft)
87
92 Q_PROPERTY(QGeoCoordinate bottomRight MEMBER bottomRight)
93
98 Q_PROPERTY(QGeoRectangle boundingBox READ boundingBox)
99
105 Q_PROPERTY(QGeoCoordinate center READ center)
106
115 Q_PROPERTY(QString collection MEMBER collection)
116
123 Q_PROPERTY(QString description READ description)
124
130 Q_PROPERTY(QString infoText READ infoText)
131
137 Q_PROPERTY(bool isValid READ isValid)
138
140 Q_PROPERTY(QString name MEMBER name)
141
147 Q_PROPERTY(QString section READ section)
148
153 Q_PROPERTY(QGeoCoordinate topLeft MEMBER topLeft)
154
159 Q_PROPERTY(QGeoCoordinate topRight MEMBER topRight)
160
162 Q_PROPERTY(QString fileName MEMBER fileName)
163
164
165 //
166 // Getter Methods
167 //
168
173 [[nodiscard]] QGeoRectangle boundingBox() const {return QGeoRectangle({topLeft, topRight, bottomLeft, bottomRight});}
174
179 [[nodiscard]] QGeoCoordinate center() const;
180
185 [[nodiscard]] QString description() const;
186
191 [[nodiscard]] QString infoText() const;
192
197 [[nodiscard]] bool isValid() const;
198
203 [[nodiscard]] QString section() const;
204
205
206
207 //
208 // Methods
209 //
210
217 [[nodiscard]] bool operator==(const VAC& other) const = default;
218
223 [[nodiscard]] static QStringList mimeTypes()
224 {
225 return {u"image/jpg"_s,
226 u"image/jpeg"_s,
227 u"image/png"_s,
228 u"image/tif"_s,
229 u"image/tiff"_s,
230 u"image/webp"_s};
231 }
232
233
234
235 //
236 // Member variable
237 //
238
240 QGeoCoordinate bottomLeft;
241
243 QGeoCoordinate bottomRight;
244
246 QString collection;
247
249 QString fileName;
250
252 QString name;
253
255 QGeoCoordinate topLeft;
256
258 QGeoCoordinate topRight;
259
260private:
261 // Obtain values for topLeft etc by looking at the file name
262 void getCoordsFromUnmingledFileName(const QString& unmingledFilename);
263
264 // Obtain value name by looking at the file name
265 void getNameFromUnmingledFileName(const QString& unmingledFilename);
266
267 // Check if all geo coordinates are valid
268 [[nodiscard]] bool hasValidCoordinates() const;
269};
270
272QDataStream& operator<<(QDataStream& stream, const GeoMaps::VAC& vac);
273
275QDataStream& operator>>(QDataStream& stream, GeoMaps::VAC& vac);
276
277} // namespace GeoMaps
278
279
Visual approach chart.
Definition VAC.h:45
bool operator==(const VAC &other) const =default
Comparison.
QGeoCoordinate bottomRight
Geographic coordinate of raster image corner.
Definition VAC.h:92
QString description
Describe installed file(s).
Definition VAC.h:123
QString section() const
Getter function for property of the same name.
QGeoCoordinate topRight
Geographic coordinate of raster image corner.
Definition VAC.h:159
QGeoCoordinate topLeft
Geographic coordinate of raster image corner.
Definition VAC.h:153
QString collection
Name of the collection containing this VAC.
Definition VAC.h:115
QGeoCoordinate center
Center coordinate.
Definition VAC.h:105
VAC()=default
Default constructor, creates an invalid VAC.
QString section
Section name, for grouping in GUI lists.
Definition VAC.h:147
QGeoRectangle boundingBox
Bounding box.
Definition VAC.h:98
bool isValid
Validity.
Definition VAC.h:137
QString name
Name of the VAC.
Definition VAC.h:140
bool isValid() const
Getter function for property of the same name.
QGeoCoordinate bottomLeft
Geographic coordinate of raster image corner.
Definition VAC.h:86
QGeoCoordinate center() const
Getter function for property of the same name.
QString infoText() const
Getter function for property of the same name.
QString infoText
Short info text.
Definition VAC.h:130
QString description() const
Getter function for property of the same name.
QString fileName
Name of raster image file.
Definition VAC.h:162
static QStringList mimeTypes()
Mime type for files that can be opened by this class.
Definition VAC.h:223