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();