1
0
mirror of https://github.com/tumic0/GPXSee.git synced 2024-11-24 03:35:53 +01:00

Handle the whole flags as flags, not as type + flags

This commit is contained in:
Martin Tůma 2022-01-27 00:25:52 +01:00
parent 69ebac9f5d
commit 1f0bd76f67

View File

@ -429,41 +429,45 @@ static quint32 readImageInfo(DataStream &stream, Waypoint &waypoint,
return rs + rh.size; return rs + rh.size;
} }
static int speed(quint8 flags) static int speed(quint16 flags)
{ {
return (((flags >> 3) & 0x0F) * 10) + (((flags >> 2) & 1) * 5); return (((flags >> 3) & 0x0F) * 10) + (((flags >> 2) & 1) * 5);
} }
static bool portable(quint8 flags) static QString units(quint16 flags)
{
return (flags & (1<<8)) ? "km/h" : "mi/h";
}
static bool portable(quint16 flags)
{ {
return (flags & 1); return (flags & 1);
} }
static QString cameraDesc(quint8 type, quint8 flags) static bool redLight(quint16 flags)
{ {
switch (type) { return (flags & (1<<9));
case 8:
return portable(flags)
? QString("<i>%1&nbsp;mi/h</i>").arg(speed(flags))
: QString("%1&nbsp;mi/h").arg(speed(flags));
case 9:
return portable(flags)
? QString("<i>%1&nbsp;km/h</i>").arg(speed(flags))
: QString("%1&nbsp;km/h").arg(speed(flags));
break;
case 10:
case 11:
return "Red light camera";
} }
return QString(); static QString cameraDesc(quint16 flags)
{
if (redLight(flags))
return "Red light camera";
else {
QString desc(QString::number(speed(flags)) + "&nbsp;" + units(flags));
if (portable(flags))
return "<i>" + desc + "<i>";
else
return desc;
}
} }
static quint32 readCamera(DataStream &stream, QVector<Waypoint> &waypoints, static quint32 readCamera(DataStream &stream, QVector<Waypoint> &waypoints,
QList<Area> &polygons) QList<Area> &polygons)
{ {
RecordHeader rh; RecordHeader rh;
quint8 flags, type, s7, rs; quint8 s7, rs;
quint16 flags;
qint32 top, right, bottom, left, lat, lon; qint32 top, right, bottom, left, lat, lon;
quint32 ds = 15; quint32 ds = 15;
@ -473,7 +477,7 @@ static quint32 readCamera(DataStream &stream, QVector<Waypoint> &waypoints,
right = stream.readInt24(); right = stream.readInt24();
bottom = stream.readInt24(); bottom = stream.readInt24();
left = stream.readInt24(); left = stream.readInt24();
stream >> flags >> type >> s7; stream >> flags >> s7;
if (s7) { if (s7) {
quint32 skip = s7 + 2 + s7/4; quint32 skip = s7 + 2 + s7/4;
@ -494,7 +498,7 @@ static quint32 readCamera(DataStream &stream, QVector<Waypoint> &waypoints,
Area area(RectC(Coordinates(toWGS24(left), toWGS24(top)), Area area(RectC(Coordinates(toWGS24(left), toWGS24(top)),
Coordinates(toWGS24(right), toWGS24(bottom)))); Coordinates(toWGS24(right), toWGS24(bottom))));
area.setDescription(cameraDesc(type, flags)); area.setDescription(cameraDesc(flags));
waypoints.append(Coordinates(toWGS24(lon), toWGS24(lat))); waypoints.append(Coordinates(toWGS24(lon), toWGS24(lat)));
polygons.append(area); polygons.append(area);