1
0
mirror of https://github.com/tumic0/GPXSee.git synced 2025-04-20 04:09:11 +02:00

Compare commits

..

No commits in common. "4ee39fe7075f9beaf2cfbb1028ec53cc2941aed3" and "347212f0129712570a53d8dac0bc07c76d766ba3" have entirely different histories.

43 changed files with 193 additions and 252 deletions

View File

@ -12,8 +12,9 @@ environment:
- QTDIR: C:\Qt\5.15\msvc2019_64 - QTDIR: C:\Qt\5.15\msvc2019_64
OPENSSLDIR: C:\OpenSSL-v111-Win64\bin OPENSSLDIR: C:\OpenSSL-v111-Win64\bin
NSISDEF: /DOPENSSL /DANGLE NSISDEF: /DOPENSSL /DANGLE
- QTDIR: C:\Qt\6.8\msvc2022_64 - QTDIR: C:\Qt\6.8\msvc2019_64
NSISDEF: /DQT6 OPENSSLDIR: C:\OpenSSL-v33-Win64\bin
NSISDEF: /DQT6 /DOPENSSL
install: install:
- cmd: |- - cmd: |-
@ -35,8 +36,8 @@ build_script:
xcopy lang\*.qm installer\translations\ /sy xcopy lang\*.qm installer\translations\ /sy
xcopy icons\symbols installer\symbols /i xcopy icons\symbols installer\symbols /i
copy licence.txt installer copy licence.txt installer
IF DEFINED OPENSSLDIR (copy %OPENSSLDIR%\libcrypto-*-x64.dll installer) copy %OPENSSLDIR%\libcrypto-*-x64.dll installer
IF DEFINED OPENSSLDIR (copy %OPENSSLDIR%\libssl-*-x64.dll installer) copy %OPENSSLDIR%\libssl-*-x64.dll installer
makensis.exe %NSISDEF% installer\gpxsee64.nsi makensis.exe %NSISDEF% installer\gpxsee64.nsi

View File

@ -15,7 +15,7 @@ jobs:
- name: Install Qt - name: Install Qt
uses: jurplel/install-qt-action@v4 uses: jurplel/install-qt-action@v4
with: with:
version: '6.8.1' version: '6.8.0'
modules: qtpositioning qtserialport qtimageformats modules: qtpositioning qtserialport qtimageformats
- name: Create localization - name: Create localization
run: lrelease gpxsee.pro run: lrelease gpxsee.pro

View File

@ -523,7 +523,7 @@ win32 {
RESOURCES += theme-color.qrc RESOURCES += theme-color.qrc
QMAKE_TARGET_DESCRIPTION = GPXSee QMAKE_TARGET_DESCRIPTION = GPXSee
QMAKE_TARGET_COPYRIGHT = Copyright (c) 2015-2025 Martin Tuma QMAKE_TARGET_COPYRIGHT = Copyright (c) 2015-2024 Martin Tuma
RC_ICONS = icons/app/gpxsee.ico \ RC_ICONS = icons/app/gpxsee.ico \
icons/formats/gpx.ico \ icons/formats/gpx.ico \
icons/formats/tcx.ico \ icons/formats/tcx.ico \

View File

@ -206,10 +206,6 @@
<file alias="kelp.png">icons/map/marine/kelp.png</file> <file alias="kelp.png">icons/map/marine/kelp.png</file>
<file alias="eddies.png">icons/map/marine/eddies.png</file> <file alias="eddies.png">icons/map/marine/eddies.png</file>
<file alias="dome.png">icons/map/marine/dome.png</file> <file alias="dome.png">icons/map/marine/dome.png</file>
<file alias="radar-reflector.png">icons/map/marine/radar-reflector.png</file>
<file alias="24h-anchorage.png">icons/map/marine/24h-anchorage.png</file>
<file alias="dw-anchorage.png">icons/map/marine/dw-anchorage.png</file>
<file alias="tanker-anchorage.png">icons/map/marine/tanker-anchorage.png</file>
</qresource> </qresource>
<!-- Patterns (Mapsforge) --> <!-- Patterns (Mapsforge) -->

Binary file not shown.

Before

Width:  |  Height:  |  Size: 348 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 296 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 236 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 413 B

View File

@ -58,7 +58,7 @@ VIProductVersion "${VERSION}.0.0"
VIAddVersionKey "ProductVersion" ${VERSION} VIAddVersionKey "ProductVersion" ${VERSION}
VIAddVersionKey "FileVersion" "${VERSION}.0.0" VIAddVersionKey "FileVersion" "${VERSION}.0.0"
VIAddVersionKey "ProductName" "GPXSee" VIAddVersionKey "ProductName" "GPXSee"
VIAddVersionKey "LegalCopyright" "Copyright (c) 2015-2025 Martin Tůma" VIAddVersionKey "LegalCopyright" "Copyright (c) 2015-2024 Martin Tůma"
VIAddVersionKey "FileDescription" "GPXSee installer (x64)" VIAddVersionKey "FileDescription" "GPXSee installer (x64)"
; Registry key to check for directory (so if you install again, it will ; Registry key to check for directory (so if you install again, it will

View File

@ -63,17 +63,16 @@ static QMap<uint,uint> orderMapInit()
map.insert(TYPE(PILPNT), 34); map.insert(TYPE(PILPNT), 34);
map.insert(TYPE(ACHBRT), 35); map.insert(TYPE(ACHBRT), 35);
map.insert(TYPE(I_ACHBRT), 35); map.insert(TYPE(I_ACHBRT), 35);
map.insert(TYPE(RADRFL), 36); map.insert(TYPE(CRANES), 36);
map.insert(TYPE(CRANES), 37); map.insert(TYPE(I_CRANES), 36);
map.insert(TYPE(I_CRANES), 37); map.insert(TYPE(I_WTWGAG), 37);
map.insert(TYPE(I_WTWGAG), 38); map.insert(TYPE(PYLONS), 38);
map.insert(TYPE(PYLONS), 39); map.insert(TYPE(SLCONS), 39);
map.insert(TYPE(SLCONS), 40); map.insert(TYPE(LNDMRK), 40);
map.insert(TYPE(LNDMRK), 41); map.insert(TYPE(SILTNK), 41);
map.insert(TYPE(SILTNK), 42); map.insert(TYPE(LNDELV), 42);
map.insert(TYPE(LNDELV), 43); map.insert(TYPE(SMCFAC), 43);
map.insert(TYPE(SMCFAC), 44); map.insert(TYPE(BUISGL), 44);
map.insert(TYPE(BUISGL), 45);
map.insert(TYPE(I_DISMAR), 0xFFFFFFFE); map.insert(TYPE(I_DISMAR), 0xFFFFFFFE);
map.insert(TYPE(SOUNDG), 0xFFFFFFFF); map.insert(TYPE(SOUNDG), 0xFFFFFFFF);
@ -170,26 +169,6 @@ static bool polygonCb(const MapData::Poly *polygon, void *context)
return true; return true;
} }
static bool polygonPointCb(const MapData::Poly *polygon, void *context)
{
QList<MapData::Point> *points = (QList<MapData::Point>*)context;
uint baseType = polygon->type()>>16;
if (!polygon->label().isEmpty() || baseType == TSSLPT || baseType == RCTLPT
|| baseType == I_TRNBSN
|| polygon->type() == SUBTYPE(ACHARE, 2)
|| polygon->type() == SUBTYPE(ACHARE, 3)
|| polygon->type() == SUBTYPE(ACHARE, 9)
|| polygon->type() == SUBTYPE(I_ACHARE, 2)
|| polygon->type() == SUBTYPE(I_ACHARE, 3)
|| polygon->type() == SUBTYPE(I_ACHARE, 9)
|| polygon->type() == SUBTYPE(I_BERTHS, 6))
points->append(MapData::Point(polygon->type(), polygon->bounds().center(),
polygon->label(), polygon->param()));
return true;
}
static Coordinates coordinates(int x, int y, uint COMF) static Coordinates coordinates(int x, int y, uint COMF)
{ {
return Coordinates(x / (double)COMF, y / (double)COMF); return Coordinates(x / (double)COMF, y / (double)COMF);
@ -306,14 +285,7 @@ MapData::Point::Point(uint type, const Coordinates &c, const QString &label,
else else
_label += "\n(" + QString::fromLatin1(params.at(0)) _label += "\n(" + QString::fromLatin1(params.at(0))
+ "\xE2\x80\x89m)"; + "\xE2\x80\x89m)";
} else if ((type == TYPE(TSSLPT) || type == TYPE(RCTLPT)) && params.size()) }
_param = QVariant(params.at(0).toDouble());
}
MapData::Point::Point(uint type, const Coordinates &c, const QString &label,
const QVariant &param) : _type(type), _pos(c), _label(label), _param(param)
{
_id = ((quint64)order(type))<<32 | (uint)qHash(c);
} }
MapData::Poly::Poly(uint type, const Polygon &path, const QString &label, MapData::Poly::Poly(uint type, const Polygon &path, const QString &label,
@ -321,7 +293,7 @@ MapData::Poly::Poly(uint type, const Polygon &path, const QString &label,
{ {
if (type == TYPE(DEPARE) && params.size()) if (type == TYPE(DEPARE) && params.size())
_type = SUBTYPE(DEPARE, depthLevel(params.at(0))); _type = SUBTYPE(DEPARE, depthLevel(params.at(0)));
else if ((type == TYPE(TSSLPT) || type == TYPE(RCTLPT)) && params.size()) else if (type == TYPE(TSSLPT) && params.size())
_param = QVariant(params.at(0).toDouble()); _param = QVariant(params.at(0).toDouble());
else if ((type == TYPE(BRIDGE) || type == TYPE(I_BRIDGE)) else if ((type == TYPE(BRIDGE) || type == TYPE(I_BRIDGE))
&& params.size()) { && params.size()) {
@ -330,8 +302,7 @@ MapData::Poly::Poly(uint type, const Polygon &path, const QString &label,
_label = QString::fromUtf8("\xE2\x86\x95") + UNIT_SPACE _label = QString::fromUtf8("\xE2\x86\x95") + UNIT_SPACE
+ QString::number(clr) + UNIT_SPACE + hUnits(HUNI); + QString::number(clr) + UNIT_SPACE + hUnits(HUNI);
} }
} else if (type>>16 == LNDARE || type>>16 == SEAARE || type>>16 == BERTHS } else if (type>>16 == LNDARE || type>>16 == SEAARE)
|| type>>16 == I_BERTHS || type>>16 == BUAARE)
_label = label; _label = label;
} }
@ -624,9 +595,7 @@ MapData::Attr MapData::pointAttr(const ISO8211::Record &r, uint OBJL)
|| (OBJL == RDOCAL && key == ORIENT) || (OBJL == RDOCAL && key == ORIENT)
|| (OBJL == I_RDOCAL && key == ORIENT) || (OBJL == I_RDOCAL && key == ORIENT)
|| (OBJL == CURENT && key == ORIENT) || (OBJL == CURENT && key == ORIENT)
|| (OBJL == LNDELV && key == ELEVAT) || (OBJL == LNDELV && key == ELEVAT))
|| (OBJL == TSSLPT && key == ORIENT)
|| (OBJL == RCTLPT && key == ORIENT))
params[0] = av.at(1).toByteArray(); params[0] = av.at(1).toByteArray();
if ((OBJL == I_RDOCAL && key == COMCHA) if ((OBJL == I_RDOCAL && key == COMCHA)
|| (OBJL == RDOCAL && key == COMCHA) || (OBJL == RDOCAL && key == COMCHA)
@ -699,7 +668,6 @@ MapData::Attr MapData::polyAttr(const ISO8211::Record &r, uint OBJL)
} }
if ((OBJL == TSSLPT && key == ORIENT) if ((OBJL == TSSLPT && key == ORIENT)
|| (OBJL == RCTLPT && key == ORIENT)
|| (OBJL == DEPARE && key == DRVAL1)) || (OBJL == DEPARE && key == DRVAL1))
params[0] = av.at(1).toByteArray(); params[0] = av.at(1).toByteArray();
if ((OBJL == BRIDGE && key == VERCLR) if ((OBJL == BRIDGE && key == VERCLR)
@ -874,7 +842,6 @@ void MapData::points(const RectC &rect, QList<Point> *points) const
rectcBounds(rect, min, max); rectcBounds(rect, min, max);
_points.Search(min, max, pointCb, points); _points.Search(min, max, pointCb, points);
_areas.Search(min, max, polygonPointCb, points);
} }
void MapData::lines(const RectC &rect, QList<Line> *lines) const void MapData::lines(const RectC &rect, QList<Line> *lines) const

