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 QGeoSatelliteInfo currentSatellite = satellites.at( i );
105 satelliteInfo.
azimuth = currentSatellite.attribute( QGeoSatelliteInfo::Azimuth );
106 satelliteInfo.
elevation = currentSatellite.attribute( QGeoSatelliteInfo::Elevation );
107 #if defined(HAVE_QT_MOBILITY_LOCATION )
108 satelliteInfo.
id = currentSatellite.prnNumber();
109 #else // QtPositioning
110 satelliteInfo.
id = currentSatellite.satelliteIdentifier();
112 satelliteInfo.
signal = currentSatellite.signalStrength();
117 QgsDebugMsg( QStringLiteral(
"satellitesInViewUpdated" ) );
121 const QList<QGeoSatelliteInfo> &satellites )
127 for (
const QGeoSatelliteInfo ¤tSatellite : satellites )
130 #if defined(HAVE_QT_MOBILITY_LOCATION )
132 #else // QtPositioning
139 #if defined(HAVE_QT_MOBILITY_LOCATION )
140 if ( satInView.
id == currentSatellite.prnNumber() )
141 #else // QtPositioning
142 if ( satInView.
id == currentSatellite.satelliteIdentifier() )
145 satInView.
inUse =
true;
152 QgsDebugMsg( QStringLiteral(
"satellitesInUseUpdated" ) );
155 void QgsQtLocationConnection::startGPS()
157 QgsDebugMsg( QStringLiteral(
"Starting GPS QtLocation connection" ) );
159 if ( !locationDataSource )
161 locationDataSource = QGeoPositionInfoSource::createDefaultSource(
this );
162 if ( locationDataSource )
164 locationDataSource->setPreferredPositioningMethods( QGeoPositionInfoSource::SatellitePositioningMethods );
165 locationDataSource->setUpdateInterval( 1000 );
168 QObject::connect( locationDataSource.data(),
169 &QGeoPositionInfoSource::positionUpdated,
173 locationDataSource->startUpdates();
178 QgsDebugMsg( QStringLiteral(
"No QtLocation Position Source" ) );
184 locationDataSource->startUpdates();
188 void QgsQtLocationConnection::startSatelliteMonitor()
190 QgsDebugMsg( QStringLiteral(
"Starting GPS QtLocation satellite monitor" ) );
192 if ( !satelliteInfoSource )
194 satelliteInfoSource = QGeoSatelliteInfoSource::createDefaultSource(
this );
195 if ( satelliteInfoSource )
197 QgsDebugMsg( QStringLiteral(
"satelliteMonitor started" ) );
201 QObject::connect( satelliteInfoSource.data(),
202 &QGeoSatelliteInfoSource::satellitesInUseUpdated,
209 QObject::connect( satelliteInfoSource.data(),
210 &QGeoSatelliteInfoSource::satellitesInViewUpdated,
215 satelliteInfoSource->startUpdates();
220 QgsDebugMsg( QStringLiteral(
"No QtLocation Satellite Source" ) );
226 satelliteInfoSource->startUpdates();