mirror of
https://github.com/GoldenCheetah/GoldenCheetah.git
synced 2026-02-13 16:18:42 +00:00
Better rounding of time in AllPlot
With realtime data there will often be samples with timestamps like 940.002 and 940.998. This cuases an issue on the ride plot, where it believes there is no sample for 941 and therefore plots a zero value. This patch rounds the timestamps to the nearest 100th of a second, which is consistent with the mechanism used in the ride editor.
This commit is contained in:
committed by
Gareth Coco
parent
ca1c4def3a
commit
92897a966b
@@ -701,7 +701,21 @@ AllPlot::setDataFromRide(RideItem *_rideItem)
|
||||
|
||||
arrayLength = 0;
|
||||
foreach (const RideFilePoint *point, ride->dataPoints()) {
|
||||
timeArray[arrayLength] = point->secs;
|
||||
|
||||
// we round the time to nearest 100th of a second
|
||||
// before adding to the array, to avoid situation
|
||||
// where 'high precision' time slice is an artefact
|
||||
// of double precision or slight timing anomalies
|
||||
// e.g. where realtime gives timestamps like
|
||||
// 940.002 followed by 940.998 and were previouslt
|
||||
// both rounded to 940s
|
||||
//
|
||||
// NOTE: this rounding mechanism is identical to that
|
||||
// used by the Ride Editor.
|
||||
double secs = floor(point->secs);
|
||||
double msecs = round((point->secs - secs) * 100) * 10;
|
||||
|
||||
timeArray[arrayLength] = secs + msecs/1000;
|
||||
if (!wattsArray.empty())
|
||||
wattsArray[arrayLength] = max(0, point->watts);
|
||||
if (!hrArray.empty())
|
||||
|
||||
Reference in New Issue
Block a user