digiKam
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  * Copyright (C) 2010-2022 by Gilles Caulier <caulier dot gilles at gmail dot com>
10  * Copyright (C) 2009-2010 by Michael G. Hansen <mike at mghansen dot de>
11  *
12  * This program is free software; you can redistribute it
13  * and/or modify it under the terms of the GNU General
14  * Public License as published by the Free Software Foundation;
15  * either version 2, or (at your option)
16  * any later version.
17  *
18  * This program is distributed in the hope that it will be useful,
19  * but WITHOUT ANY WARRANTY; without even the implied warranty of
20  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21  * GNU General Public License for more details.
22  *
23  * ============================================================ */
24 
25 #ifndef DIGIKAM_GEO_COORDINATES_H
26 #define DIGIKAM_GEO_COORDINATES_H
27 
28 // Qt includes
29 
30 #include <QFlags>
31 #include <QDebug>
32 #include <QString>
33 #include <QStringList>
34 
35 // Local includes
36 
37 #include "digikam_export.h"
38 
40 namespace Marble
41 {
42  class GeoDataCoordinates;
43 }
44 
45 namespace Digikam
46 {
47 
48 class DIGIKAM_EXPORT GeoCoordinates
49 {
50 public:
51 
52  enum HasFlag
53  {
54  HasNothing = 0,
55  HasLatitude = 1,
56  HasLongitude = 2,
57  HasCoordinates = 3,
58  HasAltitude = 4
59  };
60 
61  Q_DECLARE_FLAGS(HasFlags, HasFlag)
62 
66 
67 public:
68 
70  GeoCoordinates(const double inLat, const double inLon);
71  GeoCoordinates(const double inLat, const double inLon, const double inAlt);
72  ~GeoCoordinates();
73 
74  bool operator==(const GeoCoordinates& other) const;
75 
76  double lat() const;
77  double lon() const ;
78  double alt() const;
79 
80  bool hasCoordinates() const;
81  bool hasLatitude() const;
82  bool hasLongitude() const;
83 
84  void setLatLon(const double inLat, const double inLon);
85 
86  bool hasAltitude() const;
87  HasFlags hasFlags() const;
88 
89  void setAlt(const double inAlt);
90 
91  void clearAlt();
92  void clear();
93 
94  QString altString() const;
95  QString latString() const;
96  QString lonString() const;
97  QString geoUrl() const;
98 
99  bool sameLonLatAs(const GeoCoordinates& other) const;
100  Marble::GeoDataCoordinates toMarbleCoordinates() const;
101 
102  static GeoCoordinates fromGeoUrl(const QString& url, bool* const parsedOkay = nullptr);
103  static GeoCoordinates fromMarbleCoordinates(const Marble::GeoDataCoordinates& marbleCoordinates);
104  static Pair makePair(const qreal lat1, const qreal lon1, const qreal lat2, const qreal lon2);
105 
106 private:
107 
108  double m_lat;
109  double m_lon;
110  double m_alt;
111  HasFlags m_hasFlags;
112 };
113 
114 } // namespace Digikam
115 
116 // cppcheck-suppress unknownMacro
117 Q_DECLARE_OPERATORS_FOR_FLAGS(Digikam::GeoCoordinates::HasFlags)
118 
119 Q_DECLARE_TYPEINFO(Digikam::GeoCoordinates, Q_MOVABLE_TYPE);
120 Q_DECLARE_METATYPE(Digikam::GeoCoordinates)
121 Q_DECLARE_METATYPE(Digikam::GeoCoordinates::Pair)
122 Q_DECLARE_METATYPE(Digikam::GeoCoordinates::PairList)
123 
124 DIGIKAM_EXPORT QDebug operator<<(QDebug debug, const Digikam::GeoCoordinates& coordinate);
125 
126 #endif // DIGIKAM_GEO_COORDINATES_H
Definition: geocoordinates.h:49
QPair< GeoCoordinates, GeoCoordinates > Pair
Definition: geocoordinates.h:64
HasFlag
Definition: geocoordinates.h:53
Definition: piwigotalker.h:48
Q_DECLARE_TYPEINFO(Digikam::GeoCoordinates, Q_MOVABLE_TYPE)
Definition: datefolderview.cpp:43