mirror of
https://github.com/tumic0/GPXSee.git
synced 2024-11-24 11:45:53 +01:00
Various code cleanup
This commit is contained in:
parent
680104fec3
commit
f67eaa8dec
@ -91,7 +91,7 @@ IMG::IMG(const QString &fileName)
|
||||
}
|
||||
|
||||
QString fn(QByteArray(name, sizeof(name)));
|
||||
if (VectorTile::isTileFile(tt)) {
|
||||
if (SubFile::isTileFile(tt)) {
|
||||
VectorTile *tile;
|
||||
QMap<QString, VectorTile*>::iterator it = tileMap.find(fn);
|
||||
if (it == tileMap.end()) {
|
||||
|
@ -54,15 +54,18 @@ bool LBLFile::init()
|
||||
{
|
||||
Handle hdl;
|
||||
quint16 codepage;
|
||||
quint8 multiplier, poiMultiplier;
|
||||
|
||||
if (!(seek(hdl, 0x15) && readUInt32(hdl, _offset)
|
||||
&& readUInt32(hdl, _size) && readByte(hdl, _multiplier)
|
||||
&& readUInt32(hdl, _size) && readByte(hdl, multiplier)
|
||||
&& readByte(hdl, _encoding) && seek(hdl, 0x57)
|
||||
&& readUInt32(hdl, _poiOffset) && readUInt32(hdl, _poiSize)
|
||||
&& seek(hdl, 0xAA) && readUInt16(hdl, codepage)))
|
||||
&& readByte(hdl, poiMultiplier) && seek(hdl, 0xAA)
|
||||
&& readUInt16(hdl, codepage)))
|
||||
return false;
|
||||
|
||||
_multiplier = 1<<_multiplier;
|
||||
_multiplier = 1<<multiplier;
|
||||
_poiMultiplier = 1<<poiMultiplier;
|
||||
|
||||
if (codepage == 65001)
|
||||
_codec = QTextCodec::codecForName("UTF-8");
|
||||
@ -162,14 +165,15 @@ Label LBLFile::label8b(Handle &hdl, quint32 offset) const
|
||||
|
||||
Label LBLFile::label(Handle &hdl, quint32 offset, bool poi)
|
||||
{
|
||||
if (!_size && !init())
|
||||
if (!_multiplier && !init())
|
||||
return QString();
|
||||
|
||||
quint32 labelOffset;
|
||||
if (poi) {
|
||||
quint32 poiOffset;
|
||||
if (!(seek(hdl, _poiOffset + offset) && readUInt24(hdl, poiOffset)
|
||||
&& (poiOffset & 0x3FFFFF)))
|
||||
if (!(_poiSize >= offset * _poiMultiplier
|
||||
&& seek(hdl, _poiOffset + offset * _poiMultiplier)
|
||||
&& readUInt24(hdl, poiOffset) && (poiOffset & 0x3FFFFF)))
|
||||
return QString();
|
||||
labelOffset = _offset + (poiOffset & 0x3FFFFF) * _multiplier;
|
||||
} else
|
||||
|
@ -10,8 +10,8 @@ class LBLFile : public SubFile
|
||||
{
|
||||
public:
|
||||
LBLFile(IMG *img, quint32 size)
|
||||
: SubFile(img, size), _offset(0), _size(0), _poiOffset(0), _poiSize(0),
|
||||
_multiplier(0), _encoding(0), _codec(0) {}
|
||||
: SubFile(img, size), _codec(0), _offset(0), _size(0), _poiOffset(0),
|
||||
_poiSize(0), _poiMultiplier(0), _multiplier(0), _encoding(0) {}
|
||||
|
||||
Label label(Handle &hdl, quint32 offset, bool poi = false);
|
||||
|
||||
@ -21,13 +21,14 @@ private:
|
||||
Label label6b(Handle &hdl, quint32 offset) const;
|
||||
Label label8b(Handle &hdl, quint32 offset) const;
|
||||
|
||||
QTextCodec *_codec;
|
||||
quint32 _offset;
|
||||
quint32 _size;
|
||||
quint32 _poiOffset;
|
||||
quint32 _poiSize;
|
||||
quint8 _poiMultiplier;
|
||||
quint8 _multiplier;
|
||||
quint8 _encoding;
|
||||
QTextCodec *_codec;
|
||||
};
|
||||
|
||||
#endif // LBLFILE_H
|
||||
|
@ -3,22 +3,21 @@
|
||||
bool NETFile::init()
|
||||
{
|
||||
Handle hdl;
|
||||
quint8 multiplier;
|
||||
|
||||
if (!(seek(hdl, 0x15) && readUInt32(hdl, _offset)
|
||||
&& readUInt32(hdl, _size) && readByte(hdl, _multiplier)))
|
||||
&& readUInt32(hdl, _size) && readByte(hdl, multiplier)))
|
||||
return false;
|
||||
|
||||
_multiplier = 1<<_multiplier;
|
||||
_multiplier = 1<<multiplier;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool NETFile::lblOffset(Handle &hdl, quint32 netOffset, quint32 &lblOffset)
|
||||
{
|
||||
if (!_init) {
|
||||
if (!(_init = init()))
|
||||
if (!_multiplier && !init())
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!(seek(hdl, _offset + netOffset * _multiplier)
|
||||
&& readUInt24(hdl, lblOffset)))
|
||||
|
@ -6,7 +6,8 @@
|
||||
class NETFile : public SubFile
|
||||
{
|
||||
public:
|
||||
NETFile(IMG *img, quint32 size) : SubFile(img, size), _init(false) {}
|
||||
NETFile(IMG *img, quint32 size)
|
||||
: SubFile(img, size), _offset(0), _size(0), _multiplier(0) {}
|
||||
|
||||
bool lblOffset(Handle &hdl, quint32 netOffset, quint32 &lblOffset);
|
||||
|
||||
@ -16,8 +17,6 @@ private:
|
||||
quint32 _offset;
|
||||
quint32 _size;
|
||||
quint8 _multiplier;
|
||||
|
||||
bool _init;
|
||||
};
|
||||
|
||||
#endif // NETFILE_H
|
||||
|
@ -76,12 +76,12 @@ bool SubFile::readByte(Handle &handle, quint8 &val) const
|
||||
|
||||
quint32 SubFile::size() const
|
||||
{
|
||||
return _img ? _size : (quint32)_file->size();
|
||||
return _file ? (quint32)_file->size() : _size;
|
||||
}
|
||||
|
||||
QString SubFile::fileName() const
|
||||
{
|
||||
return _img ? _img->fileName() : _file->fileName();
|
||||
return _file ? _file->fileName() : _img->fileName();
|
||||
}
|
||||
|
||||
#ifndef QT_NO_DEBUG
|
||||
|
@ -84,6 +84,8 @@ public:
|
||||
QString fileName() const;
|
||||
|
||||
static Type type(const char str[3]);
|
||||
static bool isTileFile(Type type)
|
||||
{return (type == TRE || type == LBL || type == RGN || type == NET);}
|
||||
|
||||
friend QDebug operator<<(QDebug dbg, const SubFile &file);
|
||||
|
||||
|
@ -26,12 +26,6 @@ public:
|
||||
|
||||
friend QDebug operator<<(QDebug dbg, const VectorTile &tile);
|
||||
|
||||
static bool isTileFile(SubFile::Type type)
|
||||
{
|
||||
return (type == SubFile::TRE || type == SubFile::LBL
|
||||
|| type == SubFile::RGN || type == SubFile::NET);
|
||||
}
|
||||
|
||||
private:
|
||||
TREFile *_tre;
|
||||
RGNFile *_rgn;
|
||||
|
Loading…
Reference in New Issue
Block a user