From ee4b2221f732166f2c8bea691e29eff2f4cf7f65 Mon Sep 17 00:00:00 2001 From: Rainer Clasen Date: Mon, 26 Aug 2013 21:14:52 +0200 Subject: [PATCH] fix PWX export: handle end of gaps gracefully. As I got it pwx by itself has no concept of recording intervals. "smart recording" and other strange data require variable recoring intervals. On the other hand it's not recording the duration of a sample explicitly. This means the duration needs to be derived from the previous samples timestamp (assuming the sample timestamps are referring to the end of the sampled period). This diff writes an empty timestamp at the end of each gap so that the next real sample/ridepoint can calculate the correct duration. Please note that this may unhide some deficiencies in GCs file reading in exports. --- src/PwxRideFile.cpp | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src/PwxRideFile.cpp b/src/PwxRideFile.cpp index 26432b9cd..6462e3d94 100644 --- a/src/PwxRideFile.cpp +++ b/src/PwxRideFile.cpp @@ -486,7 +486,21 @@ PwxFileReader::writeRideFile(MainWindow *main, const RideFile *ride, QFile &file // samples // data points: timeoffset, dist, hr, spd, pwr, torq, cad, lat, lon, alt if (!ride->dataPoints().empty()) { + int secs = 0; + foreach (const RideFilePoint *point, ride->dataPoints()) { + // if there was a gap, log time when this sample started: + if( secs + ride->recIntSecs() < point->secs ){ + QDomElement sample = doc.createElement("sample"); + root.appendChild(sample); + + QDomElement timeoffset = doc.createElement("timeoffset"); + text = doc.createTextNode(QString("%1") + .arg((int)point->secs - ride->recIntSecs() )); + timeoffset.appendChild(text); + sample.appendChild(timeoffset); + } + QDomElement sample = doc.createElement("sample"); root.appendChild(sample);