Marble::GeoDataCoordinates

Search for usage in LXR

#include <GeoDataCoordinates.h>

Public Types

enum  BearingType { InitialBearing , FinalBearing }
 
enum  Notation {
  Decimal , DMS , DM , UTM ,
  Astro
}
 
using PtrVector = QVector<GeoDataCoordinates *>
 
enum  Unit { Radian , Degree }
 
using Vector = QVector<GeoDataCoordinates>
 

Public Member Functions

 GeoDataCoordinates ()
 
 GeoDataCoordinates (const GeoDataCoordinates &other)
 
 GeoDataCoordinates (qreal lon, qreal lat, qreal alt=0, GeoDataCoordinates::Unit unit=GeoDataCoordinates::Radian, int detail=0)
 
qreal altitude () const
 
qreal bearing (const GeoDataCoordinates &other, Unit unit=Radian, BearingType type=InitialBearing) const
 
quint8 detail () const
 
void geoCoordinates (qreal &lon, qreal &lat) const
 
void geoCoordinates (qreal &lon, qreal &lat, GeoDataCoordinates::Unit unit) const
 
void geoCoordinates (qreal &lon, qreal &lat, qreal &alt) const
 
void geoCoordinates (qreal &lon, qreal &lat, qreal &alt, GeoDataCoordinates::Unit unit) const
 
GeoDataCoordinates interpolate (const GeoDataCoordinates &before, const GeoDataCoordinates &target, const GeoDataCoordinates &after, double t) const
 
GeoDataCoordinates interpolate (const GeoDataCoordinates &target, double t) const
 
bool isPole (Pole=AnyPole) const
 
bool isValid () const
 
qreal latitude () const
 
qreal latitude (GeoDataCoordinates::Unit unit) const
 
QString latToString () const
 
qreal longitude () const
 
qreal longitude (GeoDataCoordinates::Unit unit) const
 
QString lonToString () const
 
GeoDataCoordinates moveByBearing (qreal bearing, qreal distance) const
 
GeoDataCoordinates nlerp (const GeoDataCoordinates &target, double t) const
 
bool operator!= (const GeoDataCoordinates &other) const
 
GeoDataCoordinatesoperator= (const GeoDataCoordinates &other)
 
bool operator== (const GeoDataCoordinates &other) const
 
void pack (QDataStream &stream) const
 
const Quaternion & quaternion () const
 
GeoDataCoordinates rotateAround (const GeoDataCoordinates &axis, qreal angle, Unit unit=Radian) const
 
GeoDataCoordinates rotateAround (const Quaternion &rotAxis) const
 
void set (qreal lon, qreal lat, qreal alt=0, GeoDataCoordinates::Unit unit=GeoDataCoordinates::Radian)
 
void setAltitude (const qreal altitude)
 
void setDetail (quint8 detail)
 
void setLatitude (qreal lat, GeoDataCoordinates::Unit unit=GeoDataCoordinates::Radian)
 
void setLongitude (qreal lon, GeoDataCoordinates::Unit unit=GeoDataCoordinates::Radian)
 
qreal sphericalDistanceTo (const GeoDataCoordinates &other) const
 
QString toString () const
 
QString toString (GeoDataCoordinates::Notation notation, int precision=-1) const
 
void unpack (QDataStream &stream)
 
qreal utmEasting () const
 
QString utmLatitudeBand () const
 
qreal utmNorthing () const
 
int utmZone () const
 

Static Public Member Functions

static GeoDataCoordinates::Notation defaultNotation ()
 
static GeoDataCoordinates fromString (const QString &string, bool &successful)
 
static QString latToString (qreal lat, GeoDataCoordinates::Notation notation, GeoDataCoordinates::Unit unit=Radian, int precision=-1, char format='f')
 
static QString lonToString (qreal lon, GeoDataCoordinates::Notation notation, GeoDataCoordinates::Unit unit=Radian, int precision=-1, char format='f')
 
static qreal normalizeLat (qreal lat, GeoDataCoordinates::Unit=GeoDataCoordinates::Radian)
 
