digiKam
Loading...
Searching...
No Matches
geocoordinates.h
Go to the documentation of this file.
1/* ============================================================
2 *
3 * This file is a part of digiKam project
4 * https://www.digikam.org
5 *
6 * Date : 2009-08-16
7 * Description : GeoCoordinates class
8 *
9 * SPDX-FileCopyrightText: 2010-2024 by Gilles Caulier <caulier dot gilles at gmail dot com>
10 * SPDX-FileCopyrightText: 2009-2010 by Michael G. Hansen <mike at mghansen dot de>
11 *
12 * SPDX-License-Identifier: GPL-2.0-or-later
13 *
14 * ============================================================ */
15
16#pragma once
17
18// Qt includes
19
20#include <QFlags>
21#include <QDebug>
22#include <QString>
23#include <QStringList>
24
25// Local includes
26
27#include "digikam_config.h"
28#include "digikam_export.h"
29
30#ifdef HAVE_GEOLOCATION
31
33namespace Marble
34{
35 class GeoDataCoordinates;
36}
37
38#endif // HAVE_GEOLOCATION
39
40namespace Digikam
41{
42
43class DIGIKAM_EXPORT GeoCoordinates
44{
45public:
46
48 {
49 HasNothing = 0,
50 HasLatitude = 1,
51 HasLongitude = 2,
52 HasCoordinates = 3,
53 HasAltitude = 4
54 };
55
56 Q_DECLARE_FLAGS(HasFlags, HasFlag)
57
58 typedef QList<GeoCoordinates> List;
60 typedef QList<GeoCoordinates::Pair> PairList;
61
62public:
63
64 GeoCoordinates() = default;
65 GeoCoordinates(const double inLat, const double inLon);
66 GeoCoordinates(const double inLat, const double inLon, const double inAlt);
67 ~GeoCoordinates() = default;
68
69 bool operator==(const GeoCoordinates& other) const;
70
71 double lat() const;
72 double lon() const;
73 double alt() const;
74
75 bool hasCoordinates() const;
76 bool hasLatitude() const;
77 bool hasLongitude() const;
78
79 void setLatLon(const double inLat, const double inLon);
80
81 bool hasAltitude() const;
82 HasFlags hasFlags() const;
83
84 void setAlt(const double inAlt);
85
86 void clearAlt();
87 void clear();
88
89 QString altString() const;
90 QString latString() const;
91 QString lonString() const;
92 QString geoUrl() const;
93
94 bool sameLonLatAs(const GeoCoordinates& other) const;
95
96 static GeoCoordinates fromGeoUrl(const QString& url, bool* const parsedOkay = nullptr);
97 static Pair makePair(const qreal lat1, const qreal lon1, const qreal lat2, const qreal lon2);
98
99#ifdef HAVE_GEOLOCATION
100
101 Marble::GeoDataCoordinates toMarbleCoordinates() const;
102 static GeoCoordinates fromMarbleCoordinates(const Marble::GeoDataCoordinates& marbleCoordinates);
103
104#endif // HAVE_GEOLOCATION
105
106private:
107
108 double m_lat = 0.0;
109 double m_lon = 0.0;
110 double m_alt = 0.0;
111 HasFlags m_hasFlags = HasNothing;
112};
113
114} // namespace Digikam
115
116// cppcheck-suppress unknownMacro
117Q_DECLARE_OPERATORS_FOR_FLAGS(Digikam::GeoCoordinates::HasFlags)
118
119Q_DECLARE_TYPEINFO(Digikam::GeoCoordinates, Q_MOVABLE_TYPE);
120Q_DECLARE_METATYPE(Digikam::GeoCoordinates)
121Q_DECLARE_METATYPE(Digikam::GeoCoordinates::Pair)
122Q_DECLARE_METATYPE(Digikam::GeoCoordinates::PairList)
123
124DIGIKAM_EXPORT QDebug operator<<(QDebug debug, const Digikam::GeoCoordinates& coordinate);
Definition geocoordinates.h:44
QPair< GeoCoordinates, GeoCoordinates > Pair
Definition geocoordinates.h:59
QList< GeoCoordinates > List
Definition geocoordinates.h:58
HasFlag
Definition geocoordinates.h:48
QList< GeoCoordinates::Pair > PairList
Definition geocoordinates.h:60
Q_DECLARE_TYPEINFO(Digikam::GeoCoordinates, Q_MOVABLE_TYPE)
Definition datefolderview.cpp:34