Skip to content

Commit

Permalink
Fixes Lap Swimming import for Garmin Swim drill mode
Browse files Browse the repository at this point in the history
For native FIT and TCX files exported from Garming Connect
  • Loading branch information
amtriathlon committed Nov 24, 2015
1 parent 65f522f commit e74e8fc
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
7 changes: 4 additions & 3 deletions src/FitRideFile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -369,7 +369,8 @@ struct FitFileReaderState
}
break;
case 44: // pool_length
pool_length = value/100000;
pool_length = value / 100000.0;
if (LAPSWIM_DEBUG) qDebug() << "Pool length" << pool_length;
break;
default: ; // do nothing
}
Expand Down Expand Up @@ -915,7 +916,7 @@ struct FitFileReaderState
}

// another pool length or pause
km = last_distance + (kph > 0.0 ? pool_length : 0.0);
km = last_distance + (length_type ? pool_length : 0.0);

if ((secs > last_time + 1) && (isGarminSmartRecording.toInt() != 0) && (secs - last_time < 10*GarminHWM.toInt())) {
double deltaSecs = secs - last_time;
Expand Down Expand Up @@ -945,7 +946,7 @@ struct FitFileReaderState
double deltaSecs = length_duration;
double deltaDist = km - last_distance;
kph = 3600.0 * deltaDist / deltaSecs;
if (LAPSWIM_DEBUG) qDebug() << "Length" << last_time+1 << deltaSecs << deltaDist;
if (LAPSWIM_DEBUG) qDebug() << "Length" << last_time+1 << deltaSecs << deltaDist << "type" << length_type;
for (int i = 1; i <= deltaSecs; i++) {
rideFile->appendPoint(
last_time + i, cad, 0.0,
Expand Down
4 changes: 2 additions & 2 deletions src/TcxParser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,7 @@ TcxParser::endElement( const QString&, const QString&, const QString& qName)

// smart recording is on and delta is less than GarminHWM seconds
// or it is pool swimming and we limit expansion for safety
for(int i = 1; i <= deltaSecs && i <= 10*GarminHWM.toInt(); i++) {
for(int i = 1; i <= deltaSecs && i <= 300*GarminHWM.toInt(); i++) {
double weight = i/ deltaSecs;
double kph = (swim == Swim) ? speed : prevPoint->kph + (deltaSpeed *weight);
// need to make sure speed goes to zero
Expand Down Expand Up @@ -268,7 +268,7 @@ TcxParser::endElement( const QString&, const QString&, const QString& qName)
// expand only if Smart Recording is enabled
if (swim == Swim && distance == 0 && isGarminSmartRecording.toInt()) {
// fill in the pause, partially if too long
for(int i = 1; i <= round(lapSecs) && i <= 10*GarminHWM.toInt(); i++)
for(int i = 1; i <= round(lapSecs) && i <= 300*GarminHWM.toInt(); i++)
rideFile->appendPoint(secs + i,
0.0,
0.0,
Expand Down

0 comments on commit e74e8fc

Please sign in to comment.