View File

@ -49,8 +49,6 @@ public:
public: public:
Point(uint type, const Coordinates &c, const QString &label, Point(uint type, const Coordinates &c, const QString &label,
const QVector<QByteArray> &params); const QVector<QByteArray> &params);
Point(uint type, const Coordinates &c, const QString &label,
const QVariant &param);
const Coordinates &pos() const {return _pos;} const Coordinates &pos() const {return _pos;}
uint type() const {return _type;} uint type() const {return _type;}

View File

@ -67,7 +67,6 @@
#define PONTON 95 #define PONTON 95
#define PRCARE 96 #define PRCARE 96
#define PYLONS 98 #define PYLONS 98
#define RADRFL 101
#define RADSTA 102 #define RADSTA 102
#define RTPBCN 103 #define RTPBCN 103
#define RDOCAL 104 #define RDOCAL 104
@ -75,7 +74,6 @@
#define RAILWY 106 #define RAILWY 106
#define RCRTCL 108 #define RCRTCL 108
#define RECTRC 109 #define RECTRC 109
#define RCTLPT 110
#define RSCSTA 111 #define RSCSTA 111
#define RESARE 112 #define RESARE 112
#define RIVERS 114 #define RIVERS 114

View File

@ -40,6 +40,31 @@ static bool showLabel(const QImage *img, const Range &range, int zoom, int type)
return true; return true;
} }
QPointF RasterTile::centroid(const QVector<Coordinates> &polygon) const
{
Q_ASSERT(polygon.size() > 3);
Q_ASSERT(polygon.first() == polygon.last());
double area = 0;
double cx = 0, cy = 0;
QPointF pi;
QPointF pj(ll2xy(polygon.at(0)));
for (int i = 0; i < polygon.size() - 1; i++) {
pi = pj;
pj = ll2xy(polygon.at(i + 1));
double f = pi.x() * pj.y() - pj.x() * pi.y();
area += f;
cx += (pi.x() + pj.x()) * f;
cy += (pi.y() + pj.y()) * f;
}
double factor = 1.0 / (3.0 * area);
return QPointF(cx * factor, cy * factor);
}
QPainterPath RasterTile::painterPath(const Polygon &polygon) const QPainterPath RasterTile::painterPath(const Polygon &polygon) const
{ {
QPainterPath path; QPainterPath path;
@ -125,28 +150,19 @@ QPolygonF RasterTile::tsslptArrow(const QPointF &p, qreal angle) const
return polygon; return polygon;
} }
static void drawArrow(QPainter *painter, const QPolygonF &polygon, uint type)
{
if (type>>16 == RCTLPT) {
painter->setPen(QPen(tsslptPen, 1, Qt::DashLine));
painter->setBrush(Qt::NoBrush);
} else {
painter->setPen(QPen(tsslptPen, 1));
painter->setBrush(QBrush(tsslptBrush));
}
painter->drawPolygon(polygon);
}
void RasterTile::drawArrows(QPainter *painter, void RasterTile::drawArrows(QPainter *painter,
const QList<MapData::Point> &points) const QList<MapData::Poly> &polygons)
{ {
for (int i = 0; i < points.size(); i++) { for (int i = 0; i < polygons.size(); i++) {
const MapData::Point &point = points.at(i); const MapData::Poly &poly = polygons.at(i);
if (point.type()>>16 == TSSLPT || point.type()>>16 == RCTLPT) { if (poly.type()>>16 == TSSLPT) {
QPolygonF polygon(tsslptArrow(ll2xy(point.pos()), QPolygonF polygon(tsslptArrow(centroid(poly.path().first()),
deg2rad(point.param().toDouble()))); deg2rad(poly.param().toDouble())));
drawArrow(painter, polygon, point.type());
painter->setPen(QPen(tsslptPen, 1));
painter->setBrush(QBrush(tsslptBrush));
painter->drawPolygon(polygon);
} }
} }
} }
@ -213,6 +229,46 @@ void RasterTile::drawTextItems(QPainter *painter,
} }
} }
void RasterTile::processPolygons(const QList<MapData::Poly> &polygons,
QList<TextItem*> &textItems)
{
for (int i = 0; i < polygons.size(); i++) {
const MapData::Poly &poly = polygons.at(i);
uint type = poly.type()>>16;
const QImage *img = 0;
const QString *label = 0;
const QFont *fnt = 0;
const QColor *color = 0, *hColor = 0;
QPoint offset(0, 0);
if (!poly.label().isEmpty()) {
const Style::Point &style = _style->point(poly.type());
fnt = _style->font(style.textFontSize());
color = &style.textColor();
hColor = style.haloColor().isValid() ? &style.haloColor() : 0;
label = &poly.label();
}
if (type == HRBFAC || type == I_TRNBSN
|| poly.type() == SUBTYPE(I_BERTHS, 6)) {
const Style::Point &style = _style->point(poly.type());
img = style.img().isNull() ? 0 : &style.img();
offset = style.offset();
}
if ((!label || !fnt) && !img)
continue;
TextPointItem *item = new TextPointItem(offset +
centroid(poly.path().first()).toPoint(), label, fnt, img, color,
hColor, 0, 0);
if (item->isValid() && _rect.contains(item->boundingRect().toRect())
&& !item->collides(textItems))
textItems.append(item);
else
delete item;
}
}
void RasterTile::processPoints(QList<MapData::Point> &points, void RasterTile::processPoints(QList<MapData::Point> &points,
QList<TextItem*> &textItems, QList<TextItem*> &lights) QList<TextItem*> &textItems, QList<TextItem*> &lights)
{ {
@ -333,6 +389,7 @@ void RasterTile::render()
fetchData(polygons, lines, points); fetchData(polygons, lines, points);
processPoints(points, textItems, lights); processPoints(points, textItems, lights);
processPolygons(polygons, textItems);
processLines(lines, textItems); processLines(lines, textItems);
QPainter painter(&img); QPainter painter(&img);
@ -342,7 +399,7 @@ void RasterTile::render()
drawPolygons(&painter, polygons); drawPolygons(&painter, polygons);
drawLines(&painter, lines); drawLines(&painter, lines);
drawArrows(&painter, points); drawArrows(&painter, polygons);
drawTextItems(&painter, lights); drawTextItems(&painter, lights);
drawTextItems(&painter, textItems); drawTextItems(&painter, textItems);

View File

@ -47,9 +47,11 @@ private:
QList<TextItem*> &textItems, QList<TextItem *> &lights); QList<TextItem*> &textItems, QList<TextItem *> &lights);
void processLines(const QList<MapData::Line> &lines, void processLines(const QList<MapData::Line> &lines,
QList<TextItem*> &textItems); QList<TextItem*> &textItems);
void processPolygons(const QList<MapData::Poly> &polygons,
QList<TextItem*> &textItems);
void drawBitmapPath(QPainter *painter, const QImage &img, void drawBitmapPath(QPainter *painter, const QImage &img,
const Polygon &polygon); const Polygon &polygon);
void drawArrows(QPainter *painter, const QList<MapData::Point> &points); void drawArrows(QPainter *painter, const QList<MapData::Poly> &polygons);
void drawPolygons(QPainter *painter, const QList<MapData::Poly> &polygons); void drawPolygons(QPainter *painter, const QList<MapData::Poly> &polygons);
void drawLines(QPainter *painter, const QList<MapData::Line> &lines); void drawLines(QPainter *painter, const QList<MapData::Line> &lines);
void drawTextItems(QPainter *painter, const QList<TextItem*> &textItems); void drawTextItems(QPainter *painter, const QList<TextItem*> &textItems);

