From 015598b951777139935ef1f05dc6dad6da1ff848 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20T=C5=AFma?= Date: Sat, 5 Nov 2022 20:38:08 +0100 Subject: [PATCH] ENC inland waters style hack --- src/map/ENC/attributes.h | 1 + src/map/ENC/mapdata.cpp | 3 ++- src/map/ENC/objects.h | 4 ++++ src/map/ENC/rastertile.cpp | 14 ++++++++------ src/map/ENC/style.cpp | 21 ++++++++++++++++++++- 5 files changed, 35 insertions(+), 8 deletions(-) diff --git a/src/map/ENC/attributes.h b/src/map/ENC/attributes.h index f8c76962..6f388bc5 100644 --- a/src/map/ENC/attributes.h +++ b/src/map/ENC/attributes.h @@ -3,6 +3,7 @@ #define CATHAF 30 #define CATLMK 35 +#define CATMOR 40 #define CATREA 56 #define CATWRK 71 #define DRVAL1 87 diff --git a/src/map/ENC/mapdata.cpp b/src/map/ENC/mapdata.cpp index 314e5db6..b5aae507 100644 --- a/src/map/ENC/mapdata.cpp +++ b/src/map/ENC/mapdata.cpp @@ -374,7 +374,8 @@ MapData::Attr MapData::pointAttr(const ISO8211::Record &r, uint OBJL) label = av.at(1).toString(); if ((OBJL == HRBFAC && key == CATHAF) || (OBJL == LNDMRK && key == CATLMK) - || (OBJL == WRECKS && key == CATWRK)) + || (OBJL == WRECKS && key == CATWRK) + || (OBJL == MORFAC && key == CATMOR)) subtype = av.at(1).toString().toUInt(); } diff --git a/src/map/ENC/objects.h b/src/map/ENC/objects.h index 1e10a658..b857f1dc 100644 --- a/src/map/ENC/objects.h +++ b/src/map/ENC/objects.h @@ -29,20 +29,24 @@ #define DYKCON 49 #define FAIRWY 51 #define FERYRT 53 +#define GATCON 61 #define HRBFAC 64 #define LAKARE 69 #define LNDARE 71 #define LNDELV 72 #define LNDMRK 74 #define LIGHTS 75 +#define MORFAC 84 #define NAVLNE 85 #define OBSTRN 86 #define OFSPLF 87 #define PILPNT 90 #define PIPSOL 94 #define PONTON 95 +#define RAILWY 106 #define RESARE 112 #define RIVERS 114 +#define ROADWY 116 #define SLCONS 122 #define SLOTOP 126 #define SOUNDG 129 diff --git a/src/map/ENC/rastertile.cpp b/src/map/ENC/rastertile.cpp index 839ada1f..f2ba630b 100644 --- a/src/map/ENC/rastertile.cpp +++ b/src/map/ENC/rastertile.cpp @@ -9,6 +9,8 @@ using namespace ENC; #define ICON_PADDING 2 +#define ECDIS(x) (((x)>TYPE(17000))?((x)-TYPE(17000)):(x)) + static const QColor haloColor(Qt::white); static struct { @@ -82,9 +84,9 @@ void RasterTile::drawPolygons(QPainter *painter) for (int n = 0; n < s.drawOrder().size(); n++) { for (int i = 0; i < _polygons.size(); i++) { const MapData::Poly *poly = _polygons.at(i); - if (poly->type() != s.drawOrder().at(n)) + if (ECDIS(poly->type()) != s.drawOrder().at(n)) continue; - const Style::Polygon &style = s.polygon(poly->type()); + const Style::Polygon &style = s.polygon(ECDIS(poly->type())); painter->setPen(style.pen()); painter->setBrush(style.brush()); @@ -101,7 +103,7 @@ void RasterTile::drawLines(QPainter *painter) for (int i = 0; i < _lines.size(); i++) { const MapData::Line *line = _lines.at(i); - const Style::Line &style = s.line(line->type()); + const Style::Line &style = s.line(ECDIS(line->type())); if (!style.img().isNull()) { BitmapLine::draw(painter, polyline(line->path()), style.img()); @@ -127,13 +129,13 @@ void RasterTile::processPoints(QList &textItems) for (int i = 0; i < _points.size(); i++) { const MapData::Point *point = _points.at(i); - const Style::Point &style = s.point(point->type()); + const Style::Point &style = s.point(ECDIS(point->type())); const QString *label = point->label().isEmpty() ? 0 : &(point->label()); 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()) + const QColor *hColor = Style::isSounding(ECDIS(point->type())) ? 0 : &haloColor; if ((!label || !fnt) && !img) @@ -154,7 +156,7 @@ void RasterTile::processLines(QList &textItems) for (int i = 0; i < _lines.size(); i++) { const MapData::Line *line = _lines.at(i); - const Style::Line &style = s.line(line->type()); + const Style::Line &style = s.line(ECDIS(line->type())); if (style.img().isNull() && style.pen() == Qt::NoPen) continue; diff --git a/src/map/ENC/style.cpp b/src/map/ENC/style.cpp index d5101302..9fc51a68 100644 --- a/src/map/ENC/style.cpp +++ b/src/map/ENC/style.cpp @@ -1,7 +1,19 @@ +#include #include "style.h" using namespace ENC; +static QImage railroad() +{ + QImage img(16, 4, QImage::Format_ARGB32_Premultiplied); + img.fill(Qt::black); + QPainter p(&img); + p.setPen(QPen(Qt::white, 2)); + p.drawLine(9, 2, 15, 2); + + return img; +} + void Style::defaultPolygonStyle() { _polygons[TYPE(M_COVR)] = Polygon(QBrush("#ffffff")); @@ -76,6 +88,9 @@ void Style::defaultLineStyle() _lines[TYPE(SLOTOP)] = Line(QPen(QColor("#797420"), 1, Qt::SolidLine)); _lines[TYPE(OBSTRN)] = Line(QPen(QColor("#000000"), 1.5, Qt::DotLine)); _lines[TYPE(FERYRT)] = Line(QImage(":/marine/ferry-line.png")); + _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)); } void Style::defaultPointStyle() @@ -107,9 +122,13 @@ void Style::defaultPointStyle() _points[SUBTYPE(WRECKS, 5)] = Point(QImage(":/marine/wreck-exposed.png")); _points[TYPE(UWTROC)] = Point(QImage(":/marine/rock-dangerous.png"), Small); _points[SUBTYPE(HRBFAC, 5)] = Point(QImage(":/marine/yacht-harbor.png")); - _points[TYPE(PILPNT)] = Point(QImage(":/marine/pile.png"), Small); _points[TYPE(ACHBRT)] = Point(QImage(":/marine/anchorage.png")); _points[TYPE(OFSPLF)] = Point(QImage(":/marine/platform.png")); + _points[TYPE(PILPNT)] = Point(QImage(":/marine/pile.png"), Small); + _points[SUBTYPE(MORFAC, 1)] = Point(QImage(":/marine/pile.png"), Small); + _points[SUBTYPE(MORFAC, 5)] = Point(QImage(":/marine/pile.png"), Small); + _points[SUBTYPE(MORFAC, 7)] = Point(QImage(":/marine/mooring-buoy.png"), + Small); } Style::Style()