static qreal normalizeLon (qreal lon, GeoDataCoordinates::Unit=GeoDataCoordinates::Radian)
 
static void normalizeLonLat (qreal &lon, qreal &lat, GeoDataCoordinates::Unit=GeoDataCoordinates::Radian)
 
static void setDefaultNotation (GeoDataCoordinates::Notation notation)
 

Detailed Description

A 3d point representation.

GeoDataCoordinates is the simple representation of a single three dimensional point. It can be used all through out marble as the data type for three dimensional objects. it comprises of a Quaternion for speed issues. This class was introduced to reflect the difference between a simple 3d point and the GeoDataGeometry object containing such a point. The latter is a GeoDataPoint and is simply derived from GeoDataGeometry.

See also
GeoDataPoint

Definition at line 40 of file GeoDataCoordinates.h.

Member Typedef Documentation

◆ PtrVector

◆ Vector

Member Enumeration Documentation

◆ BearingType

The BearingType enum specifies where to measure the bearing along great circle arcs.

When traveling along a great circle arc defined by the two points A and B, the bearing varies along the arc. The "InitialBearing" bearing corresponds to the bearing value at A, the "FinalBearing" bearing to that at B.

Definition at line 84 of file GeoDataCoordinates.h.

◆ Notation

enum used to specify the notation / numerical system

For degrees there exist two notations: "Decimal" (base-10) and the "Sexagesimal DMS" (base-60) which is traditionally used in cartography. Decimal notation uses floating point numbers to specify parts of a degree. The Sexagesimal DMS notation uses integer based Degrees-(Arc)Minutes-(Arc)Seconds to describe parts of a degree.

Enumerator
Decimal 

"Decimal" notation (base-10)

DMS 

"Sexagesimal DMS" notation (base-60)

DM 

"Sexagesimal DM" notation (base-60)

Astro 

< "RA and DEC" notation (used for astronomical sky coordinates)

Definition at line 67 of file GeoDataCoordinates.h.

◆ Unit

enum used constructor to specify the units used

Internally we always use radian for mathematical convenience. However the Marble's interfaces to the outside should default to degrees.

Definition at line 52 of file GeoDataCoordinates.h.

Constructor & Destructor Documentation

◆ GeoDataCoordinates() [1/3]

Marble::GeoDataCoordinates::GeoDataCoordinates ( const GeoDataCoordinates & other)

Definition at line 45 of file GeoDataCoordinates.cpp.

◆ GeoDataCoordinates() [2/3]

Marble::GeoDataCoordinates::GeoDataCoordinates ( )

constructs an invalid instance

Constructs an invalid instance such that calling isValid() on it will return

false

.

Definition at line 54 of file GeoDataCoordinates.cpp.

◆ GeoDataCoordinates() [3/3]

Marble::GeoDataCoordinates::GeoDataCoordinates ( qreal lon,
qreal lat,
qreal alt = 0,
GeoDataCoordinates::Unit unit = GeoDataCoordinates::Radian,
int detail = 0 )

create a geocoordinate from longitude and latitude

Parameters
lonlongitude
latlatitude
altaltitude in meters (default: 0)
unitunits that lon and lat get measured in (default for Radian: north pole at pi/2, southpole at -pi/2)
detaildetail (default: 0)

Definition at line 36 of file GeoDataCoordinates.cpp.

◆ ~GeoDataCoordinates()

Marble::GeoDataCoordinates::~GeoDataCoordinates ( )
virtual

Definition at line 64 of file GeoDataCoordinates.cpp.

Member Function Documentation

◆ altitude()

qreal Marble::GeoDataCoordinates::altitude ( ) const

return the altitude of the Point in meters

Definition at line 718 of file GeoDataCoordinates.cpp.

◆ bearing()

qreal Marble::GeoDataCoordinates::bearing ( const GeoDataCoordinates & other,
Unit unit = Radian,
BearingType type = InitialBearing ) const

