mirror of
https://github.com/GoldenCheetah/GoldenCheetah.git
synced 2026-02-13 16:18:42 +00:00
Derive Slope Data
- If Alt data present then calculate slope - Smooth the slope data after calculation
This commit is contained in:
@@ -1363,6 +1363,21 @@ RideFile::recalculateDerivedSeries()
|
||||
p->antiss = anTISS;
|
||||
}
|
||||
|
||||
// Slope
|
||||
// If there is no slope data then it can be derived
|
||||
// from distanct and altitude
|
||||
if (lastP) {
|
||||
if (!dataPresent.slope && dataPresent.alt && dataPresent.km) {
|
||||
double deltaDistance = (p->km - lastP->km) * 1000;
|
||||
double deltaAltitude = p->alt - lastP->alt;
|
||||
if (deltaDistance>0) {
|
||||
p->slope = (deltaAltitude / deltaDistance) * 100;
|
||||
} else {
|
||||
p->slope = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// last point
|
||||
lastP = p;
|
||||
}
|
||||
@@ -1377,6 +1392,24 @@ RideFile::recalculateDerivedSeries()
|
||||
avgPoint->apower = APcount ? (APtotal / APcount) : 0;
|
||||
totalPoint->apower = APtotal;
|
||||
|
||||
// Smooth the slope if it has been derived
|
||||
if (!dataPresent.slope && dataPresent.alt && dataPresent.km) {
|
||||
// initialise rolling average
|
||||
double rtot = 0;
|
||||
for (int i=10; i>0 && dataPoints_.length()-i >=0; i--) {
|
||||
rtot += dataPoints_[dataPoints_.length()-i]->slope;
|
||||
}
|
||||
|
||||
// now run backwards setting the rolling average
|
||||
for (int i=dataPoints_.length()-1; i>=10; i--) {
|
||||
double here = dataPoints_[i]->slope;
|
||||
dataPoints_[i]->slope = rtot / 10;
|
||||
rtot -= here;
|
||||
rtot += dataPoints_[i-10]->slope;
|
||||
}
|
||||
setDataPresent(slope, true);
|
||||
}
|
||||
|
||||
// and we're done
|
||||
dstale=false;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user