• Skip to content
  • Skip to link menu
KDE API Reference
  • KDE API Reference
  • kdeedu API Reference
  • KDE Home
  • Contact Us
 

marble

  • sources
  • kde-4.14
  • kdeedu
  • marble
  • src
  • plugins
  • declarative
Coordinate.cpp
Go to the documentation of this file.
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 2011 Dennis Nienhüser <earthwings@gentoo.org>
9 //
10 
11 #include "Coordinate.h"
12 
13 #include "MarbleMath.h"
14 
15 using Marble::GeoDataCoordinates;
16 using Marble::EARTH_RADIUS;
17 using Marble::DEG2RAD;
18 
19 Coordinate::Coordinate( qreal lon, qreal lat, qreal alt, QObject *parent ) :
20  QObject( parent )
21 {
22  setLongitude( lon );
23  setLatitude( lat );
24  setAltitude( alt );
25 }
26 
27 qreal Coordinate::longitude() const
28 {
29  return m_coordinate.longitude( GeoDataCoordinates::Degree );
30 }
31 
32 void Coordinate::setLongitude( qreal lon )
33 {
34  m_coordinate.setLongitude( lon, GeoDataCoordinates::Degree );
35  emit longitudeChanged();
36 }
37 
38 qreal Coordinate::latitude() const
39 {
40  return m_coordinate.latitude( GeoDataCoordinates::Degree );
41 }
42 
43 void Coordinate::setLatitude( qreal lat )
44 {
45  m_coordinate.setLatitude( lat, GeoDataCoordinates::Degree );
46  emit latitudeChanged();
47 }
48 
49 qreal Coordinate::altitude() const
50 {
51  return m_coordinate.altitude();
52 }
53 
54 void Coordinate::setAltitude( qreal alt )
55 {
56  m_coordinate.setAltitude( alt );
57  emit altitudeChanged();
58 }
59 
60 GeoDataCoordinates Coordinate::coordinates() const
61 {
62  return m_coordinate;
63 }
64 
65 void Coordinate::setCoordinates( const GeoDataCoordinates &coordinates )
66 {
67  m_coordinate = coordinates;
68 }
69 
70 qreal Coordinate::distance( qreal longitude, qreal latitude ) const
71 {
72  GeoDataCoordinates::Unit deg = GeoDataCoordinates::Degree;
73  GeoDataCoordinates other( longitude, latitude, 0, deg );
74  return EARTH_RADIUS * distanceSphere( coordinates(), other );
75 }
76 
77 qreal Coordinate::bearing( qreal longitude, qreal latitude ) const
78 {
79  qreal deltaLon = longitude * DEG2RAD - m_coordinate.longitude();
80  qreal y = sin( deltaLon ) * cos( latitude * DEG2RAD );
81  qreal x = cos( m_coordinate.latitude() ) * sin( latitude * DEG2RAD ) -
82  sin( m_coordinate.latitude() ) * cos( latitude * DEG2RAD ) * cos( deltaLon );
83  return Marble::RAD2DEG * atan2( y, x );
84 }
85 
86 bool Coordinate::operator == ( const Coordinate &other ) const
87 {
88  return m_coordinate == other.m_coordinate;
89 }
90 
91 bool Coordinate::operator != ( const Coordinate &other ) const
92 {
93  return !operator == ( other );
94 }
95 
96 #include "Coordinate.moc"
Marble::RAD2DEG
const qreal RAD2DEG
Definition: MarbleGlobal.h:220
Marble::GeoDataCoordinates
A 3d point representation.
Definition: GeoDataCoordinates.h:52
Marble::GeoDataCoordinates::setAltitude
void setAltitude(const qreal altitude)
set the altitude of the Point in meters
Definition: GeoDataCoordinates.cpp:1191
MarbleMath.h
Coordinate::longitude
qreal longitude() const
Provides access to the longitude (degree) of the coordinate.
Coordinate::operator!=
bool operator!=(const Coordinate &other) const
Definition: Coordinate.cpp:91
Marble::distanceSphere
qreal distanceSphere(qreal lon1, qreal lat1, qreal lon2, qreal lat2)
This method calculates the shortest distance between two points on a sphere.
Definition: MarbleMath.h:52
Marble::GeoDataCoordinates::latitude
qreal latitude(GeoDataCoordinates::Unit unit=GeoDataCoordinates::Radian) const
retrieves the latitude of the GeoDataCoordinates object use the unit parameter to switch between Radi...
Definition: GeoDataCoordinates.cpp:751
Coordinate
Represents a coordinate with the properties of a name and coordinates.
Definition: Coordinate.h:28
Coordinate::altitude
qreal altitude() const
Provides access to the altitude (meters) of the coordinate.
Marble::GeoDataCoordinates::altitude
qreal altitude() const
return the altitude of the Point in meters
Definition: GeoDataCoordinates.cpp:1197
Marble::EARTH_RADIUS
const qreal EARTH_RADIUS
Definition: MarbleGlobal.h:257
Coordinate::distance
Q_INVOKABLE qreal distance(qreal longitude, qreal latitude) const
Distance (in meter) to the given coordinate.
Definition: Coordinate.cpp:70
QObject
Coordinate::longitudeChanged
void longitudeChanged()
Marble::DEG2RAD
const qreal DEG2RAD
Definition: MarbleGlobal.h:219
Coordinate::setCoordinates
void setCoordinates(const Marble::GeoDataCoordinates &coordinates)
Change all coordinates at once.
Definition: Coordinate.cpp:65
Coordinate::Coordinate
Coordinate(qreal lon=0.0, qreal lat=0.0, qreal altitude=0.0, QObject *parent=0)
Constructor.
Definition: Coordinate.cpp:19
Coordinate::altitudeChanged
void altitudeChanged()
Marble::GeoDataCoordinates::longitude
qreal longitude(GeoDataCoordinates::Unit unit=GeoDataCoordinates::Radian) const
retrieves the longitude of the GeoDataCoordinates object use the unit parameter to switch between Rad...
Definition: GeoDataCoordinates.cpp:739
Coordinate::coordinates
Marble::GeoDataCoordinates coordinates() const
Change the altitude of the coordinate.
Definition: Coordinate.cpp:60
Marble::GeoDataCoordinates::setLatitude
void setLatitude(qreal lat, GeoDataCoordinates::Unit unit=GeoDataCoordinates::Radian)
set the longitude in a GeoDataCoordinates object
Definition: GeoDataCoordinates.cpp:699
Marble::GeoDataCoordinates::setLongitude
void setLongitude(qreal lon, GeoDataCoordinates::Unit unit=GeoDataCoordinates::Radian)
set the longitude in a GeoDataCoordinates object
Definition: GeoDataCoordinates.cpp:679
Coordinate::operator==
bool operator==(const Coordinate &other) const
Definition: Coordinate.cpp:86
Coordinate::setLatitude
void setLatitude(qreal lat)
Change the latitude of the coordinate.
Definition: Coordinate.cpp:43
Coordinate.h
Coordinate::setAltitude
void setAltitude(qreal alt)
Change the altitude of the coordinate.
Definition: Coordinate.cpp:54
Coordinate::setLongitude
void setLongitude(qreal lon)
Change the longitude of the coordinate.
Definition: Coordinate.cpp:32
Coordinate::bearing
Q_INVOKABLE qreal bearing(qreal longitude, qreal latitude) const
Bearing (in degree) to the given coordinate.
Definition: Coordinate.cpp:77
Coordinate::latitude
qreal latitude() const
Provides access to the latitude (degree) of the coordinate.
Coordinate::latitudeChanged
void latitudeChanged()
This file is part of the KDE documentation.
Documentation copyright © 1996-2020 The KDE developers.
Generated on Mon Jun 22 2020 13:13:38 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

marble

Skip menu "marble"
  • Main Page
  • Namespace List
  • Namespace Members
  • Alphabetical List
  • Class List
  • Class Hierarchy
  • Class Members
  • File List
  • File Members
  • Related Pages

kdeedu API Reference

Skip menu "kdeedu API Reference"
  • Analitza
  •     lib
  • kalgebra
  • kalzium
  •   libscience
  • kanagram
  • kig
  •   lib
  • klettres
  • marble
  • parley
  • rocs
  •   App
  •   RocsCore
  •   VisualEditor
  •   stepcore

Search



Report problems with this website to our bug tracking system.
Contact the specific authors with questions and comments about the page contents.

KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal