21 #include <QLocalSocket> 29 qRegisterMetaType< QList<QGeoSatelliteInfo> >(
"QList<QGeoSatelliteInfo>" );
31 startSatelliteMonitor();
43 if ( locationDataSource )
59 if ( locationDataSource )
63 if ( mInfo.isValid() )
91 QgsDebugMsg(
"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();
121 const QList<QGeoSatelliteInfo> &satellites )
127 for (
int i = 0; i < satellites.size(); ++i )
129 QGeoSatelliteInfo currentSatellite = satellites.at( i );
131 #if defined(HAVE_QT_MOBILITY_LOCATION ) 133 #else // QtPositioning 141 #if defined(HAVE_QT_MOBILITY_LOCATION ) 142 if ( satInView.
id == currentSatellite.prnNumber() )
144 if ( satInView.
id == currentSatellite.satelliteIdentifier() )
147 satInView.
inUse =
true;
157 void QgsQtLocationConnection::startGPS()
159 QgsDebugMsg(
"Starting GPS QtLocation connection" );
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();
186 locationDataSource->startUpdates();
190 void QgsQtLocationConnection::startSatelliteMonitor()
192 QgsDebugMsg(
"Starting GPS QtLocation satellite monitor" );
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();
228 satelliteInfoSource->startUpdates();
void satellitesInUseUpdated(const QList< QGeoSatelliteInfo > &satellites)
Called when the number of satellites in use is updated.
QgsGpsInformation mLastGPSInformation
Last state of the gps related variables (e.g. position, time, ...)
void positionUpdated(const QGeoPositionInfo &info)
Called when the position updated.
void parseData() override
Parse available data source content.
void satellitesInViewUpdated(const QList< QGeoSatelliteInfo > &satellites)
Called when the number of satellites in view is updated.
void stateChanged(const QgsGpsInformation &info)
void broadcastConnectionAvailable()
Needed to make QtLocation detected.
Status mStatus
Connection status.
QgsQtLocationConnection()
Abstract base class for connection to a GPS device.