ViewVC Help
View File | Revision Log | Show Annotations | Download File | View Changeset | Root Listing
root/truck/GPS/GPS.hpp
Revision: 25
Committed: 2008-02-09T01:39:22-08:00 (17 years, 4 months ago) by douglas
File size: 1138 byte(s)
Log Message:
All kinds of changes!

File Contents

# Content
1 // GPS
2 //
3 // Douglas Thrift
4 //
5 // $Id$
6
7 #ifndef _GPS_hpp_
8 #define _GPS_hpp_
9
10 #include <cmath>
11 #include <string>
12
13 #include <truck.hpp>
14
15 #include <gps.h>
16
17 namespace GPS
18 {
19
20 class Error : public std::exception
21 {
22 std::string message;
23 public:
24 Error();
25 virtual ~Error() throw() {}
26 virtual const char *what() const throw() { return message.c_str(); }
27 };
28
29 class GPS
30 {
31 gps_data_t *gps;
32 public:
33 GPS(const std::string &host = _B("localhost"), const std::string &port = _B(DEFAULT_GPSD_PORT));
34 ~GPS() { ::gps_close(gps); }
35 void Poll();
36 void Query(const std::string &query);
37 double GetLatitude() { return gps->fix.latitude; }
38 double GetLongitude() { return gps->fix.longitude; }
39 double GetAltitude() { return gps->fix.altitude; }
40 double GetAltitudeFeet() { return GetAltitude() * METERS_TO_FEET; }
41 double GetTrack() { return gps->fix.track; }
42 double GetSpeed() { return gps->fix.speed; }
43 double GetSpeedMPH() { return GetSpeed() * MPS_TO_MPH; }
44 double GetSpeedKMH() { return GetSpeed() * MPS_TO_KPH; }
45 double GetSpeedKnots() { return GetSpeed() * MPS_TO_KNOTS; }
46 double GetClimb() { return gps->fix.climb; }
47 };
48
49 }
50
51 #endif//_GPS_hpp_

Properties

Name Value
svn:keywords Id