mirror of
https://github.com/GoldenCheetah/GoldenCheetah.git
synced 2026-02-13 16:18:42 +00:00
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:
@@ -37,6 +37,7 @@ vdottime(VDOT, distance)
|
||||
MEAN MAX and ZONE FUNCTIONS
|
||||
best(...)
|
||||
tiz(...)
|
||||
besttime(km)
|
||||
|
||||
PMC FUNCTIONS
|
||||
lts(p1)
|
||||
|
||||
@@ -96,8 +96,9 @@ static struct {
|
||||
{ "unset", 2 }, // unset(symbol, filter)
|
||||
{ "isset", 1 }, // isset(symbol) - is the metric or metadata overridden/defined
|
||||
|
||||
// VDOT functions
|
||||
// VDOT and time/distance functions
|
||||
{ "vdottime", 2 }, // vdottime(VDOT, distance[km]) - result is seconds
|
||||
{ "besttime", 1 }, // besttime(distance[km]) - result is seconds
|
||||
|
||||
// add new ones above this line
|
||||
{ "", -1 }
|
||||
@@ -2198,6 +2199,14 @@ Result Leaf::eval(DataFilterRuntime *df, Leaf *leaf, float x, RideItem *m, RideF
|
||||
}
|
||||
break;
|
||||
|
||||
case 36 :
|
||||
{ // BESTTIME (distance[km])
|
||||
|
||||
if (leaf->fparms.count() != 1 || m->fileCache() == NULL) return Result(0);
|
||||
|
||||
return Result (m->fileCache()->bestTime(eval(df, leaf->fparms[0], x, m, p, c).number));
|
||||
}
|
||||
|
||||
default:
|
||||
return Result(0);
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -224,6 +224,9 @@ class RideFileCache
|
||||
static void doubleArray(QVector<double> &into, QVector<float> &from, RideFile::SeriesType series);
|
||||
static void doubleArrayForDistribution(QVector<double> &into, QVector<float> &from);
|
||||
|
||||
// Best time for distance, used by metrics and Data Filter
|
||||
int bestTime(double km);
|
||||
|
||||
protected:
|
||||
|
||||
void refreshCache(); // compute arrays and update cache
|
||||
|
||||
Reference in New Issue
Block a user