added smart recording support to TcxParser.cpp

The recording interval can vary. If the recording interval is not 1
second, then the data is linearly interpolated for the time period at
1 second intervals. This allows for smart recording or garmin 705 data
drops to work correctly with GC.
This commit is contained in:
Greg Lonnon
2009-09-24 17:07:54 -06:00
committed by Sean Rhea
parent a15904937d
commit 97cb66c128
3 changed files with 51 additions and 2 deletions

View File

@@ -128,9 +128,53 @@ TcxParser::endElement( const QString&, const QString&, const QString& qName)
}
// Record trackpoint
rideFile->appendPoint(secs, cadence, hr, distance,
speed, torque, power, alt, lap);
// for smart recording, the delta_t will not be constant
// average all the calculations based on the previous
// point.
if(rideFile->dataPoints().empty()) {
// first point
rideFile->appendPoint(secs, cadence, hr, distance,
speed, torque, power, alt, lap);
}
else {
// assumption that the change in ride is linear... :)
RideFilePoint *prevPoint = rideFile->dataPoints().back();
double deltaSecs = secs - prevPoint->secs;
double deltaCad = cadence - prevPoint->cad;
double deltaHr = hr - prevPoint->hr;
double deltaDist = distance - prevPoint->km;
double deltaSpeed = speed - prevPoint->kph;
double deltaTorque = torque - prevPoint->nm;
double deltaPower = power - prevPoint->watts;
double deltaAlt = alt - prevPoint->alt;
if(deltaSecs == 1) {
// no smart recording, just insert the data
rideFile->appendPoint(secs, cadence, hr, distance,
speed, torque, power, alt, lap);
}
else {
for(int i = 1; i <= deltaSecs; i++) {
double weight = i/ deltaSecs;
double kph = prevPoint->kph + (deltaSpeed *weight);
// need to make sure speed goes to zero
kph = kph > 0.35 ? kph : 0;
double cad = prevPoint->cad + (deltaCad * weight);
cad = cad > 0.35 ? cad : 0;
rideFile->appendPoint(
prevPoint->secs + (deltaSecs * weight),
prevPoint->cad + (deltaCad * weight),
prevPoint->hr + (deltaHr * weight),
prevPoint->km + (deltaDist * weight),
kph,
prevPoint->nm + (deltaTorque * weight),
prevPoint->watts + (deltaPower * weight),
prevPoint->alt + (deltaAlt * weight),
lap);
}
prevPoint = rideFile->dataPoints().back();
}
}
lastDistance = distance;
}
last_time = time;

File diff suppressed because one or more lines are too long

View File

@@ -1,3 +1,6 @@
2009_09_19_09_22_42.tcx
A TCX file with "smart recording", i.e. variable recording intervals.
2009_08_30_21_17_25.tcx
A TCX file from a Garmin 705. Includes power, altitude, and heart rate
data. Good general case test of TCX import