Qt
Internal/Contributor docs for the Qt SDK. <b>Note:</b> These are NOT official API docs; those are found <a href='https://doc.qt.io/'>here</a>.
Loading...
Searching...
No Matches
QGeoPositionInfo Class Reference

\inmodule QtPositioning More...

#include <qgeopositioninfo.h>

+ Collaboration diagram for QGeoPositionInfo:

Public Types

enum  Attribute {
  Direction , GroundSpeed , VerticalSpeed , MagneticVariation ,
  HorizontalAccuracy , VerticalAccuracy , DirectionAccuracy
}
 Defines the attributes for positional information. More...
 

Public Member Functions

 QGeoPositionInfo ()
 Creates an invalid QGeoPositionInfo object.
 
 QGeoPositionInfo (const QGeoCoordinate &coordinate, const QDateTime &updateTime)
 Creates a QGeoPositionInfo for the given coordinate and timestamp.
 
 QGeoPositionInfo (const QGeoPositionInfo &other)
 Creates a QGeoPositionInfo with the values of other.
 
 QGeoPositionInfo (QGeoPositionInfo &&other) noexcept=default
 
 QGeoPositionInfo (QGeoPositionInfoPrivate &dd)
 
 ~QGeoPositionInfo ()
 Destroys a QGeoPositionInfo object.
 
QGeoPositionInfooperator= (const QGeoPositionInfo &other)
 Assigns the values from other to this QGeoPositionInfo.
 
void swap (QGeoPositionInfo &other) noexcept
 
bool isValid () const
 Returns true if the timestamp() and coordinate() values are both valid.
 
void setTimestamp (const QDateTime &timestamp)
 Sets the date and time at which this position was reported to timestamp.
 
QDateTime timestamp () const
 Returns the date and time at which this position was reported, in UTC time.
 
void setCoordinate (const QGeoCoordinate &coordinate)
 Sets the coordinate for this position to coordinate.
 
QGeoCoordinate coordinate () const
 Returns the coordinate for this position.
 
void setAttribute (Attribute attribute, qreal value)
 Sets the value for attribute to value.
 
qreal attribute (Attribute attribute) const
 Returns the value of the specified attribute as a qreal value.
 
void removeAttribute (Attribute attribute)
 Removes the specified attribute and its value.
 
bool hasAttribute (Attribute attribute) const
 Returns true if the specified attribute is present for this QGeoPositionInfo object.
 
void detach ()
 

Friends

class QGeoPositionInfoPrivate
 
bool operator== (const QGeoPositionInfo &lhs, const QGeoPositionInfo &rhs)
 Returns true if all of the lhs object's values are the same as those of rhs.
 
bool operator!= (const QGeoPositionInfo &lhs, const QGeoPositionInfo &rhs)
 Returns true if any of the lhs object's values are not the same as those of rhs.
 
QDebug operator<< (QDebug dbg, const QGeoPositionInfo &info)
 
QDataStreamoperator<< (QDataStream &stream, const QGeoPositionInfo &info)
 Writes the given info to the specified stream.
 
QDataStreamoperator>> (QDataStream &stream, QGeoPositionInfo &info)
 Reads a coordinate from the specified stream into the given info.
 
QDataStreamoperator<< (QDataStream &stream, QGeoPositionInfo::Attribute attr)
 Writes the given attr enumeration to the specified stream.
 
QDataStreamoperator>> (QDataStream &stream, QGeoPositionInfo::Attribute &attr)
 Reads an attribute enumeration from the specified stream info the given attr.
 
Q_POSITIONING_EXPORT size_t qHash (const QGeoPositionInfo &key, size_t seed) noexcept
 
Q_POSITIONING_EXPORT char * QTest::toString (const QGeoPositionInfo &info)
 

Detailed Description

\inmodule QtPositioning

Since
5.2

The QGeoPositionInfo class contains information gathered on a global position, direction and velocity at a particular point in time.

