-rw-r--r-- | noncore/net/wellenreiter/gui/gps.cpp | 66 | ||||
-rw-r--r-- | noncore/net/wellenreiter/gui/gps.h | 13 | ||||
-rw-r--r-- | noncore/net/wellenreiter/gui/mainwindow.cpp | 8 | ||||
-rw-r--r-- | noncore/net/wellenreiter/gui/scanlist.cpp | 9 | ||||
-rw-r--r-- | noncore/net/wellenreiter/gui/scanlist.h | 2 | ||||
-rw-r--r-- | noncore/net/wellenreiter/gui/wellenreiter.cpp | 2 |
6 files changed, 82 insertions, 18 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 | |||
@@ -14,10 +14,14 @@ | |||
14 | **********************************************************************/ | 14 | **********************************************************************/ |
15 | 15 | ||
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 ) |
22 | :QObject( parent, name ) | 26 | :QObject( parent, name ) |
23 | { | 27 | { |
@@ -64,6 +68,64 @@ GpsLocation GPS::position() const | |||
64 | return GpsLocation( lat, lon ); | 68 | return GpsLocation( lat, lon ); |
65 | } | 69 | } |
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 | |||
diff --git a/noncore/net/wellenreiter/gui/gps.h b/noncore/net/wellenreiter/gui/gps.h index 8143fe4..cfe1cdb 100644 --- a/noncore/net/wellenreiter/gui/gps.h +++ b/noncore/net/wellenreiter/gui/gps.h | |||
@@ -19,12 +19,17 @@ | |||
19 | #include <qobject.h> | 19 | #include <qobject.h> |
20 | #include <qsocket.h> | 20 | #include <qsocket.h> |
21 | 21 | ||
22 | struct GpsLocation | 22 | class GpsLocation |
23 | { | 23 | { |
24 | GpsLocation( const float& lat, const float& lon ) : latitude(lat), longitude(lon) {}; | 24 | public: |
25 | GpsLocation( const float& lat, const float& lon ) : _latitude(lat), _longitude(lon) {}; | ||
25 | ~GpsLocation() {}; | 26 | ~GpsLocation() {}; |
26 | float latitude; | 27 | float latitude() const { return _latitude; }; |
27 | float longitude; | 28 | float longitude() const { return _longitude; }; |
29 | QString dmsPosition() const; | ||
30 | private: | ||
31 | float _latitude; | ||
32 | float _longitude; | ||
28 | }; | 33 | }; |
29 | 34 | ||
30 | 35 | ||
diff --git a/noncore/net/wellenreiter/gui/mainwindow.cpp b/noncore/net/wellenreiter/gui/mainwindow.cpp index ca9851c..d4e3279 100644 --- a/noncore/net/wellenreiter/gui/mainwindow.cpp +++ b/noncore/net/wellenreiter/gui/mainwindow.cpp | |||
@@ -224,11 +224,11 @@ void WellenreiterMainWindow::demoAddStations() | |||
224 | { | 224 | { |
225 | //mw = 0; // test SIGSGV handling | 225 | //mw = 0; // test SIGSGV handling |
226 | 226 | ||
227 | mw->netView()->addNewItem( "managed", "Vanille", OMacAddress::fromString("00:00:20:EF:A6:43"), true, 6, 80, GpsLocation( 10.10, 20.20 ) ); | 227 | mw->netView()->addNewItem( "managed", "Vanille", OMacAddress::fromString("00:00:20:EF:A6:43"), true, 6, 80, GpsLocation( 39.8794, -94.0936) ); |
228 | mw->netView()->addNewItem( "managed", "Vanille", OMacAddress::fromString("00:30:6D:EF:A6:23"), true, 11, 10, GpsLocation( 0.0, 0.0 ) ); | 228 | mw->netView()->addNewItem( "managed", "Vanille", OMacAddress::fromString("00:30:6D:EF:A6:23"), true, 11, 10, GpsLocation( 0.0, 0.0 ) ); |
229 | mw->netView()->addNewItem( "adhoc", "ELAN", OMacAddress::fromString("00:A0:F8:E7:16:22"), false, 3, 10, GpsLocation( 5.5, 2.3 ) ); | 229 | mw->netView()->addNewItem( "adhoc", "ELAN", OMacAddress::fromString("00:03:F8:E7:16:22"), false, 3, 10, GpsLocation( 5.5, 2.3 ) ); |
230 | mw->netView()->addNewItem( "adhoc", "ELAN", OMacAddress::fromString("00:AA:01:E7:56:62"), false, 3, 15, GpsLocation( 2.3, 5.5 ) ); | 230 | mw->netView()->addNewItem( "adhoc", "ELAN", OMacAddress::fromString("00:04:01:E7:56:62"), false, 3, 15, GpsLocation( 2.3, 5.5 ) ); |
231 | mw->netView()->addNewItem( "adhoc", "ELAN", OMacAddress::fromString("00:B0:8E:E7:56:E2"), false, 3, 20, GpsLocation( -10.0, -20.5 ) ); | 231 | mw->netView()->addNewItem( "adhoc", "ELAN", OMacAddress::fromString("00:05:8E:E7:56:E2"), false, 3, 20, GpsLocation( -10.0, -20.5 ) ); |
232 | } | 232 | } |
233 | 233 | ||
234 | 234 | ||
diff --git a/noncore/net/wellenreiter/gui/scanlist.cpp b/noncore/net/wellenreiter/gui/scanlist.cpp index 1cca507..d89c71f 100644 --- a/noncore/net/wellenreiter/gui/scanlist.cpp +++ b/noncore/net/wellenreiter/gui/scanlist.cpp | |||
@@ -189,7 +189,7 @@ void MScanListView::addNewItem( const QString& type, | |||
189 | 189 | ||
190 | MScanListItem* station = new MScanListItem( network, type, "", macaddr, wep, channel, signal ); | 190 | MScanListItem* station = new MScanListItem( network, type, "", macaddr, wep, channel, signal ); |
191 | station->setManufacturer( mac.manufacturer() ); | 191 | station->setManufacturer( mac.manufacturer() ); |
192 | station->setLocation( loc.latitude, loc.longitude ); | 192 | station->setLocation( loc.dmsPosition() ); |
193 | 193 | ||
194 | if ( type == "managed" ) | 194 | if ( type == "managed" ) |
195 | { | 195 | { |
@@ -533,12 +533,9 @@ void MScanListItem::setManufacturer( const QString& manufacturer ) | |||
533 | } | 533 | } |
534 | 534 | ||
535 | 535 | ||
536 | void MScanListItem::setLocation( const float& latitude, const float& longitude ) | 536 | void MScanListItem::setLocation( const QString& location ) |
537 | { | 537 | { |
538 | if ( latitude == 0.0 || longitude == 0.0 ) | 538 | setText( col_location, location ); |
539 | setText( col_location, "N/A" ); | ||
540 | else | ||
541 | setText( col_location, QString().sprintf( "%.2f / %.2f", latitude, longitude ) ); | ||
542 | } | 539 | } |
543 | 540 | ||
544 | 541 | ||
diff --git a/noncore/net/wellenreiter/gui/scanlist.h b/noncore/net/wellenreiter/gui/scanlist.h index a9b74f1..6cd8fc0 100644 --- a/noncore/net/wellenreiter/gui/scanlist.h +++ b/noncore/net/wellenreiter/gui/scanlist.h | |||
@@ -103,7 +103,7 @@ class MScanListItem: public OListViewItem | |||
103 | void receivedBeacon(); | 103 | void receivedBeacon(); |
104 | 104 | ||
105 | void setManufacturer( const QString& manufacturer ); | 105 | void setManufacturer( const QString& manufacturer ); |
106 | void setLocation( const float& latitude, const float& longitude ); | 106 | void setLocation( const QString& location ); |
107 | 107 | ||
108 | virtual OListViewItem* childFactory(); | 108 | virtual OListViewItem* childFactory(); |
109 | virtual void serializeTo( QDataStream& s ) const; | 109 | virtual void serializeTo( QDataStream& s ) const; |
diff --git a/noncore/net/wellenreiter/gui/wellenreiter.cpp b/noncore/net/wellenreiter/gui/wellenreiter.cpp index 9255a6d..5575d6e 100644 --- a/noncore/net/wellenreiter/gui/wellenreiter.cpp +++ b/noncore/net/wellenreiter/gui/wellenreiter.cpp | |||
@@ -189,7 +189,7 @@ void Wellenreiter::handleBeacon( OPacket* p, OWaveLanManagementPacket* beacon ) | |||
189 | // TODO: add check if GPS is working!? | 189 | // TODO: add check if GPS is working!? |
190 | qDebug( "Wellenreiter::gathering GPS data..." ); | 190 | qDebug( "Wellenreiter::gathering GPS data..." ); |
191 | loc = gps->position(); | 191 | loc = gps->position(); |
192 | qDebug( "Wellenreiter::GPS data received is ( %f , %f )", loc.latitude, loc.longitude ); | 192 | qDebug( "Wellenreiter::GPS data received is ( %f , %f ) - dms string = '%s'", loc.latitude(), loc.longitude(), loc.dmsPosition().latin1() ); |
193 | } | 193 | } |
194 | 194 | ||
195 | netView()->addNewItem( type, essid, header->macAddress2(), beacon->canPrivacy(), channel, 0, loc ); | 195 | netView()->addNewItem( type, essid, header->macAddress2(), beacon->canPrivacy(), channel, 0, loc ); |