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)
This commit is contained in:
Mark Liversedge
2015-05-29 10:18:09 +01:00
parent 3dca5ab996
commit 41890c852a

View File

@@ -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); }