A QGeoPositionInfo contains, at a minimum, a geographical coordinate and a timestamp. It may also have heading and speed measurements as well as estimates of the accuracy of the provided data.

See also
QGeoPositionInfoSource

Definition at line 28 of file qgeopositioninfo.h.

Member Enumeration Documentation

◆ Attribute

Defines the attributes for positional information.

\value Direction The bearing measured in degrees clockwise from true north to the direction of travel. \value GroundSpeed The ground speed, in meters/sec. \value VerticalSpeed The vertical speed, in meters/sec. \value MagneticVariation The angle between the horizontal component of the magnetic field and true north, in degrees. Also known as magnetic declination. A positive value indicates a clockwise direction from true north and a negative value indicates a counter-clockwise direction. \value HorizontalAccuracy The accuracy of the provided latitude-longitude value, in meters. \value VerticalAccuracy The accuracy of the provided altitude value, in meters. \value DirectionAccuracy The accuracy of the provided bearing, in degrees. This attribute is available only on Android (API level 26 or above) and macOS/iOS. See corresponding \l {Android getBearingAccuracyDegrees} {Android} and \l {iOS courseAccuracy}{Apple} documentation for more details.

NMEA protocol also suggests another type of accuracy - PositionAccuracy, which is a 3D accuracy value. Qt does not provide a separate attribute for it. If you need this value, you can calculate it based on the following formula:

{PositionAccuracy} \sup 2 {= HorizontalAccuracy} \sup 2 { + VerticalAccuracy} \sup 2

Enumerator
Direction 
GroundSpeed 
VerticalSpeed 
MagneticVariation 
HorizontalAccuracy 
VerticalAccuracy 
DirectionAccuracy 

Definition at line 31 of file qgeopositioninfo.h.

Constructor & Destructor Documentation

◆ QGeoPositionInfo() [1/5]

QGeoPositionInfo::QGeoPositionInfo ( )

Creates an invalid QGeoPositionInfo object.

See also
isValid()

Definition at line 61 of file qgeopositioninfo.cpp.

◆ QGeoPositionInfo() [2/5]

QGeoPositionInfo::QGeoPositionInfo ( const QGeoCoordinate & coordinate,
const QDateTime & updateTime )

Creates a QGeoPositionInfo for the given coordinate and timestamp.

Definition at line 69 of file qgeopositioninfo.cpp.

References QGeoPositionInfoPrivate::coord, coordinate(), timestamp(), and QGeoPositionInfoPrivate::timestamp.

+ Here is the call graph for this function:

◆ QGeoPositionInfo() [3/5]

QGeoPositionInfo::QGeoPositionInfo ( const QGeoPositionInfo & other)

Creates a QGeoPositionInfo with the values of other.

Definition at line 79 of file qgeopositioninfo.cpp.

◆ QGeoPositionInfo() [4/5]

QGeoPositionInfo::QGeoPositionInfo ( QGeoPositionInfo && other)
defaultnoexcept
Since
6.2

Creates a QGeoPositionInfo object by moving from other.

Note that a moved-from QGeoPositionInfo can only be destroyed or assigned to. The effect of calling other functions than the destructor or one of the assignment operators is undefined.

◆ QGeoPositionInfo() [5/5]

QGeoPositionInfo::QGeoPositionInfo ( QGeoPositionInfoPrivate & dd)

Definition at line 95 of file qgeopositioninfo.cpp.

◆ ~QGeoPositionInfo()

QGeoPositionInfo::~QGeoPositionInfo ( )

Destroys a QGeoPositionInfo object.

Definition at line 102 of file qgeopositioninfo.cpp.

Member Function Documentation

◆ attribute()

qreal QGeoPositionInfo::attribute ( Attribute attribute) const

Returns the value of the specified attribute as a qreal value.

Returns NaN if the value has not been set.

The function hasAttribute() should be used to determine whether or not a value has been set for an attribute.

