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 <qqmlregistration.h>
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 QML_ELEMENT
22
23 Q_PROPERTY(qreal longitude READ longitude WRITE setLongitude NOTIFY longitudeChanged)
24 Q_PROPERTY(qreal latitude READ latitude WRITE setLatitude NOTIFY latitudeChanged)
25 Q_PROPERTY(qreal altitude READ altitude WRITE setAltitude NOTIFY altitudeChanged)
26
27 Q_PROPERTY(Notation defaultNotation READ defaultNotation WRITE setDefaultNotation NOTIFY defaultNotationChanged)
28
29public:
30 enum Notation {
31 Decimal, ///< "Decimal" notation (base-10)
32 DMS, ///< "Sexagesimal DMS" notation (base-60)
33 DM, ///< "Sexagesimal DM" notation (base-60)
34 UTM,
35 Astro /// < "RA and DEC" notation (used for astronomical sky coordinates)
36 };
37 Q_ENUM(Notation)
38
39 /** Constructor */
40 explicit Coordinate(qreal lon = 0.0, qreal lat = 0.0, qreal altitude = 0.0, QObject *parent = nullptr);
42
43 /** Provides access to the longitude (degree) of the coordinate */
44 qreal longitude() const;
45
46 /** Change the longitude of the coordinate */
47 void setLongitude(qreal lon);
48
49 /** Provides access to the latitude (degree) of the coordinate */
50 qreal latitude() const;
51
52 /** Change the latitude of the coordinate */
53 void setLatitude(qreal lat);
54
55 /** Provides access to the altitude (meters) of the coordinate */
56 qreal altitude() const;
57
58 /** Change the altitude of the coordinate */
59 void setAltitude(qreal alt);
60
61 /** Change the altitude of the coordinate */
63
64 /** Change all coordinates at once */
66
67 Q_INVOKABLE QString toGeoString(Coordinate::Notation notation = Coordinate::DMS, int precision = -1) const;
68
69 /** Distance (in meter) to the given coordinate */
70 Q_INVOKABLE qreal distance(qreal longitude, qreal latitude) const;
71
72 /** Bearing (in degree) to the given coordinate */
73 Q_INVOKABLE qreal bearing(qreal longitude, qreal latitude) const;
74
75 bool operator==(const Coordinate &other) const;
76
77 bool operator!=(const Coordinate &other) const;
78
79 Notation defaultNotation();
80 void setDefaultNotation(Notation defaultNotation);
81
83 void longitudeChanged();
84 void latitudeChanged();
85 void altitudeChanged();
86
87 void defaultNotationChanged(Notation defaultNotation);
88
89private:
90 Marble::GeoDataCoordinates m_coordinate;
91 Notation m_defaultNotation;
92};
93
94#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:32
@ DM
"Sexagesimal DM" notation (base-60)
Definition Coordinate.h:33
@ Decimal
"Decimal" notation (base-10)
Definition Coordinate.h:31
@ Astro
< "RA and DEC" notation (used for astronomical sky coordinates)
Definition Coordinate.h:35
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
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Mon Nov 4 2024 16:37:03 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.