Returns the bearing (true bearing, the angle between the line defined by this point and the other and the prime meridian)

Parameters
otherThe second point that, together with this point, defines a line
unitUnit of the result
typeType of the bearing
Returns
The true bearing in the requested unit, not range normalized, in clockwise direction, with the value 0 corresponding to north

Definition at line 768 of file GeoDataCoordinates.cpp.

◆ defaultNotation()

GeoDataCoordinates::Notation Marble::GeoDataCoordinates::defaultNotation ( )
static

return Notation of string representation

Definition at line 233 of file GeoDataCoordinates.cpp.

◆ detail()

quint8 Marble::GeoDataCoordinates::detail ( ) const

return the detail flag detail range: 0 for most important points, 5 for least important

Definition at line 739 of file GeoDataCoordinates.cpp.

◆ fromString()

GeoDataCoordinates Marble::GeoDataCoordinates::fromString ( const QString & string,
bool & successful )
static

try to parse the string into a coordinate pair

Parameters
stringthe string
successfulbecomes true if the conversion succeeds
Returns
the geodatacoordinates

Definition at line 378 of file GeoDataCoordinates.cpp.

◆ geoCoordinates() [1/4]

void Marble::GeoDataCoordinates::geoCoordinates ( qreal & lon,
qreal & lat ) const

Definition at line 178 of file GeoDataCoordinates.cpp.

◆ geoCoordinates() [2/4]

void Marble::GeoDataCoordinates::geoCoordinates ( qreal & lon,
qreal & lat,
GeoDataCoordinates::Unit unit ) const

use this function to get the longitude and latitude with one call - use the unit parameter to switch between Radian and DMS

Parameters
lonlongitude
latlatitude
unitunits that lon and lat get measured in (default for Radian: north pole at pi/2, southpole at -pi/2)

Definition at line 161 of file GeoDataCoordinates.cpp.

◆ geoCoordinates() [3/4]

void Marble::GeoDataCoordinates::geoCoordinates ( qreal & lon,
qreal & lat,
qreal & alt ) const

Definition at line 191 of file GeoDataCoordinates.cpp.

◆ geoCoordinates() [4/4]

void Marble::GeoDataCoordinates::geoCoordinates ( qreal & lon,
qreal & lat,
qreal & alt,
GeoDataCoordinates::Unit unit ) const

use this function to get the longitude, latitude and altitude with one call - use the unit parameter to switch between Radian and DMS

Parameters
lonlongitude
latlatitude
altaltitude in meters
unitunits that lon and lat get measured in (default for Radian: north pole at pi/2, southpole at -pi/2)

Definition at line 184 of file GeoDataCoordinates.cpp.

◆ interpolate() [1/2]

GeoDataCoordinates Marble::GeoDataCoordinates::interpolate ( const GeoDataCoordinates & before,
const GeoDataCoordinates & target,
const GeoDataCoordinates & after,
double t ) const

squad (spherical and quadrangle) interpolation between b and c

Parameters
beforeFirst base point
targetThird base point (second interpolation point)
afterFourth base point
tOffset between b (t<=0) and c (t>=1)

Definition at line 822 of file GeoDataCoordinates.cpp.

◆ interpolate() [2/2]

GeoDataCoordinates Marble::GeoDataCoordinates::interpolate ( const GeoDataCoordinates & target,
double t ) const

slerp (spherical linear) interpolation between this coordinate and the given target coordinate

Parameters
targetDestination coordinate
tFraction 0..1 to weight between this and target
Returns
Interpolated coordinate between this (t<=0.0) and target (t>=1.0)

Definition at line 799 of file GeoDataCoordinates.cpp.

◆ isPole()

bool Marble::GeoDataCoordinates::isPole ( Pole pole = AnyPole) const

return whether our coordinates represent a pole This method can be used to check whether the coordinate equals one of the poles.

Definition at line 837 of file GeoDataCoordinates.cpp.

◆ isValid()

bool Marble::GeoDataCoordinates::isValid ( ) const