View File

@ -82,27 +82,7 @@ void Style::polygonStyle()
_polygons[SUBTYPE(I_RESARE, 12)] = Polygon(QImage(":/marine/safety-zone-line.png")); _polygons[SUBTYPE(I_RESARE, 12)] = Polygon(QImage(":/marine/safety-zone-line.png"));
_polygons[SUBTYPE(RESARE, 1)] = Polygon(QImage(":/marine/safety-zone-line.png")); _polygons[SUBTYPE(RESARE, 1)] = Polygon(QImage(":/marine/safety-zone-line.png"));
_polygons[SUBTYPE(ACHARE, 1)] = Polygon(QImage(":/marine/anchor-line.png")); _polygons[SUBTYPE(ACHARE, 1)] = Polygon(QImage(":/marine/anchor-line.png"));
_polygons[SUBTYPE(ACHARE, 2)] = _polygons[SUBTYPE(ACHARE, 1)]; _polygons[SUBTYPE(I_ACHARE, 1)] = Polygon(QImage(":/marine/anchor-line.png"));
_polygons[SUBTYPE(ACHARE, 3)] = _polygons[SUBTYPE(ACHARE, 1)];
_polygons[SUBTYPE(ACHARE, 4)] = _polygons[SUBTYPE(ACHARE, 1)];
_polygons[SUBTYPE(ACHARE, 5)] = _polygons[SUBTYPE(ACHARE, 1)];
_polygons[SUBTYPE(ACHARE, 6)] = _polygons[SUBTYPE(ACHARE, 1)];
_polygons[SUBTYPE(ACHARE, 7)] = _polygons[SUBTYPE(ACHARE, 1)];
_polygons[SUBTYPE(ACHARE, 8)] = Polygon(Qt::NoBrush,
QPen(QColor(0xeb, 0x49, 0xeb), 1, Qt::DashLine));
_polygons[SUBTYPE(ACHARE, 9)] = _polygons[SUBTYPE(ACHARE, 1)];
_polygons[SUBTYPE(I_ACHARE, 1)] = _polygons[SUBTYPE(ACHARE, 1)];
_polygons[SUBTYPE(I_ACHARE, 2)] = _polygons[SUBTYPE(ACHARE, 2)];
_polygons[SUBTYPE(I_ACHARE, 3)] = _polygons[SUBTYPE(ACHARE, 3)];
_polygons[SUBTYPE(I_ACHARE, 4)] = _polygons[SUBTYPE(ACHARE, 4)];
_polygons[SUBTYPE(I_ACHARE, 5)] = _polygons[SUBTYPE(ACHARE, 5)];
_polygons[SUBTYPE(I_ACHARE, 6)] = _polygons[SUBTYPE(ACHARE, 6)];
_polygons[SUBTYPE(I_ACHARE, 7)] = _polygons[SUBTYPE(ACHARE, 7)];
_polygons[SUBTYPE(I_ACHARE, 8)] = _polygons[SUBTYPE(ACHARE, 8)];
_polygons[SUBTYPE(I_ACHARE, 9)] = _polygons[SUBTYPE(ACHARE, 9)];
_polygons[SUBTYPE(I_ACHARE, 10)] = _polygons[SUBTYPE(I_ACHARE, 1)];
_polygons[SUBTYPE(I_ACHARE, 11)] = _polygons[SUBTYPE(I_ACHARE, 1)];
_polygons[SUBTYPE(I_ACHARE, 12)] = _polygons[SUBTYPE(I_ACHARE, 1)];
_polygons[TYPE(PRCARE)] = Polygon(QBrush(QColor(0xeb, 0x49, 0xeb), _polygons[TYPE(PRCARE)] = Polygon(QBrush(QColor(0xeb, 0x49, 0xeb),
Qt::BDiagPattern)); Qt::BDiagPattern));
_polygons[TYPE(DAMCON)] = Polygon(QBrush(QColor(0xd9, 0x8b, 0x21)), _polygons[TYPE(DAMCON)] = Polygon(QBrush(QColor(0xd9, 0x8b, 0x21)),
@ -133,12 +113,8 @@ void Style::polygonStyle()
_polygons[TYPE(CBLARE)] = Polygon(QImage(":/marine/cable-area-line.png")); _polygons[TYPE(CBLARE)] = Polygon(QImage(":/marine/cable-area-line.png"));
_polygons[TYPE(PIPARE)] = Polygon(QImage(":/marine/pipeline-area-line.png")); _polygons[TYPE(PIPARE)] = Polygon(QImage(":/marine/pipeline-area-line.png"));
_polygons[SUBTYPE(MARKUL, 3)] = Polygon(QImage(":/marine/fishing-farm-line.png")); _polygons[SUBTYPE(MARKUL, 3)] = Polygon(QImage(":/marine/fishing-farm-line.png"));
_polygons[TYPE(BERTHS)] = Polygon(Qt::NoBrush, QPen(QColor(0xeb, 0x49, 0xeb), _polygons[SUBTYPE(I_BERTHS, 6)] = Polygon(Qt::NoBrush,
1, Qt::DashLine)); QPen(QColor(0xeb, 0x49, 0xeb), 1, Qt::DashLine));
_polygons[TYPE(I_BERTHS)] = _polygons[TYPE(BERTHS)];
_polygons[SUBTYPE(I_BERTHS, 6)] = _polygons[TYPE(BERTHS)];
_polygons[TYPE(I_TRNBSN)] = Polygon(Qt::NoBrush, QPen(QColor(0xeb, 0x49, 0xeb),
1, Qt::DashLine));
_polygons[TYPE(CONZNE)] = Polygon(Qt::NoBrush, QPen(QColor(0xeb, 0x49, 0xeb), _polygons[TYPE(CONZNE)] = Polygon(Qt::NoBrush, QPen(QColor(0xeb, 0x49, 0xeb),
1, Qt::DashDotLine)); 1, Qt::DashDotLine));
@ -153,20 +129,13 @@ void Style::polygonStyle()
<< TYPE(I_TERMNL) << TYPE(SLCONS) << TYPE(I_SLCONS) << TYPE(PONTON) << TYPE(I_TERMNL) << TYPE(SLCONS) << TYPE(I_SLCONS) << TYPE(PONTON)
<< TYPE(I_PONTON) << TYPE(HULKES) << TYPE(I_HULKES) << TYPE(FLODOC) << TYPE(I_PONTON) << TYPE(HULKES) << TYPE(I_HULKES) << TYPE(FLODOC)
<< TYPE(I_FLODOC) << TYPE(DRYDOC) << TYPE(DAMCON) << TYPE(PYLONS) << TYPE(I_FLODOC) << TYPE(DRYDOC) << TYPE(DAMCON) << TYPE(PYLONS)
<< TYPE(MORFAC) << TYPE(GATCON) << TYPE(I_GATCON) << TYPE(BERTHS) << TYPE(MORFAC) << TYPE(GATCON) << TYPE(I_GATCON) << SUBTYPE(I_BERTHS, 6)
<< TYPE(I_BERTHS) << SUBTYPE(I_BERTHS, 6) << TYPE(DMPGRD) << TYPE(TSEZNE) << TYPE(DMPGRD) << TYPE(TSEZNE) << TYPE(OBSTRN) << TYPE(UWTROC)
<< TYPE(OBSTRN) << TYPE(UWTROC) << TYPE(DWRTPT) << SUBTYPE(ACHARE, 1) << TYPE(DWRTPT) << SUBTYPE(ACHARE, 1) << SUBTYPE(I_ACHARE, 1)
<< SUBTYPE(ACHARE, 2) << SUBTYPE(ACHARE, 3) << SUBTYPE(ACHARE, 4) << SUBTYPE(RESARE, 9) << SUBTYPE(RESARE, 2) << SUBTYPE(I_RESARE, 2)
<< SUBTYPE(ACHARE, 5) << SUBTYPE(ACHARE, 6) << SUBTYPE(ACHARE, 7) << SUBTYPE(RESARE, 17) << SUBTYPE(I_RESARE, 17) << SUBTYPE(RESARE, 12)
<< SUBTYPE(ACHARE, 8) << SUBTYPE(ACHARE, 9) << SUBTYPE(I_ACHARE, 1) << SUBTYPE(I_RESARE, 12) << SUBTYPE(RESARE, 1) << TYPE(CBLARE)
<< SUBTYPE(I_ACHARE, 2) << SUBTYPE(I_ACHARE, 3) << SUBTYPE(I_ACHARE, 4) << TYPE(PIPARE) << TYPE(PRCARE) << SUBTYPE(MARKUL, 3) << TYPE(CONZNE);
<< SUBTYPE(I_ACHARE, 5) << SUBTYPE(I_ACHARE, 6) << SUBTYPE(I_ACHARE, 7)
<< SUBTYPE(I_ACHARE, 8) << SUBTYPE(I_ACHARE, 9) << SUBTYPE(I_ACHARE, 10)
<< SUBTYPE(I_ACHARE, 11) << SUBTYPE(I_ACHARE, 12) << SUBTYPE(RESARE, 9)
<< SUBTYPE(RESARE, 2) << SUBTYPE(I_RESARE, 2) << SUBTYPE(RESARE, 17)
<< SUBTYPE(I_RESARE, 17) << SUBTYPE(RESARE, 12) << SUBTYPE(I_RESARE, 12)
<< SUBTYPE(RESARE, 1) << TYPE(CBLARE) << TYPE(PIPARE) << TYPE(PRCARE)
<< TYPE(I_TRNBSN) << SUBTYPE(MARKUL, 3) << TYPE(CONZNE);
} }
void Style::lineStyle(qreal ratio) void Style::lineStyle(qreal ratio)
@ -183,7 +152,7 @@ void Style::lineStyle(qreal ratio)
_lines[TYPE(CBLSUB)].setTextFontSize(Small); _lines[TYPE(CBLSUB)].setTextFontSize(Small);
_lines[TYPE(PIPSOL)] = Line(QImage(":/marine/pipeline.png")); _lines[TYPE(PIPSOL)] = Line(QImage(":/marine/pipeline.png"));
_lines[TYPE(PIPSOL)].setTextFontSize(Small); _lines[TYPE(PIPSOL)].setTextFontSize(Small);
_lines[TYPE(NAVLNE)] = Line(QPen(QColor(0, 0, 0), 1, Qt::DashLine)); _lines[TYPE(NAVLNE)] = Line(QPen(QColor(0xeb, 0x49, 0xeb), 1, Qt::DashLine));
_lines[TYPE(COALNE)] = Line(QPen(QColor(0, 0, 0), 1, Qt::SolidLine)); _lines[TYPE(COALNE)] = Line(QPen(QColor(0, 0, 0), 1, Qt::SolidLine));
_lines[TYPE(SLCONS)] = Line(QPen(QColor(0, 0, 0), 2, Qt::SolidLine)); _lines[TYPE(SLCONS)] = Line(QPen(QColor(0, 0, 0), 2, Qt::SolidLine));
_lines[TYPE(I_SLCONS)] = Line(QPen(QColor(0, 0, 0), 2, Qt::SolidLine)); _lines[TYPE(I_SLCONS)] = Line(QPen(QColor(0, 0, 0), 2, Qt::SolidLine));
@ -266,7 +235,6 @@ void Style::pointStyle(qreal ratio)
_points[SUBTYPE(LNDMRK, 7)] = Point(QImage(":/marine/pylon.png"), Small); _points[SUBTYPE(LNDMRK, 7)] = Point(QImage(":/marine/pylon.png"), Small);
_points[SUBTYPE(LNDMRK, 9)] = Point(QImage(":/marine/monument.png"), Small, _points[SUBTYPE(LNDMRK, 9)] = Point(QImage(":/marine/monument.png"), Small,
QPoint(0, -7)); QPoint(0, -7));
_points[SUBTYPE(LNDMRK, 10)] = Point(QImage(":/marine/pylon.png"), Small);
_points[SUBTYPE(LNDMRK, 15)] = Point(QImage(":/marine/dome.png"), Small, _points[SUBTYPE(LNDMRK, 15)] = Point(QImage(":/marine/dome.png"), Small,
QPoint(0, -5)); QPoint(0, -5));
_points[SUBTYPE(LNDMRK, 17)] = Point(QImage(":/marine/tower.png"), Small, _points[SUBTYPE(LNDMRK, 17)] = Point(QImage(":/marine/tower.png"), Small,
@ -355,6 +323,7 @@ void Style::pointStyle(qreal ratio)
_points[SUBTYPE(I_RDOCAL, 3)].setTextColor(QColor(0xeb, 0x49, 0xeb)); _points[SUBTYPE(I_RDOCAL, 3)].setTextColor(QColor(0xeb, 0x49, 0xeb));
_points[SUBTYPE(I_RDOCAL, 4)].setTextColor(QColor(0xeb, 0x49, 0xeb)); _points[SUBTYPE(I_RDOCAL, 4)].setTextColor(QColor(0xeb, 0x49, 0xeb));
_points[TYPE(PYLONS)] = Point(QImage(":/marine/pylon.png")); _points[TYPE(PYLONS)] = Point(QImage(":/marine/pylon.png"));
_points[SUBTYPE(I_BERTHS, 6)] = Point(QImage(":/marine/fleeting-area.png"));
_points[SUBTYPE(WATTUR, 1)] = Point(QImage(":/marine/breakers.png")); _points[SUBTYPE(WATTUR, 1)] = Point(QImage(":/marine/breakers.png"));
_points[SUBTYPE(WATTUR, 2)] = Point(QImage(":/marine/eddies.png")); _points[SUBTYPE(WATTUR, 2)] = Point(QImage(":/marine/eddies.png"));
_points[SUBTYPE(WATTUR, 3)] = Point(QImage(":/marine/overfalls.png")); _points[SUBTYPE(WATTUR, 3)] = Point(QImage(":/marine/overfalls.png"));
@ -366,19 +335,6 @@ void Style::pointStyle(qreal ratio)
_points[SUBTYPE(WEDKLP, 0)] = Point(QImage(":/marine/kelp.png")); _points[SUBTYPE(WEDKLP, 0)] = Point(QImage(":/marine/kelp.png"));
_points[SUBTYPE(WEDKLP, 1)] = Point(QImage(":/marine/kelp.png")); _points[SUBTYPE(WEDKLP, 1)] = Point(QImage(":/marine/kelp.png"));
_points[TYPE(SEAARE)].setHaloColor(QColor()); _points[TYPE(SEAARE)].setHaloColor(QColor());
_points[TYPE(RADRFL)] = Point(QImage(":/marine/radar-reflector.png"));
_points[SUBTYPE(I_BERTHS, 6)] = Point(QImage(":/marine/fleeting-area.png"),
Small);
_points[SUBTYPE(ACHARE, 2)] = Point(QImage(":/marine/dw-anchorage.png"),
Small);
_points[SUBTYPE(ACHARE, 3)] = Point(QImage(":/marine/tanker-anchorage.png"),
Small);
_points[SUBTYPE(ACHARE, 9)] = Point(QImage(":/marine/24h-anchorage.png"),
Small);
_points[SUBTYPE(I_ACHARE, 2)] = _points[SUBTYPE(ACHARE, 2)];
_points[SUBTYPE(I_ACHARE, 3)] = _points[SUBTYPE(ACHARE, 3)];
_points[SUBTYPE(I_ACHARE, 9)] = _points[SUBTYPE(ACHARE, 9)];
_points[SUBTYPE(SMCFAC, 7)] = Point(svg2img(":/POI/restaurant-11.svg", _points[SUBTYPE(SMCFAC, 7)] = Point(svg2img(":/POI/restaurant-11.svg",
ratio), Small); ratio), Small);

View File

@ -11,7 +11,7 @@ class DEMFile : public SubFile
{ {
public: public:
DEMFile(const IMGData *img) : SubFile(img) {} DEMFile(const IMGData *img) : SubFile(img) {}
DEMFile(const QString &path) : SubFile(path) {} DEMFile(const QString *path) : SubFile(path) {}
DEMFile(const SubFile *gmp, quint32 offset) : SubFile(gmp, offset) {} DEMFile(const SubFile *gmp, quint32 offset) : SubFile(gmp, offset) {}
bool load(Handle &hdl); bool load(Handle &hdl);

View File

@ -87,16 +87,12 @@ bool GMAPData::loadTile(const QDir &dir)
const QFileInfo &fi = ml.at(i); const QFileInfo &fi = ml.at(i);
SubFile::Type tt = tileType(fi.suffix()); SubFile::Type tt = tileType(fi.suffix());
if (VectorTile::isTileFile(tt)) { if (VectorTile::isTileFile(tt)) {
if (!tile->addFile(fi.absoluteFilePath(), tt)) { _files.append(new QString(fi.absoluteFilePath()));
qWarning("%s: Invalid map tile structure", tile->addFile(_files.last(), tt);
qPrintable(dir.path()));
delete tile;
return false;
}
} }
} }
if (!tile->init()) { if (!tile->init(0)) {
qWarning("%s: Invalid map tile", qPrintable(dir.path())); qWarning("%s: Invalid map tile", qPrintable(dir.path()));
delete tile; delete tile;
return false; return false;
@ -135,8 +131,10 @@ GMAPData::GMAPData(const QString &fileName) : MapData(fileName)
loadTile(QDir(fi.absoluteFilePath())); loadTile(QDir(fi.absoluteFilePath()));
} }
if (baseDir.exists(typFilePath)) if (baseDir.exists(typFilePath)) {
_typ = new SubFile(baseDir.filePath(typFilePath)); _files.append(new QString(baseDir.filePath(typFilePath)));
_typ = new SubFile(_files.last());
}
if (!_tileTree.Count()) if (!_tileTree.Count())
_errorString = "No usable map tile found"; _errorString = "No usable map tile found";
@ -145,3 +143,8 @@ GMAPData::GMAPData(const QString &fileName) : MapData(fileName)
computeZooms(); computeZooms();
} }
GMAPData::~GMAPData()
{
qDeleteAll(_files);
}

