21#include <QLocalSocket>
29 qRegisterMetaType< QList<QGeoSatelliteInfo> >(
"QList<QGeoSatelliteInfo>" );
31 startSatelliteMonitor();
43 if ( locationDataSource )
59 if ( locationDataSource )
63 if ( mInfo.isValid() )
74 switch ( mInfo.coordinate().type() )
76 case QGeoCoordinate::InvalidCoordinate:
79 case QGeoCoordinate::Coordinate2D:
82 case QGeoCoordinate::Coordinate3D:
105 QgsDebugMsgLevel( QStringLiteral(
"Valid QGeoPositionInfo, positionUpdated" ), 2 );
111 const QList<QGeoSatelliteInfo> &satellites )
115 for (
int i = 0; i < satellites.size(); ++i )
117 const QGeoSatelliteInfo currentSatellite = satellites.at( i );
119 satelliteInfo.
azimuth = currentSatellite.attribute( QGeoSatelliteInfo::Azimuth );
120 satelliteInfo.
elevation = currentSatellite.attribute( QGeoSatelliteInfo::Elevation );
121 satelliteInfo.
id = currentSatellite.satelliteIdentifier();
122 satelliteInfo.
signal = currentSatellite.signalStrength();
131 const QList<QGeoSatelliteInfo> &satellites )
137 for (
const QGeoSatelliteInfo ¤tSatellite : satellites )
145 if ( satInView.id == currentSatellite.satelliteIdentifier() )
147 satInView.inUse =
true;
157void QgsQtLocationConnection::startGPS()
159 QgsDebugMsgLevel( QStringLiteral(
"Starting GPS QtLocation connection" ), 2 );
161 if ( !locationDataSource )
163 locationDataSource = QGeoPositionInfoSource::createDefaultSource(
this );
164 if ( locationDataSource )
166 locationDataSource->setPreferredPositioningMethods( QGeoPositionInfoSource::SatellitePositioningMethods );
167 locationDataSource->setUpdateInterval( 1000 );
170 QObject::connect( locationDataSource.data(),
171 &QGeoPositionInfoSource::positionUpdated,
175 locationDataSource->startUpdates();
180 QgsDebugError( QStringLiteral(
"No QtLocation Position Source" ) );
186 locationDataSource->startUpdates();
190void QgsQtLocationConnection::startSatelliteMonitor()
192 QgsDebugMsgLevel( QStringLiteral(
"Starting GPS QtLocation satellite monitor" ), 2 );
194 if ( !satelliteInfoSource )
196 satelliteInfoSource = QGeoSatelliteInfoSource::createDefaultSource(
this );
197 if ( satelliteInfoSource )
203 QObject::connect( satelliteInfoSource.data(),
204 &QGeoSatelliteInfoSource::satellitesInUseUpdated,
211 QObject::connect( satelliteInfoSource.data(),
212 &QGeoSatelliteInfoSource::satellitesInViewUpdated,
217 satelliteInfoSource->startUpdates();
222 QgsDebugError( QStringLiteral(
"No QtLocation Satellite Source" ) );
228 satelliteInfoSource->startUpdates();
@ Unknown
Unknown/other system.
Abstract base class for connection to a GPS device.
QgsGpsInformation mLastGPSInformation
Last state of the gps related variables (e.g. position, time, ...)
Status mStatus
Connection status.
void stateChanged(const QgsGpsInformation &info)
Emitted whenever the GPS state is changed.
void satellitesInViewUpdated(const QList< QGeoSatelliteInfo > &satellites)
Called when the number of satellites in view is updated.
void broadcastConnectionAvailable()
Needed to make QtLocation detected.
QgsQtLocationConnection()
void positionUpdated(const QGeoPositionInfo &info)
Called when the position updated.
void satellitesInUseUpdated(const QList< QGeoSatelliteInfo > &satellites)
Called when the number of satellites in use is updated.
void parseData() override
Parse available data source content.
Encapsulates information relating to a GPS satellite.
double elevation
Elevation of the satellite, in degrees.
int signal
Signal strength (0-99dB), or -1 if not available.
int id
Contains the satellite identifier number.
double azimuth
The azimuth of the satellite to true north, in degrees.
#define QgsDebugMsgLevel(str, level)
#define QgsDebugError(str)