Returns.

true

if the coordinate is valid,

false

otherwise.

Returns
whether the coordinate is valid

A coordinate is valid, if at least one component has been set and the last assignment was not an invalid GeoDataCoordinates object.

Definition at line 76 of file GeoDataCoordinates.cpp.

◆ latitude() [1/2]

qreal Marble::GeoDataCoordinates::latitude ( ) const

Definition at line 227 of file GeoDataCoordinates.cpp.

◆ latitude() [2/2]

qreal Marble::GeoDataCoordinates::latitude ( GeoDataCoordinates::Unit unit) const

retrieves the latitude of the GeoDataCoordinates object use the unit parameter to switch between Radian and DMS

Parameters
unitunits that lon and lat get measured in (default for Radian: north pole at pi/2, southpole at -pi/2)
Returns
latitude

Definition at line 215 of file GeoDataCoordinates.cpp.

◆ latToString() [1/2]

QString Marble::GeoDataCoordinates::latToString ( ) const

return a string representation of latitude of the coordinate convenience function that uses the default notation

Definition at line 697 of file GeoDataCoordinates.cpp.

◆ latToString() [2/2]

QString Marble::GeoDataCoordinates::latToString ( qreal lat,
GeoDataCoordinates::Notation notation,
GeoDataCoordinates::Unit unit = Radian,
int precision = -1,
char format = 'f' )
static
Fixme
: UTM needs lon + lat to know latitude band and northing By now, this code returns the band+northing of the point (meridian, lat), but this can differ a lot at different locations See bug 347536 https://bugs.kde.org/show_bug.cgi?id=347536

Definition at line 586 of file GeoDataCoordinates.cpp.

◆ longitude() [1/2]

qreal Marble::GeoDataCoordinates::longitude ( ) const

Definition at line 210 of file GeoDataCoordinates.cpp.

◆ longitude() [2/2]

qreal Marble::GeoDataCoordinates::longitude ( GeoDataCoordinates::Unit unit) const

retrieves the longitude of the GeoDataCoordinates object use the unit parameter to switch between Radian and DMS

Parameters
unitunits that lon and lat get measured in (default for Radian: north pole at pi/2, southpole at -pi/2)
Returns
longitude

Definition at line 198 of file GeoDataCoordinates.cpp.

◆ lonToString() [1/2]

QString Marble::GeoDataCoordinates::lonToString ( ) const

return a string representation of longitude of the coordinate convenience function that uses the default notation

Definition at line 581 of file GeoDataCoordinates.cpp.

◆ lonToString() [2/2]

QString Marble::GeoDataCoordinates::lonToString ( qreal lon,
GeoDataCoordinates::Notation notation,
GeoDataCoordinates::Unit unit = Radian,
int precision = -1,
char format = 'f' )
static
Fixme
: UTM needs lon + lat to know zone number and easting By now, this code returns the zone+easting of the point (lon, equator), but this can differ a lot at different locations See bug 347536 https://bugs.kde.org/show_bug.cgi?id=347536

Definition at line 421 of file GeoDataCoordinates.cpp.

◆ moveByBearing()

GeoDataCoordinates Marble::GeoDataCoordinates::moveByBearing ( qreal bearing,
qreal distance ) const

Returns the coordinates of the resulting point after moving this point according to the distance and bearing parameters.

Parameters
bearingthe same as above
distancethe distance on a unit sphere

Definition at line 781 of file GeoDataCoordinates.cpp.

◆ nlerp()

GeoDataCoordinates Marble::GeoDataCoordinates::nlerp ( const GeoDataCoordinates & target,
double t ) const

nlerp (normalized linear interpolation) between this coordinates and the given target coordinates

Parameters
targetDestination coordinates
tFraction 0..1 to weight between this and target
Returns
Interpolated coordinate between this (t<=0.0) and target (t>=1.0)

Definition at line 809 of file GeoDataCoordinates.cpp.

◆ normalizeLat()

