1
0
mirror of https://github.com/tumic0/GPXSee.git synced 2024-11-30 22:51:16 +01:00

ENC map style enhancement

+ code cleanup
This commit is contained in:
Martin Tůma 2022-11-09 21:37:33 +01:00
parent 9d8c23bc32
commit 877d9331e4
4 changed files with 23 additions and 27 deletions

View File

@ -12,5 +12,6 @@
#define OBJNAM 116 #define OBJNAM 116
#define RESTRN 131 #define RESTRN 131
#define VALDCO 174 #define VALDCO 174
#define WATLEV 187
#endif // ENC_ATTRIBUTES_H #endif // ENC_ATTRIBUTES_H

View File

@ -258,7 +258,7 @@ QVector<Coordinates> MapData::lineGeometry(const ISO8211::Record &r,
{ {
QVector<Coordinates> path; QVector<Coordinates> path;
Coordinates c[2]; Coordinates c[2];
uint ORNT, MASK; uint ORNT;
quint8 type; quint8 type;
quint32 id; quint32 id;
@ -270,8 +270,6 @@ QVector<Coordinates> MapData::lineGeometry(const ISO8211::Record &r,
if (!parseNAME(FSPT, &type, &id, i) || type != RCNM_VE) if (!parseNAME(FSPT, &type, &id, i) || type != RCNM_VE)
return QVector<Coordinates>(); return QVector<Coordinates>();
ORNT = FSPT->data().at(i).at(1).toUInt(); ORNT = FSPT->data().at(i).at(1).toUInt();
MASK = FSPT->data().at(i).at(3).toUInt();
Q_ASSERT(MASK != 1);
RecordMapIterator it = ve.find(id); RecordMapIterator it = ve.find(id);
if (it == ve.constEnd()) if (it == ve.constEnd())
@ -326,7 +324,7 @@ Polygon MapData::polyGeometry(const ISO8211::Record &r, const RecordMap &vc,
Polygon path; Polygon path;
QVector<Coordinates> v; QVector<Coordinates> v;
Coordinates c[2]; Coordinates c[2];
uint ORNT, USAG, MASK; uint ORNT, USAG;
quint8 type; quint8 type;
quint32 id; quint32 id;
@ -339,8 +337,6 @@ Polygon MapData::polyGeometry(const ISO8211::Record &r, const RecordMap &vc,
return Polygon(); return Polygon();
ORNT = FSPT->data().at(i).at(1).toUInt(); ORNT = FSPT->data().at(i).at(1).toUInt();
USAG = FSPT->data().at(i).at(2).toUInt(); USAG = FSPT->data().at(i).at(2).toUInt();
MASK = FSPT->data().at(i).at(3).toUInt();
Q_ASSERT(MASK != 1);
if (USAG == 2 && path.isEmpty()) { if (USAG == 2 && path.isEmpty()) {
path.append(v); path.append(v);
@ -420,7 +416,8 @@ MapData::Attr MapData::pointAttr(const ISO8211::Record &r, uint OBJL)
if ((OBJL == HRBFAC && key == CATHAF) if ((OBJL == HRBFAC && key == CATHAF)
|| (OBJL == LNDMRK && key == CATLMK) || (OBJL == LNDMRK && key == CATLMK)
|| (OBJL == WRECKS && key == CATWRK) || (OBJL == WRECKS && key == CATWRK)
|| (OBJL == MORFAC && key == CATMOR)) || (OBJL == MORFAC && key == CATMOR)
|| (OBJL == UWTROC && key == WATLEV))
subtype = av.at(1).toString().toUInt(); subtype = av.at(1).toString().toUInt();
} }
@ -608,7 +605,7 @@ bool MapData::bounds(const QVector<ISO8211::Record> &gv, Rect &b)
return true; return true;
} }
bool MapData::fetchBoundsAndName() MapData::MapData(const QString &path): _fileName(path)
{ {
QFile file(_fileName); QFile file(_fileName);
QVector<ISO8211::Record> gv; QVector<ISO8211::Record> gv;
@ -617,42 +614,34 @@ bool MapData::fetchBoundsAndName()
if (!file.open(QIODevice::ReadOnly)) { if (!file.open(QIODevice::ReadOnly)) {
_errorString = file.errorString(); _errorString = file.errorString();
return false; return;
} }
if (!ddf.readDDR(file)) { if (!ddf.readDDR(file)) {
_errorString = ddf.errorString(); _errorString = ddf.errorString();
return false; return;
} }
while (!file.atEnd()) { while (!file.atEnd()) {
ISO8211::Record record; ISO8211::Record record;
if (!ddf.readRecord(file, record)) { if (!ddf.readRecord(file, record)) {
_errorString = ddf.errorString(); _errorString = ddf.errorString();
return false; return;
} }
if (!processRecord(record, gv, COMF, _name)) if (!processRecord(record, gv, COMF, _name))
return false; return;
} }
Rect b; Rect b;
if (!bounds(gv, b)) { if (!bounds(gv, b)) {
_errorString = "Error fetching geometries bounds"; _errorString = "Error fetching geometries bounds";
return false; return;
} }
RectC br(Coordinates(b.minX() / (double)COMF, b.maxY() / (double)COMF), RectC br(Coordinates(b.minX() / (double)COMF, b.maxY() / (double)COMF),
Coordinates(b.maxX() / (double)COMF, b.minY() / (double)COMF)); Coordinates(b.maxX() / (double)COMF, b.minY() / (double)COMF));
if (!br.isValid()) { if (!br.isValid())
_errorString = "Invalid geometries bounds"; _errorString = "Invalid geometries bounds";
return false; else
} else
_bounds = br; _bounds = br;
return true;
}
MapData::MapData(const QString &path): _fileName(path)
{
fetchBoundsAndName();
} }
MapData::~MapData() MapData::~MapData()

View File

@ -147,8 +147,6 @@ private:
typedef RTree<Line*, double, 2> LineTree; typedef RTree<Line*, double, 2> LineTree;
typedef RTree<Point*, double, 2> PointTree; typedef RTree<Point*, double, 2> PointTree;
bool fetchBoundsAndName();
static QVector<Sounding> soundings(const ISO8211::Record &r, uint COMF, static QVector<Sounding> soundings(const ISO8211::Record &r, uint COMF,
uint SOMF); uint SOMF);
static QVector<Sounding> soundingGeometry(const ISO8211::Record &r, static QVector<Sounding> soundingGeometry(const ISO8211::Record &r,

View File

@ -115,14 +115,22 @@ void Style::defaultPointStyle()
_points[SUBTYPE(LNDMRK, 17)] = Point(QImage(":/marine/tower.png")); _points[SUBTYPE(LNDMRK, 17)] = Point(QImage(":/marine/tower.png"));
_points[TYPE(LNDELV)] = Point(QImage(":/marine/triangulation-point.png")); _points[TYPE(LNDELV)] = Point(QImage(":/marine/triangulation-point.png"));
_points[TYPE(OBSTRN)] = Point(QImage(":/marine/obstruction.png"), Small); _points[TYPE(OBSTRN)] = Point(QImage(":/marine/obstruction.png"), Small);
_points[TYPE(WRECKS)] = Point(QImage(":/marine/wreck.png"), Small);
_points[SUBTYPE(WRECKS, 1)] = Point(QImage(":/marine/wreck.png"), Small); _points[SUBTYPE(WRECKS, 1)] = Point(QImage(":/marine/wreck.png"), Small);
_points[SUBTYPE(WRECKS, 2)] = Point(QImage(":/marine/wreck-dangerous.png"), _points[SUBTYPE(WRECKS, 2)] = Point(QImage(":/marine/wreck-dangerous.png"),
Small); Small);
_points[SUBTYPE(WRECKS, 3)] = Point(QImage(":/marine/wreck.png"), Small); _points[SUBTYPE(WRECKS, 3)] = Point(QImage(":/marine/wreck.png"), Small);
_points[SUBTYPE(WRECKS, 4)] = Point(QImage(":/marine/wreck.png"), Small); _points[SUBTYPE(WRECKS, 4)] = Point(QImage(":/marine/wreck.png"), Small);
_points[SUBTYPE(WRECKS, 5)] = Point(QImage(":/marine/wreck-exposed.png")); _points[SUBTYPE(WRECKS, 5)] = Point(QImage(":/marine/wreck-exposed.png"));
_points[TYPE(UWTROC)] = Point(QImage(":/marine/rock-dangerous.png"), Small); _points[SUBTYPE(UWTROC, 1)] = Point(QImage(":/marine/rock-exposed.png"),
Small);
_points[SUBTYPE(UWTROC, 2)] = Point(QImage(":/marine/rock-exposed.png"),
Small);
_points[SUBTYPE(UWTROC, 3)] = Point(QImage(":/marine/rock-dangerous.png"),
Small);
_points[SUBTYPE(UWTROC, 4)] = Point(QImage(":/marine/rock-dangerous.png"),
Small);
_points[SUBTYPE(UWTROC, 5)] = Point(QImage(":/marine/rock-dangerous.png"),
Small);
_points[SUBTYPE(HRBFAC, 5)] = Point(QImage(":/marine/yacht-harbor.png")); _points[SUBTYPE(HRBFAC, 5)] = Point(QImage(":/marine/yacht-harbor.png"));
_points[TYPE(ACHBRT)] = Point(QImage(":/marine/anchorage.png")); _points[TYPE(ACHBRT)] = Point(QImage(":/marine/anchorage.png"));
_points[TYPE(OFSPLF)] = Point(QImage(":/marine/platform.png")); _points[TYPE(OFSPLF)] = Point(QImage(":/marine/platform.png"));