mirror of
https://github.com/tumic0/GPXSee.git
synced 2024-11-23 19:25:54 +01:00
Added basic support for marine lights to IMG maps
This commit is contained in:
parent
524ac8347f
commit
d412390c75
@ -99,7 +99,6 @@
|
||||
<!-- marine stuff (IMG & ENC style) -->
|
||||
<qresource prefix="/marine">
|
||||
<file alias="light-major.png">icons/map/marine/light-major.png</file>
|
||||
<file alias="light-platform.png">icons/map/marine/light-platform.png</file>
|
||||
<file alias="buoy.png">icons/map/marine/buoy.png</file>
|
||||
<file alias="beacon.png">icons/map/marine/beacon.png</file>
|
||||
<file alias="rock-exposed.png">icons/map/marine/rock-exposed.png</file>
|
||||
|
Binary file not shown.
Before Width: | Height: | Size: 4.6 KiB After Width: | Height: | Size: 226 B |
Binary file not shown.
Before Width: | Height: | Size: 4.5 KiB |
@ -45,13 +45,19 @@ public:
|
||||
};
|
||||
|
||||
struct Point {
|
||||
Point() : id(0), classLabel(false) {}
|
||||
Point() : id(0), flags(0) {}
|
||||
|
||||
enum Flags {
|
||||
NoFlag = 0,
|
||||
ClassLabel = 1,
|
||||
Light = 2
|
||||
};
|
||||
|
||||
Coordinates coordinates;
|
||||
Label label;
|
||||
quint32 type;
|
||||
quint64 id;
|
||||
bool classLabel;
|
||||
quint32 type;
|
||||
quint32 flags;
|
||||
|
||||
bool operator<(const Point &other) const
|
||||
{return id < other.id;}
|
||||
|
@ -418,31 +418,36 @@ void RasterTile::processPoints(QList<MapData::Point> &points,
|
||||
|
||||
for (int i = 0; i < points.size(); i++) {
|
||||
const MapData::Point &point = points.at(i);
|
||||
const Style::Point &style = _data->style()->point(point.type);
|
||||
const Style *style = _data->style();
|
||||
const Style::Point &ps = style->point(point.type);
|
||||
bool poi = Style::isPOI(point.type);
|
||||
|
||||
const QString *label = point.label.text().isEmpty()
|
||||
? 0 : &(point.label.text());
|
||||
const QImage *img = style.img().isNull() ? 0 : &style.img();
|
||||
const QImage *img = ps.img().isNull() ? 0 : &ps.img();
|
||||
const QFont *fnt = poi
|
||||
? poiFont(style.text().size(), _zoom, point.classLabel)
|
||||
: _data->style()->font(style.text().size());
|
||||
const QColor *color = style.text().color().isValid()
|
||||
? &style.text().color() : &textColor;
|
||||
? poiFont(ps.text().size(), _zoom, point.flags
|
||||
& MapData::Point::ClassLabel)
|
||||
: style->font(ps.text().size());
|
||||
const QColor *color = ps.text().color().isValid()
|
||||
? &ps.text().color() : &textColor;
|
||||
const QColor *hcolor = Style::isDepthPoint(point.type)
|
||||
? 0 : &haloColor;
|
||||
|
||||
if ((!label || !fnt) && !img)
|
||||
continue;
|
||||
|
||||
QPoint offset = img ? style.offset() : QPoint(0, 0);
|
||||
QPoint pos(point.coordinates.lon(), point.coordinates.lat());
|
||||
QPoint offset = img ? ps.offset() : QPoint(0, 0);
|
||||
|
||||
TextPointItem *item = new TextPointItem(QPoint(point.coordinates.lon(),
|
||||
point.coordinates.lat()) + offset, label, fnt, img, color, hcolor, 0,
|
||||
ICON_PADDING);
|
||||
if (item->isValid() && !item->collides(textItems))
|
||||
TextPointItem *item = new TextPointItem(pos + offset, label, fnt, img,
|
||||
color, hcolor, 0, ICON_PADDING);
|
||||
if (item->isValid() && !item->collides(textItems)) {
|
||||
textItems.append(item);
|
||||
else
|
||||
if (point.flags & MapData::Point::Light)
|
||||
textItems.append(new TextPointItem(pos + style->lightOffset(),
|
||||
0, 0, style->light(), 0, 0, 0, 0));
|
||||
} else
|
||||
delete item;
|
||||
}
|
||||
}
|
||||
|
@ -107,6 +107,27 @@ bool RGNFile::readObstructionInfo(Handle &hdl, quint8 flags, quint32 size,
|
||||
return true;
|
||||
}
|
||||
|
||||
bool RGNFile::readBuoyInfo(Handle &hdl, quint8 flags, MapData::Point *point) const
|
||||
{
|
||||
quint16 val;
|
||||
quint8 lc;
|
||||
|
||||
if ((flags & 0xe0) != 0xe0)
|
||||
return true;
|
||||
|
||||
if (!readUInt16(hdl, val))
|
||||
return false;
|
||||
|
||||
lc = (val >> 10) & 0x0f;
|
||||
if (!lc)
|
||||
lc = (val >> 6) & 7;
|
||||
|
||||
if (lc)
|
||||
point->flags |= MapData::Point::Light;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool RGNFile::readLabel(Handle &hdl, LBLFile *lbl, Handle &lblHdl,
|
||||
quint8 flags, quint32 size, MapData::Point *point) const
|
||||
{
|
||||
@ -116,7 +137,7 @@ bool RGNFile::readLabel(Handle &hdl, LBLFile *lbl, Handle &lblHdl,
|
||||
return false;
|
||||
|
||||
point->label = lbl->label(lblHdl, this, hdl, size);
|
||||
point->classLabel = true;
|
||||
point->flags |= MapData::Point::ClassLabel;
|
||||
|
||||
return true;
|
||||
}
|
||||
@ -154,12 +175,17 @@ bool RGNFile::readClassFields(Handle &hdl, SegmentType segmentType,
|
||||
|
||||
if (poly && Style::isRaster(poly->type))
|
||||
readRasterInfo(hdl, lbl, rs, poly);
|
||||
if (point && !Style::isMarinePoint(point->type))
|
||||
readLabel(hdl, lbl, lblHdl, flags, rs, point);
|
||||
|
||||
if (point && Style::isDepthPoint(point->type))
|
||||
readDepthInfo(hdl, flags, rs, point);
|
||||
if (point && Style::isObstructionPoint(point->type))
|
||||
readObstructionInfo(hdl, flags, rs, point);
|
||||
if (point && !Style::isMarinePoint(point->type))
|
||||
readLabel(hdl, lbl, lblHdl, flags, rs, point);
|
||||
if (point && Style::isBuoy(point->type))
|
||||
readBuoyInfo(hdl, flags, point);
|
||||
if (point && Style::isLight(point->type))
|
||||
point->flags |= MapData::Point::Light;
|
||||
|
||||
return seek(hdl, off + rs);
|
||||
}
|
||||
|
@ -64,6 +64,7 @@ private:
|
||||
MapData::Point *point) const;
|
||||
bool readObstructionInfo(Handle &hdl, quint8 flags, quint32 size,
|
||||
MapData::Point *point) const;
|
||||
bool readBuoyInfo(Handle &hdl, quint8 flags, MapData::Point *point) const;
|
||||
bool readLabel(Handle &hdl, LBLFile *lbl, Handle &lblHdl,
|
||||
quint8 flags, quint32 size, MapData::Point *point) const;
|
||||
|
||||
|
@ -675,17 +675,17 @@ void Style::defaultPointStyle(qreal ratio)
|
||||
_points[0x11108] = _points[0x3008];
|
||||
|
||||
// Marine stuff
|
||||
_points[0x10100] = Point(QImage(":/marine/light-major.png"), QPoint(8, -8));
|
||||
_points[0x10101] = Point(QImage(":/marine/light-major.png"), QPoint(8, -8));
|
||||
_points[0x10102] = Point(QImage(":/marine/light-major.png"), QPoint(8, -8));
|
||||
_points[0x10103] = Point(QImage(":/marine/light-major.png"), QPoint(8, -8));
|
||||
_points[0x10104] = Point(QImage(":/marine/light-major.png"), QPoint(8, -8));
|
||||
_points[0x10105] = Point(QImage(":/marine/light-major.png"), QPoint(8, -8));
|
||||
_points[0x10106] = Point(QImage(":/marine/light-major.png"), QPoint(8, -8));
|
||||
_points[0x10107] = Point(QImage(":/marine/light-major.png"), QPoint(8, -8));
|
||||
_points[0x10108] = Point(QImage(":/marine/light-major.png"), QPoint(8, -8));
|
||||
_points[0x10109] = Point(QImage(":/marine/light-major.png"), QPoint(8, -8));
|
||||
_points[0x1010a] = Point(QImage(":/marine/light-major.png"), QPoint(8, -8));
|
||||
_points[0x10100] = Point(QImage(":/marine/light-major.png"));
|
||||
_points[0x10101] = Point(QImage(":/marine/light-major.png"));
|
||||
_points[0x10102] = Point(QImage(":/marine/light-major.png"));
|
||||
_points[0x10103] = Point(QImage(":/marine/light-major.png"));
|
||||
_points[0x10104] = Point(QImage(":/marine/light-major.png"));
|
||||
_points[0x10105] = Point(QImage(":/marine/light-major.png"));
|
||||
_points[0x10106] = Point(QImage(":/marine/light-major.png"));
|
||||
_points[0x10107] = Point(QImage(":/marine/light-major.png"));
|
||||
_points[0x10108] = Point(QImage(":/marine/light-major.png"));
|
||||
_points[0x10109] = Point(QImage(":/marine/light-major.png"));
|
||||
_points[0x1010a] = Point(QImage(":/marine/light-major.png"));
|
||||
_points[0x10200] = Point(QImage(":/marine/buoy.png"), QPoint(6, -6));
|
||||
_points[0x10201] = Point(QImage(":/marine/buoy.png"), QPoint(6, -6));
|
||||
_points[0x10202] = Point(QImage(":/marine/buoy.png"), QPoint(6, -6));
|
||||
@ -699,8 +699,7 @@ void Style::defaultPointStyle(qreal ratio)
|
||||
_points[0x1020a] = Point(QImage(":/marine/buoy.png"), QPoint(6, -6));
|
||||
_points[0x1020b] = Point(QImage(":/marine/buoy.png"), QPoint(6, -6));
|
||||
_points[0x1020c] = Point(QImage(":/marine/buoy.png"), QPoint(6, -6));
|
||||
_points[0x1020d] = Point(QImage(":/marine/light-platform.png"),
|
||||
QPoint(8, -8));
|
||||
_points[0x1020d] = Point(QImage(":/marine/platform.png"));
|
||||
_points[0x1020e] = Point(QImage(":/marine/beacon.png"), QPoint(0, -8));
|
||||
_points[0x1020f] = Point(QImage(":/marine/beacon.png"), QPoint(0, -8));
|
||||
_points[0x10210] = Point(QImage(":/marine/beacon.png"), QPoint(0, -8));
|
||||
@ -1278,6 +1277,9 @@ Style::Style(qreal ratio, SubFile *typ)
|
||||
_small = pixelSizeFont(12);
|
||||
_extraSmall = pixelSizeFont(10);
|
||||
|
||||
_light = QImage(":/marine/light.png");
|
||||
_lightOffset = QPoint(11, 11);
|
||||
|
||||
defaultLineStyle(ratio);
|
||||
defaultPolygonStyle();
|
||||
defaultPointStyle(ratio);
|
||||
|
@ -113,6 +113,9 @@ public:
|
||||
const QFont *font(Style::FontSize size, Style::FontSize defaultSize
|
||||
= Style::Normal) const;
|
||||
|
||||
const QImage *light() const {return &_light;}
|
||||
const QPoint &lightOffset() const {return _lightOffset;}
|
||||
|
||||
static bool isPOI(quint32 type)
|
||||
{return !((type >= TYPE(0x01) && type <= TYPE(0x1f))
|
||||
|| (type >= 0x11400 && type < 0x11500));}
|
||||
@ -143,6 +146,10 @@ public:
|
||||
{return (type == 0x10301);}
|
||||
static bool isObstructionPoint(quint32 type)
|
||||
{return (type >= 0x10400 && type <= 0x10401);}
|
||||
static bool isBuoy(quint32 type)
|
||||
{return (type >= 0x10200 && type < 0x10300);}
|
||||
static bool isLight(quint32 type)
|
||||
{return (type >= 0x10100 && type < 0x10200);}
|
||||
static bool isMarinePoint(quint32 type)
|
||||
{return type >= 0x10100 && type < 0x10a00;}
|
||||
static bool isMarina(quint32 type)
|
||||
@ -193,6 +200,9 @@ private:
|
||||
|
||||
/* Fonts and images must be initialized after QGuiApplication! */
|
||||
QFont _large, _normal, _small, _extraSmall;
|
||||
|
||||
QImage _light;
|
||||
QPoint _lightOffset;
|
||||
};
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user