1
0
mirror of https://github.com/tumic0/GPXSee.git synced 2025-02-12 14:20:48 +01:00
GPXSee/src/common/garmin.h

42 lines
597 B
C
Raw Normal View History

#ifndef GARMIN_H
#define GARMIN_H
#include <QtGlobal>
#define LS(val, bits) ((qint32)(((quint32)(val))<<(bits)))
inline double toWGS32(qint32 v)
{
return ((double)v / (double)(1U<<31)) * 180.0;
}
2019-11-10 19:48:17 +01:00
inline double toWGS24(qint32 v)
{
return toWGS32(LS(v, 8));
}
inline quint8 vs(const quint8 b0)
{
static const quint8 sizes[] = {4, 1, 2, 1, 3, 1, 2, 1};
return sizes[b0 & 0x07];
}
inline quint8 bs(const quint8 val)
{
return (val + 7) >> 3;
}
2021-03-19 20:09:11 +01:00
inline quint8 byteSize(quint32 val)
{
quint8 ret = 0;
do {
ret++;
val = val >> 8;
} while (val != 0);
return ret;
}
#endif // GARMIN_H