From 64d44cdd0ff2df3221c880bf3d6ae1e0d452bf26 Mon Sep 17 00:00:00 2001 From: Mark Liversedge Date: Tue, 26 Apr 2011 21:56:05 +0100 Subject: [PATCH] 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. --- src/RideFileCache.cpp | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/src/RideFileCache.cpp b/src/RideFileCache.cpp index 6bb22f247..8b418a01b 100644 --- a/src/RideFileCache.cpp +++ b/src/RideFileCache.cpp @@ -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; irecIntSecs() *1000.0)/1000), 0)); - } + int count = (p->secs - lastsecs - ride->recIntSecs()) / ride->recIntSecs(); + for(int i=0; irecIntSecs() *1000.0)/1000), 0)); lastsecs = p->secs; double secs = round(p->secs * 1000.0) / 1000;