mirror of
https://github.com/GoldenCheetah/GoldenCheetah.git
synced 2026-02-13 08:08:42 +00:00
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:
@@ -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;
|
||||
|
||||
2
src/test/rides/2009_09_19_09_22_42.tcx
Normal file
2
src/test/rides/2009_09_19_09_22_42.tcx
Normal file
File diff suppressed because one or more lines are too long
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user