QNmeaPositionInfoSource Class
The QNmeaPositionInfoSource class provides positional information using a NMEA data source. 更多...
头文件: | #include <QNmeaPositionInfoSource> |
qmake: | QT += positioning |
开始支持版本: | Qt 5.2 |
基类: | QGeoPositionInfoSource |
公有类型
enum | UpdateMode { RealTimeMode, SimulationMode } |
公有函数
QNmeaPositionInfoSource(UpdateMode updateMode, QObject *parent = Q_NULLPTR) | |
~QNmeaPositionInfoSource() | |
QIODevice * | device() const |
void | setDevice(QIODevice *device) |
void | setUserEquivalentRangeError(double uere) |
UpdateMode | updateMode() const |
double | userEquivalentRangeError() const |
重新实现的公有函数
virtual Error | error() const |
virtual QGeoPositionInfo | lastKnownPosition(bool fromSatellitePositioningMethodsOnly = false) const |
virtual int | minimumUpdateInterval() const |
virtual void | setUpdateInterval(int msec) |
virtual PositioningMethods | supportedPositioningMethods() const |
- 9 个公有函数继承自 QGeoPositionInfoSource
- 32 个公有函数继承自 QObject
公有槽函数
virtual void | requestUpdate(int msec = 0) |
virtual void | startUpdates() |
virtual void | stopUpdates() |
- 3 个公有槽函数继承自 QGeoPositionInfoSource
- 1 个公有槽函数继承自 QObject
受保护的函数
virtual bool | parsePosInfoFromNmeaData(const char *data, int size, QGeoPositionInfo *posInfo, bool *hasFix) |
- 9 个受保护的函数继承自 QObject
其他继承的成员
- 3 个属性继承自 QGeoPositionInfoSource
- 1 个属性继承自 QObject
- 3 个信号继承自 QGeoPositionInfoSource
- 2 个信号继承自 QObject
- 1 个公有变量继承自 QObject
- 3 个静态公有成员继承自 QGeoPositionInfoSource
- 10 个静态公有成员继承自 QObject
- 2 个受保护的变量继承自 QObject
详细描述
The QNmeaPositionInfoSource class provides positional information using a NMEA data source.
NMEA is a commonly used protocol for the specification of one's global position at a certain point in time. The QNmeaPositionInfoSource class reads NMEA data and uses it to provide positional data in the form of QGeoPositionInfo objects.
A QNmeaPositionInfoSource instance operates in either RealTimeMode or SimulationMode. These modes allow NMEA data to be read from either a live source of positional data, or replayed for simulation purposes from previously recorded NMEA data.
The source of NMEA data is set with setDevice().
Use startUpdates() to start receiving regular position updates and stopUpdates() to stop these updates. If you only require updates occasionally, you can call requestUpdate() to request a single update.
In both cases the position information is received via the positionUpdated() signal and the last known position can be accessed with lastKnownPosition().
QNmeaPositionInfoSource supports reporting the accuracy of the horizontal and vertical position. To enable position accuracy reporting an estimate of the User Equivalent Range Error associated with the NMEA source must be set with setUserEquivalentRangeError().
成员类型
enum QNmeaPositionInfoSource::UpdateMode
Defines the available update modes.
Constant | Value | Description |
---|---|---|
QNmeaPositionInfoSource::RealTimeMode | 1 | Positional data is read and distributed from the data source as it becomes available. Use this mode if you are using a live source of positional data (for example, a GPS hardware device). |
QNmeaPositionInfoSource::SimulationMode | 2 | The data and time information in the NMEA source data is used to provide positional updates at the rate at which the data was originally recorded. Use this mode if the data source contains previously recorded NMEA data and you want to replay the data for simulation purposes. |
成员函数
QNmeaPositionInfoSource::QNmeaPositionInfoSource(UpdateMode updateMode, QObject *parent = Q_NULLPTR)
Constructs a QNmeaPositionInfoSource instance with the given parent and updateMode.
QNmeaPositionInfoSource::~QNmeaPositionInfoSource()
Destroys the position source.
QIODevice *QNmeaPositionInfoSource::device() const
Returns the NMEA data source.
参见 setDevice().
[virtual]
Error QNmeaPositionInfoSource::error() const
Reimplemented from QGeoPositionInfoSource::error().
[virtual]
QGeoPositionInfo QNmeaPositionInfoSource::lastKnownPosition(bool fromSatellitePositioningMethodsOnly = false) const
Reimplemented from QGeoPositionInfoSource::lastKnownPosition().
[virtual]
int QNmeaPositionInfoSource::minimumUpdateInterval() const
Reimplemented from QGeoPositionInfoSource::minimumUpdateInterval().
[virtual protected]
bool QNmeaPositionInfoSource::parsePosInfoFromNmeaData(const char *data, int size, QGeoPositionInfo *posInfo, bool *hasFix)
Parses an NMEA sentence string into a QGeoPositionInfo.
The default implementation will parse standard NMEA sentences. This method should be reimplemented in a subclass whenever the need to deal with non-standard NMEA sentences arises.
The parser reads size bytes from data and uses that information to setup posInfo and hasFix. If hasFix is set to false then posInfo may contain only the time or the date and the time.
Returns true if the sentence was succsesfully parsed, otherwise returns false and should not modifiy posInfo or hasFix.
[virtual slot]
void QNmeaPositionInfoSource::requestUpdate(int msec = 0)
Reimplemented from QGeoPositionInfoSource::requestUpdate().
void QNmeaPositionInfoSource::setDevice(QIODevice *device)
Sets the NMEA data source to device. If the device is not open, it will be opened in QIODevice::ReadOnly mode.
The source device can only be set once and must be set before calling startUpdates() or requestUpdate().
Note: The device must emit QIODevice::readyRead() for the source to be notified when data is available for reading. QNmeaPositionInfoSource does not assume the ownership of the device, and hence does not deallocate it upon destruction.
参见 device().
[virtual]
void QNmeaPositionInfoSource::setUpdateInterval(int msec)
Reimplemented from QGeoPositionInfoSource::setUpdateInterval().
void QNmeaPositionInfoSource::setUserEquivalentRangeError(double uere)
Sets the User Equivalent Range Error (UERE) to uere. The UERE is used in calculating an estimate of the accuracy of the position information reported by the position info source. The UERE should be set to a value appropriate for the GPS device which generated the NMEA stream.
The true UERE value is calculated from multiple error sources including errors introduced by the satellites and signal propogation delays through the atmosphere as well as errors introduced by the receiving GPS equipment. For details on GPS accuracy see http://edu-observatory.org/gps/gps_accuracy.html.
A typical value for UERE is approximately 5.1.
This function was introduced in Qt 5.3.
参见 userEquivalentRangeError().
[virtual slot]
void QNmeaPositionInfoSource::startUpdates()
Reimplemented from QGeoPositionInfoSource::startUpdates().
[virtual slot]
void QNmeaPositionInfoSource::stopUpdates()
Reimplemented from QGeoPositionInfoSource::stopUpdates().
[virtual]
PositioningMethods QNmeaPositionInfoSource::supportedPositioningMethods() const
Reimplemented from QGeoPositionInfoSource::supportedPositioningMethods().
UpdateMode QNmeaPositionInfoSource::updateMode() const
Returns the update mode.
double QNmeaPositionInfoSource::userEquivalentRangeError() const
Returns the current User Equivalent Range Error (UERE). The UERE is used in calculating an estimate of the accuracy of the position information reported by the position info source. The default value is NaN which means no accuracy information will be provided.
This function was introduced in Qt 5.3.