R GC.activity() improvements

.. don't fill with lots of missing series when they're obscure
.. distinguish between time and seconds
This commit is contained in:
Mark Liversedge
2016-04-13 20:05:19 +01:00
parent f418a8658e
commit 894e694556
2 changed files with 19 additions and 2 deletions

View File

@@ -72,16 +72,27 @@ RTool::activity()
// access via global as this is a static function
if(rtool->context && rtool->context->currentRideItem() && const_cast<RideItem*>(rtool->context->currentRideItem())->ride()) {
// get the ride
RideFile *f = const_cast<RideItem*>(rtool->context->currentRideItem())->ride();
f->recalculateDerivedSeries();
int points = f->dataPoints().count();
// run through each data series adding to the frame, if the
// add in actual time in POSIXct format (via Rcpp::Datetime)
Rcpp::DatetimeVector time(points);
for(int k=0; k<points; k++)
time[k] = Rcpp::Datetime(f->startTime().addSecs(f->dataPoints()[k]->secs).toTime_t());
d["time"] = time;
// now run through each data series adding to the frame, if the
// series does not exist we set all values to NA
for(int i=0; i < static_cast<int>(RideFile::none); i++) {
// what series we working with?
RideFile::SeriesType series = static_cast<RideFile::SeriesType>(i);
// lets not add lots of NA for the more obscure data series
if (i > 15 && !f->isDataPresent(series)) continue;
// set a vector
Rcpp::NumericVector vector(points);
for(int j=0; j<points; j++) {
@@ -95,6 +106,7 @@ RTool::activity()
// use the compatability 'name' to work with e.g. R package trackeR
d[RideFile::seriesName(series, true).toStdString()] = vector;
}
}
return d;
}

View File

@@ -169,7 +169,7 @@ RideFile::seriesName(SeriesType series, bool compat)
{
if (compat) {
switch (series) {
case RideFile::secs: return QString(tr("time"));
case RideFile::secs: return QString(tr("seconds"));
case RideFile::cad: return QString(tr("cadence"));
case RideFile::hr: return QString(tr("heart.rate"));
case RideFile::km: return QString(tr("distance"));
@@ -1212,11 +1212,16 @@ RideFile::isDataPresent(SeriesType series)
{
switch (series) {
case secs : return dataPresent.secs; break;
case cadd :
case cad : return dataPresent.cad; break;
case hrd :
case hr : return dataPresent.hr; break;
case km : return dataPresent.km; break;
case kphd :
case kph : return dataPresent.kph; break;
case nmd :
case nm : return dataPresent.nm; break;
case wattsd :
case watts : return dataPresent.watts; break;
case aPower : return dataPresent.apower; break;
case aTISS : return dataPresent.atiss; break;