Skip to content
Permalink
Browse files

Added utc date and time to gps information and insert connection into…

… the registry

git-svn-id: http://svn.osgeo.org/qgis/trunk@12862 c8812cc2-4d05-0410-92ff-de0c093fc19c
  • Loading branch information
mhugent
mhugent committed Feb 3, 2010
1 parent dfbe471 commit 0081c37f6143661ce5ca91453984a52a0400349d
@@ -18,6 +18,7 @@
#include "qgsgpsinformationwidget.h"
#include "qgsvectorlayer.h"
#include "qgsnmeaconnection.h"
#include "qgsgpsconnectionregistry.h"
#include "qgsgpsdetector.h"
#include "qgscoordinatetransform.h"
#include <qgspoint.h>
@@ -338,12 +339,14 @@ void QgsGPSInformationWidget::connected( QgsGPSConnection *conn )
this, SLOT( displayGPSInformation( const QgsGPSInformation& ) ) );
mGPSTextEdit->append( tr( "Connected!" ) );
mConnectButton->setText( tr( "Disconnect" ) );
//insert connection into registry such that it can also be used by other dialogs or plugins
QgsGPSConnectionRegistry::instance()->registerConnection( mNmea );
}

void QgsGPSInformationWidget::disconnectGps()
{
QgsGPSConnectionRegistry::instance()->unregisterConnection( mNmea );
delete mNmea;

mGPSTextEdit->append( tr( "Disconnected..." ) );
mConnectButton->setChecked( false );
mConnectButton->setText( tr( "Connect" ) );
@@ -94,4 +94,6 @@ void QgsGPSConnection::clearLastGPSInformation()
mLastGPSInformation.satellitesInView.clear();
mLastGPSInformation.speed = 0;
mLastGPSInformation.vdop = 0;
mLastGPSInformation.utcDateTime.setDate( QDate() );
mLastGPSInformation.utcDateTime.setTime( QTime() );
}
@@ -18,6 +18,7 @@
#ifndef QGSGPSCONNECTION_H
#define QGSGPSCONNECTION_H

#include <QDateTime>
#include <QObject>

class QIODevice;
@@ -42,6 +43,7 @@ struct CORE_EXPORT QgsGPSInformation
double pdop;
double hdop;
double vdop;
QDateTime utcDateTime;
};

/**Abstract base class for connection to a GPS device*/
@@ -178,6 +178,13 @@ void QgsNMEAConnection::processRMCSentence( const char* data, int len )
mLastGPSInformation.latitude = nmea_ndeg2degree( latitude );
mLastGPSInformation.speed = KNOTS_TO_KMH * result.speed;
mLastGPSInformation.direction = result.direction;

//date and time
QDate date( result.utc.year, result.utc.day, result.utc.sec );
QTime time( result.utc.hour, result.utc.min, result.utc.sec );
mLastGPSInformation.utcDateTime.setTimeSpec( Qt::UTC );
mLastGPSInformation.utcDateTime.setDate( date );
mLastGPSInformation.utcDateTime.setTime( time );
}
}

0 comments on commit 0081c37

Please sign in to comment.
You can’t perform that action at this time.