Added bestime(km) to formulas

To have a general way to track best times for non stardard
distances in Metrics Trends charts and User Defined Metrics.
This commit is contained in:
Alejandro Martinez
2016-07-14 10:35:39 -03:00
parent 4a7b7a7c85
commit e71edb94f6
4 changed files with 27 additions and 1 deletions

View File

@@ -2296,3 +2296,16 @@ RideBest::getForSymbol(QString symbol, bool metric) const
return metricValue;
}
}
int
RideFileCache::bestTime(double km)
{
// divisor for series and conversion from secs to hours
double divisor = pow(10, decimalsFor(RideFile::kph)) * 3600.0;
// linear search over kph mean max array
int secs = 0;
while (secs < kphMeanMax.count() &&
double(kphMeanMax[secs] * secs) / divisor < km) secs++;
if (secs < kphMeanMax.count()) return secs;
return RideFile::NIL;
}