qreal Marble::GeoDataCoordinates::normalizeLat ( qreal lat,
GeoDataCoordinates::Unit unit = GeoDataCoordinates::Radian )
static

normalize latitude to always be in -M_PI / 2.

<= lat <= +M_PI / 2 (Radian).

Parameters
latlatitude
unitunit of the result

Definition at line 268 of file GeoDataCoordinates.cpp.

◆ normalizeLon()

qreal Marble::GeoDataCoordinates::normalizeLon ( qreal lon,
GeoDataCoordinates::Unit unit = GeoDataCoordinates::Radian )
static

normalize the longitude to always be -M_PI <= lon <= +M_PI (Radian).

Parameters
lonlongitude
unitunit of the result

Definition at line 245 of file GeoDataCoordinates.cpp.

◆ normalizeLonLat()

void Marble::GeoDataCoordinates::normalizeLonLat ( qreal & lon,
qreal & lat,
GeoDataCoordinates::Unit unit = GeoDataCoordinates::Radian )
static

normalize both longitude and latitude at the same time This method normalizes both latitude and longitude, so that the latitude and the longitude stay within the "usual" range.

NOTE: If the latitude exceeds M_PI/2 (+90.0 deg) or -M_PI/2 (-90.0 deg) then this will be interpreted as a pole traversion where the point will
end up on the opposite side of the globe. Therefore the longitude will change by M_PI (180 deg). If you don't want this behaviour use both normalizeLat() and normalizeLon() instead.

Parameters
lonthe longitude value
latthe latitude value
unitunit of the result

Definition at line 314 of file GeoDataCoordinates.cpp.

◆ operator!=()

bool Marble::GeoDataCoordinates::operator!= ( const GeoDataCoordinates & other) const

Definition at line 707 of file GeoDataCoordinates.cpp.

◆ operator=()

GeoDataCoordinates & Marble::GeoDataCoordinates::operator= ( const GeoDataCoordinates & other)

Definition at line 903 of file GeoDataCoordinates.cpp.

◆ operator==()

bool Marble::GeoDataCoordinates::operator== ( const GeoDataCoordinates & other) const

Definition at line 702 of file GeoDataCoordinates.cpp.

◆ pack()

void Marble::GeoDataCoordinates::pack ( QDataStream & stream) const

Serialize the contents of the feature to stream.

Definition at line 909 of file GeoDataCoordinates.cpp.

◆ quaternion()

const Quaternion & Marble::GeoDataCoordinates::quaternion ( ) const

return a Quaternion with the used coordinates

Definition at line 791 of file GeoDataCoordinates.cpp.

◆ rotateAround() [1/2]

GeoDataCoordinates Marble::GeoDataCoordinates::rotateAround ( const GeoDataCoordinates & axis,
qreal angle,
Unit unit = Radian ) const

Rotates one coordinate around another.

Parameters
axisThe coordinate that serves as a rotation axis
angleRotation angle
unitUnit of the result
Returns
The coordinate rotated in anticlockwise direction

Definition at line 750 of file GeoDataCoordinates.cpp.

◆ rotateAround() [2/2]

GeoDataCoordinates Marble::GeoDataCoordinates::rotateAround ( const Quaternion & rotAxis) const

Definition at line 759 of file GeoDataCoordinates.cpp.

◆ set()

void Marble::GeoDataCoordinates::set ( qreal lon,
qreal lat,
qreal alt = 0,
GeoDataCoordinates::Unit unit = GeoDataCoordinates::Radian )

(re)set the coordinates in a GeoDataCoordinates object

Parameters
lonlongitude
latlatitude
altaltitude in meters (default: 0)
unitunits that lon and lat get measured in (default for Radian: north pole at pi/2, southpole at -pi/2)

Definition at line 110 of file GeoDataCoordinates.cpp.

◆ setAltitude()

void Marble::GeoDataCoordinates::setAltitude ( const qreal altitude)

set the altitude of the Point in meters

Parameters
altitudealtitude

Definition at line 712 of file GeoDataCoordinates.cpp.

