mirror of
https://github.com/tumic0/GPXSee.git
synced 2025-05-04 10:27:44 +02:00
Code cleanup
This commit is contained in:
parent
ed7fc5fba3
commit
0d9daf8b4f
@ -44,6 +44,15 @@ ISO8211::SubFieldDefinition ISO8211::fieldType(const QString &str, int cnt)
|
|||||||
return SubFieldDefinition();
|
return SubFieldDefinition();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const ISO8211::Field *ISO8211::Record::field(quint32 name) const
|
||||||
|
{
|
||||||
|
for (int i = 0; i < size(); i++)
|
||||||
|
if (at(i).tag() == name)
|
||||||
|
return &at(i);
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
int ISO8211::readDR(QVector<FieldDefinition> &fields)
|
int ISO8211::readDR(QVector<FieldDefinition> &fields)
|
||||||
{
|
{
|
||||||
DR ddr;
|
DR ddr;
|
||||||
@ -275,16 +284,12 @@ bool ISO8211::readRecord(Record &record)
|
|||||||
|
|
||||||
FieldsMap::const_iterator it(_map.find(def.tag));
|
FieldsMap::const_iterator it(_map.find(def.tag));
|
||||||
if (it == _map.constEnd()) {
|
if (it == _map.constEnd()) {
|
||||||
QByteArray tag(sizeof(quint32), Qt::Initialization::Uninitialized);
|
_errorString = QString("%1: unknown record").arg(NAME(def.tag));
|
||||||
qToLittleEndian<quint32>(def.tag, tag.data());
|
|
||||||
_errorString = QString("%1: unknown record").arg(QString(tag));
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!readUDA(pos, def, it->defs(), it->repeat(), data)) {
|
if (!readUDA(pos, def, it->defs(), it->repeat(), data)) {
|
||||||
QByteArray tag(sizeof(quint32), Qt::Initialization::Uninitialized);
|
_errorString = QString("Error reading %1 record").arg(NAME(def.tag));
|
||||||
qToLittleEndian<quint32>(def.tag, tag.data());
|
|
||||||
_errorString = QString("Error reading %1 record").arg(QString(tag));
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -294,11 +299,9 @@ bool ISO8211::readRecord(Record &record)
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
const ISO8211::Field *ISO8211::Record::field(quint32 name) const
|
QString ISO8211::NAME(quint32 tag)
|
||||||
{
|
{
|
||||||
for (int i = 0; i < size(); i++)
|
QByteArray ba(sizeof(quint32), Qt::Initialization::Uninitialized);
|
||||||
if (at(i).tag() == name)
|
qToLittleEndian<quint32>(tag, ba.data());
|
||||||
return &at(i);
|
return QString::fromLatin1(ba);
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
@ -38,13 +38,14 @@ public:
|
|||||||
bool atEnd() const {return _file.atEnd();}
|
bool atEnd() const {return _file.atEnd();}
|
||||||
const QString &errorString() const {return _errorString;}
|
const QString &errorString() const {return _errorString;}
|
||||||
|
|
||||||
static constexpr quint32 NAME(const char str[4])
|
static constexpr quint32 TAG(const char name[4])
|
||||||
{
|
{
|
||||||
return static_cast<quint32>(str[0])
|
return static_cast<quint32>(name[0])
|
||||||
+ (static_cast<quint32>(str[1]) << 8)
|
+ (static_cast<quint32>(name[1]) << 8)
|
||||||
+ (static_cast<quint32>(str[2]) << 16)
|
+ (static_cast<quint32>(name[2]) << 16)
|
||||||
+ (static_cast<quint32>(str[3]) << 24);
|
+ (static_cast<quint32>(name[3]) << 24);
|
||||||
}
|
}
|
||||||
|
static QString NAME(quint32 tag);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
enum FieldType {Unknown, String, Array, S8, S16, S32, U8, U16, U32};
|
enum FieldType {Unknown, String, Array, S8, S16, S32, U8, U16, U32};
|
||||||
|
@ -15,14 +15,14 @@ using namespace ENC;
|
|||||||
#define PRIM_L 2
|
#define PRIM_L 2
|
||||||
#define PRIM_A 3
|
#define PRIM_A 3
|
||||||
|
|
||||||
constexpr quint32 SG2D = ISO8211::NAME("SG2D");
|
constexpr quint32 SG2D = ISO8211::TAG("SG2D");
|
||||||
constexpr quint32 SG3D = ISO8211::NAME("SG3D");
|
constexpr quint32 SG3D = ISO8211::TAG("SG3D");
|
||||||
constexpr quint32 FSPT = ISO8211::NAME("FSPT");
|
constexpr quint32 FSPT = ISO8211::TAG("FSPT");
|
||||||
constexpr quint32 VRPT = ISO8211::NAME("VRPT");
|
constexpr quint32 VRPT = ISO8211::TAG("VRPT");
|
||||||
constexpr quint32 ATTF = ISO8211::NAME("ATTF");
|
constexpr quint32 ATTF = ISO8211::TAG("ATTF");
|
||||||
constexpr quint32 VRID = ISO8211::NAME("VRID");
|
constexpr quint32 VRID = ISO8211::TAG("VRID");
|
||||||
constexpr quint32 FRID = ISO8211::NAME("FRID");
|
constexpr quint32 FRID = ISO8211::TAG("FRID");
|
||||||
constexpr quint32 DSPM = ISO8211::NAME("DSPM");
|
constexpr quint32 DSPM = ISO8211::TAG("DSPM");
|
||||||
|
|
||||||
static QMap<uint,uint> orderMapInit()
|
static QMap<uint,uint> orderMapInit()
|
||||||
{
|
{
|
||||||
|
@ -12,7 +12,7 @@ using namespace ENC;
|
|||||||
#define EPSILON 1e-6
|
#define EPSILON 1e-6
|
||||||
#define TILE_SIZE 512
|
#define TILE_SIZE 512
|
||||||
|
|
||||||
constexpr quint32 CATD = ISO8211::NAME("CATD");
|
constexpr quint32 CATD = ISO8211::TAG("CATD");
|
||||||
|
|
||||||
Range ENCAtlas::zooms(IntendedUsage usage)
|
Range ENCAtlas::zooms(IntendedUsage usage)
|
||||||
{
|
{
|
||||||
|
@ -15,11 +15,11 @@ using namespace ENC;
|
|||||||
#define EPSILON 1e-6
|
#define EPSILON 1e-6
|
||||||
#define TILE_SIZE 512
|
#define TILE_SIZE 512
|
||||||
|
|
||||||
constexpr quint32 SG2D = ISO8211::NAME("SG2D");
|
constexpr quint32 SG2D = ISO8211::TAG("SG2D");
|
||||||
constexpr quint32 SG3D = ISO8211::NAME("SG3D");
|
constexpr quint32 SG3D = ISO8211::TAG("SG3D");
|
||||||
constexpr quint32 VRID = ISO8211::NAME("VRID");
|
constexpr quint32 VRID = ISO8211::TAG("VRID");
|
||||||
constexpr quint32 DSID = ISO8211::NAME("DSID");
|
constexpr quint32 DSID = ISO8211::TAG("DSID");
|
||||||
constexpr quint32 DSPM = ISO8211::NAME("DSPM");
|
constexpr quint32 DSPM = ISO8211::TAG("DSPM");
|
||||||
|
|
||||||
static Range zooms(const RectC &bounds)
|
static Range zooms(const RectC &bounds)
|
||||||
{
|
{
|
||||||
|
Loading…
x
Reference in New Issue
Block a user