Fix CP curve only shows first 6 seconds bug

Many thanks to Gary Smith for helping to diagnose and fix
this error. It is caused by ridefiles that have a gap in
recording at the very start of the ride (i.e. the first
sample is > recIntSecs).

Hopefully this means the CP code is now robust. It is also
worth noting that after fixing the erroneous copy/paste
code in compute() it is now 5 times faster than the original
code and computes 5 times more data series.

Fixes #316.
This commit is contained in:
Mark Liversedge
2011-04-26 21:56:05 +01:00
parent e8d213c444
commit 64d44cdd0f

View File

@@ -269,15 +269,13 @@ MeanMaxComputer::run()
// timestamps on each sample
cpintdata data;
data.rec_int_ms = (int) round(ride->recIntSecs() * 1000.0);
double lastsecs = -1;
double lastsecs = 0;
foreach (const RideFilePoint *p, ride->dataPoints()) {
// fill in any gaps in recording - use same dodgy rounding as before
if (lastsecs != -1) {
int count = (p->secs - lastsecs - ride->recIntSecs()) / ride->recIntSecs();
for(int i=0; i<count; i++)
data.points.append(cpintpoint(round(lastsecs+((i+1)*ride->recIntSecs() *1000.0)/1000), 0));
}
int count = (p->secs - lastsecs - ride->recIntSecs()) / ride->recIntSecs();
for(int i=0; i<count; i++)
data.points.append(cpintpoint(round(lastsecs+((i+1)*ride->recIntSecs() *1000.0)/1000), 0));
lastsecs = p->secs;
double secs = round(p->secs * 1000.0) / 1000;