Skip to content

Commit

Permalink
SixCycle Improvements
Browse files Browse the repository at this point in the history
.. get distance/duration in SixCycle::readdir()

.. don't include 0 values in PWX export
  • Loading branch information
liversedge committed Jan 18, 2017
1 parent 4adc774 commit d825428
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 16 deletions.
6 changes: 3 additions & 3 deletions src/Cloud/SixCycle.cpp
Expand Up @@ -236,7 +236,7 @@ SixCycle::readdir(QString path, QStringList &errors, QDateTime from, QDateTime t

// did we get a good response ?
QByteArray r = reply->readAll();
printd("response begins: %s ...\n", r.toStdString().substr(0,300).c_str());
printd("response begins: %s ...\n", r.toStdString().substr(0,900).c_str());

QJsonParseError parseError;
QJsonDocument document = QJsonDocument::fromJson(r, &parseError);
Expand All @@ -259,8 +259,8 @@ SixCycle::readdir(QString path, QStringList &errors, QDateTime from, QDateTime t
add->id = each["url"].toString();
add->label = QString("%1").arg(each["id"].toInt());
add->isDir = false;
add->distance = 0; // NA
add->duration = 0; // NA
add->distance = double(each["meters_in_distance"].toInt()) / 1000.0f;
add->duration = double(each["seconds_in_activity"].toInt());
//add->size
//add->modified

Expand Down
30 changes: 17 additions & 13 deletions src/FileIO/PwxRideFile.cpp
Expand Up @@ -891,19 +891,23 @@ PwxFileReader::writeRideFile(Context *context, const RideFile *ride, QFile &file
sample.appendChild(dist);


// lat
if (ride->areDataPresent()->lat && point->lat > -90.0 && point->lat < 90.0) {
QDomElement lat = doc.createElement("lat");
text = doc.createTextNode(QString("%1").arg(point->lat, 0, 'g', 11));
lat.appendChild(text);
sample.appendChild(lat);
}
// lon
if (ride->areDataPresent()->lon && point->lon > -180.00 && point->lon < 180.00) {
QDomElement lon = doc.createElement("lon");
text = doc.createTextNode(QString("%1").arg(point->lon, 0, 'g', 11));
lon.appendChild(text);
sample.appendChild(lon);
// lat/lon only if both non-zero and valid.
if (point->lat && point->lon) {

// lon
if (ride->areDataPresent()->lat && point->lat > -90.0 && point->lat < 90.0) {
QDomElement lat = doc.createElement("lat");
text = doc.createTextNode(QString("%1").arg(point->lat, 0, 'g', 11));
lat.appendChild(text);
sample.appendChild(lat);
}
// lon
if (ride->areDataPresent()->lon && point->lon > -180.00 && point->lon < 180.00) {
QDomElement lon = doc.createElement("lon");
text = doc.createTextNode(QString("%1").arg(point->lon, 0, 'g', 11));
lon.appendChild(text);
sample.appendChild(lon);
}
}

// alt
Expand Down

0 comments on commit d825428

Please sign in to comment.