◆ setDefaultNotation()

void Marble::GeoDataCoordinates::setDefaultNotation ( GeoDataCoordinates::Notation notation)
static

set the Notation of the string representation

Parameters
notationNotation

Definition at line 239 of file GeoDataCoordinates.cpp.

◆ setDetail()

void Marble::GeoDataCoordinates::setDetail ( quint8 detail)

set the detail flag

Parameters
detaildetail

Definition at line 744 of file GeoDataCoordinates.cpp.

◆ setLatitude()

void Marble::GeoDataCoordinates::setLatitude ( qreal lat,
GeoDataCoordinates::Unit unit = GeoDataCoordinates::Radian )

set the longitude in a GeoDataCoordinates object

Parameters
latlongitude
unitunits that lon and lat get measured in (default for Radian: north pole at pi/2, southpole at -pi/2)

Definition at line 148 of file GeoDataCoordinates.cpp.

◆ setLongitude()

void Marble::GeoDataCoordinates::setLongitude ( qreal lon,
GeoDataCoordinates::Unit unit = GeoDataCoordinates::Radian )

set the longitude in a GeoDataCoordinates object

Parameters
lonlongitude
unitunits that lon and lat get measured in (default for Radian: north pole at pi/2, southpole at -pi/2)

Definition at line 130 of file GeoDataCoordinates.cpp.

◆ sphericalDistanceTo()

qreal Marble::GeoDataCoordinates::sphericalDistanceTo ( const GeoDataCoordinates & other) const

This method calculates the shortest distance between two points on a sphere.

See: https://en.wikipedia.org/wiki/Great-circle_distance

Definition at line 893 of file GeoDataCoordinates.cpp.

◆ toString() [1/2]

QString Marble::GeoDataCoordinates::toString ( ) const

return a string representation of the coordinate this is a convenience function which uses the default notation

Definition at line 390 of file GeoDataCoordinates.cpp.

◆ toString() [2/2]

QString Marble::GeoDataCoordinates::toString ( GeoDataCoordinates::Notation notation,
int precision = -1 ) const

return a string with the notation given by notation

Parameters
notationset a notation different from the default one
precisionset the number of digits below degrees. The precision depends on the current notation: For Decimal representation the precision is the number of digits after the decimal point. In DMS a precision of 1 or 2 shows the arc minutes; a precision of 3 or 4 will show arc seconds. A precision beyond that will increase the number of digits after the arc second decimal point.

Definition at line 395 of file GeoDataCoordinates.cpp.

◆ unpack()

void Marble::GeoDataCoordinates::unpack ( QDataStream & stream)

Unserialize the contents of the feature from stream.

Definition at line 916 of file GeoDataCoordinates.cpp.

◆ utmEasting()

qreal Marble::GeoDataCoordinates::utmEasting ( ) const

retrieves the UTM easting of the GeoDataCoordinates object, in meters.

Returns
UTM easting

Definition at line 727 of file GeoDataCoordinates.cpp.

◆ utmLatitudeBand()

QString Marble::GeoDataCoordinates::utmLatitudeBand ( ) const

retrieves the UTM latitude band of the GeoDataCoordinates object

Returns
UTM latitude band

Definition at line 731 of file GeoDataCoordinates.cpp.

◆ utmNorthing()

qreal Marble::GeoDataCoordinates::utmNorthing ( ) const

retrieves the UTM northing of the GeoDataCoordinates object, in meters

Returns
UTM northing

Definition at line 735 of file GeoDataCoordinates.cpp.

◆ utmZone()

int Marble::GeoDataCoordinates::utmZone ( ) const

retrieves the UTM zone of the GeoDataCoordinates object.

If the point is located on one of the poles (latitude < 80S or latitude > 84N) there is no UTM zone associated; in this case, 0 is returned.

Returns
UTM zone.

Definition at line 723 of file GeoDataCoordinates.cpp.


The documentation for this class was generated from the following files:
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Tue Mar 26 2024 11:18:18 by doxygen 1.10.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.