21 #include <QLocalSocket>
29 qRegisterMetaType< QList<QGeoSatelliteInfo> >(
"QList<QGeoSatelliteInfo>" );
31 startSatelliteMonitor();
43 if ( locationDataSource )
59 if ( locationDataSource )
63 if ( mInfo.isValid() )
91 QgsDebugMsg( QStringLiteral(
"Valid QGeoPositionInfo, positionUpdated" ) );
97 const QList<QGeoSatelliteInfo> &satellites )
101 for (
int i = 0; i < satellites.size(); ++i )
103 const QGeoSatelliteInfo currentSatellite = satellites.at( i );
105 satelliteInfo.
azimuth = currentSatellite.attribute( QGeoSatelliteInfo::Azimuth );
106 satelliteInfo.
elevation = currentSatellite.attribute( QGeoSatelliteInfo::Elevation );
107 satelliteInfo.
id = currentSatellite.satelliteIdentifier();
108 satelliteInfo.
signal = currentSatellite.signalStrength();
113 QgsDebugMsg( QStringLiteral(
"satellitesInViewUpdated" ) );
117 const QList<QGeoSatelliteInfo> &satellites )
123 for (
const QGeoSatelliteInfo ¤tSatellite : satellites )
131 if ( satInView.
id == currentSatellite.satelliteIdentifier() )
133 satInView.
inUse =
true;
140 QgsDebugMsg( QStringLiteral(
"satellitesInUseUpdated" ) );
143 void QgsQtLocationConnection::startGPS()
145 QgsDebugMsg( QStringLiteral(
"Starting GPS QtLocation connection" ) );
147 if ( !locationDataSource )
149 locationDataSource = QGeoPositionInfoSource::createDefaultSource(
this );
150 if ( locationDataSource )
152 locationDataSource->setPreferredPositioningMethods( QGeoPositionInfoSource::SatellitePositioningMethods );
153 locationDataSource->setUpdateInterval( 1000 );
156 QObject::connect( locationDataSource.data(),
157 &QGeoPositionInfoSource::positionUpdated,
161 locationDataSource->startUpdates();
166 QgsDebugMsg( QStringLiteral(
"No QtLocation Position Source" ) );
172 locationDataSource->startUpdates();
176 void QgsQtLocationConnection::startSatelliteMonitor()
178 QgsDebugMsg( QStringLiteral(
"Starting GPS QtLocation satellite monitor" ) );
180 if ( !satelliteInfoSource )
182 satelliteInfoSource = QGeoSatelliteInfoSource::createDefaultSource(
this );
183 if ( satelliteInfoSource )
185 QgsDebugMsg( QStringLiteral(
"satelliteMonitor started" ) );
189 QObject::connect( satelliteInfoSource.data(),
190 &QGeoSatelliteInfoSource::satellitesInUseUpdated,
197 QObject::connect( satelliteInfoSource.data(),
198 &QGeoSatelliteInfoSource::satellitesInViewUpdated,
203 satelliteInfoSource->startUpdates();
208 QgsDebugMsg( QStringLiteral(
"No QtLocation Satellite Source" ) );
214 satelliteInfoSource->startUpdates();
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)
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.