diff --git a/utils/GPSsmooth/gps.cxx b/utils/GPSsmooth/gps.cxx index 54bdeb48f..f266623fb 100644 --- a/utils/GPSsmooth/gps.cxx +++ b/utils/GPSsmooth/gps.cxx @@ -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 ); diff --git a/utils/GPSsmooth/gps.hxx b/utils/GPSsmooth/gps.hxx index 6a6137ace..3daea45a0 100644 --- a/utils/GPSsmooth/gps.hxx +++ b/utils/GPSsmooth/gps.hxx @@ -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(); } };