fix neg alt bug in ElevationGain metric

This commit is contained in:
Sean Rhea
2009-12-25 10:09:56 -05:00
parent ed063cf6a4
commit 0d488cb9ea

View File

@@ -126,15 +126,13 @@ class ElevationGain : public RideMetric {
}
void compute(const RideFile *ride, const Zones *, int,
const QHash<QString,RideMetric*> &) {
bool first = true;
foreach (const RideFilePoint *point, ride->dataPoints()) {
if (prevalt <= 0) {
prevalt = point->alt;
} else if (prevalt <= point->alt) {
elegain += (point->alt-prevalt);
prevalt = point->alt;
} else {
prevalt = point->alt;
}
if (first)
first = false;
else if (point->alt > prevalt)
elegain += point->alt - prevalt;
prevalt = point->alt;
}
}
bool canAggregate() const { return true; }