Marble

Coordinate.h
1 // SPDX-License-Identifier: LGPL-2.1-or-later
2 //
3 // SPDX-FileCopyrightText: 2011 Dennis Nienhüser <[email protected]>
4 //
5 
6 #ifndef MARBLE_DECLARATIVE_COORDINATE_H
7 #define MARBLE_DECLARATIVE_COORDINATE_H
8 
9 #include "GeoDataCoordinates.h"
10 #include <QObject>
11 #include <QtQml>
12 
13 /**
14  * Represents a coordinate with the properties of a name and coordinates
15  *
16  * @todo: Introduce GeoDataCoordinates
17  */
18 class Coordinate : public QObject
19 {
20  Q_OBJECT
21 
22  Q_PROPERTY( qreal longitude READ longitude WRITE setLongitude NOTIFY longitudeChanged )
23  Q_PROPERTY( qreal latitude READ latitude WRITE setLatitude NOTIFY latitudeChanged )
24  Q_PROPERTY( qreal altitude READ altitude WRITE setAltitude NOTIFY altitudeChanged )
25 
26  Q_PROPERTY( Notation defaultNotation READ defaultNotation WRITE setDefaultNotation NOTIFY defaultNotationChanged )
27 
28 public:
29  enum Notation{
30  Decimal, ///< "Decimal" notation (base-10)
31  DMS, ///< "Sexagesimal DMS" notation (base-60)
32  DM, ///< "Sexagesimal DM" notation (base-60)
33  UTM,
34  Astro /// < "RA and DEC" notation (used for astronomical sky coordinates)
35  };
37 
38  /** Constructor */
39  explicit Coordinate( qreal lon = 0.0, qreal lat = 0.0, qreal altitude = 0.0, QObject *parent = nullptr );
41 
42  /** Provides access to the longitude (degree) of the coordinate */
43  qreal longitude() const;
44 
45  /** Change the longitude of the coordinate */
46  void setLongitude( qreal lon );
47 
48  /** Provides access to the latitude (degree) of the coordinate */
49  qreal latitude() const;
50 
51  /** Change the latitude of the coordinate */
52  void setLatitude( qreal lat );
53 
54  /** Provides access to the altitude (meters) of the coordinate */
55  qreal altitude() const;
56 
57  /** Change the altitude of the coordinate */
58  void setAltitude( qreal alt );
59 
60  /** Change the altitude of the coordinate */
62 
63  /** Change all coordinates at once */
65 
66  Q_INVOKABLE QString toGeoString( Coordinate::Notation notation = Coordinate::DMS, int precision = -1 ) const;
67 
68  /** Distance (in meter) to the given coordinate */
69  Q_INVOKABLE qreal distance( qreal longitude, qreal latitude ) const;
70 
71  /** Bearing (in degree) to the given coordinate */
72  Q_INVOKABLE qreal bearing( qreal longitude, qreal latitude ) const;
73 
74  bool operator == ( const Coordinate &other ) const;
75 
76  bool operator != ( const Coordinate &other ) const;
77 
78  Notation defaultNotation();
79  void setDefaultNotation(Notation defaultNotation);
80 
81 Q_SIGNALS:
82  void longitudeChanged();
83  void latitudeChanged();
84  void altitudeChanged();
85 
86  void defaultNotationChanged(Notation defaultNotation);
87 
88 private:
89  Marble::GeoDataCoordinates m_coordinate;
90  Notation m_defaultNotation;
91 };
92 
93 QML_DECLARE_TYPE( Coordinate )
94 
95 #endif // MARBLE_DECLARATIVE_COORDINATE_H
Q_OBJECTQ_OBJECT
A 3d point representation.
Q_INVOKABLE qreal bearing(qreal longitude, qreal latitude) const
Bearing (in degree) to the given coordinate.
Definition: Coordinate.cpp:83
Q_PROPERTY(...)
@ DMS
"Sexagesimal DMS" notation (base-60)
Definition: Coordinate.h:31
Q_ENUM(...)
void setAltitude(qreal alt)
Change the altitude of the coordinate.
Definition: Coordinate.cpp:55
@ DM
"Sexagesimal DM" notation (base-60)
Definition: Coordinate.h:32
Marble::GeoDataCoordinates coordinates() const
Change the altitude of the coordinate.
Definition: Coordinate.cpp:61
Coordinate(qreal lon=0.0, qreal lat=0.0, qreal altitude=0.0, QObject *parent=nullptr)
Constructor.
Definition: Coordinate.cpp:15
Q_INVOKABLE qreal distance(qreal longitude, qreal latitude) const
Distance (in meter) to the given coordinate.
Definition: Coordinate.cpp:76
Q_INVOKABLEQ_INVOKABLE
Q_SIGNALSQ_SIGNALS
@ Decimal
"Decimal" notation (base-10)
Definition: Coordinate.h:30
void setLongitude(qreal lon)
Change the longitude of the coordinate.
Definition: Coordinate.cpp:33
@ Astro
< "RA and DEC" notation (used for astronomical sky coordinates)
Definition: Coordinate.h:34
void setLatitude(qreal lat)
Change the latitude of the coordinate.
Definition: Coordinate.cpp:44
void setCoordinates(const Marble::GeoDataCoordinates &coordinates)
Change all coordinates at once.
Definition: Coordinate.cpp:66
Represents a coordinate with the properties of a name and coordinates.
Definition: Coordinate.h:18
QObject * parent() const const
This file is part of the KDE documentation.
Documentation copyright © 1996-2023 The KDE developers.
Generated on Fri Sep 29 2023 03:52:20 by doxygen 1.8.17 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.