mirror of
https://github.com/GoldenCheetah/GoldenCheetah.git
synced 2026-02-13 16:18:42 +00:00
Fix FitRideFile 'hangs'
We now only interpolate for gaps less than 30 minutes since some corrupt files may be longer (or forgot to press stop).
This commit is contained in:
@@ -22,6 +22,7 @@
|
||||
#include <QSet>
|
||||
#include <QtEndian>
|
||||
#include <QDebug>
|
||||
#include <QTime>
|
||||
#include <assert.h>
|
||||
#include <stdio.h>
|
||||
#include <stdint.h>
|
||||
@@ -444,26 +445,32 @@ struct FitFileReaderState
|
||||
double deltaSlope = headwind - prevPoint->slope;
|
||||
double deltaLeftRightBalance = lrbalance - prevPoint->lrbalance;
|
||||
|
||||
for (int i = 1; i < deltaSecs; i++) {
|
||||
double weight = 1.0 * i / deltaSecs;
|
||||
rideFile->appendPoint(
|
||||
prevPoint->secs + (deltaSecs * weight),
|
||||
prevPoint->cad + (deltaCad * weight),
|
||||
prevPoint->hr + (deltaHr * weight),
|
||||
prevPoint->km + (deltaDist * weight),
|
||||
prevPoint->kph + (deltaSpeed * weight),
|
||||
prevPoint->nm + (deltaTorque * weight),
|
||||
prevPoint->watts + (deltaPower * weight),
|
||||
prevPoint->alt + (deltaAlt * weight),
|
||||
(badgps == 1) ? 0 : prevPoint->lon + (deltaLon * weight),
|
||||
(badgps == 1) ? 0 : prevPoint->lat + (deltaLat * weight),
|
||||
prevPoint->headwind + (deltaHeadwind * weight),
|
||||
prevPoint->slope + (deltaSlope * weight),
|
||||
temperature,
|
||||
prevPoint->lrbalance + (deltaLeftRightBalance * weight),
|
||||
interval);
|
||||
// only smooth for less than 30 minutes
|
||||
// we don't want to crash / stall on bad
|
||||
// or corrupt files
|
||||
if (deltaSecs > 0 && deltaSecs < (60*30)) {
|
||||
|
||||
for (int i = 1; i < deltaSecs; i++) {
|
||||
double weight = 1.0 * i / deltaSecs;
|
||||
rideFile->appendPoint(
|
||||
prevPoint->secs + (deltaSecs * weight),
|
||||
prevPoint->cad + (deltaCad * weight),
|
||||
prevPoint->hr + (deltaHr * weight),
|
||||
prevPoint->km + (deltaDist * weight),
|
||||
prevPoint->kph + (deltaSpeed * weight),
|
||||
prevPoint->nm + (deltaTorque * weight),
|
||||
prevPoint->watts + (deltaPower * weight),
|
||||
prevPoint->alt + (deltaAlt * weight),
|
||||
(badgps == 1) ? 0 : prevPoint->lon + (deltaLon * weight),
|
||||
(badgps == 1) ? 0 : prevPoint->lat + (deltaLat * weight),
|
||||
prevPoint->headwind + (deltaHeadwind * weight),
|
||||
prevPoint->slope + (deltaSlope * weight),
|
||||
temperature,
|
||||
prevPoint->lrbalance + (deltaLeftRightBalance * weight),
|
||||
interval);
|
||||
}
|
||||
prevPoint = rideFile->dataPoints().back();
|
||||
}
|
||||
prevPoint = rideFile->dataPoints().back();
|
||||
}
|
||||
|
||||
if (km < 0.00001f) km = last_distance;
|
||||
|
||||
BIN
src/test/rides/2013-04-11-17-32-50.fit
Normal file
BIN
src/test/rides/2013-04-11-17-32-50.fit
Normal file
Binary file not shown.
@@ -63,3 +63,6 @@ lgulseth...pwx
|
||||
A PWX file from a Timex GPS with a permanent recording interval of
|
||||
2 seconds claimed. But looks more like 2.02s.
|
||||
|
||||
2013-04-11-17-32-50.fit
|
||||
A FIT file with a massive gap in recording at the end.
|
||||
|
||||
|
||||
Reference in New Issue
Block a user