Marble

Coordinate.h
1// SPDX-License-Identifier: LGPL-2.1-or-later
2//
3// SPDX-FileCopyrightText: 2011 Dennis Nienhüser <nienhueser@kde.org>
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 */
18class Coordinate : public QObject
19{
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
28public:
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 };
36 Q_ENUM(Notation)
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
82 void longitudeChanged();
83 void latitudeChanged();
84 void altitudeChanged();
85
86 void defaultNotationChanged(Notation defaultNotation);
87
88private:
89 Marble::GeoDataCoordinates m_coordinate;
90 Notation m_defaultNotation;
91};
92
93QML_DECLARE_TYPE( Coordinate )
94
95#endif // MARBLE_DECLARATIVE_COORDINATE_H
Represents a coordinate with the properties of a name and coordinates.
Definition Coordinate.h:19
void setLatitude(qreal lat)
Change the latitude of the coordinate.
Q_INVOKABLE qreal bearing(qreal longitude, qreal latitude) const
Bearing (in degree) to the given coordinate.
Coordinate(qreal lon=0.0, qreal lat=0.0, qreal altitude=0.0, QObject *parent=nullptr)
Constructor.
void setLongitude(qreal lon)
Change the longitude of the coordinate.
void setAltitude(qreal alt)
Change the altitude of the coordinate.
Marble::GeoDataCoordinates coordinates() const
Change the altitude of the coordinate.
@ DMS
"Sexagesimal DMS" notation (base-60)
Definition Coordinate.h:31
@ DM
"Sexagesimal DM" notation (base-60)
Definition Coordinate.h:32
@ Decimal
"Decimal" notation (base-10)
Definition Coordinate.h:30
@ Astro
< "RA and DEC" notation (used for astronomical sky coordinates)
Definition Coordinate.h:34
void setCoordinates(const Marble::GeoDataCoordinates &coordinates)
Change all coordinates at once.
Q_INVOKABLE qreal distance(qreal longitude, qreal latitude) const
Distance (in meter) to the given coordinate.
A 3d point representation.
Q_ENUM(...)
Q_INVOKABLEQ_INVOKABLE
Q_OBJECTQ_OBJECT
Q_PROPERTY(...)
Q_SIGNALSQ_SIGNALS
QObject * parent() const const
T qobject_cast(QObject *object)
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Tue Mar 26 2024 11:18:16 by doxygen 1.10.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.