void QgsQtLocationConnection::satellitesInUseUpdated(
    const QList<QGeoSatelliteInfo>& satellites )
{
    // The number of satellites in use is updated
    mLastGPSInformation.satellitesUsed = QString::number( satellites.count() ).toInt();

    mLastGPSInformation.satPrn.clear();
    for ( int i = 0; i < satellites.size(); ++i )
    {
        QGeoSatelliteInfo currentSatellite = satellites.at( i );
        //add pnr to mLastGPSInformation.satPrn
        mLastGPSInformation.satPrn.append( currentSatellite.prnNumber() );

        //set QgsSatelliteInfo.inuse to true for the satellites in use
        for ( int i = 0; i < mLastGPSInformation.satellitesInView.size(); ++i )
        {
            QgsSatelliteInfo satInView = mLastGPSInformation.satellitesInView.at( i );
            if ( satInView.id == currentSatellite.prnNumber() )
            {
                satInView.inUse = true;
                break;
            }
        }
    }
    mLastGPSInformation.satInfoComplete = true;  //to be used to determine when to graph signal and satellite position
    emit stateChanged( mLastGPSInformation );
    QgsDebugMsg( "satellitesInUseUpdated" );
}
/*
 This is _only_ called when QGeoSatelliteInfoValidator::valid() returns true for the position.
 This means that it is implied that:
 - (data.dwValidFields & GPS_VALID_SATELLITE_COUNT) != 0
 - (data.dwValidFields & GPS_VALID_SATELLITES_IN_VIEW) != 0
 - (data.dwValidFields & GPS_VALID_SATELLITES_IN_VIEW_PRNS) != 0
 - (data.dwValidFields & GPS_VALID_SATELLITES_IN_VIEW_SIGNAL_TO_NOISE_RATIO) != 0

 This guarantees that the newly created position will be valid.
 If the code is changed such that this is no longer guaranteed then this method will need to be
 updated to test for those conditions.
*/
void QGeoSatelliteInfoSourceWinCE::dataUpdated(GPS_POSITION data)
{
    // Satellites in view are hashed on the PRN values since the PRN value is how we
    // determine which of the satellites are in use.
    QHash<int, QGeoSatelliteInfo> satellitesInView;

    for (unsigned int i = 0; i < data.dwSatellitesInView; ++i) {
        QGeoSatelliteInfo satellite;

        satellite.setPrnNumber(data.rgdwSatellitesInViewPRNs[i]);
        satellite.setSignalStrength(data.rgdwSatellitesInViewSignalToNoiseRatio[i]);

        // The following properties are optional, and so are set if the data is present and valid
        // in the GPS_POSITION structure.
        if ((data.dwValidFields & GPS_VALID_SATELLITES_IN_VIEW_AZIMUTH) != 0) {
            satellite.setAttribute(QGeoSatelliteInfo::Azimuth,
                                   data.rgdwSatellitesInViewAzimuth[i]);
        }

        if ((data.dwValidFields & GPS_VALID_SATELLITES_IN_VIEW_ELEVATION) != 0) {
            satellite.setAttribute(QGeoSatelliteInfo::Elevation,
                                   data.rgdwSatellitesInViewElevation[i]);
        }

        satellitesInView.insert(satellite.prnNumber(), satellite);
    }

    emit satellitesInViewUpdated(satellitesInView.values());

    // If the PRN data for the satellites which were used is unavailable we are done...
    if ((data.dwValidFields & GPS_VALID_SATELLITES_USED_PRNS) == 0)
        return;

    // ...otherwise we construct the list of satellites which are in use and emit the appropriate
    // signal
    QList<QGeoSatelliteInfo> satellitesInUse;

    for (unsigned int i = 0; i < data.dwSatelliteCount; ++i) {
        int inUsePRN = data.rgdwSatellitesUsedPRNs[i];
        if (satellitesInView.contains(inUsePRN))
            satellitesInUse << satellitesInView.value(inUsePRN);
    }

    emit satellitesInUseUpdated(satellitesInUse);
}
void QgsQtLocationConnection::satellitesInViewUpdated(
    const QList<QGeoSatelliteInfo>& satellites )
{
    // The number of satellites in view is updated
    mLastGPSInformation.satellitesInView.clear();
    for ( int i = 0; i < satellites.size(); ++i )
    {
        QGeoSatelliteInfo currentSatellite = satellites.at( i );
        QgsSatelliteInfo satelliteInfo;
        satelliteInfo.azimuth = currentSatellite.attribute( QGeoSatelliteInfo::Azimuth );
        satelliteInfo.elevation = currentSatellite.attribute( QGeoSatelliteInfo::Elevation );
        satelliteInfo.id = currentSatellite.prnNumber();
        satelliteInfo.signal = currentSatellite.signalStrength();
        mLastGPSInformation.satellitesInView.append( satelliteInfo );
    }
    mLastGPSInformation.satInfoComplete = true;  //to be used to determine when to graph signal and satellite position
    emit stateChanged( mLastGPSInformation );
    QgsDebugMsg( "satellitesInViewUpdated" );
}