mirror of
https://github.com/GoldenCheetah/GoldenCheetah.git
synced 2026-02-13 08:08:42 +00:00
Better support for Negative, Inf, NaN and High Values
Some ride file formats use -1 to indicate sensor not present or data loss (e.g. TPX) and on occasion a NaN or Infinite value will be presented. This patch handles this by converting negative data sample values to zero and handling out of bounds values when selecting zone ranges. This is not a substitute for better handling of poor ride data but it reduces the effect. Also fixes #311.
This commit is contained in:
committed by
Gareth Coco
parent
57c7260a19
commit
00959bed8c
@@ -440,7 +440,10 @@ int HrZones::whichZone(int rnum, double value) const
|
||||
if ((value >= info.lo) && (value < info.hi))
|
||||
return j;
|
||||
}
|
||||
return -1;
|
||||
|
||||
// if we got here either it is negative, nan, inf or way high
|
||||
if (value < 0 || isnan(value)) return 0;
|
||||
else return range.zones.size()-1;
|
||||
}
|
||||
|
||||
void HrZones::zoneInfo(int rnum, int znum,
|
||||
|
||||
@@ -287,6 +287,17 @@ void RideFile::appendPoint(double secs, double cad, double hr, double km,
|
||||
double kph, double nm, double watts, double alt,
|
||||
double lon, double lat, double headwind, int interval)
|
||||
{
|
||||
// negative values are not good, make them zero
|
||||
// although alt, lat, lon, headwind can be negative of course!
|
||||
if (secs<0) secs=0;
|
||||
if (cad<0) cad=0;
|
||||
if (hr<0) hr=0;
|
||||
if (km<0) km=0;
|
||||
if (kph<0) kph=0;
|
||||
if (nm<0) nm=0;
|
||||
if (watts<0) watts=0;
|
||||
if (interval<0) interval=0;
|
||||
|
||||
dataPoints_.append(new RideFilePoint(secs, cad, hr, km, kph,
|
||||
nm, watts, alt, lon, lat, headwind, interval));
|
||||
dataPresent.secs |= (secs != 0);
|
||||
|
||||
@@ -437,7 +437,10 @@ int Zones::whichZone(int rnum, double value) const
|
||||
if ((value >= info.lo) && (value < info.hi))
|
||||
return j;
|
||||
}
|
||||
return -1;
|
||||
|
||||
// if we got here either it is negative, nan, inf or way high
|
||||
if (value < 0 || isnan(value)) return 0;
|
||||
else return range.zones.size()-1;
|
||||
}
|
||||
|
||||
void Zones::zoneInfo(int rnum, int znum,
|
||||
|
||||
Reference in New Issue
Block a user