From 8e2ff85aaa0166c3208e9dccedb4e5895d4f1617 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20T=C5=AFma?= Date: Fri, 24 Sep 2021 19:45:17 +0200 Subject: [PATCH] Added support for location files --- src/data/fitparser.cpp | 30 +++++++++++++++++++++++++++++- 1 file changed, 29 insertions(+), 1 deletion(-) diff --git a/src/data/fitparser.cpp b/src/data/fitparser.cpp index 73db21e5..d8b252ab 100644 --- a/src/data/fitparser.cpp +++ b/src/data/fitparser.cpp @@ -6,6 +6,7 @@ #define RECORD_MESSAGE 20 #define EVENT_MESSAGE 21 +#define LOCATION 29 #define COURSE_POINT 32 #define TIMESTAMP_FIELD 253 @@ -343,6 +344,26 @@ bool FITParser::parseData(CTX &ctx, const MessageDefinition *def) waypoint.setName(val.toString()); break; } + } else if (def->globalId == LOCATION) { + switch (field->id) { + case 0: + waypoint.setName(val.toString()); + break; + case 1: + waypoint.rcoordinates().setLat( + (val.toInt() / (double)0x7fffffff) * 180); + break; + case 2: + waypoint.rcoordinates().setLon( + (val.toInt() / (double)0x7fffffff) * 180); + break; + case 4: + waypoint.setElevation((val.toUInt() / 5.0) - 500); + break; + case 6: + waypoint.setDescription(val.toString()); + break; + } } } @@ -367,9 +388,16 @@ bool FITParser::parseData(CTX &ctx, const MessageDefinition *def) ctx.segment.append(ctx.trackpoint); ctx.trackpoint = Trackpoint(); } - } else if (def->globalId == COURSE_POINT) + } else if (def->globalId == COURSE_POINT) { if (waypoint.coordinates().isValid()) ctx.waypoints.append(waypoint); + } else if (def->globalId == LOCATION) { + if (waypoint.coordinates().isValid()) { + waypoint.setTimestamp(QDateTime::fromSecsSinceEpoch(ctx.timestamp + + 631065600, Qt::UTC)); + ctx.waypoints.append(waypoint); + } + } return true; }