Skip to content

Commit

Permalink
Bugfix: If GPS is lost, coordinates default to invalid (0x7FFFFFFF)
Browse files Browse the repository at this point in the history
Invalid coordinates must be ignored, not converted to DEG
  • Loading branch information
adiesner committed Aug 29, 2013
1 parent 22ce76e commit b3ede17
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 9 deletions.
23 changes: 14 additions & 9 deletions src/Fit2TcxConverter.cpp
Expand Up @@ -111,15 +111,20 @@ void Fit2TcxConverter::handle_Record(FitMsg_Record *record) {

string timeId = GpsFunctions::print_dtime(record->getTimestamp());

stringstream lat;
lat.precision(10); // default 4 decimal chars which is not enough
stringstream lon;
lon.precision(10); // default 4 decimal chars which is not enough
lat << SEMI2DEG(record->getPositionLat());
lon << SEMI2DEG(record->getPositionLong());

TcxTrackpoint * point = new TcxTrackpoint(timeId, lat.str(), lon.str());
*(tcxTrack) << point;
TcxTrackpoint * point;
if ((record->getPositionLat() != FIT_POSITION_INVALID) && (record->getPositionLong() != FIT_POSITION_INVALID)) {
stringstream lat;
lat.precision(10); // default 4 decimal chars which is not enough
stringstream lon;
lon.precision(10); // default 4 decimal chars which is not enough
lat << SEMI2DEG(record->getPositionLat());
lon << SEMI2DEG(record->getPositionLong());
point = new TcxTrackpoint(timeId, lat.str(), lon.str());
} else {
point = new TcxTrackpoint(timeId);
}

*(tcxTrack) << point;
trackpointList.push_back(point);

stringstream ss;
Expand Down
1 change: 1 addition & 0 deletions src/fit/fitDefines.hpp
Expand Up @@ -37,6 +37,7 @@ enum FIT_SPORT {
};

#define FIT_ENUM_INVALID (0xFF)
#define FIT_POSITION_INVALID ((signed long)0x7FFFFFFF)

enum FIT_LAP_INTENSITY {
INTENSITY_ACTIVE=0,
Expand Down

0 comments on commit b3ede17

Please sign in to comment.