mirror of
https://github.com/tumic0/GPXSee.git
synced 2024-11-28 13:41:16 +01:00
Code cleanup
This commit is contained in:
parent
ef011cad67
commit
cb9606e057
@ -149,19 +149,9 @@ bool EXIFParser::readIFD(TIFFFile &file, quint32 offset,
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool EXIFParser::parseTIFF(QDataStream &stream, QVector<Waypoint> &waypoints)
|
bool EXIFParser::parseTIFF(QFile *file, QVector<Waypoint> &waypoints)
|
||||||
{
|
{
|
||||||
quint16 size;
|
TIFFFile tiff(file);
|
||||||
char magic[6];
|
|
||||||
|
|
||||||
stream >> size;
|
|
||||||
if (stream.readRawData(magic, sizeof(magic)) != sizeof(magic) ||
|
|
||||||
memcmp(magic, "Exif\0\0", sizeof(magic))) {
|
|
||||||
_errorString = "No EXIF data found";
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
TIFFFile tiff(stream.device());
|
|
||||||
if (!tiff.isValid()) {
|
if (!tiff.isValid()) {
|
||||||
_errorString = "Invalid EXIF data";
|
_errorString = "Invalid EXIF data";
|
||||||
return false;
|
return false;
|
||||||
@ -201,7 +191,6 @@ bool EXIFParser::parseTIFF(QDataStream &stream, QVector<Waypoint> &waypoints)
|
|||||||
}
|
}
|
||||||
|
|
||||||
Waypoint wp(c);
|
Waypoint wp(c);
|
||||||
QFile *file = static_cast<QFile*>(stream.device());
|
|
||||||
wp.setName(QFileInfo(file->fileName()).baseName());
|
wp.setName(QFileInfo(file->fileName()).baseName());
|
||||||
wp.setImage(file->fileName());
|
wp.setImage(file->fileName());
|
||||||
wp.setElevation(altitude(tiff, gps.value(GPSAltitude),
|
wp.setElevation(altitude(tiff, gps.value(GPSAltitude),
|
||||||
@ -228,8 +217,16 @@ bool EXIFParser::parse(QFile *file, QList<TrackData> &tracks,
|
|||||||
quint16 marker;
|
quint16 marker;
|
||||||
while (!stream.atEnd()) {
|
while (!stream.atEnd()) {
|
||||||
stream >> marker;
|
stream >> marker;
|
||||||
if (marker == 0xFFE1)
|
if (marker == 0xFFE1) {
|
||||||
return parseTIFF(stream, waypoints);
|
quint16 size;
|
||||||
|
char magic[6];
|
||||||
|
stream >> size;
|
||||||
|
if (stream.readRawData(magic, sizeof(magic)) == sizeof(magic) &&
|
||||||
|
!memcmp(magic, "Exif\0\0", sizeof(magic)))
|
||||||
|
return parseTIFF(file, waypoints);
|
||||||
|
else
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
_errorString = "No EXIF data found";
|
_errorString = "No EXIF data found";
|
||||||
|
@ -4,7 +4,6 @@
|
|||||||
#include <QDateTime>
|
#include <QDateTime>
|
||||||
#include "parser.h"
|
#include "parser.h"
|
||||||
|
|
||||||
class QDataStream;
|
|
||||||
class TIFFFile;
|
class TIFFFile;
|
||||||
|
|
||||||
class EXIFParser : public Parser
|
class EXIFParser : public Parser
|
||||||
@ -24,7 +23,7 @@ private:
|
|||||||
quint32 offset;
|
quint32 offset;
|
||||||
};
|
};
|
||||||
|
|
||||||
bool parseTIFF(QDataStream &stream, QVector<Waypoint> &waypoints);
|
bool parseTIFF(QFile *file, QVector<Waypoint> &waypoints);
|
||||||
bool readIFD(TIFFFile &file, quint32 offset, const QSet<quint16> &tags,
|
bool readIFD(TIFFFile &file, quint32 offset, const QSet<quint16> &tags,
|
||||||
QMap<quint16, IFDEntry> &entries) const;
|
QMap<quint16, IFDEntry> &entries) const;
|
||||||
bool readEntry(TIFFFile &file, const QSet<quint16> &tags,
|
bool readEntry(TIFFFile &file, const QSet<quint16> &tags,
|
||||||
|
Loading…
Reference in New Issue
Block a user