API Fetch Activity format=...

.. when retreiving an activity using the API
   you can now specify the format you want the
   data to be returned in.

   it can be one of;
   tcx - garmin training centre xml
   pwx - training peaks xml
   json - goldencheetah json
   csv - all available data (not powertap csv)

.. along the way the file writers for the respective
   formats now accept a NULL context to work standalone.
   this may be useful as a file conversion tool.
This commit is contained in:
Mark Liversedge
2015-09-08 21:13:17 +01:00
parent 1d1508c524
commit d95ec38593
4 changed files with 258 additions and 164 deletions

View File

@@ -616,9 +616,11 @@ RideFile *RideFileFactory::openRideFile(Context *context, QFile &file,
// Construct the summary text used on the calendar
QString calendarText;
foreach (FieldDefinition field, context->athlete->rideMetadata()->getFields()) {
if (field.diary == true && result->getTag(field.name, "") != "") {
calendarText += field.calendarText(result->getTag(field.name, ""));
if (context) { // will be null in standalone open
foreach (FieldDefinition field, context->athlete->rideMetadata()->getFields()) {
if (field.diary == true && result->getTag(field.name, "") != "") {
calendarText += field.calendarText(result->getTag(field.name, ""));
}
}
}
result->setTag("Calendar Text", calendarText);
@@ -627,7 +629,7 @@ RideFile *RideFileFactory::openRideFile(Context *context, QFile &file,
result->setTag("Filename", QFileInfo(file.fileName()).fileName());
result->setTag("Device", result->deviceType());
result->setTag("File Format", result->fileFormat());
result->setTag("Athlete", context->athlete->cyclist);
if (context) result->setTag("Athlete", context->athlete->cyclist);
result->setTag("Year", result->startTime().toString("yyyy"));
result->setTag("Month", result->startTime().toString("MMMM"));
result->setTag("Weekday", result->startTime().toString("ddd"));
@@ -656,7 +658,7 @@ RideFile *RideFileFactory::openRideFile(Context *context, QFile &file,
DataProcessorFactory::instance().autoProcess(result);
// calculate derived data series -- after data fixers applied above
result->recalculateDerivedSeries();
if (context) result->recalculateDerivedSeries();
// what data is present - after processor in case 'derived' or adjusted
QString flags;