From 41890c852ad6f8bc7b26fd152d63e8ea73defcce Mon Sep 17 00:00:00 2001 From: Mark Liversedge Date: Fri, 29 May 2015 10:18:09 +0100 Subject: [PATCH] Power Zone metric has 1 decimal .. to indicate how far into the zone we got, so 3.1 is 10% into zone 3, whilst 7.9 is seriously high Neuromuscular power, but below Pmax .. we use Pmax to bound the upper value when calculating how deep we got into the very upper zone; so it is possible for the metric to be 8.x when only 7 zones are defined (when the power value is > Pmax) --- src/PeakPower.cpp | 27 +++++++++++++++++++++++++-- 1 file changed, 25 insertions(+), 2 deletions(-) diff --git a/src/PeakPower.cpp b/src/PeakPower.cpp index 8dd9832b2..088622091 100644 --- a/src/PeakPower.cpp +++ b/src/PeakPower.cpp @@ -105,7 +105,7 @@ class PowerZone : public RideMetric { setInternalName("Power Zone"); setName(tr("Power Zone")); setMetricUnits(tr("")); - setPrecision(0); // e.g. 99.9% + setPrecision(1); // e.g. 99.9% setImperialUnits(tr("")); } @@ -130,10 +130,33 @@ class PowerZone : public RideMetric { } else { double ap = deps.value("average_power")->value(true); + double percent=0; // if range is -1 we need to fall back to a default value int zone = zoneRange >= 0 ? zones->whichZone(zoneRange, ap) + 1 : 0; - setValue(zone); + + // ok, how far up the zone was this? + if (zoneRange >= 0 && zone) { + + // get zone info + QString name, description; + int low, high; + zones->zoneInfo(zoneRange, zone-1, name, description, low, high); + + // use Pmax as upper bound, this is used + // for the limit of upper zone ALWAYS + if (high > zones->getPmax(zoneRange)) + high = zones->getPmax(zoneRange); + + // how far in? + percent = double(ap-low) / double(high-low); + + // avoid rounding up ! + if (percent >0.9f && percent <1.00f) percent = 0.9f; + } + + // we want 4.1 as zone, for 10% into zone 4 + setValue(double(zone) + percent); } } RideMetric *clone() const { return new PowerZone(*this); }