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.
This commit is contained in:
Rainer Clasen
2013-08-26 21:14:52 +02:00
committed by Gareth Coco
parent e57ab8a689
commit ee4b2221f7

View File

@@ -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);