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
113 Q_PROPERTY(QString description READ description)
114
120 Q_PROPERTY(QString infoText READ infoText)
121
127 Q_PROPERTY(bool isValid READ isValid)
128
130 Q_PROPERTY(QString name MEMBER name)
131
136 Q_PROPERTY(QGeoCoordinate topLeft MEMBER topLeft)
137
142 Q_PROPERTY(QGeoCoordinate topRight MEMBER topRight)
143
145 Q_PROPERTY(QString fileName MEMBER fileName)
146
147
148 //
149 // Getter Methods
150 //
151
156 [[nodiscard]] QGeoRectangle boundingBox() const {return QGeoRectangle({topLeft, topRight, bottomLeft, bottomRight});}
157
162 [[nodiscard]] QGeoCoordinate center() const;
163
168 [[nodiscard]] QString description() const;
169
174 [[nodiscard]] QString infoText() const;
175
180 [[nodiscard]] bool isValid() const;
181
182
183
184 //
185 // Methods
186 //
187
194 [[nodiscard]] bool operator==(const VAC& other) const = default;
195
200 [[nodiscard]] static QStringList mimeTypes()
201 {
202 return {u"image/jpg"_s,
203 u"image/jpeg"_s,
204 u"image/png"_s,
205 u"image/tif"_s,
206 u"image/tiff"_s,
207 u"image/webp"_s};
208 }
209
210
211
212 //
213 // Member variable
214 //
215
217 QGeoCoordinate bottomLeft;
218
220 QGeoCoordinate bottomRight;
221
223 QString fileName;
224
226 QString name;
227
229 QGeoCoordinate topLeft;
230
232 QGeoCoordinate topRight;
233
234private:
235 // Obtain values for topLeft etc by looking at the file name
236 void getCoordsFromUnmingledFileName(const QString& unmingledFilename);
237
238 // Obtain value name by looking at the file name
239 void getNameFromUnmingledFileName(const QString& unmingledFilename);
240
241 // Check if all geo coordinates are valid
242 [[nodiscard]] bool hasValidCoordinates() const;
243};
244
246QDataStream& operator<<(QDataStream& stream, const GeoMaps::VAC& vac);
247
249QDataStream& operator>>(QDataStream& stream, GeoMaps::VAC& vac);
250
251} // namespace GeoMaps
252
253
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:113
QGeoCoordinate topRight
Geographic coordinate of raster image corner.
Definition VAC.h:142
QGeoCoordinate topLeft
Geographic coordinate of raster image corner.
Definition VAC.h:136
QGeoCoordinate center
Center coordinate.
Definition VAC.h:105
VAC()=default
Default constructor, creates an invalid VAC.
QGeoRectangle boundingBox
Bounding box.
Definition VAC.h:98
bool isValid
Validity.
Definition VAC.h:127
QString name
Name of the VAC.
Definition VAC.h:130
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:120
QString description() const
Getter function for property of the same name.
QString fileName
Name of raster image file.
Definition VAC.h:145
static QStringList mimeTypes()
Mime type for files that can be opened by this class.
Definition VAC.h:200