Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Added utc date and time to gps information and insert connection into…
… the registry

git-svn-id: http://svn.osgeo.org/qgis/trunk/qgis@12862 c8812cc2-4d05-0410-92ff-de0c093fc19c
  • Loading branch information
mhugent committed Feb 3, 2010
1 parent 26856e7 commit f2d9145
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/app/gps/qgsgpsinformationwidget.cpp
Expand Up @@ -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>
Expand Down Expand Up @@ -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" ) );
Expand Down
2 changes: 2 additions & 0 deletions src/core/gps/qgsgpsconnection.cpp
Expand Up @@ -94,4 +94,6 @@ void QgsGPSConnection::clearLastGPSInformation()
mLastGPSInformation.satellitesInView.clear();
mLastGPSInformation.speed = 0;
mLastGPSInformation.vdop = 0;
mLastGPSInformation.utcDateTime.setDate( QDate() );
mLastGPSInformation.utcDateTime.setTime( QTime() );
}
2 changes: 2 additions & 0 deletions src/core/gps/qgsgpsconnection.h
Expand Up @@ -18,6 +18,7 @@
#ifndef QGSGPSCONNECTION_H
#define QGSGPSCONNECTION_H

#include <QDateTime>
#include <QObject>

class QIODevice;
Expand All @@ -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*/
Expand Down
7 changes: 7 additions & 0 deletions src/core/gps/qgsnmeaconnection.cpp
Expand Up @@ -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 );
}
}

Expand Down

0 comments on commit f2d9145

Please sign in to comment.