Skip to content

Commit

Permalink
Add a TrainingSession::getPolarSportName method #91
Browse files Browse the repository at this point in the history
This will be used soon as a fallback when the Polar session name field
is missing, as is often (always?) the case for the Polar Vantage V.
  • Loading branch information
pcolby committed Mar 13, 2019
1 parent 1517f07 commit 6e6e65d
Show file tree
Hide file tree
Showing 2 changed files with 137 additions and 0 deletions.
136 changes: 136 additions & 0 deletions src/polar/v2/trainingsession.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,142 @@ int TrainingSession::exerciseCount() const
return (isValid()) ? parsedExercises.count() : -1;
}

QString TrainingSession::getPolarSportName(const quint64 &polarSportValue)
{
// Tip: sed -nEe 's/.*sports\[([0-9]+)\].*(".*").*/ {\1, QStringLiteral(\2)},/p' file |
// sed -Ee 's/\{([0-9],)/{ \1/' -e 's/\{([0-9]{2},)/{ \1/' */
static QMap<quint64, QString> map{
{ 1, QStringLiteral("Running")},
{ 2, QStringLiteral("Cycling")},
{ 3, QStringLiteral("Walking")},
{ 4, QStringLiteral("Jogging")},
{ 5, QStringLiteral("Mountain biking")},
{ 6, QStringLiteral("Skiing")},
{ 7, QStringLiteral("Downhill skiing")},
{ 8, QStringLiteral("Rowing")},
{ 9, QStringLiteral("Nordic walking")},
{ 10, QStringLiteral("Skating")},
{ 11, QStringLiteral("Hiking")},
{ 12, QStringLiteral("Tennis")},
{ 13, QStringLiteral("Squash")},
{ 14, QStringLiteral("Badminton")},
{ 15, QStringLiteral("Strength training")},
{ 16, QStringLiteral("Other outdoor")},
{ 17, QStringLiteral("Treadmill running")},
{ 18, QStringLiteral("Indoor cycling")},
{ 19, QStringLiteral("Road running")},
{ 20, QStringLiteral("Circuit training")},
{ 22, QStringLiteral("Snowboarding")},
{ 23, QStringLiteral("Swimming")},
{ 24, QStringLiteral("Freestyle XC skiing")},
{ 25, QStringLiteral("Classic XC skiing")},
{ 27, QStringLiteral("Trail running")},
{ 28, QStringLiteral("Ice skating")},
{ 29, QStringLiteral("Inline skating")},
{ 30, QStringLiteral("Roller skating")},
{ 32, QStringLiteral("Group exercise")},
{ 33, QStringLiteral("Yoga")},
{ 34, QStringLiteral("Crossfit")},
{ 35, QStringLiteral("Golf")},
{ 36, QStringLiteral("Track&amp;field running")},
{ 38, QStringLiteral("Road cycling")},
{ 39, QStringLiteral("Soccer")},
{ 40, QStringLiteral("Cricket")},
{ 41, QStringLiteral("Basketball")},
{ 42, QStringLiteral("Baseball")},
{ 43, QStringLiteral("Rugby")},
{ 44, QStringLiteral("Field hockey")},
{ 45, QStringLiteral("Volleyball")},
{ 46, QStringLiteral("Ice hockey")},
{ 47, QStringLiteral("Football")},
{ 48, QStringLiteral("Handball")},
{ 49, QStringLiteral("Beach volley")},
{ 50, QStringLiteral("Futsal")},
{ 51, QStringLiteral("Floorball")},
{ 52, QStringLiteral("Dancing")},
{ 53, QStringLiteral("Trotting")},
{ 54, QStringLiteral("Riding")},
{ 55, QStringLiteral("Cross-trainer")},
{ 56, QStringLiteral("Fitness martial arts")},
{ 57, QStringLiteral("Functional training")},
{ 58, QStringLiteral("Bootcamp")},
{ 59, QStringLiteral("Freestyle roller skiing")},
{ 60, QStringLiteral("Classic roller skiing")},
{ 61, QStringLiteral("Aerobics")},
{ 62, QStringLiteral("Aqua fitness")},
{ 63, QStringLiteral("Step workout")},
{ 64, QStringLiteral("Body&amp;Mind")},
{ 65, QStringLiteral("Pilates")},
{ 66, QStringLiteral("Stretching")},
{ 67, QStringLiteral("Fitness dancing")},
{ 68, QStringLiteral("Triathlon")},
{ 69, QStringLiteral("Duathlon")},
{ 70, QStringLiteral("Off-road triathlon")},
{ 71, QStringLiteral("Off-road duathlon")},
{ 83, QStringLiteral("Other indoor")},
{ 84, QStringLiteral("Orienteering")},
{ 85, QStringLiteral("Ski orienteering")},
{ 86, QStringLiteral("Mountain bike orienteering")},
{ 87, QStringLiteral("Biathlon")},
{ 88, QStringLiteral("Sailing")},
{ 89, QStringLiteral("Wheelchair racing")},
{ 90, QStringLiteral("Disc golf")},
{ 91, QStringLiteral("Table tennis")},
{ 92, QStringLiteral("Ultra running")},
{ 94, QStringLiteral("Climbing (indoor)")},
{ 95, QStringLiteral("Kayaking")},
{ 96, QStringLiteral("Canoeing")},
{100, QStringLiteral("Kitesurfing")},
{101, QStringLiteral("Windsurfing")},
{102, QStringLiteral("Surfing")},
{103, QStringLiteral("Pool swimming")},
{104, QStringLiteral("Finnish baseball")},
{105, QStringLiteral("Open water swimming")},
{107, QStringLiteral("Wakeboarding")},
{108, QStringLiteral("Water skiing")},
{109, QStringLiteral("Boxing")},
{110, QStringLiteral("Kickboxing")},
{111, QStringLiteral("Mobility (dynamic)")},
{112, QStringLiteral("Telemark skiing")},
{113, QStringLiteral("Backcountry skiing")},
{114, QStringLiteral("Gymnastics")},
{115, QStringLiteral("Judo")},
{116, QStringLiteral("Snowshoe trekking")},
{117, QStringLiteral("Indoor rowing")},
{118, QStringLiteral("Spinning")},
{119, QStringLiteral("Street")},
{120, QStringLiteral("Latin")},
{121, QStringLiteral("Show")},
{122, QStringLiteral("Ballet")},
{123, QStringLiteral("Jazz")},
{124, QStringLiteral("Modern")},
{125, QStringLiteral("Ballroom")},
{126, QStringLiteral("Core")},
{127, QStringLiteral("Mobility (static)")},
{128, QStringLiteral("LES MILLS BODYPUMP")},
{129, QStringLiteral("LES MILLS BODYATTACK")},
{130, QStringLiteral("LES MILLS BODYCOMBAT")},
{131, QStringLiteral("LES MILLS GRIT Cardio")},
{132, QStringLiteral("LES MILLS GRIT Strength")},
{133, QStringLiteral("LES MILLS GRIT Plyo")},
{134, QStringLiteral("LES MILLS SH&#x27;BAM")},
{135, QStringLiteral("LES MILLS RPM")},
{136, QStringLiteral("LES MILLS BODYJAM")},
{137, QStringLiteral("LES MILLS BODYSTEP")},
{138, QStringLiteral("LES MILLS SPRINT")},
{139, QStringLiteral("LES MILLS TONE")},
{140, QStringLiteral("LES MILLS BODYBALANCE")},
{141, QStringLiteral("LES MILLS THE TRIP")},
{142, QStringLiteral("LES MILLS CXWORX")},
{143, QStringLiteral("LES MILLS BARRE")},
};
QMap<quint64, QString>::ConstIterator iter = map.constFind(polarSportValue);
if (iter == map.constEnd()) {
qWarning() << "Unknown polar sport value" << polarSportValue;
}
return (iter == map.constEnd()) ? QString() : iter.value();
}

#define TCX_RUNNING QLatin1String("Running")
#define TCX_BIKING QLatin1String("Biking")
#define TCX_OTHER QLatin1String("Other")
Expand Down
1 change: 1 addition & 0 deletions src/polar/v2/trainingsession.h
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,7 @@ class TrainingSession : public QObject {
HrmOptions hrmOptions;
TcxOptions tcxOptions;

static QString getPolarSportName(const quint64 &polarSportValue);
static QString getTcxCadenceSensor(const quint64 &polarSportValue);
static QString getTcxSport(const quint64 &polarSportValue);
QString getOutputBaseFileName(const QString &format);
Expand Down

0 comments on commit 6e6e65d

Please sign in to comment.