View File

@ -12,13 +12,15 @@ class GMAPData : public MapData
{ {
public: public:
GMAPData(const QString &fileName); GMAPData(const QString &fileName);
~GMAPData();
private: private:
bool readXML(const QString &path, QString &dataDir, QString &typFile); bool readXML(const QString &path, QString &dataDir, QString &typFile);
void mapProduct(QXmlStreamReader &reader, QString &dataDir, void mapProduct(QXmlStreamReader &reader, QString &dataDir, QString &typFile);
QString &typFile);
void subProduct(QXmlStreamReader &reader, QString &dataDir); void subProduct(QXmlStreamReader &reader, QString &dataDir);
bool loadTile(const QDir &dir); bool loadTile(const QDir &dir);
QList<const QString*> _files;
}; };
} }

View File

@ -117,7 +117,8 @@ bool IMGData::readFAT(QFile *file, TileMap &tileMap)
} else } else
tile = *it; tile = *it;
SubFile *subFile = part ? tile->file(tt) : tile->addFile(this, tt); SubFile *subFile = part ? tile->file(tt)
: tile->addFile(this, tt);
if (!(subFile && readSubFileBlocks(file, offset, subFile))) if (!(subFile && readSubFileBlocks(file, offset, subFile)))
return false; return false;
} else if (tt == SubFile::TYP) { } else if (tt == SubFile::TYP) {

View File

@ -18,7 +18,7 @@ public:
LBLFile(const IMGData *img) LBLFile(const IMGData *img)
: SubFile(img), _huffmanText(0), _imgIdSize(0), _poiShift(0), _shift(0), : SubFile(img), _huffmanText(0), _imgIdSize(0), _poiShift(0), _shift(0),
_encoding(0) {} _encoding(0) {}
LBLFile(const QString &path) LBLFile(const QString *path)
: SubFile(path), _huffmanText(0), _imgIdSize(0), _poiShift(0), _shift(0), : SubFile(path), _huffmanText(0), _imgIdSize(0), _poiShift(0), _shift(0),
_encoding(0) {} _encoding(0) {}
LBLFile(const SubFile *gmp, quint32 offset) LBLFile(const SubFile *gmp, quint32 offset)

View File

@ -99,14 +99,14 @@ void MapData::load(qreal ratio)
Q_ASSERT(!_style); Q_ASSERT(!_style);
if (_typ) if (_typ)
_style = new Style(ratio, _typ); _style = new Style(0, ratio, _typ);
else { else {
QString typFile(ProgramPaths::typFile()); QString typFile(ProgramPaths::typFile());
if (QFileInfo::exists(typFile)) { if (QFileInfo::exists(typFile)) {
SubFile typ(typFile); SubFile typ(&typFile);
_style = new Style(ratio, &typ); _style = new Style(0, ratio, &typ);
} else } else
_style = new Style(ratio); _style = new Style(0, ratio);
} }
} }

