Marble

GeoDataCoordinates.h
1 //
2 // This file is part of the Marble Virtual Globe.
3 //
4 // This program is free software licensed under the GNU LGPL. You can
5 // find a copy of this license in LICENSE.txt in the top directory of
6 // the source code.
7 //
8 // Copyright 2006-2007 Torsten Rahn <[email protected]>
9 // Copyright 2007-2008 Inge Wallin <[email protected]>
10 // Copyright 2008 Patrick Spendrin <[email protected]>
11 // Copyright 2015 Alejandro Garcia Montoro <[email protected]>
12 //
13 
14 
15 #ifndef MARBLE_GEODATACOORDINATES_H
16 #define MARBLE_GEODATACOORDINATES_H
17 
18 #include <QCoreApplication>
19 #include <QMetaType>
20 #include <QVector>
21 
22 #include "geodata_export.h"
23 #include "MarbleGlobal.h"
24 
25 class QString;
26 
27 namespace Marble
28 {
29 
30 class GeoDataCoordinatesPrivate;
31 class Quaternion;
32 
45 class GEODATA_EXPORT GeoDataCoordinates
46 {
47  Q_DECLARE_TR_FUNCTIONS(GeoDataCoordinates)
48 
49  public:
57  enum Unit{
58  Radian,
59  Degree
60  };
61 
72  enum Notation{
74  DMS,
75  DM,
76  UTM,
77  Astro
78  };
79 
89  enum BearingType {
90  InitialBearing,
91  FinalBearing
92  };
93 
94  // Type definitions
97 
98  GeoDataCoordinates( const GeoDataCoordinates& other );
99 
107 
117  GeoDataCoordinates( qreal lon, qreal lat, qreal alt = 0,
118  GeoDataCoordinates::Unit unit = GeoDataCoordinates::Radian,
119  int detail = 0 );
120 
121  virtual ~GeoDataCoordinates();
122 
130  bool isValid() const;
131 
140  void set( qreal lon, qreal lat, qreal alt = 0,
141  GeoDataCoordinates::Unit unit = GeoDataCoordinates::Radian );
142 
151  void geoCoordinates(qreal& lon, qreal& lat, GeoDataCoordinates::Unit unit) const;
152  void geoCoordinates(qreal& lon, qreal& lat) const;
153 
163  void geoCoordinates(qreal& lon, qreal& lat, qreal& alt, GeoDataCoordinates::Unit unit) const;
164  void geoCoordinates(qreal& lon, qreal& lat, qreal& alt) const;
165 
172  void setLongitude( qreal lon,
173  GeoDataCoordinates::Unit unit = GeoDataCoordinates::Radian );
174 
182  qreal longitude(GeoDataCoordinates::Unit unit) const;
183  qreal longitude() const;
184 
192  qreal latitude( GeoDataCoordinates::Unit unit ) const;
193  qreal latitude() const;
194 
201  void setLatitude( qreal lat,
202  GeoDataCoordinates::Unit unit = GeoDataCoordinates::Radian );
203 
207  qreal altitude() const;
212  void setAltitude( const qreal altitude );
213 
221  int utmZone() const;
222 
228  qreal utmEasting() const;
229 
234  QString utmLatitudeBand() const;
235 
241  qreal utmNorthing() const;
242 
247  quint8 detail() const;
248 
253  void setDetail(quint8 detail);
254 
262  GeoDataCoordinates rotateAround( const GeoDataCoordinates &axis, qreal angle, Unit unit = Radian ) const;
263 
264  GeoDataCoordinates rotateAround(const Quaternion &rotAxis) const;
265 
275  qreal bearing( const GeoDataCoordinates &other, Unit unit = Radian, BearingType type = InitialBearing ) const;
276 
283  GeoDataCoordinates moveByBearing( qreal bearing, qreal distance ) const;
284 
288  const Quaternion &quaternion() const;
289 
296  GeoDataCoordinates interpolate( const GeoDataCoordinates &target, double t ) const;
297 
304  GeoDataCoordinates nlerp(const GeoDataCoordinates &target, double t) const;
305 
313  GeoDataCoordinates interpolate( const GeoDataCoordinates &before, const GeoDataCoordinates &target, const GeoDataCoordinates &after, double t ) const;
314 
320  bool isPole( Pole = AnyPole ) const;
321 
326  qreal sphericalDistanceTo(const GeoDataCoordinates &other) const;
327 
331  static GeoDataCoordinates::Notation defaultNotation();
332 
337  static void setDefaultNotation( GeoDataCoordinates::Notation notation );
338 
344  static qreal normalizeLon( qreal lon,
345  GeoDataCoordinates::Unit = GeoDataCoordinates::Radian );
346 
352  static qreal normalizeLat( qreal lat,
353  GeoDataCoordinates::Unit = GeoDataCoordinates::Radian );
354 
369  static void normalizeLonLat( qreal &lon, qreal &lat,
370  GeoDataCoordinates::Unit = GeoDataCoordinates::Radian );
371 
378  static GeoDataCoordinates fromString( const QString &string, bool& successful );
379 
384  QString toString() const;
385 
398  QString toString( GeoDataCoordinates::Notation notation, int precision = -1 ) const;
399 
400  static QString lonToString( qreal lon, GeoDataCoordinates::Notation notation,
401  GeoDataCoordinates::Unit unit = Radian,
402  int precision = -1,
403  char format = 'f' );
408  QString lonToString() const;
409 
410  static QString latToString( qreal lat, GeoDataCoordinates::Notation notation,
411  GeoDataCoordinates::Unit unit = Radian,
412  int precision = -1,
413  char format = 'f' );
418  QString latToString() const;
419 
420  bool operator==(const GeoDataCoordinates &other) const;
421  bool operator!=(const GeoDataCoordinates &other) const;
422 
423  GeoDataCoordinates& operator=( const GeoDataCoordinates &other );
424 
426  void pack(QDataStream &stream) const;
428  void unpack(QDataStream &stream);
429 
430  private:
431  void detach();
432 
433  GeoDataCoordinatesPrivate *d;
434 
435  static GeoDataCoordinates::Notation s_notation;
436  static const GeoDataCoordinates null;
437 };
438 
439 GEODATA_EXPORT uint qHash(const GeoDataCoordinates& coordinates );
440 
441 
442 }
443 
444 Q_DECLARE_METATYPE( Marble::GeoDataCoordinates )
445 
446 #endif
Unit
enum used constructor to specify the units used
Any pole.
Definition: MarbleGlobal.h:144
A 3d point representation.
Binds a QML item to a specific geodetic location in screen coordinates.
"Decimal" notation (base-10)
BearingType
The BearingType enum specifies where to measure the bearing along great circle arcs.
KCALENDARCORE_EXPORT uint qHash(const KCalendarCore::Period &key)
Notation
enum used to specify the notation / numerical system
"Sexagesimal DMS" notation (base-60)
"Sexagesimal DM" notation (base-60)
This file is part of the KDE documentation.
Documentation copyright © 1996-2020 The KDE developers.
Generated on Thu Sep 24 2020 23:21:13 by doxygen 1.8.11 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.