1
0
mirror of https://github.com/tumic0/GPXSee.git synced 2024-10-06 06:43:22 +02:00

Some more inland wates ECDIS style fixes/improvements

This commit is contained in:
Martin Tůma 2022-11-25 02:16:17 +01:00
parent 0c8a77a4ca
commit 04f45013eb
9 changed files with 171 additions and 66 deletions

View File

@ -175,6 +175,7 @@
<file alias="dw-route-line.png">icons/map/marine/dw-route-line.png</file>
<file alias="fence-line.png">icons/map/marine/fence-line.png</file>
<file alias="crane.png">icons/map/marine/crane.png</file>
<file alias="distance-mark.png">icons/map/marine/distance-mark.png</file>
</qresource>
<!-- Mapsforge rendertheme -->

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.5 KiB

View File

@ -3,6 +3,7 @@
#define CATACH 8
#define CATBUA 10
#define CATDIS 21
#define CATHAF 30
#define CATLMK 35
#define CATMOR 40
@ -19,5 +20,7 @@
#define I_CATACH 17000
#define I_RESTRN 17004
#define I_WTWDIS 17064
#define I_HUNITS 17103
#endif // ENC_ATTRIBUTES_H

View File

@ -29,12 +29,14 @@ static QMap<uint,uint> orderMapInit()
map.insert(SUBTYPE(BUAARE, 0), 7);
map.insert(TYPE(BCNISD), 8);
map.insert(TYPE(BCNLAT), 9);
map.insert(TYPE(I_BCNLAT), 9);
map.insert(TYPE(BCNSAW), 10);
map.insert(TYPE(BCNSPP), 11);
map.insert(TYPE(BOYCAR), 12);
map.insert(TYPE(BOYINB), 13);
map.insert(TYPE(BOYISD), 14);
map.insert(TYPE(BOYLAT), 15);
map.insert(TYPE(I_BOYLAT), 15);
map.insert(TYPE(BOYSAW), 16);
map.insert(TYPE(BOYSPP), 17);
map.insert(TYPE(MORFAC), 18);
@ -46,8 +48,12 @@ static QMap<uint,uint> orderMapInit()
map.insert(TYPE(HRBFAC), 24);
map.insert(TYPE(PILPNT), 25);
map.insert(TYPE(ACHBRT), 26);
map.insert(TYPE(LNDELV), 27);
map.insert(TYPE(I_ACHBRT), 26);
map.insert(TYPE(CRANES), 27);
map.insert(TYPE(I_CRANES), 27);
map.insert(TYPE(LNDMRK), 28);
map.insert(TYPE(LNDELV), 29);
map.insert(TYPE(I_DISMAR), 30);
map.insert(TYPE(SOUNDG), 0xFFFFFFFF);
return map;
@ -142,26 +148,6 @@ static bool polygonCb(MapData::Poly *polygon, void *context)
return true;
}
static uint depthLevel(const QString &str)
{
double minDepth = str.isEmpty() ? -1 : str.toDouble();
if (minDepth < 0)
return 0;
else if (minDepth < 2)
return 1;
else if (minDepth < 5)
return 2;
else if (minDepth < 10)
return 3;
else if (minDepth < 20)
return 4;
else if (minDepth < 50)
return 5;
else
return 6;
}
static Coordinates coordinates(int x, int y, uint COMF)
{
return Coordinates(x / (double)COMF, y / (double)COMF);
@ -179,11 +165,85 @@ static Coordinates point(const ISO8211::Record &r, uint COMF)
return coordinates(x, y, COMF);
}
MapData::Point::Point(uint type, const Coordinates &c, const QString &label)
: _type(type), _pos(c), _label(label)
static uint depthLevel(const QByteArray &ba)
{
double minDepth = ba.isEmpty() ? -1 : ba.toDouble();
if (minDepth < 0)
return 0;
else if (minDepth < 2)
return 1;
else if (minDepth < 5)
return 2;
else if (minDepth < 10)
return 3;
else if (minDepth < 20)
return 4;
else if (minDepth < 50)
return 5;
else
return 6;
}
static QString hUnits(uint type)
{
switch (type) {
case 1:
return "m";
case 2:
return "ft";
case 3:
return "km";
case 4:
return "hm";
case 5:
return "mi";
case 6:
return "nm";
default:
return QString();
}
}
MapData::Point::Point(uint type, const Coordinates &c, const QString &label,
const QByteArray &param) : _type(type), _pos(c), _label(label)
{
uint hash = (uint)qHash(QPair<double,double>(c.lon(), c.lat()));
_id = ((quint64)order(type))<<32 | hash;
if ((type & 0xFFFF0000) == TYPE(I_DISMAR)) {
_label = hUnits((type>>8)&0xFF) + " " + QString::fromLatin1(param);
_type = SUBTYPE(I_DISMAR, type & 0xFF);
}
}
MapData::Poly::Poly(uint type, const Polygon &path, const QByteArray &param)
: _type(type), _path(path)
{
if (type == TYPE(DEPARE))
_type = SUBTYPE(DEPARE, depthLevel(param));
else if (type == TYPE(TSSLPT)) {
double angle = param.toDouble();
_type = SUBTYPE(TSSLPT, (uint)(angle * 10));
}
}
MapData::Line::Line(uint type, const QVector<Coordinates> &path,
const QString &label, const QByteArray &param) : _type(type), _path(path),
_label(label)
{
if (type == TYPE(DEPCNT) || type == TYPE(LNDELV))
_label = QString::fromLatin1(param);
}
RectC MapData::Line::bounds() const
{
RectC b;
for (int i = 0; i < _path.size(); i++)
b = b.united(_path.at(i));
return b;
}
QVector<MapData::Sounding> MapData::soundings(const ISO8211::Record &r,
@ -409,6 +469,7 @@ Polygon MapData::polyGeometry(const ISO8211::Record &r, const RecordMap &vc,
MapData::Attr MapData::pointAttr(const ISO8211::Record &r, uint OBJL)
{
QString label;
QByteArray param;
uint subtype = 0;
const ISO8211::Field *ATTF = r.field("ATTF");
@ -421,6 +482,7 @@ MapData::Attr MapData::pointAttr(const ISO8211::Record &r, uint OBJL)
if (key == OBJNAM)
label = QString::fromLatin1(av.at(1).toByteArray());
if ((OBJL == HRBFAC && key == CATHAF)
|| (OBJL == LNDMRK && key == CATLMK)
|| (OBJL == WRECKS && key == CATWRK)
@ -428,14 +490,22 @@ MapData::Attr MapData::pointAttr(const ISO8211::Record &r, uint OBJL)
|| (OBJL == UWTROC && key == WATLEV)
|| (OBJL == BUAARE && key == CATBUA))
subtype = av.at(1).toByteArray().toUInt();
else if (OBJL == I_DISMAR && key == CATDIS)
subtype |= av.at(1).toByteArray().toUInt();
else if (OBJL == I_DISMAR && key == I_HUNITS)
subtype |= av.at(1).toByteArray().toUInt() << 8;
if (OBJL == I_DISMAR && key == I_WTWDIS)
param = av.at(1).toByteArray();
}
return Attr(subtype, label);
return Attr(subtype, label, param);
}
MapData::Attr MapData::lineAttr(const ISO8211::Record &r, uint OBJL)
{
QString label;
QByteArray param;
uint subtype = 0;
const ISO8211::Field *ATTF = r.field("ATTF");
@ -448,19 +518,22 @@ MapData::Attr MapData::lineAttr(const ISO8211::Record &r, uint OBJL)
if (key == OBJNAM)
label = QString::fromLatin1(av.at(1).toByteArray());
if ((OBJL == DEPCNT && key == VALDCO)
|| (OBJL == LNDELV && key == ELEVAT))
label = QString::fromLatin1(av.at(1).toByteArray());
if ((OBJL == RECTRC || OBJL == RCRTCL) && key == CATTRK)
subtype = av.at(1).toByteArray().toUInt();
if ((OBJL == DEPCNT && key == VALDCO)
|| (OBJL == LNDELV && key == ELEVAT))
param = av.at(1).toByteArray();
}
return Attr(subtype, label);
return Attr(subtype, label, param);
}
MapData::Attr MapData::polyAttr(const ISO8211::Record &r, uint OBJL)
{
QString label;
QByteArray param;
uint subtype = 0;
const ISO8211::Field *ATTF = r.field("ATTF");
@ -471,9 +544,7 @@ MapData::Attr MapData::polyAttr(const ISO8211::Record &r, uint OBJL)
const QVector<QVariant> &av = ATTF->data().at(i);
uint key = av.at(0).toUInt();
if (OBJL == DEPARE && key == DRVAL1)
subtype = depthLevel(av.at(1).toByteArray());
else if ((OBJL == RESARE && key == CATREA)
if ((OBJL == RESARE && key == CATREA)
|| (OBJL == I_RESARE && key == CATREA)
|| (OBJL == ACHARE && key == CATACH)
|| (OBJL == I_ACHARE && key == I_CATACH))
@ -482,18 +553,19 @@ MapData::Attr MapData::polyAttr(const ISO8211::Record &r, uint OBJL)
|| (OBJL == I_RESARE && key == I_RESTRN)) {
if (av.at(1).toByteArray().toUInt() == 1)
subtype = 2;
} else if (OBJL == TSSLPT && key == ORIENT) {
double angle = av.at(1).toByteArray().toDouble();
subtype = (uint)(angle * 10);
}
if ((OBJL == TSSLPT && key == ORIENT)
|| (OBJL == DEPARE && key == DRVAL1))
param = av.at(1).toByteArray();
}
return Attr(subtype, label);
return Attr(subtype, label, param);
}
MapData::Point *MapData::pointObject(const Sounding &s)
{
return new Point(SOUNDG<<16, s.c, QString::number(s.depth));
return new Point(TYPE(SOUNDG), s.c, QString::number(s.depth), QByteArray());
}
MapData::Point *MapData::pointObject(const ISO8211::Record &r,
@ -502,8 +574,8 @@ MapData::Point *MapData::pointObject(const ISO8211::Record &r,
Coordinates c(pointGeometry(r, vi, vc, COMF));
Attr attr(pointAttr(r, OBJL));
return (c.isNull() ? 0 : new Point(OBJL<<16|attr.subtype(), c,
attr.label()));
return (c.isNull() ? 0 : new Point(SUBTYPE(OBJL,attr.subtype()), c,
attr.label(), attr.param()));
}
MapData::Line *MapData::lineObject(const ISO8211::Record &r,
@ -512,8 +584,8 @@ MapData::Line *MapData::lineObject(const ISO8211::Record &r,
QVector<Coordinates> path(lineGeometry(r, vc, ve, COMF));
Attr attr(lineAttr(r, OBJL));
return (path.isEmpty() ? 0 : new Line(OBJL<<16|attr.subtype(), path,
attr.label()));
return (path.isEmpty() ? 0 : new Line(SUBTYPE(OBJL, attr.subtype()), path,
attr.label(), attr.param()));
}
MapData::Poly *MapData::polyObject(const ISO8211::Record &r,
@ -522,7 +594,8 @@ MapData::Poly *MapData::polyObject(const ISO8211::Record &r,
Polygon path(polyGeometry(r, vc, ve, COMF));
Attr attr(polyAttr(r, OBJL));
return (path.isEmpty() ? 0 : new Poly(OBJL<<16|attr.subtype(), path));
return (path.isEmpty() ? 0 : new Poly(SUBTYPE(OBJL, attr.subtype()), path,
attr.param()));
}
bool MapData::processRecord(const ISO8211::Record &record,

View File

@ -15,8 +15,7 @@ class MapData
public:
class Poly {
public:
Poly(uint type, const Polygon &path)
: _type(type), _path(path) {}
Poly(uint type, const Polygon &path, const QByteArray &param);
RectC bounds() const {return _path.boundingRect();}
const Polygon &path() const {return _path;}
@ -29,18 +28,10 @@ public:
class Line {
public:
Line(uint type, const QVector<Coordinates> &path, const QString &label)
: _type(type), _path(path), _label(label) {}
Line(uint type, const QVector<Coordinates> &path, const QString &label,
const QByteArray &param);
RectC bounds() const
{
RectC b;
for (int i = 0; i < _path.size(); i++)
b = b.united(_path.at(i));
return b;
}
RectC bounds() const;
const QVector<Coordinates> &path() const {return _path;}
uint type() const {return _type;}
const QString &label() const {return _label;}
@ -53,7 +44,8 @@ public:
class Point {
public:
Point(uint type, const Coordinates &c, const QString &label);
Point(uint type, const Coordinates &c, const QString &label,
const QByteArray &param);
const Coordinates &pos() const {return _pos;}
uint type() const {return _type;}
@ -124,15 +116,17 @@ private:
class Attr {
public:
Attr() : _subtype(0) {}
Attr(uint subtype, const QString &label = QString())
: _subtype(subtype), _label(label) {}
Attr(uint subtype, const QString &label, const QByteArray &param)
: _subtype(subtype), _label(label), _param(param) {}
unsigned subtype() const {return _subtype;}
const QString &label() const {return _label;}
const QByteArray &param() const {return _param;}
private:
unsigned _subtype;
QString _label;
QByteArray _param;
};
struct Sounding {

View File

@ -38,6 +38,7 @@
#define FLODOC 57
#define GATCON 61
#define HRBFAC 64
#define HULKES 65
#define LAKARE 69
#define LNDARE 71
#define LNDELV 72
@ -72,11 +73,21 @@
#define I_ACHBRT 17000
#define I_ACHARE 17001
#define I_DISMAR 17004
#define I_RESARE 17005
#define I_BERTHS 17010
#define I_BRIDGE 17011
#define I_CBLOHD 17012
#define I_FERYRT 17013
#define I_HULKES 17020
#define I_PONTON 17021
#define I_FLODOC 17025
#define I_BCNLAT 17028
#define I_BOYLAT 17029
#define I_CRANES 17030
#define I_GATCON 17031
#define I_SLCONS 17032
#define I_WTWAXS 17051
#define I_TERMNL 17064
#endif // ENC_OBJECTS_H

View File

@ -216,8 +216,8 @@ void RasterTile::processPoints(QList<TextItem*> &textItems)
const QImage *img = style.img().isNull() ? 0 : &style.img();
const QFont *fnt = font(style.textFontSize());
const QColor *color = &style.textColor();
const QColor *hColor = Style::isSounding(point->type())
? 0 : &haloColor;
const QColor *hColor = (Style::isSounding(point->type())
|| Style::isDistanceMark(point->type())) ? 0 : &haloColor;
if ((!label || !fnt) && !img)
continue;

View File

@ -37,9 +37,14 @@ void Style::defaultPolygonStyle()
_polygons[TYPE(OBSTRN)] = Polygon(Qt::NoBrush, QPen(QColor("#000000"), 1.5,
Qt::DotLine));
_polygons[TYPE(PONTON)] = Polygon(QBrush("#333333"));
_polygons[TYPE(I_PONTON)] = Polygon(QBrush("#333333"));
_polygons[TYPE(HULKES)] = Polygon(QBrush("#333333"));
_polygons[TYPE(I_HULKES)] = Polygon(QBrush("#333333"));
_polygons[TYPE(DRYDOC)] = Polygon(QBrush("#333333"));
_polygons[TYPE(SLCONS)] = Polygon(Qt::NoBrush, QPen(QColor("#333333"), 1.5,
Qt::DashLine));
_polygons[TYPE(I_SLCONS)] = Polygon(Qt::NoBrush, QPen(QColor("#333333"), 1.5,
Qt::DashLine));
_polygons[TYPE(LAKARE)] = Polygon(QBrush("#9fc4e1"),
QPen(QColor("#000000"), 1));
_polygons[TYPE(CANALS)] = Polygon(QBrush("#9fc4e1"),
@ -68,9 +73,15 @@ void Style::defaultPolygonStyle()
1));
_polygons[TYPE(FLODOC)] = Polygon(QBrush("#333333"), QPen(QColor("#000000"),
1));
_polygons[TYPE(I_FLODOC)] = Polygon(QBrush("#333333"),
QPen(QColor("#000000"), 1));
_polygons[TYPE(DWRTPT)] = Polygon(QImage(":/marine/dw-route-line"));
_polygons[TYPE(MORFAC)] = Polygon(QBrush("#e8e064"), QPen(QColor("#000000"),
2));
_polygons[TYPE(GATCON)] = Polygon(QBrush("#000000"));
_polygons[TYPE(I_GATCON)] = Polygon(QBrush("#000000"));
_polygons[TYPE(I_TERMNL)] = Polygon(QBrush(QColor("#b8b04b")),
QPen(QColor("#966118")));
_drawOrder
<< TYPE(M_COVR) << TYPE(LNDARE) << SUBTYPE(DEPARE, 0)
@ -79,8 +90,10 @@ void Style::defaultPolygonStyle()
<< SUBTYPE(DEPARE, 6) << TYPE(LAKARE) << TYPE(CANALS) << TYPE(DYKCON)
<< TYPE(RIVERS) << TYPE(DRGARE) << TYPE(FAIRWY) << TYPE(BUAARE)
<< TYPE(BUISGL) << TYPE(AIRARE) << TYPE(BRIDGE) << TYPE(I_BRIDGE)
<< TYPE(SLCONS) << TYPE(PONTON) << TYPE(FLODOC) << TYPE(DRYDOC)
<< TYPE(DAMCON) << TYPE(PYLONS) << TYPE(MORFAC) << TYPE(DMPGRD)
<< TYPE(I_TERMNL) << TYPE(SLCONS) << TYPE(I_SLCONS) << TYPE(PONTON)
<< TYPE(I_PONTON) << TYPE(HULKES) << TYPE(I_HULKES) << TYPE(FLODOC)
<< TYPE(I_FLODOC) << TYPE(DRYDOC) << TYPE(DAMCON) << TYPE(PYLONS)
<< TYPE(MORFAC) << TYPE(GATCON) << TYPE(I_GATCON) << TYPE(DMPGRD)
<< TYPE(TSEZNE) << TYPE(OBSTRN) << TYPE(DWRTPT) << SUBTYPE(ACHARE, 1)
<< SUBTYPE(I_ACHARE, 1) << SUBTYPE(RESARE, 9) << SUBTYPE(RESARE, 2)
<< SUBTYPE(I_RESARE, 2) << TYPE(PRCARE);
@ -102,6 +115,7 @@ void Style::defaultLineStyle()
_lines[TYPE(NAVLNE)] = Line(QPen(QColor("#eb49eb"), 1, Qt::DashLine));
_lines[TYPE(COALNE)] = Line(QPen(QColor("#000000"), 1, Qt::SolidLine));
_lines[TYPE(SLCONS)] = Line(QPen(QColor("#000000"), 2, Qt::SolidLine));
_lines[TYPE(I_SLCONS)] = Line(QPen(QColor("#000000"), 2, Qt::SolidLine));
_lines[TYPE(PONTON)] = Line(QPen(QColor("#333333"), 1, Qt::SolidLine));
_lines[TYPE(DYKCON)] = Line(QPen(QColor("#333333"), 2, Qt::SolidLine));
_lines[TYPE(RIVERS)] = Line(QPen(QColor("#000000"), 1, Qt::SolidLine));
@ -116,6 +130,7 @@ void Style::defaultLineStyle()
_lines[TYPE(RAILWY)] = Line(railroad());
_lines[TYPE(ROADWY)] = Line(QPen(QColor("#000000"), 2, Qt::SolidLine));
_lines[TYPE(GATCON)] = Line(QPen(QColor("#000000"), 2, Qt::SolidLine));
_lines[TYPE(I_GATCON)] = Line(QPen(QColor("#000000"), 2, Qt::SolidLine));
_lines[TYPE(TSELNE)] = Line(QPen(QColor("#80fcb4fc"), 4, Qt::SolidLine));
_lines[TYPE(I_WTWAXS)] = Line(QPen(QColor("#000000"), 0, Qt::DashLine));
_lines[SUBTYPE(RECTRC, 1)] = Line(QPen(QColor("#000000"), 0, Qt::SolidLine));
@ -141,10 +156,12 @@ void Style::defaultPointStyle()
_points[TYPE(BOYINB)] = Point(QImage(":/marine/buoy.png"), Small);
_points[TYPE(BOYISD)] = Point(QImage(":/marine/buoy.png"), Small);
_points[TYPE(BOYLAT)] = Point(QImage(":/marine/buoy.png"), Small);
_points[TYPE(I_BOYLAT)] = Point(QImage(":/marine/buoy.png"), Small);
_points[TYPE(BOYSAW)] = Point(QImage(":/marine/buoy.png"), Small);
_points[TYPE(BOYSPP)] = Point(QImage(":/marine/buoy.png"), Small);
_points[TYPE(BCNISD)] = Point(QImage(":/marine/beacon.png"), Small);
_points[TYPE(BCNLAT)] = Point(QImage(":/marine/beacon.png"), Small);
_points[TYPE(I_BCNLAT)] = Point(QImage(":/marine/beacon.png"), Small);
_points[TYPE(BCNSAW)] = Point(QImage(":/marine/beacon.png"), Small);
_points[TYPE(BCNSPP)] = Point(QImage(":/marine/beacon.png"), Small);
_points[SUBTYPE(LNDMRK, 3)] = Point(QImage(":/marine/chimney.png"));
@ -179,6 +196,10 @@ void Style::defaultPointStyle()
_points[SUBTYPE(MORFAC, 7)] = Point(QImage(":/marine/mooring-buoy.png"),
Small);
_points[TYPE(CRANES)] = Point(QImage(":/marine/crane.png"));
_points[TYPE(I_CRANES)] = Point(QImage(":/marine/crane.png"));
_points[SUBTYPE(I_DISMAR, 1)] = Point(QImage(":/marine/distance-mark.png"));
_points[SUBTYPE(I_DISMAR, 1)].setTextColor(QColor("#ffffff"));
_points[SUBTYPE(I_DISMAR, 1)].setTextFontSize(Small);
}
Style::Style()
@ -188,7 +209,7 @@ Style::Style()
defaultPointStyle();
}
const Style::Line &Style::line(quint32 type) const
const Style::Line &Style::line(uint type) const
{
static Line null;
@ -196,7 +217,7 @@ const Style::Line &Style::line(quint32 type) const
return (it == _lines.constEnd()) ? null : *it;
}
const Style::Polygon &Style::polygon(quint32 type) const
const Style::Polygon &Style::polygon(uint type) const
{
static Polygon null;
@ -204,7 +225,7 @@ const Style::Polygon &Style::polygon(quint32 type) const
return (it == _polygons.constEnd()) ? null : *it;
}
const Style::Point &Style::point(quint32 type) const
const Style::Point &Style::point(uint type) const
{
static Point null;

View File

@ -89,11 +89,13 @@ public:
const Line &line(uint type) const;
const Polygon &polygon(uint type) const;
const Point &point(quint32 type) const;
const Point &point(uint type) const;
const QVector<uint> &drawOrder() const {return _drawOrder;}
static bool isSounding(quint32 type)
static bool isSounding(uint type)
{return type == TYPE(SOUNDG);}
static bool isDistanceMark(uint type)
{return (type & 0xFFFF0000) == TYPE(I_DISMAR);}
private:
void defaultPolygonStyle();