See also
hasAttribute(), setAttribute()

Definition at line 224 of file qgeopositioninfo.cpp.

References QHash< Key, T >::contains(), QGeoPositionInfoPrivate::doubleAttribs, and qQNaN().

Referenced by QNmeaPositionInfoSourcePrivate::notifyNewUpdate(), and QDeclarativePosition::setPosition().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ coordinate()

QGeoCoordinate QGeoPositionInfo::coordinate ( ) const

Returns the coordinate for this position.

Returns an invalid coordinate if no coordinate has been set.

See also
setCoordinate()

Definition at line 198 of file qgeopositioninfo.cpp.

References QGeoPositionInfoPrivate::coord.

Referenced by QGeoPositionInfo(), setCoordinate(), and QDeclarativePosition::setPosition().

+ Here is the caller graph for this function:

◆ detach()

void QGeoPositionInfo::detach ( )

Definition at line 252 of file qgeopositioninfo.cpp.

References QExplicitlySharedDataPointer< T >::detach(), and QGeoPositionInfoPrivate.

+ Here is the call graph for this function:

◆ hasAttribute()

bool QGeoPositionInfo::hasAttribute ( Attribute attribute) const

Returns true if the specified attribute is present for this QGeoPositionInfo object.

Definition at line 244 of file qgeopositioninfo.cpp.

References QHash< Key, T >::contains(), and QGeoPositionInfoPrivate::doubleAttribs.

Referenced by QNmeaPositionInfoSourcePrivate::notifyNewUpdate().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ isValid()

bool QGeoPositionInfo::isValid ( ) const

Returns true if the timestamp() and coordinate() values are both valid.

See also
QGeoCoordinate::isValid(), QDateTime::isValid()

Definition at line 150 of file qgeopositioninfo.cpp.

References QGeoPositionInfoPrivate::coord, QDateTime::isValid(), QGeoCoordinate::isValid, and QGeoPositionInfoPrivate::timestamp.

Referenced by QNmeaPositionInfoSourcePrivate::notifyNewUpdate(), and QGeoPositionInfoSourceGeoclue2::startUpdates().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ operator=()

QGeoPositionInfo & QGeoPositionInfo::operator= ( const QGeoPositionInfo & other)

Assigns the values from other to this QGeoPositionInfo.

Since
6.2

Move-assigns the values from other to this object.

Note that a moved-from QGeoPositionInfo can only be destroyed or assigned to. The effect of calling other functions than the destructor or one of the assignment operators is undefined.

Definition at line 111 of file qgeopositioninfo.cpp.

◆ removeAttribute()

void QGeoPositionInfo::removeAttribute ( Attribute attribute)

Removes the specified attribute and its value.

Definition at line 234 of file qgeopositioninfo.cpp.

References QExplicitlySharedDataPointer< T >::detach(), QGeoPositionInfoPrivate::doubleAttribs, and QHash< Key, T >::remove().

+ Here is the call graph for this function:

◆ setAttribute()

void QGeoPositionInfo::setAttribute ( Attribute attribute,
qreal value )

Sets the value for attribute to value.

See also
attribute()

Definition at line 208 of file qgeopositioninfo.cpp.

References QExplicitlySharedDataPointer< T >::detach(), and QGeoPositionInfoPrivate::doubleAttribs.

Referenced by QNmeaPositionInfoSourcePrivate::notifyNewUpdate().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ setCoordinate()

void QGeoPositionInfo::setCoordinate ( const QGeoCoordinate & coordinate)

Sets the coordinate for this position to coordinate.

See also
coordinate()

Definition at line 185 of file qgeopositioninfo.cpp.

References QGeoPositionInfoPrivate::coord, coordinate(), and QExplicitlySharedDataPointer< T >::detach().

+ Here is the call graph for this function:

◆ setTimestamp()

void QGeoPositionInfo::setTimestamp ( const QDateTime & timestamp)

Sets the date and time at which this position was reported to timestamp.

