summaryrefslogtreecommitdiff
path: root/noncore/net/wellenreiter/gui/gps.cpp
Side-by-side diff
Diffstat (limited to 'noncore/net/wellenreiter/gui/gps.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/net/wellenreiter/gui/gps.cpp8
1 files changed, 4 insertions, 4 deletions
diff --git a/noncore/net/wellenreiter/gui/gps.cpp b/noncore/net/wellenreiter/gui/gps.cpp
index 31f95ce..b814427 100644
--- a/noncore/net/wellenreiter/gui/gps.cpp
+++ b/noncore/net/wellenreiter/gui/gps.cpp
@@ -37,65 +37,65 @@ GPS::~GPS()
bool GPS::open( const QString& host, int port )
{
_socket->connectToHost( host, port );
}
GpsLocation GPS::position() const
{
char buf[256];
int result = _socket->writeBlock( "p\r\n", 3 );
_socket->flush();
if ( result )
{
int numAvail = _socket->bytesAvailable();
qDebug( "GPS write succeeded, %d bytes available for reading...", numAvail );
if ( numAvail )
{
QTextStream stream( _socket );
QString str;
stream.readRawBytes( &buf[0], 7 );
- float lat = -111.111;
+ float lat = -111;
stream >> lat;
stream.skipWhiteSpace();
- float lon = -111.111;
+ float lon = -111;
stream >> lon;
stream.readRawBytes( &buf[0], 200 ); // read and discard the stuff until EOF
return GpsLocation( lat, lon );
}
}
- return GpsLocation( -111.111, -111.111 );
+ return GpsLocation( -111, -111 );
}
QString GpsLocation::dmsPosition() const
{
- if ( _latitude == -111.111 || _longitude == -111.11 )
+ if ( _latitude == -111 || _longitude == -111 )
return "N/A";
if ( _latitude == 0.0 && _longitude == 0.0 )
return "NULL";
/* compute latitude */
QString dms = "N";
if ( _latitude >= 0 ) dms.append( "+" );
int trunc = int( _latitude );
float rest = _latitude - trunc;
float minf = rest * 60;
int minutes = int( minf );
rest = minf - minutes;
int seconds = int( rest * 60 );
dms.append( QString::number( trunc ) );
dms.append( "° " );
dms.append( QString::number( ::abs( minutes ) ) );
dms.append( "' " );
dms.append( QString::number( ::abs( seconds ) ) );
dms.append( "'' " );