1
0
mirror of https://github.com/tumic0/GPXSee.git synced 2025-02-07 12:05:14 +01:00
GPXSee/src/common/garmin.h
2021-09-29 19:52:39 +02:00

45 lines
646 B
C++

#ifndef GARMIN_H
#define GARMIN_H
#include <QtGlobal>
#define LS(val, bits) ((qint32)(((quint32)(val))<<(bits)))
namespace Garmin
{
inline double toWGS32(qint32 v)
{
return ((double)v / (double)(1U<<31)) * 180.0;
}
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 quint32 bs(const quint32 val)
{
return (val + 7) >> 3;
}
inline quint8 byteSize(quint32 val)
{
quint8 ret = 0;
do {
ret++;
val = val >> 8;
} while (val != 0);
return ret;
}
}
#endif // GARMIN_H