The timestamp must be in UTC time.

See also
timestamp()

Definition at line 162 of file qgeopositioninfo.cpp.

References QExplicitlySharedDataPointer< T >::detach(), timestamp(), and QGeoPositionInfoPrivate::timestamp.

Referenced by QNmeaPositionInfoSourcePrivate::notifyNewUpdate().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ swap()

void QGeoPositionInfo::swap ( QGeoPositionInfo & other)
inlinenoexcept

Definition at line 51 of file qgeopositioninfo.h.

References d, and other().

+ Here is the call graph for this function:

◆ timestamp()

QDateTime QGeoPositionInfo::timestamp ( ) const

Returns the date and time at which this position was reported, in UTC time.

Returns an invalid QDateTime if no date/time value has been set.

See also
setTimestamp()

Definition at line 175 of file qgeopositioninfo.cpp.

References QGeoPositionInfoPrivate::timestamp.

Referenced by QGeoPositionInfo(), QNmeaRealTimeReader::notifyNewUpdate(), QNmeaPositionInfoSourcePrivate::notifyNewUpdate(), QNmeaRealTimeReader::readAvailableData(), QDeclarativePosition::setPosition(), and setTimestamp().

+ Here is the caller graph for this function:

Friends And Related Symbol Documentation

◆ operator!=

bool QGeoPositionInfo::operator!= ( const QGeoPositionInfo & lhs,
const QGeoPositionInfo & rhs )
friend

Returns true if any of the lhs object's values are not the same as those of rhs.

Otherwise returns false.

Definition at line 57 of file qgeopositioninfo.h.

◆ operator<< [1/3]

QDataStream & QGeoPositionInfo::operator<< ( QDataStream & stream,
const QGeoPositionInfo & info )
friend

Writes the given info to the specified stream.

See also
{Serializing Qt Data Types}

Definition at line 87 of file qgeopositioninfo.h.

◆ operator<< [2/3]

QDataStream & QGeoPositionInfo::operator<< ( QDataStream & stream,
QGeoPositionInfo::Attribute attr )
friend

Writes the given attr enumeration to the specified stream.

See also
{Serializing Qt Data Types}

Definition at line 98 of file qgeopositioninfo.h.

◆ operator<< [3/3]

QDebug operator<< ( QDebug dbg,
const QGeoPositionInfo & info )
friend

Definition at line 80 of file qgeopositioninfo.h.

◆ operator==

bool QGeoPositionInfo::operator== ( const QGeoPositionInfo & lhs,
const QGeoPositionInfo & rhs )
friend

Returns true if all of the lhs object's values are the same as those of rhs.

Otherwise returns false.

Definition at line 53 of file qgeopositioninfo.h.

◆ operator>> [1/2]

QDataStream & QGeoPositionInfo::operator>> ( QDataStream & stream,
QGeoPositionInfo & info )
friend

Reads a coordinate from the specified stream into the given info.

See also
{Serializing Qt Data Types}

Definition at line 91 of file qgeopositioninfo.h.

◆ operator>> [2/2]

QDataStream & QGeoPositionInfo::operator>> ( QDataStream & stream,
QGeoPositionInfo::Attribute & attr )
friend

Reads an attribute enumeration from the specified stream info the given attr.

See also
{Serializing Qt Data Types}

Definition at line 102 of file qgeopositioninfo.h.

◆ QGeoPositionInfoPrivate

friend class QGeoPositionInfoPrivate
friend

Definition at line 110 of file qgeopositioninfo.h.

Referenced by detach().

◆ qHash

Q_POSITIONING_EXPORT size_t qHash ( const QGeoPositionInfo & key,
size_t seed )
friend

Definition at line 399 of file qgeopositioninfo.cpp.

◆ QTest::toString

Q_POSITIONING_EXPORT char * QTest::toString ( const QGeoPositionInfo & info)
friend

The documentation for this class was generated from the following files: