// GPS // // Douglas Thrift // // $Id$ #ifndef _GPS_hpp_ #define _GPS_hpp_ #include #include #include #include namespace GPS { class Error : public std::exception { std::string message; public: Error(); virtual ~Error() throw() {} virtual const char *what() const throw() { return message.c_str(); } }; class GPS { gps_data_t *gps; public: GPS(const std::string &host = _B("localhost"), const std::string &port = _B(DEFAULT_GPSD_PORT)); ~GPS() { ::gps_close(gps); } void Poll(); void Query(const std::string &query); double GetLatitude() { return gps->fix.latitude; } double GetLongitude() { return gps->fix.longitude; } double GetAltitude() { return gps->fix.altitude; } double GetAltitudeFeet() { return GetAltitude() * METERS_TO_FEET; } double GetTrack() { return gps->fix.track; } double GetSpeed() { return gps->fix.speed; } double GetSpeedMPH() { return GetSpeed() * MPS_TO_MPH; } double GetSpeedKMH() { return GetSpeed() * MPS_TO_KPH; } double GetSpeedKnots() { return GetSpeed() * MPS_TO_KNOTS; } double GetClimb() { return gps->fix.climb; } }; } #endif//_GPS_hpp_