From c1791b34389e318d5ff3a07f8be93de759d998cf Mon Sep 17 00:00:00 2001 From: Mark Liversedge Date: Fri, 1 Nov 2013 16:47:15 +0000 Subject: [PATCH] Fix W' calculator for bad data Fix 1s smoothing to ensure time doesn't go backwards as when the same timestamp is used more than once the QwtSpline used to interpolate returns all zeroes. --- src/WPrime.cpp | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/WPrime.cpp b/src/WPrime.cpp index fa8b0c36a..901456c78 100644 --- a/src/WPrime.cpp +++ b/src/WPrime.cpp @@ -71,9 +71,16 @@ WPrime::setRide(RideFile *input) // create a raw time series in the format QwtSpline wants QVector points; int last=0; + RideFilePoint *lp=NULL; foreach(RideFilePoint *p, input->dataPoints()) { - points << QPointF(p->secs, p->watts); + + // lets not go backwards -- or two sampls at the same time + if ((lp && p->secs > lp->secs) || !lp) + points << QPointF(p->secs, p->watts); + + // update state last = p->secs; + lp = p; } // Create a spline