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) )
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 );
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;
}
};
course_true(0.0)
{ }
- inline int get_time() const { return gps_time.get_time(); }
+ inline double get_time() const { return gps_time.get_time(); }
};