View File

@ -18,7 +18,7 @@ class NETFile : public SubFile
public: public:
NETFile(const IMGData *img) NETFile(const IMGData *img)
: SubFile(img), _huffmanTable(0), _tp(0), _netShift(0), _linksShift(0) {} : SubFile(img), _huffmanTable(0), _tp(0), _netShift(0), _linksShift(0) {}
NETFile(const QString &path) NETFile(const QString *path)
: SubFile(path), _huffmanTable(0), _tp(0), _netShift(0), _linksShift(0) {} : SubFile(path), _huffmanTable(0), _tp(0), _netShift(0), _linksShift(0) {}
NETFile(const SubFile *gmp, quint32 offset) NETFile(const SubFile *gmp, quint32 offset)
: SubFile(gmp, offset), _huffmanTable(0), _tp(0), _netShift(0), : SubFile(gmp, offset), _huffmanTable(0), _tp(0), _netShift(0),

View File

@ -62,7 +62,7 @@ public:
NODFile(const IMGData *img) NODFile(const IMGData *img)
: SubFile(img), _indexFlags(0), _indexRecordSize(0), _blockRecordSize(0), : SubFile(img), _indexFlags(0), _indexRecordSize(0), _blockRecordSize(0),
_blockShift(0), _nodeShift(0), _indexIdSize(0) {} _blockShift(0), _nodeShift(0), _indexIdSize(0) {}
NODFile(const QString &path) NODFile(const QString *path)
: SubFile(path), _indexFlags(0), _indexRecordSize(0), _blockRecordSize(0), : SubFile(path), _indexFlags(0), _indexRecordSize(0), _blockRecordSize(0),
_blockShift(0), _nodeShift(0), _indexIdSize(0) {} _blockShift(0), _nodeShift(0), _indexIdSize(0) {}
NODFile(const SubFile *gmp, quint32 offset) NODFile(const SubFile *gmp, quint32 offset)

