mirror of
https://github.com/GoldenCheetah/GoldenCheetah.git
synced 2026-02-14 08:38:45 +00:00
Update of all metrics to work with a RideItem not directly with a RideFile. When iterating over the activity samples we now use a Specification and RideFileIterator to bound the set of samples used. This means that we can compute metrics for intervals without having to create a temporary ridefile. RideItem now has first class members for zoneRange, hrZoneRange and paceZoneRange to avoid calculating for every metric which are stored in RideDB.json. Compare pane continues to construct a ride file when working with intervals since it is used lots of charts, this is unlikely to ever change. A SEGV in compare intervals has been fixed where interval items were repointed to temporary compare pane objects that are deleted - see RideItem::setFrom. THIS COMMIT CONTAINS 3 REGRESSIONS: 1. TcxRideFile no longer computes metrics 2. FitlogRideFile no longer computes metrics 3. WorkoutWizard no longer computes metrics -- The workout wizard will be replaced with a new Workout editor, whilst the RideFile metrics may be deprecated (but considering options)
118 lines
2.7 KiB
C++
118 lines
2.7 KiB
C++
/*
|
|
* Copyright (c) 2014 Mark Liversedge (liversedge@gmail.com)
|
|
*
|
|
* This program is free software; you can redistribute it and/or modify it
|
|
* under the terms of the GNU General Public License as published by the Free
|
|
* Software Foundation; either version 2 of the License, or (at your option)
|
|
* any later version.
|
|
*
|
|
* This program is distributed in the hope that it will be useful, but WITHOUT
|
|
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
|
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
|
|
* more details.
|
|
*
|
|
* You should have received a copy of the GNU General Public License along
|
|
* with this program; if not, write to the Free Software Foundation, Inc., 51
|
|
* Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
|
*/
|
|
|
|
#include "Specification.h"
|
|
#include "RideItem.h"
|
|
#include "IntervalItem.h"
|
|
#include "RideFile.h"
|
|
|
|
Specification::Specification(DateRange dr, FilterSet fs) : dr(dr), fs(fs), it(NULL), recintsecs(0), ri(NULL) {}
|
|
Specification::Specification(IntervalItem *it, double recintsecs) : it(it), recintsecs(recintsecs), ri(NULL) {}
|
|
Specification::Specification() : it(NULL), recintsecs(0), ri(NULL) {}
|
|
|
|
// does the rideitem pass the specification ?
|
|
bool
|
|
Specification::pass(RideItem*item)
|
|
{
|
|
return (dr.pass(item->dateTime.date()) && fs.pass(item->fileName));
|
|
}
|
|
|
|
bool
|
|
Specification::pass(RideFilePoint *p)
|
|
{
|
|
if (it == NULL) return true;
|
|
else if ((p->secs+recintsecs) >= it->start && p->secs <= it->stop) return true;
|
|
return false;
|
|
}
|
|
|
|
// set criteria
|
|
void
|
|
Specification::setDateRange(DateRange dr)
|
|
{
|
|
this->dr = dr;
|
|
}
|
|
|
|
void
|
|
Specification::setFilterSet(FilterSet fs)
|
|
{
|
|
this->fs = fs;
|
|
}
|
|
|
|
void
|
|
Specification::addMatches(QStringList other)
|
|
{
|
|
fs.addFilter(true, other);
|
|
}
|
|
|
|
void
|
|
Specification::setIntervalItem(IntervalItem *it, double recintsecs)
|
|
{
|
|
this->it = it;
|
|
this->recintsecs = recintsecs;
|
|
}
|
|
|
|
double
|
|
Specification::secsStart()
|
|
{
|
|
if (it) return it->start;
|
|
else return -1;
|
|
}
|
|
|
|
double
|
|
Specification::secsEnd()
|
|
{
|
|
if (it) return it->stop;
|
|
else return -1;
|
|
}
|
|
|
|
bool
|
|
Specification::isEmpty(RideFile *ride)
|
|
{
|
|
// its null !
|
|
if (!ride) return true;
|
|
|
|
// no data points
|
|
if (ride->dataPoints().count() <= 0) return true;
|
|
|
|
// interval points yield no points ?
|
|
if (it) {
|
|
RideFileIterator i(ride, *this);
|
|
|
|
// yikes
|
|
if (i.firstIndex() < 0 || i.lastIndex() < 0) return true;
|
|
|
|
// reversed (1s interval has same start and stop)
|
|
if ((i.lastIndex() - i.firstIndex()) < 0) return true;
|
|
}
|
|
|
|
return false;
|
|
}
|
|
|
|
void
|
|
Specification::setRideItem(RideItem *ri)
|
|
{
|
|
this->ri = ri;
|
|
}
|
|
|
|
void
|
|
Specification::print()
|
|
{
|
|
if (it) qDebug()<<it->name<<it->start<<it->stop;
|
|
else qDebug()<<"item";
|
|
}
|