mirror of
https://github.com/GoldenCheetah/GoldenCheetah.git
synced 2026-04-15 05:32:21 +00:00
Merge pull request #2616 from amtriathlon/XData
Preserve XData on Activity Split&Combine
This commit is contained in:
@@ -109,6 +109,12 @@ MergeActivityWizard::setRide(RideFile **here, RideFile *with)
|
||||
// data to 'pollute' the process
|
||||
if (with) *here = with->resample(recIntSecs);
|
||||
else *here = NULL;
|
||||
|
||||
// preserve XData
|
||||
if (with && *here) {
|
||||
foreach (XDataSeries *xdata, with->xdata())
|
||||
(*here)->addXData(xdata->name, new XDataSeries(*xdata));
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
@@ -284,6 +290,10 @@ MergeActivityWizard::combine()
|
||||
lp = p;
|
||||
}
|
||||
|
||||
// preserve XData from first ride
|
||||
foreach (XDataSeries *xdata, ride1->xdata())
|
||||
combined->addXData(xdata->name, new XDataSeries (*xdata));
|
||||
|
||||
// now add the data from the second one!
|
||||
double distanceOffset=0;
|
||||
double timeOffset=0;
|
||||
@@ -306,6 +316,28 @@ MergeActivityWizard::combine()
|
||||
combined->appendPoint(add);
|
||||
}
|
||||
|
||||
// and XData from second ride, append if series already present
|
||||
foreach (XDataSeries *xdata, ride2->xdata()) {
|
||||
if (combined->xdata().contains(xdata->name)) {
|
||||
foreach (XDataPoint *point, xdata->datapoints) {
|
||||
XDataPoint *pt = new XDataPoint(*point);
|
||||
pt->secs = point->secs + timeOffset;
|
||||
pt->km = point->km + distanceOffset;
|
||||
combined->xdata(xdata->name)->datapoints.append(pt);
|
||||
}
|
||||
} else {
|
||||
XDataSeries *xd = new XDataSeries(*xdata);
|
||||
xd->datapoints.clear();
|
||||
foreach (XDataPoint *point, xdata->datapoints) {
|
||||
XDataPoint *pt = new XDataPoint(*point);
|
||||
pt->secs = point->secs + timeOffset;
|
||||
pt->km = point->km + distanceOffset;
|
||||
xd->datapoints.append(pt);
|
||||
}
|
||||
combined->addXData(xd->name, xd);
|
||||
}
|
||||
}
|
||||
|
||||
// any intervals with a number name? find the last
|
||||
int intervalN=0;
|
||||
foreach(RideFileInterval *interval, ride1->intervals()) {
|
||||
@@ -376,6 +408,16 @@ MergeActivityWizard::combine()
|
||||
last = add;
|
||||
}
|
||||
|
||||
// Just preserve XData from first ride and add XData from the second,
|
||||
// if not already present, in the future we could let the user to
|
||||
// choose, like for standard series
|
||||
foreach (XDataSeries *xdata, ride1->xdata())
|
||||
combined->addXData(xdata->name, new XDataSeries (*xdata));
|
||||
foreach (XDataSeries *xdata, ride2->xdata()) {
|
||||
if (!combined->xdata().contains(xdata->name))
|
||||
combined->addXData(xdata->name, new XDataSeries (*xdata));
|
||||
}
|
||||
|
||||
// now realign the intervals, first we need to
|
||||
// clear what we already have in combined
|
||||
combined->clearIntervals();
|
||||
@@ -717,7 +759,6 @@ MergeChoose::validatePage()
|
||||
RideFile *ride = RideFileFactory::instance().openRideFile(wizard->context, thisfile, errors, &rides);
|
||||
|
||||
if (ride && ride->dataPoints().count()) {
|
||||
|
||||
wizard->setRide(&wizard->ride2, ride);
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -792,10 +792,29 @@ SplitConfirm::createRideFile(long start, long stop)
|
||||
p->interval);
|
||||
}
|
||||
|
||||
double startTime = ride->dataPoints().at(start)->secs;
|
||||
double stopTime = ride->dataPoints().at(stop)->secs;
|
||||
|
||||
// and the XData Series, check in bounds too!
|
||||
foreach (XDataSeries *xdata, ride->xdata()) {
|
||||
XDataSeries* xd = new XDataSeries(*xdata);
|
||||
xd->datapoints.clear();
|
||||
foreach (XDataPoint *point, xdata->datapoints) {
|
||||
if (point->secs >= startTime && point->secs <= stopTime) {
|
||||
XDataPoint *pt = new XDataPoint(*point);
|
||||
pt->secs = point->secs - offset;
|
||||
pt->km = point->km - distanceoffset;
|
||||
xd->datapoints.append(pt);
|
||||
}
|
||||
}
|
||||
if (xd->datapoints.count() > 0)
|
||||
returning->addXData(xd->name, xd);
|
||||
else
|
||||
delete xd;
|
||||
}
|
||||
|
||||
// lets keep intervals that start in our section truncating them
|
||||
// if neccessary (some folks want to keep lap markers)
|
||||
double startTime = wizard->rideItem->ride()->dataPoints().at(start)->secs;
|
||||
double stopTime = wizard->rideItem->ride()->dataPoints().at(stop)->secs;
|
||||
foreach (RideFileInterval *interval, wizard->rideItem->ride()->intervals()) {
|
||||
|
||||
if (interval->start >= startTime && interval->start <= stopTime) {
|
||||
|
||||
Reference in New Issue
Block a user