22#include <QLocalSocket>
26#include "moc_qgsqtlocationconnection.cpp"
32 qRegisterMetaType< QList<QGeoSatelliteInfo> >(
"QList<QGeoSatelliteInfo>" );
34 startSatelliteMonitor();
46 if ( locationDataSource )
62 if ( locationDataSource )
66 if ( mInfo.isValid() )
77 switch ( mInfo.coordinate().type() )
79 case QGeoCoordinate::InvalidCoordinate:
82 case QGeoCoordinate::Coordinate2D:
85 case QGeoCoordinate::Coordinate3D:
108 QgsDebugMsgLevel( QStringLiteral(
"Valid QGeoPositionInfo, positionUpdated" ), 2 );
114 const QList<QGeoSatelliteInfo> &satellites )
118 for (
int i = 0; i < satellites.size(); ++i )
120 const QGeoSatelliteInfo currentSatellite = satellites.at( i );
122 satelliteInfo.
azimuth = currentSatellite.attribute( QGeoSatelliteInfo::Azimuth );
123 satelliteInfo.
elevation = currentSatellite.attribute( QGeoSatelliteInfo::Elevation );
124 satelliteInfo.
id = currentSatellite.satelliteIdentifier();
125 satelliteInfo.
signal = currentSatellite.signalStrength();
134 const QList<QGeoSatelliteInfo> &satellites )
140 for (
const QGeoSatelliteInfo ¤tSatellite : satellites )
148 if ( satInView.
id == currentSatellite.satelliteIdentifier() )
150 satInView.
inUse =
true;
160void QgsQtLocationConnection::startGPS()
162 QgsDebugMsgLevel( QStringLiteral(
"Starting GPS QtLocation connection" ), 2 );
164 if ( !locationDataSource )
166 locationDataSource = QGeoPositionInfoSource::createDefaultSource(
this );
167 if ( locationDataSource )
169 locationDataSource->setPreferredPositioningMethods( QGeoPositionInfoSource::SatellitePositioningMethods );
170 locationDataSource->setUpdateInterval( 1000 );
173 QObject::connect( locationDataSource.data(),
174 &QGeoPositionInfoSource::positionUpdated,
178 locationDataSource->startUpdates();
183 QgsDebugError( QStringLiteral(
"No QtLocation Position Source" ) );
189 locationDataSource->startUpdates();
193void QgsQtLocationConnection::startSatelliteMonitor()
195 QgsDebugMsgLevel( QStringLiteral(
"Starting GPS QtLocation satellite monitor" ), 2 );
197 if ( !satelliteInfoSource )
199 satelliteInfoSource = QGeoSatelliteInfoSource::createDefaultSource(
this );
200 if ( satelliteInfoSource )
206 QObject::connect( satelliteInfoSource.data(),
207 &QGeoSatelliteInfoSource::satellitesInUseUpdated,
214 QObject::connect( satelliteInfoSource.data(),
215 &QGeoSatelliteInfoSource::satellitesInViewUpdated,
220 satelliteInfoSource->startUpdates();
225 QgsDebugError( QStringLiteral(
"No QtLocation Satellite Source" ) );
231 satelliteInfoSource->startUpdates();
@ Unknown
Unknown/other system.
QgsGpsInformation mLastGPSInformation
Last state of the gps related variables (e.g. position, time, ...).
QgsGpsConnection(QIODevice *dev)
Constructor.
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.
bool inUse
true if satellite was used in obtaining the position fix.
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)