Diffstat (limited to 'noncore/net/wellenreiter/gui/gps.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | noncore/net/wellenreiter/gui/gps.cpp | 66 |
1 files changed, 64 insertions, 2 deletions
diff --git a/noncore/net/wellenreiter/gui/gps.cpp b/noncore/net/wellenreiter/gui/gps.cpp index 288afee..31f95ce 100644 --- a/noncore/net/wellenreiter/gui/gps.cpp +++ b/noncore/net/wellenreiter/gui/gps.cpp | |||
@@ -16,6 +16,10 @@ | |||
16 | #include "gps.h" | 16 | #include "gps.h" |
17 | #include <unistd.h> | ||
18 | 17 | ||
18 | /* QT */ | ||
19 | #include <qtextstream.h> | 19 | #include <qtextstream.h> |
20 | 20 | ||
21 | /* STD */ | ||
22 | #include <stdlib.h> | ||
23 | #include <unistd.h> | ||
24 | |||
21 | GPS::GPS( QObject* parent, const char * name ) | 25 | GPS::GPS( QObject* parent, const char * name ) |
@@ -66,4 +70,62 @@ GpsLocation GPS::position() const | |||
66 | } | 70 | } |
67 | return GpsLocation( -1.0, -1.0 ); | 71 | return GpsLocation( -111.111, -111.111 ); |
68 | } | 72 | } |
69 | 73 | ||
74 | |||
75 | QString GpsLocation::dmsPosition() const | ||
76 | { | ||
77 | if ( _latitude == -111.111 || _longitude == -111.11 ) | ||
78 | return "N/A"; | ||
79 | if ( _latitude == 0.0 && _longitude == 0.0 ) | ||
80 | return "NULL"; | ||
81 | |||
82 | /* compute latitude */ | ||
83 | |||
84 | QString dms = "N"; | ||
85 | if ( _latitude >= 0 ) dms.append( "+" ); | ||
86 | |||
87 | int trunc = int( _latitude ); | ||
88 | float rest = _latitude - trunc; | ||
89 | |||
90 | float minf = rest * 60; | ||
91 | int minutes = int( minf ); | ||
92 | |||
93 | rest = minf - minutes; | ||
94 | int seconds = int( rest * 60 ); | ||
95 | |||
96 | dms.append( QString::number( trunc ) ); | ||
97 | dms.append( "° " ); | ||
98 | dms.append( QString::number( ::abs( minutes ) ) ); | ||
99 | dms.append( "' " ); | ||
100 | dms.append( QString::number( ::abs( seconds ) ) ); | ||
101 | dms.append( "'' " ); | ||
102 | |||
103 | /* compute longitude */ | ||
104 | |||
105 | dms.append( " | W" ); | ||
106 | if ( _longitude > 0 ) dms.append( "+" ); | ||
107 | |||
108 | trunc = int( _longitude ); | ||
109 | rest = _longitude - trunc; | ||
110 | |||
111 | minf = rest * 60; | ||
112 | minutes = int( minf ); | ||
113 | |||
114 | rest = minf - minutes; | ||
115 | seconds = int( rest * 60 ); | ||
116 | |||
117 | dms.append( QString::number( trunc ) ); | ||
118 | dms.append( "° " ); | ||
119 | dms.append( QString::number( ::abs( minutes ) ) ); | ||
120 | dms.append( "' " ); | ||
121 | dms.append( QString::number( ::abs( seconds ) ) ); | ||
122 | dms.append( "'' " ); | ||
123 | |||
124 | return dms; | ||
125 | } | ||
126 | |||
127 | |||
128 | |||
129 | |||
130 | |||
131 | |||