1
0
Fork 0

Don't assume that gps times are integer only (some units kick out data at 10hz

and specify time down to tenths of a second.)
This commit is contained in:
curt 2005-07-18 15:03:45 +00:00
parent e4390aac42
commit 44b882abe4
2 changed files with 13 additions and 13 deletions

View file

@ -42,7 +42,7 @@ int GPSTrack::load( const string &file ) {
double raw, min;
if ( tokens[0] == "$GPRMC" && tokens.size() == 13 ) {
int raw_time = atoi(tokens[1].c_str());
double raw_time = atof(tokens[1].c_str());
GPSTime gps_time = GPSTime( raw_time );
if ( (gps_time.get_time() > p.gps_time.get_time()) &&
(p.gps_time.get_time() > 1.0) )
@ -78,9 +78,9 @@ int GPSTrack::load( const string &file ) {
p.course_true = atof( tokens[8].c_str() ) * SGD_DEGREES_TO_RADIANS;
} else if ( tokens[0] == "$GPGGA" && tokens.size() == 15 ) {
int raw_time = atoi(tokens[1].c_str());
double raw_time = atof(tokens[1].c_str());
GPSTime gps_time = GPSTime( raw_time );
if ( (gps_time.get_time() != p.gps_time.get_time()) &&
if ( fabs(gps_time.get_time() - p.gps_time.get_time()) < 0.0001 &&
(p.gps_time.get_time() > 1.0) ) {
// new data cycle store last data before continuing
data.push_back( p );

View file

@ -20,25 +20,25 @@ class GPSTime {
public:
int seconds;
double seconds;
inline GPSTime( const int hh, const int mm, const int ss ) {
inline GPSTime( const int hh, const int mm, const double ss ) {
seconds = hh*3600 + mm*60 + ss;
}
inline GPSTime( const int gpstime ) {
int tmp = gpstime;
int hh = tmp / 10000;
inline GPSTime( const double gpstime ) {
double tmp = gpstime;
int hh = (int)(tmp / 10000);
tmp -= hh * 10000;
int mm = tmp / 100;
int mm = (int)(tmp / 100);
tmp -= mm * 100;
int ss = tmp;
double ss = tmp;
seconds = hh*3600 + mm*60 + ss;
// cout << gpstime << " = " << seconds << endl;
}
inline ~GPSTime() {}
inline int get_time() const { return seconds; }
inline int diff_sec( const GPSTime t ) const {
inline double get_time() const { return seconds; }
inline double diff_sec( const GPSTime t ) const {
return seconds - t.seconds;
}
};
@ -72,7 +72,7 @@ public:
course_true(0.0)
{ }
inline int get_time() const { return gps_time.get_time(); }
inline double get_time() const { return gps_time.get_time(); }
};