mirror of
https://github.com/tumic0/GPXSee.git
synced 2025-06-01 15:53:04 +02:00
Refactoring
This commit is contained in:
parent
eb81ee9aaa
commit
ba50e67380
@ -298,11 +298,11 @@ bool ISO8211::readRecord(Record &record)
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
const ISO8211::Field *ISO8211::field(const Record &record, quint32 name)
|
const ISO8211::Field *ISO8211::Record::field(quint32 name) const
|
||||||
{
|
{
|
||||||
for (int i = 0; i < record.size(); i++)
|
for (int i = 0; i < size(); i++)
|
||||||
if (record.at(i).tag() == name)
|
if (at(i).tag() == name)
|
||||||
return &record.at(i);
|
return &at(i);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -26,14 +26,17 @@ public:
|
|||||||
Data _data;
|
Data _data;
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef QVector<Field> Record;
|
class Record : public QVector<Field>
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
const Field *field(quint32 name) const;
|
||||||
|
};
|
||||||
|
|
||||||
ISO8211(const QString &path) : _file(path) {}
|
ISO8211(const QString &path) : _file(path) {}
|
||||||
bool readDDR();
|
bool readDDR();
|
||||||
bool readRecord(Record &record);
|
bool readRecord(Record &record);
|
||||||
const QString &errorString() const {return _errorString;}
|
const QString &errorString() const {return _errorString;}
|
||||||
|
|
||||||
static const Field *field(const Record &record, quint32 name);
|
|
||||||
static constexpr quint32 NAME(const char str[4])
|
static constexpr quint32 NAME(const char str[4])
|
||||||
{
|
{
|
||||||
return static_cast<quint32>(str[0])
|
return static_cast<quint32>(str[0])
|
||||||
|
@ -151,9 +151,9 @@ static const ISO8211::Field *SGXD(const ISO8211::Record &r)
|
|||||||
{
|
{
|
||||||
const ISO8211::Field *f;
|
const ISO8211::Field *f;
|
||||||
|
|
||||||
if ((f = ISO8211::field(r, SG2D)))
|
if ((f = r.field(SG2D)))
|
||||||
return f;
|
return f;
|
||||||
else if ((f = ISO8211::field(r, SG3D)))
|
else if ((f = r.field(SG3D)))
|
||||||
return f;
|
return f;
|
||||||
else
|
else
|
||||||
return 0;
|
return 0;
|
||||||
@ -495,7 +495,7 @@ QVector<MapData::Sounding> MapData::soundings(const ISO8211::Record &r,
|
|||||||
uint comf, uint somf)
|
uint comf, uint somf)
|
||||||
{
|
{
|
||||||
QVector<Sounding> s;
|
QVector<Sounding> s;
|
||||||
const ISO8211::Field *f = ISO8211::field(r, SG3D);
|
const ISO8211::Field *f = r.field(SG3D);
|
||||||
if (!f)
|
if (!f)
|
||||||
return QVector<Sounding>();
|
return QVector<Sounding>();
|
||||||
|
|
||||||
@ -517,7 +517,7 @@ QVector<MapData::Sounding> MapData::soundingGeometry(const ISO8211::Record &r,
|
|||||||
quint32 id;
|
quint32 id;
|
||||||
RecordMapIterator it;
|
RecordMapIterator it;
|
||||||
|
|
||||||
const ISO8211::Field *fspt = ISO8211::field(r, FSPT);
|
const ISO8211::Field *fspt = r.field(FSPT);
|
||||||
if (!fspt || fspt->data().at(0).size() != 4)
|
if (!fspt || fspt->data().at(0).size() != 4)
|
||||||
return QVector<Sounding>();
|
return QVector<Sounding>();
|
||||||
|
|
||||||
@ -545,7 +545,7 @@ Coordinates MapData::pointGeometry(const ISO8211::Record &r,
|
|||||||
quint32 id;
|
quint32 id;
|
||||||
RecordMapIterator it;
|
RecordMapIterator it;
|
||||||
|
|
||||||
const ISO8211::Field *fspt = ISO8211::field(r, FSPT);
|
const ISO8211::Field *fspt = r.field(FSPT);
|
||||||
if (!fspt || fspt->data().at(0).size() != 4)
|
if (!fspt || fspt->data().at(0).size() != 4)
|
||||||
return Coordinates();
|
return Coordinates();
|
||||||
|
|
||||||
@ -575,7 +575,7 @@ QVector<Coordinates> MapData::lineGeometry(const ISO8211::Record &r,
|
|||||||
quint8 type;
|
quint8 type;
|
||||||
quint32 id;
|
quint32 id;
|
||||||
|
|
||||||
const ISO8211::Field *fspt = ISO8211::field(r, FSPT);
|
const ISO8211::Field *fspt = r.field(FSPT);
|
||||||
if (!fspt || fspt->data().at(0).size() != 4)
|
if (!fspt || fspt->data().at(0).size() != 4)
|
||||||
return QVector<Coordinates>();
|
return QVector<Coordinates>();
|
||||||
|
|
||||||
@ -588,7 +588,7 @@ QVector<Coordinates> MapData::lineGeometry(const ISO8211::Record &r,
|
|||||||
if (it == ve.constEnd())
|
if (it == ve.constEnd())
|
||||||
return QVector<Coordinates>();
|
return QVector<Coordinates>();
|
||||||
const ISO8211::Record &frid = it.value();
|
const ISO8211::Record &frid = it.value();
|
||||||
const ISO8211::Field *vrpt = ISO8211::field(frid, VRPT);
|
const ISO8211::Field *vrpt = frid.field(VRPT);
|
||||||
if (!vrpt || vrpt->data().size() != 2)
|
if (!vrpt || vrpt->data().size() != 2)
|
||||||
return QVector<Coordinates>();
|
return QVector<Coordinates>();
|
||||||
|
|
||||||
@ -641,7 +641,7 @@ Polygon MapData::polyGeometry(const ISO8211::Record &r, const RecordMap &vc,
|
|||||||
quint8 type;
|
quint8 type;
|
||||||
quint32 id;
|
quint32 id;
|
||||||
|
|
||||||
const ISO8211::Field *fspt = ISO8211::field(r, FSPT);
|
const ISO8211::Field *fspt = r.field(FSPT);
|
||||||
if (!fspt || fspt->data().at(0).size() != 4)
|
if (!fspt || fspt->data().at(0).size() != 4)
|
||||||
return Polygon();
|
return Polygon();
|
||||||
|
|
||||||
@ -660,7 +660,7 @@ Polygon MapData::polyGeometry(const ISO8211::Record &r, const RecordMap &vc,
|
|||||||
if (it == ve.constEnd())
|
if (it == ve.constEnd())
|
||||||
return Polygon();
|
return Polygon();
|
||||||
const ISO8211::Record &frid = it.value();
|
const ISO8211::Record &frid = it.value();
|
||||||
const ISO8211::Field *vrpt = ISO8211::field(frid, VRPT);
|
const ISO8211::Field *vrpt = frid.field(VRPT);
|
||||||
if (!vrpt || vrpt->data().size() != 2)
|
if (!vrpt || vrpt->data().size() != 2)
|
||||||
return Polygon();
|
return Polygon();
|
||||||
|
|
||||||
@ -723,7 +723,7 @@ MapData::Attributes MapData::attributes(const ISO8211::Record &r)
|
|||||||
{
|
{
|
||||||
Attributes attr;
|
Attributes attr;
|
||||||
|
|
||||||
const ISO8211::Field *attf = ISO8211::field(r, ATTF);
|
const ISO8211::Field *attf = r.field(ATTF);
|
||||||
if (!(attf && attf->data().at(0).size() == 2))
|
if (!(attf && attf->data().at(0).size() == 2))
|
||||||
return attr;
|
return attr;
|
||||||
|
|
||||||
|
@ -63,9 +63,9 @@ static const ISO8211::Field *SGXD(const ISO8211::Record &r)
|
|||||||
{
|
{
|
||||||
const ISO8211::Field *f;
|
const ISO8211::Field *f;
|
||||||
|
|
||||||
if ((f = ISO8211::field(r, SG2D)))
|
if ((f = r.field(SG2D)))
|
||||||
return f;
|
return f;
|
||||||
else if ((f = ISO8211::field(r, SG3D)))
|
else if ((f = r.field(SG3D)))
|
||||||
return f;
|
return f;
|
||||||
else
|
else
|
||||||
return 0;
|
return 0;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user