View File

@ -152,7 +152,7 @@ void RasterTile::drawPolygons(QPainter *painter,
bool insert = false; bool insert = false;
SubFile::Handle *hdl = hc.object(poly.raster.lbl()); SubFile::Handle *hdl = hc.object(poly.raster.lbl());
if (!hdl) { if (!hdl) {
hdl = new SubFile::Handle(poly.raster.lbl(), _file); hdl = new SubFile::Handle(_file, poly.raster.lbl());
insert = true; insert = true;
} }
QPixmap pm(poly.raster.lbl()->image(*hdl, poly.raster.id())); QPixmap pm(poly.raster.lbl()->image(*hdl, poly.raster.id()));
@ -445,11 +445,7 @@ void RasterTile::fetchData(QList<MapData::Poly> &polygons,
if (dynamic_cast<IMGData*>(_data)) { if (dynamic_cast<IMGData*>(_data)) {
_file = new QFile(_data->fileName()); _file = new QFile(_data->fileName());
if (!_file->open(QIODevice::ReadOnly | QIODevice::Unbuffered)) { _file->open(QIODevice::ReadOnly | QIODevice::Unbuffered);
qWarning("%s: %s", qPrintable(_file->fileName()),
qPrintable(_file->errorString()));
return;
}
} }
QRectF polyRect(ttl, QPointF(ttl.x() + _rect.width(), ttl.y() QRectF polyRect(ttl, QPointF(ttl.x() + _rect.width(), ttl.y()

View File

@ -24,7 +24,7 @@ public:
}; };
RGNFile(const IMGData *img) : SubFile(img), _huffmanTable(0) {} RGNFile(const IMGData *img) : SubFile(img), _huffmanTable(0) {}
RGNFile(const QString &path) : SubFile(path), _huffmanTable(0) {} RGNFile(const QString *path) : SubFile(path), _huffmanTable(0) {}
RGNFile(const SubFile *gmp, quint32 offset) RGNFile(const SubFile *gmp, quint32 offset)
: SubFile(gmp, offset), _huffmanTable(0) {} : SubFile(gmp, offset), _huffmanTable(0) {}
~RGNFile(); ~RGNFile();

View File

@ -1268,9 +1268,9 @@ bool Style::parseDrawOrder(SubFile *file, SubFile::Handle &hdl,
return true; return true;
} }
bool Style::parseTYPFile(SubFile *typ) bool Style::parseTYPFile(QFile *file, SubFile *typ)
{ {
SubFile::Handle hdl(typ); SubFile::Handle hdl(file, typ);
Section points, lines, polygons, order; Section points, lines, polygons, order;
quint16 tmp16, codepage; quint16 tmp16, codepage;
@ -1311,7 +1311,7 @@ bool Style::parseTYPFile(SubFile *typ)
return true; return true;
} }
Style::Style(qreal ratio, SubFile *typ) Style::Style(QFile *file, qreal ratio, SubFile *typ)
{ {
_large = pixelSizeFont(16); _large = pixelSizeFont(16);
_normal = pixelSizeFont(14); _normal = pixelSizeFont(14);
@ -1326,7 +1326,7 @@ Style::Style(qreal ratio, SubFile *typ)
defaultPointStyle(ratio); defaultPointStyle(ratio);
if (typ) if (typ)
parseTYPFile(typ); parseTYPFile(file, typ);
} }
const Style::Line &Style::line(quint32 type) const const Style::Line &Style::line(quint32 type) const

View File

@ -104,7 +104,7 @@ public:
}; };
Style(qreal ratio, SubFile *typ = 0); Style(QFile *file, qreal ratio, SubFile *typ = 0);
const Line &line(quint32 type) const; const Line &line(quint32 type) const;
const Polygon &polygon(quint32 type) const; const Polygon &polygon(quint32 type) const;
@ -171,7 +171,7 @@ private:
bool extended; bool extended;
}; };
bool parseTYPFile(SubFile *typ); bool parseTYPFile(QFile *file, SubFile *typ);
bool parsePoints(SubFile *file, SubFile::Handle &hdl, bool parsePoints(SubFile *file, SubFile::Handle &hdl,
const Section &section); const Section &section);
bool parsePoint(SubFile *file, SubFile::Handle &hdl, bool parsePoint(SubFile *file, SubFile::Handle &hdl,

View File

@ -18,7 +18,7 @@ public:
class Handle class Handle
{ {
public: public:
Handle(const SubFile *subFile, QFile *file = 0) Handle(QFile *file, const SubFile *subFile)
: _file(file), _blockNum(-1), _blockPos(-1), _pos(-1), _delete(false) : _file(file), _blockNum(-1), _blockPos(-1), _pos(-1), _delete(false)
{ {
if (!subFile) if (!subFile)
@ -26,9 +26,7 @@ public:
if (!_file) { if (!_file) {
_file = new QFile(subFile->fileName()); _file = new QFile(subFile->fileName());
if (!_file->open(QIODevice::ReadOnly | QIODevice::Unbuffered)) _file->open(QIODevice::ReadOnly | QIODevice::Unbuffered);
qWarning("%s: %s", qPrintable(_file->fileName()),
qPrintable(_file->errorString()));
_delete = true; _delete = true;
} }
_data.resize(subFile->blockSize()); _data.resize(subFile->blockSize());
@ -53,18 +51,13 @@ public:
SubFile(const IMGData *img) SubFile(const IMGData *img)
: _gmpOffset(0), _img(img), _blocks(new QVector<quint16>()), _path(0) {} : _gmpOffset(0), _img(img), _blocks(new QVector<quint16>()), _path(0) {}
SubFile(const SubFile *gmp, quint32 offset) : _gmpOffset(offset), SubFile(const SubFile *gmp, quint32 offset) : _gmpOffset(offset),
_img(gmp->_img), _blocks(gmp->_blocks), _path(gmp->_path) _img(gmp->_img), _blocks(gmp->_blocks), _path(gmp->_path) {}
{ SubFile(const QString *path)
Q_ASSERT(offset); : _gmpOffset(0), _img(0), _blocks(0), _path(path) {}
}
SubFile(const QString &path)
: _gmpOffset(0), _img(0), _blocks(0), _path(new QString(path)) {}
~SubFile() ~SubFile()
{ {
if (!_gmpOffset) { if (!_gmpOffset)
delete _blocks; delete _blocks;
delete _path;
}
} }
void addBlock(quint16 block) {_blocks->append(block);} void addBlock(quint16 block) {_blocks->append(block);}

View File

@ -51,7 +51,7 @@ TREFile::~TREFile()
bool TREFile::init(QFile *file) bool TREFile::init(QFile *file)
{ {
Handle hdl(this, file); Handle hdl(file, this);
quint8 locked, levels[64]; quint8 locked, levels[64];
quint16 hdrLen; quint16 hdrLen;
qint32 north, east, south, west; qint32 north, east, south, west;
@ -156,7 +156,7 @@ int TREFile::readExtEntry(Handle &hdl, quint32 &polygons, quint32 &lines,
bool TREFile::load(QFile *file, int idx) bool TREFile::load(QFile *file, int idx)
{ {
Handle hdl(this, file); Handle hdl(file, this);
QList<SubDiv*> sl; QList<SubDiv*> sl;
SubDiv *s = 0; SubDiv *s = 0;
SubDivTree *tree = new SubDivTree(); SubDivTree *tree = new SubDivTree();

View File

@ -18,7 +18,7 @@ class TREFile : public SubFile
public: public:
TREFile(const IMGData *img) TREFile(const IMGData *img)
: SubFile(img), _flags(0), _extItemSize(0) {} : SubFile(img), _flags(0), _extItemSize(0) {}
TREFile(const QString &path) TREFile(const QString *path)
: SubFile(path), _flags(0), _extItemSize(0) {} : SubFile(path), _flags(0), _extItemSize(0) {}
TREFile(const SubFile *gmp, quint32 offset) TREFile(const SubFile *gmp, quint32 offset)
: SubFile(gmp, offset), _flags(0), _extItemSize(0) {} : SubFile(gmp, offset), _flags(0), _extItemSize(0) {}

View File

@ -53,12 +53,9 @@ bool VectorTile::init(QFile *file)
bool VectorTile::initGMP(QFile *file) bool VectorTile::initGMP(QFile *file)
{ {
SubFile::Handle hdl(_gmp, file); SubFile::Handle hdl(file, _gmp);
quint32 tre, rgn, lbl, net, nod, dem; quint32 tre, rgn, lbl, net, nod, dem;
if (_tre || _rgn || _lbl || _net || _nod || _dem)
return false;
if (!(_gmp->seek(hdl, 0x19) && _gmp->readUInt32(hdl, tre) if (!(_gmp->seek(hdl, 0x19) && _gmp->readUInt32(hdl, tre)
&& _gmp->readUInt32(hdl, rgn) && _gmp->readUInt32(hdl, lbl) && _gmp->readUInt32(hdl, rgn) && _gmp->readUInt32(hdl, lbl)
&& _gmp->readUInt32(hdl, net) && _gmp->readUInt32(hdl, nod) && _gmp->readUInt32(hdl, net) && _gmp->readUInt32(hdl, nod)
@ -136,10 +133,10 @@ void VectorTile::polys(QFile *file, const RectC &rect, const Zoom &zoom,
} }
if (!_loaded) { if (!_loaded) {
rgnHdl = new SubFile::Handle(_rgn, file); rgnHdl = new SubFile::Handle(file, _rgn);
lblHdl = new SubFile::Handle(_lbl, file); lblHdl = new SubFile::Handle(file, _lbl);
netHdl = new SubFile::Handle(_net, file); netHdl = new SubFile::Handle(file, _net);
nodHdl = new SubFile::Handle(_nod, file); nodHdl = new SubFile::Handle(file, _nod);
if (!load(*rgnHdl, *lblHdl, *netHdl, *nodHdl)) { if (!load(*rgnHdl, *lblHdl, *netHdl, *nodHdl)) {
_lock.unlock(); _lock.unlock();
@ -162,9 +159,9 @@ void VectorTile::polys(QFile *file, const RectC &rect, const Zoom &zoom,
quint32 shift = _tre->shift(subdiv->bits()); quint32 shift = _tre->shift(subdiv->bits());
if (!rgnHdl) { if (!rgnHdl) {
rgnHdl = new SubFile::Handle(_rgn, file); rgnHdl = new SubFile::Handle(file, _rgn);
lblHdl = new SubFile::Handle(_lbl, file); lblHdl = new SubFile::Handle(file, _lbl);
netHdl = new SubFile::Handle(_net, file); netHdl = new SubFile::Handle(file, _net);
} }
if (!subdiv->initialized() && !_rgn->subdivInit(*rgnHdl, subdiv)) { if (!subdiv->initialized() && !_rgn->subdivInit(*rgnHdl, subdiv)) {
@ -185,9 +182,9 @@ void VectorTile::polys(QFile *file, const RectC &rect, const Zoom &zoom,
if (_net && _net->hasLinks()) { if (_net && _net->hasLinks()) {
if (!nodHdl) if (!nodHdl)
nodHdl = new SubFile::Handle(_nod, file); nodHdl = new SubFile::Handle(file, _nod);
if (!nodHdl2) if (!nodHdl2)
nodHdl2 = new SubFile::Handle(_nod, file); nodHdl2 = new SubFile::Handle(file, _nod);
_rgn->links(*rgnHdl, subdiv, shift, _net, *netHdl, _nod, *nodHdl, _rgn->links(*rgnHdl, subdiv, shift, _net, *netHdl, _nod, *nodHdl,
*nodHdl2, _lbl, *lblHdl, &polys->lines); *nodHdl2, _lbl, *lblHdl, &polys->lines);
} }
@ -224,10 +221,10 @@ void VectorTile::points(QFile *file, const RectC &rect, const Zoom &zoom,
} }
if (!_loaded) { if (!_loaded) {
rgnHdl = new SubFile::Handle(_rgn, file); rgnHdl = new SubFile::Handle(file, _rgn);
lblHdl = new SubFile::Handle(_lbl, file); lblHdl = new SubFile::Handle(file, _lbl);
SubFile::Handle nodHdl(_nod, file); SubFile::Handle nodHdl(file, _nod);
SubFile::Handle netHdl(_net, file); SubFile::Handle netHdl(file, _net);
if (!load(*rgnHdl, *lblHdl, netHdl, nodHdl)) { if (!load(*rgnHdl, *lblHdl, netHdl, nodHdl)) {
_lock.unlock(); _lock.unlock();
@ -248,8 +245,8 @@ void VectorTile::points(QFile *file, const RectC &rect, const Zoom &zoom,
cacheLock->unlock(); cacheLock->unlock();
if (!rgnHdl) { if (!rgnHdl) {
rgnHdl = new SubFile::Handle(_rgn, file); rgnHdl = new SubFile::Handle(file, _rgn);
lblHdl = new SubFile::Handle(_lbl, file); lblHdl = new SubFile::Handle(file, _lbl);
} }
if (!subdiv->initialized() && !_rgn->subdivInit(*rgnHdl, subdiv)) { if (!subdiv->initialized() && !_rgn->subdivInit(*rgnHdl, subdiv)) {
@ -293,7 +290,7 @@ void VectorTile::elevations(QFile *file, const RectC &rect, const Zoom &zoom,
} }
if (!_demLoaded) { if (!_demLoaded) {
hdl = new SubFile::Handle(_dem, file); hdl = new SubFile::Handle(file, _dem);
if (!loadDem(*hdl)) { if (!loadDem(*hdl)) {
_demLock.unlock(); _demLock.unlock();
@ -318,7 +315,7 @@ void VectorTile::elevations(QFile *file, const RectC &rect, const Zoom &zoom,
cacheLock->unlock(); cacheLock->unlock();
if (!hdl) if (!hdl)
hdl = new SubFile::Handle(_dem, file); hdl = new SubFile::Handle(file, _dem);
el = _dem->elevations(*hdl, level, tile); el = _dem->elevations(*hdl, level, tile);
if (!el->m.isNull()) if (!el->m.isNull())

View File

@ -21,7 +21,7 @@ public:
delete _dem; delete _gmp; delete _dem; delete _gmp;
} }
bool init(QFile *file = 0); bool init(QFile *file);
void clear(); void clear();
const RectC &bounds() const {return _tre->bounds();} const RectC &bounds() const {return _tre->bounds();}
@ -49,37 +49,25 @@ public:
} }
template<typename T> template<typename T>
SubFile *addFile(T container, SubFile::Type type) SubFile *addFile(T *container, SubFile::Type type)
{ {
switch (type) { switch (type) {
case SubFile::TRE: case SubFile::TRE:
if (_tre)
return 0;
_tre = new TREFile(container); _tre = new TREFile(container);
return _tre; return _tre;
case SubFile::RGN: case SubFile::RGN:
if (_rgn)
return 0;
_rgn = new RGNFile(container); _rgn = new RGNFile(container);
return _rgn; return _rgn;
case SubFile::LBL: case SubFile::LBL:
if (_lbl)
return 0;
_lbl = new LBLFile(container); _lbl = new LBLFile(container);
return _lbl; return _lbl;
case SubFile::NET: case SubFile::NET:
if (_net)
return 0;
_net = new NETFile(container); _net = new NETFile(container);
return _net; return _net;
case SubFile::NOD: case SubFile::NOD:
if (_nod)
return 0;
_nod = new NODFile(container); _nod = new NODFile(container);
return _nod; return _nod;
case SubFile::DEM: case SubFile::DEM:
if (_dem)
return 0;
_dem = new DEMFile(container); _dem = new DEMFile(container);
return _dem; return _dem;
case SubFile::GMP: case SubFile::GMP:

View File

@ -258,9 +258,7 @@ void AQMMap::load(const Projection &in, const Projection &out,
Q_UNUSED(out); Q_UNUSED(out);
_mapRatio = hidpi ? deviceRatio : 1.0; _mapRatio = hidpi ? deviceRatio : 1.0;
if (!_file.open(QIODevice::ReadOnly)) _file.open(QIODevice::ReadOnly);
qWarning("%s: %s", qPrintable(_file.fileName()),
qPrintable(_file.errorString()));
} }
void AQMMap::unload() void AQMMap::unload()

View File

@ -141,7 +141,8 @@ bool Conversion::loadList(const QString &path)
bool res; bool res;
if (!file.open(QFile::ReadOnly)) { if (!file.open(QFile::ReadOnly)) {
qWarning("%s: %s", qPrintable(path), qPrintable(file.errorString())); qWarning("Error opening projections file: %s: %s", qPrintable(path),
qPrintable(file.errorString()));
return false; return false;
} }

View File

@ -38,7 +38,8 @@ bool Ellipsoid::loadList(const QString &path)
bool res; bool res;
if (!file.open(QFile::ReadOnly)) { if (!file.open(QFile::ReadOnly)) {
qWarning("%s: %s", qPrintable(path), qPrintable(file.errorString())); qWarning("Error opening ellipsoids file: %s: %s", qPrintable(path),
qPrintable(file.errorString()));
return false; return false;
} }

View File

@ -102,7 +102,8 @@ bool GCS::loadList(const QString &path)
bool res; bool res;
if (!file.open(QFile::ReadOnly)) { if (!file.open(QFile::ReadOnly)) {
qWarning("%s: %s", qPrintable(path), qPrintable(file.errorString())); qWarning("Error opening GCS file: %s: %s", qPrintable(path),
qPrintable(file.errorString()));
return false; return false;
} }

View File

@ -189,9 +189,7 @@ void GEMFMap::load(const Projection &in, const Projection &out,
Q_UNUSED(out); Q_UNUSED(out);
_mapRatio = hidpi ? deviceRatio : 1.0; _mapRatio = hidpi ? deviceRatio : 1.0;
if (!_file.open(QIODevice::ReadOnly)) _file.open(QIODevice::ReadOnly);
qWarning("%s: %s", qPrintable(_file.fileName()),
qPrintable(_file.errorString()));
} }
void GEMFMap::unload() void GEMFMap::unload()

View File

@ -162,10 +162,7 @@ void JNXMap::load(const Projection &in, const Projection &out,
_projection = in; _projection = in;
_mapRatio = hidpi ? deviceRatio : 1.0; _mapRatio = hidpi ? deviceRatio : 1.0;
if (!_file.open(QIODevice::ReadOnly)) if (_file.open(QIODevice::ReadOnly))
qWarning("%s: %s", qPrintable(_file.fileName()),
qPrintable(_file.errorString()));
else
readTiles(); readTiles();
} }

View File

@ -459,11 +459,7 @@ RectC MapData::bounds() const
void MapData::load() void MapData::load()
{ {
QFile file(_fileName); QFile file(_fileName);
if (file.open(QIODevice::ReadOnly | QIODevice::Unbuffered))
if (!file.open(QIODevice::ReadOnly | QIODevice::Unbuffered))
qWarning("%s: %s", qPrintable(file.fileName()),
qPrintable(file.errorString()));
else
readSubFiles(file); readSubFiles(file);
} }

View File

@ -410,11 +410,8 @@ void RasterTile::fetchData(QList<MapData::Path> &paths,
QPoint ttl(_rect.topLeft()); QPoint ttl(_rect.topLeft());
QFile file(_data->fileName()); QFile file(_data->fileName());
if (!file.open(QIODevice::ReadOnly | QIODevice::Unbuffered)) { if (!file.open(QIODevice::ReadOnly | QIODevice::Unbuffered))
qWarning("%s: %s", qPrintable(file.fileName()),
qPrintable(file.errorString()));
return; return;
}
QRectF pathRect(QPointF(ttl.x() - PATHS_EXTENT, ttl.y() - PATHS_EXTENT), QRectF pathRect(QPointF(ttl.x() - PATHS_EXTENT, ttl.y() - PATHS_EXTENT),
QPointF(ttl.x() + _rect.width() + PATHS_EXTENT, ttl.y() + _rect.height() QPointF(ttl.x() + _rect.width() + PATHS_EXTENT, ttl.y() + _rect.height()

View File

@ -31,7 +31,8 @@ bool PCS::loadList(const QString &path)
bool res; bool res;
if (!file.open(QFile::ReadOnly)) { if (!file.open(QFile::ReadOnly)) {
qWarning("%s: %s", qPrintable(path), qPrintable(file.errorString())); qWarning("Error opening PCS file: %s: %s", qPrintable(path),
qPrintable(file.errorString()));
return false; return false;
} }

View File

@ -361,9 +361,7 @@ void QCTMap::load(const Projection &in, const Projection &out,
Q_UNUSED(out); Q_UNUSED(out);
_mapRatio = hidpi ? deviceRatio : 1.0; _mapRatio = hidpi ? deviceRatio : 1.0;
if (!_file.open(QIODevice::ReadOnly)) _file.open(QIODevice::ReadOnly);
qWarning("%s: %s", qPrintable(_file.fileName()),
qPrintable(_file.errorString()));
} }
void QCTMap::unload() void QCTMap::unload()

View File

@ -365,9 +365,7 @@ void RMap::load(const Projection &in, const Projection &out, qreal deviceRatio,
Q_UNUSED(out); Q_UNUSED(out);
_mapRatio = hidpi ? deviceRatio : 1.0; _mapRatio = hidpi ? deviceRatio : 1.0;
if (!_file.open(QIODevice::ReadOnly)) _file.open(QIODevice::ReadOnly);
qWarning("%s: %s", qPrintable(_file.fileName()),
qPrintable(_file.errorString()));
} }
void RMap::unload() void RMap::unload()