QGeoPositionInfo Class
The QGeoPositionInfo class contains information gathered on a global position, direction and velocity at a particular point in time. More...
Header: | #include <QGeoPositionInfo> |
CMake: | find_package(Qt6 REQUIRED COMPONENTS Positioning) target_link_libraries(mytarget PRIVATE Qt6::Positioning) |
qmake: | QT += positioning |
- List of all members, including inherited members
- QGeoPositionInfo is part of Implicitly Shared Classes.
Public Types
enum | Attribute { Direction, GroundSpeed, VerticalSpeed, MagneticVariation, HorizontalAccuracy, …, DirectionAccuracy } |
Public Functions
QGeoPositionInfo() | |
QGeoPositionInfo(const QGeoCoordinate &coordinate, const QDateTime ×tamp) | |
QGeoPositionInfo(const QGeoPositionInfo &other) | |
(since 6.2) | QGeoPositionInfo(QGeoPositionInfo &&other) |
~QGeoPositionInfo() | |
qreal | attribute(QGeoPositionInfo::Attribute attribute) const |
QGeoCoordinate | coordinate() const |
bool | hasAttribute(QGeoPositionInfo::Attribute attribute) const |
bool | isValid() const |
void | removeAttribute(QGeoPositionInfo::Attribute attribute) |
void | setAttribute(QGeoPositionInfo::Attribute attribute, qreal value) |
void | setCoordinate(const QGeoCoordinate &coordinate) |
void | setTimestamp(const QDateTime ×tamp) |
QDateTime | timestamp() const |
(since 6.2) QGeoPositionInfo & | operator=(QGeoPositionInfo &&other) |
QGeoPositionInfo & | operator=(const QGeoPositionInfo &other) |
Related Non-Members
bool | operator!=(const QGeoPositionInfo &lhs, const QGeoPositionInfo &rhs) |
QDataStream & | operator<<(QDataStream &stream, QGeoPositionInfo::Attribute attr) |
QDataStream & | operator<<(QDataStream &stream, const QGeoPositionInfo &info) |
bool | operator==(const QGeoPositionInfo &lhs, const QGeoPositionInfo &rhs) |
QDataStream & | operator>>(QDataStream &stream, QGeoPositionInfo &info) |
QDataStream & | operator>>(QDataStream &stream, QGeoPositionInfo::Attribute &attr) |
Detailed Description
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.
Member Type Documentation
enum QGeoPositionInfo::Attribute
Defines the attributes for positional information.
Constant | Value | Description |
---|---|---|
QGeoPositionInfo::Direction | 0 | The bearing measured in degrees clockwise from true north to the direction of travel. |
QGeoPositionInfo::GroundSpeed | 1 | The ground speed, in meters/sec. |
QGeoPositionInfo::VerticalSpeed | 2 | The vertical speed, in meters/sec. |
QGeoPositionInfo::MagneticVariation | 3 | 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. |
QGeoPositionInfo::HorizontalAccuracy | 4 | The accuracy of the provided latitude-longitude value, in meters. |
QGeoPositionInfo::VerticalAccuracy | 5 | The accuracy of the provided altitude value, in meters. |
QGeoPositionInfo::DirectionAccuracy | 6 | 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 Android and 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
2 = HorizontalAccuracy
2 + VerticalAccuracy
2
Member Function Documentation
QGeoPositionInfo::QGeoPositionInfo()
Creates an invalid QGeoPositionInfo object.
See also isValid().
QGeoPositionInfo::QGeoPositionInfo(const QGeoCoordinate &coordinate, const QDateTime ×tamp)
Creates a QGeoPositionInfo for the given coordinate and timestamp.
QGeoPositionInfo::QGeoPositionInfo(const QGeoPositionInfo &other)
Creates a QGeoPositionInfo with the values of other.
[noexcept, since 6.2]
QGeoPositionInfo::QGeoPositionInfo(QGeoPositionInfo &&other)
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.
This function was introduced in Qt 6.2.
[noexcept]
QGeoPositionInfo::~QGeoPositionInfo()
Destroys a QGeoPositionInfo object.
qreal QGeoPositionInfo::attribute(QGeoPositionInfo::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() and setAttribute().
QGeoCoordinate QGeoPositionInfo::coordinate() const
Returns the coordinate for this position.
Returns an invalid coordinate if no coordinate has been set.
See also setCoordinate().
bool QGeoPositionInfo::hasAttribute(QGeoPositionInfo::Attribute attribute) const
Returns true if the specified attribute is present for this QGeoPositionInfo object.
bool QGeoPositionInfo::isValid() const
Returns true if the timestamp() and coordinate() values are both valid.
See also QGeoCoordinate::isValid() and QDateTime::isValid().
void QGeoPositionInfo::removeAttribute(QGeoPositionInfo::Attribute attribute)
Removes the specified attribute and its value.
void QGeoPositionInfo::setAttribute(QGeoPositionInfo::Attribute attribute, qreal value)
Sets the value for attribute to value.
See also attribute().
void QGeoPositionInfo::setCoordinate(const QGeoCoordinate &coordinate)
Sets the coordinate for this position to coordinate.
See also coordinate().
void QGeoPositionInfo::setTimestamp(const QDateTime ×tamp)
Sets the date and time at which this position was reported to timestamp.
The timestamp must be in UTC time.
See also 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().
[noexcept, since 6.2]
QGeoPositionInfo &QGeoPositionInfo::operator=(QGeoPositionInfo &&other)
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.
This function was introduced in Qt 6.2.
QGeoPositionInfo &QGeoPositionInfo::operator=(const QGeoPositionInfo &other)
Assigns the values from other to this QGeoPositionInfo.
Related Non-Members
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. Otherwise returns false
.
QDataStream &operator<<(QDataStream &stream, QGeoPositionInfo::Attribute attr)
Writes the given attr enumeration to the specified stream.
See also Serializing Qt Data Types.
QDataStream &operator<<(QDataStream &stream, const QGeoPositionInfo &info)
Writes the given info to the specified stream.
See also Serializing Qt Data Types.
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. Otherwise returns false
.
QDataStream &operator>>(QDataStream &stream, QGeoPositionInfo &info)
Reads a coordinate from the specified stream into the given info.
See also Serializing Qt Data Types.
QDataStream &operator>>(QDataStream &stream, QGeoPositionInfo::Attribute &attr)
Reads an attribute enumeration from the specified stream info the given attr.
See also Serializing Qt Data Types.
© 2024 The Qt Company Ltd. Documentation contributions included herein are the copyrights of their respective owners. The documentation provided herein is licensed under the terms of the GNU Free Documentation License version 1.3 as published by the Free Software Foundation. Qt and respective logos are trademarks of The Qt Company Ltd. in Finland and/or other countries worldwide. All other trademarks are property of their respective owners.