diff --git a/src/HrZones.cpp b/src/HrZones.cpp index 1882eeab4..31d08d2c6 100644 --- a/src/HrZones.cpp +++ b/src/HrZones.cpp @@ -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, diff --git a/src/RideFile.cpp b/src/RideFile.cpp index 23d4d9f23..c3911849d 100644 --- a/src/RideFile.cpp +++ b/src/RideFile.cpp @@ -341,6 +341,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); diff --git a/src/Zones.cpp b/src/Zones.cpp index 4147a0f07..9239478b2 100644 --- a/src/Zones.cpp +++ b/src/Zones.cpp @@ -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,