22#include <QLocalSocket>
27#include "moc_qgsqtlocationconnection.cpp"
29using namespace Qt::StringLiterals;
35 qRegisterMetaType< QList<QGeoSatelliteInfo> >(
"QList<QGeoSatelliteInfo>" );
37 startSatelliteMonitor();
49 if ( locationDataSource )
65 if ( locationDataSource )
69 if ( mInfo.isValid() )
80 switch ( mInfo.coordinate().type() )
82 case QGeoCoordinate::InvalidCoordinate:
85 case QGeoCoordinate::Coordinate2D:
88 case QGeoCoordinate::Coordinate3D:
117 const QList<QGeoSatelliteInfo> &satellites )
121 for (
int i = 0; i < satellites.size(); ++i )
123 const QGeoSatelliteInfo currentSatellite = satellites.at( i );
125 satelliteInfo.
azimuth = currentSatellite.attribute( QGeoSatelliteInfo::Azimuth );
126 satelliteInfo.
elevation = currentSatellite.attribute( QGeoSatelliteInfo::Elevation );
127 satelliteInfo.
id = currentSatellite.satelliteIdentifier();
128 satelliteInfo.
signal = currentSatellite.signalStrength();
137 const QList<QGeoSatelliteInfo> &satellites )
143 for (
const QGeoSatelliteInfo ¤tSatellite : satellites )
151 if ( satInView.
id == currentSatellite.satelliteIdentifier() )
153 satInView.
inUse =
true;
163void QgsQtLocationConnection::startGPS()
167 if ( !locationDataSource )
169 locationDataSource = QGeoPositionInfoSource::createDefaultSource(
this );
170 if ( locationDataSource )
172 locationDataSource->setPreferredPositioningMethods( QGeoPositionInfoSource::SatellitePositioningMethods );
173 locationDataSource->setUpdateInterval( 1000 );
176 QObject::connect( locationDataSource.data(),
177 &QGeoPositionInfoSource::positionUpdated,
181 locationDataSource->startUpdates();
192 locationDataSource->startUpdates();
196void QgsQtLocationConnection::startSatelliteMonitor()
200 if ( !satelliteInfoSource )
202 satelliteInfoSource = QGeoSatelliteInfoSource::createDefaultSource(
this );
203 if ( satelliteInfoSource )
209 QObject::connect( satelliteInfoSource.data(),
210 &QGeoSatelliteInfoSource::satellitesInUseUpdated,
217 QObject::connect( satelliteInfoSource.data(),
218 &QGeoSatelliteInfoSource::satellitesInViewUpdated,
223 satelliteInfoSource->startUpdates();
234 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)