![]() |
Qt 6.x
The Qt SDK
|
\inmodule QtPositioning More...
#include <qgeopositioninfo.h>
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. | |
QGeoPositionInfo & | operator= (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 ×tamp) |
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) |
QDataStream & | operator<< (QDataStream &stream, const QGeoPositionInfo &info) |
Writes the given info to the specified stream. | |
QDataStream & | operator>> (QDataStream &stream, QGeoPositionInfo &info) |
Reads a coordinate from the specified stream into the given info. | |
QDataStream & | operator<< (QDataStream &stream, QGeoPositionInfo::Attribute attr) |
Writes the given attr enumeration to the specified stream. | |
QDataStream & | operator>> (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) |
\inmodule QtPositioning
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.
Definition at line 28 of file qgeopositioninfo.h.
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.
QGeoPositionInfo::QGeoPositionInfo | ( | ) |
Creates an invalid QGeoPositionInfo object.
Definition at line 61 of file qgeopositioninfo.cpp.
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.
QGeoPositionInfo::QGeoPositionInfo | ( | const QGeoPositionInfo & | other | ) |
Creates a QGeoPositionInfo with the values of other.
Definition at line 79 of file qgeopositioninfo.cpp.
|
defaultnoexcept |
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::QGeoPositionInfo | ( | QGeoPositionInfoPrivate & | dd | ) |
Definition at line 95 of file qgeopositioninfo.cpp.
QGeoPositionInfo::~QGeoPositionInfo | ( | ) |
Destroys a QGeoPositionInfo object.
Definition at line 102 of file qgeopositioninfo.cpp.
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.
Definition at line 224 of file qgeopositioninfo.cpp.
References QHash< Key, T >::contains(), QGeoPositionInfoPrivate::doubleAttribs, and qQNaN().
Referenced by QNmeaPositionInfoSourcePrivate::notifyNewUpdate(), and QDeclarativePosition::setPosition().
QGeoCoordinate QGeoPositionInfo::coordinate | ( | ) | const |
Returns the coordinate for this position.
Returns an invalid coordinate if no coordinate has been set.
Definition at line 198 of file qgeopositioninfo.cpp.
References QGeoPositionInfoPrivate::coord.
Referenced by QGeoPositionInfo(), setCoordinate(), and QDeclarativePosition::setPosition().
void QGeoPositionInfo::detach | ( | ) |
Definition at line 252 of file qgeopositioninfo.cpp.
References QExplicitlySharedDataPointer< T >::detach(), and QGeoPositionInfoPrivate.
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().
bool QGeoPositionInfo::isValid | ( | ) | const |
Returns true if the timestamp() and coordinate() values are both valid.
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().
QGeoPositionInfo & QGeoPositionInfo::operator= | ( | const QGeoPositionInfo & | other | ) |
Assigns the values from other to this QGeoPositionInfo.
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.
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().
Sets the value for attribute to value.
Definition at line 208 of file qgeopositioninfo.cpp.
References QExplicitlySharedDataPointer< T >::detach(), and QGeoPositionInfoPrivate::doubleAttribs.
Referenced by QNmeaPositionInfoSourcePrivate::notifyNewUpdate(), and QGeoPositionInfoSourceWinRT::onPositionChanged().
void QGeoPositionInfo::setCoordinate | ( | const QGeoCoordinate & | coordinate | ) |
Sets the coordinate for this position to coordinate.
Definition at line 185 of file qgeopositioninfo.cpp.
References QGeoPositionInfoPrivate::coord, coordinate(), and QExplicitlySharedDataPointer< T >::detach().
Referenced by QGeoPositionInfoSourceWinRT::onPositionChanged().
Sets the date and time at which this position was reported to timestamp.
The timestamp must be in UTC time.
Definition at line 162 of file qgeopositioninfo.cpp.
References QExplicitlySharedDataPointer< T >::detach(), timestamp(), and QGeoPositionInfoPrivate::timestamp.
Referenced by QNmeaPositionInfoSourcePrivate::notifyNewUpdate(), and QGeoPositionInfoSourceWinRT::onPositionChanged().
|
inlinenoexcept |
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.
Definition at line 175 of file qgeopositioninfo.cpp.
References QGeoPositionInfoPrivate::timestamp.
Referenced by QGeoPositionInfo(), QNmeaRealTimeReader::notifyNewUpdate(), QNmeaPositionInfoSourcePrivate::notifyNewUpdate(), QNmeaRealTimeReader::readAvailableData(), QDeclarativePosition::setPosition(), and setTimestamp().
|
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.
|
friend |
Writes the given info to the specified stream.
Definition at line 87 of file qgeopositioninfo.h.
|
friend |
Writes the given attr enumeration to the specified stream.
Definition at line 98 of file qgeopositioninfo.h.
|
friend |
Definition at line 80 of file qgeopositioninfo.h.
|
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.
|
friend |
Reads a coordinate from the specified stream into the given info.
Definition at line 91 of file qgeopositioninfo.h.
|
friend |
Reads an attribute enumeration from the specified stream info the given attr.
Definition at line 102 of file qgeopositioninfo.h.
|
friend |
Definition at line 110 of file qgeopositioninfo.h.
Referenced by detach().
|
friend |
Definition at line 399 of file qgeopositioninfo.cpp.
|
friend |