1
0
mirror of https://github.com/tumic0/GPXSee.git synced 2025-07-23 15:14:24 +02:00

Compare commits

...

6 Commits

Author SHA1 Message Date
c96a0fd8f4 Added missing traffic separation line style 2022-11-09 23:12:40 +01:00
877d9331e4 ENC map style enhancement
+ code cleanup
2022-11-09 21:37:33 +01:00
9d8c23bc32 Fixed crash on ENC map unload 2022-11-09 21:37:05 +01:00
af688314fb Define symbols draw order 2022-11-08 01:16:38 +01:00
1946c3cc6f Image polygon lines 2022-11-08 00:38:45 +01:00
8ae8c3b0a3 Added missing 000 files association 2022-11-06 22:13:53 +01:00
10 changed files with 123 additions and 55 deletions

View File

@ -181,13 +181,14 @@ Section "GPXSee" SEC_APP
!insertmacro FILE_ASSOCIATION_ADD "qct" "QuickChart Map File" 24
!insertmacro FILE_ASSOCIATION_ADD "trk" "TwoNav Track File" 25
!insertmacro FILE_ASSOCIATION_ADD "gemf" "GEMF Map File" 26
!insertmacro FILE_ASSOCIATION_ADD "kml" "Keyhole Markup Language" 27
!insertmacro FILE_ASSOCIATION_ADD "kmz" "KML geographic compressed data" 27
!insertmacro FILE_ASSOCIATION_ADD "fit" "Flexible and Interoperable Data Transfer" 28
!insertmacro FILE_ASSOCIATION_ADD "igc" "Flight Recorder Data Format" 29
!insertmacro FILE_ASSOCIATION_ADD "nmea" "NMEA 0183 Data" 30
!insertmacro FILE_ASSOCIATION_ADD "plt" "OziExplorer Track File" 31
!insertmacro FILE_ASSOCIATION_ADD "rte" "OziExplorer Route File" 32
!insertmacro FILE_ASSOCIATION_ADD "000" "IHO S-57 Electronic Navigation Chart" 27
!insertmacro FILE_ASSOCIATION_ADD "kml" "Keyhole Markup Language" 28
!insertmacro FILE_ASSOCIATION_ADD "kmz" "KML geographic compressed data" 28
!insertmacro FILE_ASSOCIATION_ADD "fit" "Flexible and Interoperable Data Transfer" 29
!insertmacro FILE_ASSOCIATION_ADD "igc" "Flight Recorder Data Format" 30
!insertmacro FILE_ASSOCIATION_ADD "nmea" "NMEA 0183 Data" 31
!insertmacro FILE_ASSOCIATION_ADD "plt" "OziExplorer Track File" 32
!insertmacro FILE_ASSOCIATION_ADD "rte" "OziExplorer Route File" 33
WriteRegStr HKCR "Applications\GPXSee.exe\shell\open\command" "" "$\"$INSTDIR\GPXSee.exe$\" $\"%1$\""
WriteRegStr HKCR ".gpx\OpenWithList" "GPXSee.exe" ""
@ -237,6 +238,7 @@ Section "GPXSee" SEC_APP
WriteRegStr HKCR ".qct\OpenWithList" "GPXSee.exe" ""
WriteRegStr HKCR ".trk\OpenWithList" "GPXSee.exe" ""
WriteRegStr HKCR ".gemf\OpenWithList" "GPXSee.exe" ""
WriteRegStr HKCR ".000\OpenWithList" "GPXSee.exe" ""
System::Call 'shell32.dll::SHChangeNotify(i, i, i, i) v (0x08000000, 0, 0, 0)'
@ -392,6 +394,7 @@ Section "Uninstall"
!insertmacro FILE_ASSOCIATION_REMOVE "qct"
!insertmacro FILE_ASSOCIATION_REMOVE "trk"
!insertmacro FILE_ASSOCIATION_REMOVE "gemf"
!insertmacro FILE_ASSOCIATION_REMOVE "000"
DeleteRegValue HKCR ".gpx\OpenWithList" "GPXSee.exe"
DeleteRegValue HKCR ".tcx\OpenWithList" "GPXSee.exe"
@ -440,6 +443,7 @@ Section "Uninstall"
DeleteRegValue HKCR ".qct\OpenWithList" "GPXSee.exe"
DeleteRegValue HKCR ".trk\OpenWithList" "GPXSee.exe"
DeleteRegValue HKCR ".gemf\OpenWithList" "GPXSee.exe"
DeleteRegValue HKCR ".000\OpenWithList" "GPXSee.exe"
DeleteRegKey HKCR "Applications\GPXSee.exe"
System::Call 'shell32.dll::SHChangeNotify(i, i, i, i) v (0x08000000, 0, 0, 0)'

View File

@ -1,6 +1,7 @@
#ifndef ENC_ATTRIBUTES_H
#define ENC_ATTRIBUTES_H
#define CATACH 8
#define CATHAF 30
#define CATLMK 35
#define CATMOR 40
@ -9,6 +10,8 @@
#define DRVAL1 87
#define ELEVAT 90
#define OBJNAM 116
#define RESTRN 131
#define VALDCO 174
#define WATLEV 187
#endif // ENC_ATTRIBUTES_H

View File

@ -15,6 +15,45 @@ using namespace ENC;
#define PRIM_L 2
#define PRIM_A 3
static QMap<uint,uint> orderMapInit()
{
QMap<uint,uint> map;
map.insert(BUAARE, 1);
map.insert(BCNISD, 2);
map.insert(BCNLAT, 3);
map.insert(BCNSAW, 4);
map.insert(BCNSPP, 5);
map.insert(BOYCAR, 6);
map.insert(BOYINB, 7);
map.insert(BOYISD, 8);
map.insert(BOYLAT, 9);
map.insert(BOYSAW, 10);
map.insert(BOYSPP, 11);
map.insert(MORFAC, 12);
map.insert(OFSPLF, 13);
map.insert(LIGHTS, 14);
map.insert(OBSTRN, 15);
map.insert(WRECKS, 16);
map.insert(UWTROC, 17);
map.insert(HRBFAC, 18);
map.insert(PILPNT, 19);
map.insert(ACHBRT, 20);
map.insert(LNDELV, 21);
map.insert(LNDMRK, 22);
map.insert(SOUNDG, 0xFFFFFFFF);
return map;
}
static QMap<uint,uint> orderMap = orderMapInit();
static uint order(uint type)
{
QMap<uint, uint>::const_iterator it = orderMap.find(type);
return (it == orderMap.constEnd()) ? type + 512 : it.value();
}
static void warning(const ISO8211::Field &FRID, uint PRIM)
{
uint RCID = 0xFFFFFFFF;
@ -132,6 +171,13 @@ 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)
{
uint hash = (uint)qHash(QPair<double,double>(c.lon(), c.lat()));
_id = ((quint64)order(type>>16))<<32 | hash;
}
QVector<MapData::Sounding> MapData::soundings(const ISO8211::Record &r,
uint COMF, uint SOMF)
{
@ -212,7 +258,7 @@ QVector<Coordinates> MapData::lineGeometry(const ISO8211::Record &r,
{
QVector<Coordinates> path;
Coordinates c[2];
uint ORNT, MASK;
uint ORNT;
quint8 type;
quint32 id;
@ -224,8 +270,6 @@ QVector<Coordinates> MapData::lineGeometry(const ISO8211::Record &r,
if (!parseNAME(FSPT, &type, &id, i) || type != RCNM_VE)
return QVector<Coordinates>();
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);
if (it == ve.constEnd())
@ -280,7 +324,7 @@ Polygon MapData::polyGeometry(const ISO8211::Record &r, const RecordMap &vc,
Polygon path;
QVector<Coordinates> v;
Coordinates c[2];
uint ORNT, USAG, MASK;
uint ORNT, USAG;
quint8 type;
quint32 id;
@ -293,8 +337,6 @@ Polygon MapData::polyGeometry(const ISO8211::Record &r, const RecordMap &vc,
return Polygon();
ORNT = FSPT->data().at(i).at(1).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()) {
path.append(v);
@ -374,7 +416,8 @@ MapData::Attr MapData::pointAttr(const ISO8211::Record &r, uint OBJL)
if ((OBJL == HRBFAC && key == CATHAF)
|| (OBJL == LNDMRK && key == CATLMK)
|| (OBJL == WRECKS && key == CATWRK)
|| (OBJL == MORFAC && key == CATMOR))
|| (OBJL == MORFAC && key == CATMOR)
|| (OBJL == UWTROC && key == WATLEV))
subtype = av.at(1).toString().toUInt();
}
@ -419,8 +462,13 @@ MapData::Attr MapData::polyAttr(const ISO8211::Record &r, uint OBJL)
if (OBJL == DEPARE && key == DRVAL1)
subtype = depthLevel(av.at(1).toString());
else if (OBJL == RESARE && key == CATREA)
else if ((OBJL == RESARE && key == CATREA)
|| (OBJL == ACHARE && key == CATACH))
subtype = av.at(1).toString().toUInt();
else if (OBJL == RESARE && key == RESTRN) {
if (av.at(1).toString().toUInt() == 1)
subtype = 2;
}
}
return Attr(subtype, label);
@ -557,7 +605,7 @@ bool MapData::bounds(const QVector<ISO8211::Record> &gv, Rect &b)
return true;
}
bool MapData::fetchBoundsAndName()
MapData::MapData(const QString &path): _fileName(path)
{
QFile file(_fileName);
QVector<ISO8211::Record> gv;
@ -566,42 +614,34 @@ bool MapData::fetchBoundsAndName()
if (!file.open(QIODevice::ReadOnly)) {
_errorString = file.errorString();
return false;
return;
}
if (!ddf.readDDR(file)) {
_errorString = ddf.errorString();
return false;
return;
}
while (!file.atEnd()) {
ISO8211::Record record;
if (!ddf.readRecord(file, record)) {
_errorString = ddf.errorString();
return false;
return;
}
if (!processRecord(record, gv, COMF, _name))
return false;
return;
}
Rect b;
if (!bounds(gv, b)) {
_errorString = "Error fetching geometries bounds";
return false;
return;
}
RectC br(Coordinates(b.minX() / (double)COMF, b.maxY() / (double)COMF),
Coordinates(b.maxX() / (double)COMF, b.minY() / (double)COMF));
if (!br.isValid()) {
if (!br.isValid())
_errorString = "Invalid geometries bounds";
return false;
} else
else
_bounds = br;
return true;
}
MapData::MapData(const QString &path): _fileName(path)
{
fetchBoundsAndName();
}
MapData::~MapData()

View File

@ -52,12 +52,7 @@ public:
class Point {
public:
Point(uint type, const Coordinates &c, const QString &label)
: _type(type), _pos(c), _label(label)
{
uint hash = (uint)qHash(QPair<double,double>(c.lon(), c.lat()));
_id = ((quint64)type)<<32 | hash;
}
Point(uint type, const Coordinates &c, const QString &label);
const Coordinates &pos() const {return _pos;}
uint type() const {return _type;}
@ -152,8 +147,6 @@ private:
typedef RTree<Line*, double, 2> LineTree;
typedef RTree<Point*, double, 2> PointTree;
bool fetchBoundsAndName();
static QVector<Sounding> soundings(const ISO8211::Record &r, uint COMF,
uint SOMF);
static QVector<Sounding> soundingGeometry(const ISO8211::Record &r,

View File

@ -50,6 +50,7 @@
#define SLCONS 122
#define SLOTOP 126
#define SOUNDG 129
#define TSELNE 145
#define TSSBND 146
#define TSEZNE 150
#define UWTROC 153

View File

@ -88,9 +88,15 @@ void RasterTile::drawPolygons(QPainter *painter)
continue;
const Style::Polygon &style = s.polygon(ECDIS(poly->type()));
painter->setPen(style.pen());
painter->setBrush(style.brush());
painter->drawPath(painterPath(poly->path()));
if (!style.img().isNull()) {
for (int i = 0; i < poly->path().size(); i++)
BitmapLine::draw(painter, polyline(poly->path().at(i)),
style.img());
} else {
painter->setPen(style.pen());
painter->setBrush(style.brush());
painter->drawPath(painterPath(poly->path()));
}
}
}
}

View File

@ -38,8 +38,6 @@ void Style::defaultPolygonStyle()
_polygons[TYPE(PONTON)] = Polygon(QBrush("#333333"));
_polygons[TYPE(SLCONS)] = Polygon(Qt::NoBrush, QPen(QColor("#333333"), 1.5,
Qt::DashLine));
_polygons[TYPE(ACHARE)] = Polygon(Qt::NoBrush, QPen(QColor("#e728e7"), 1,
Qt::DashDotLine));
_polygons[TYPE(LAKARE)] = Polygon(QBrush("#9fc4e1"),
QPen(QColor("#000000"), 1));
_polygons[TYPE(CANALS)] = Polygon(QBrush("#9fc4e1"),
@ -48,12 +46,15 @@ void Style::defaultPolygonStyle()
_polygons[TYPE(DYKCON)] = Polygon(QBrush(QColor("#9fc4e1"),
Qt::Dense4Pattern), QPen(QColor("#000000"), 1));
_polygons[TYPE(AIRARE)] = Polygon(QBrush("#333333"));
_polygons[SUBTYPE(RESARE, 9)] = Polygon(QBrush(QColor("#ff0000"),
Qt::BDiagPattern), QPen(QColor("#ff0000"), 1));
_polygons[TYPE(TSEZNE)] = Polygon(QBrush("#80fcb4fc"));
_polygons[TYPE(DRGARE)] = Polygon(QBrush(QColor("#a0a0ff"),
Qt::Dense4Pattern));
_polygons[TYPE(UNSARE)] = Polygon(QBrush("#999999"));
_polygons[SUBTYPE(RESARE, 9)] = Polygon(QBrush(QColor("#ff0000"),
Qt::BDiagPattern));
_polygons[SUBTYPE(RESARE, 2)] = Polygon(QImage(":/marine/noanchor-line.png"));
_polygons[SUBTYPE(ACHARE, 1)] = Polygon(QImage(":/marine/anchor-line.png"));
_drawOrder
<< TYPE(M_COVR) << TYPE(LNDARE) << SUBTYPE(DEPARE, 0)
@ -63,7 +64,7 @@ void Style::defaultPolygonStyle()
<< TYPE(RIVERS) << TYPE(DRGARE) << TYPE(FAIRWY) << TYPE(BUAARE)
<< TYPE(BUISGL) << TYPE(AIRARE) << TYPE(BRIDGE) << TYPE(SLCONS)
<< TYPE(PONTON) << TYPE(DMPGRD) << TYPE(TSEZNE) << TYPE(OBSTRN)
<< TYPE(ACHARE) << SUBTYPE(RESARE, 9) << TYPE(154);
<< SUBTYPE(ACHARE, 1) << SUBTYPE(RESARE, 9) << SUBTYPE(RESARE, 2);
}
void Style::defaultLineStyle()
@ -92,6 +93,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(TSELNE)] = Line(QPen(QColor("#80fcb4fc"), 4, Qt::SolidLine));
}
void Style::defaultPointStyle()
@ -114,14 +116,22 @@ void Style::defaultPointStyle()
_points[SUBTYPE(LNDMRK, 17)] = Point(QImage(":/marine/tower.png"));
_points[TYPE(LNDELV)] = Point(QImage(":/marine/triangulation-point.png"));
_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, 2)] = Point(QImage(":/marine/wreck-dangerous.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, 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[TYPE(ACHBRT)] = Point(QImage(":/marine/anchorage.png"));
_points[TYPE(OFSPLF)] = Point(QImage(":/marine/platform.png"));

View File

@ -29,13 +29,18 @@ public:
{
_pen = (pen == Qt::NoPen) ? QPen(_brush, 0) : pen;
}
Polygon(const QImage &img)
: _brush(Qt::NoBrush), _pen(Qt::NoPen), _img(img.convertToFormat(
QImage::Format_ARGB32_Premultiplied)) {}
const QPen &pen() const {return _pen;}
const QBrush &brush() const {return _brush;}
const QImage &img() const {return _img;}
private:
QBrush _brush;
QPen _pen;
QImage _img;
};
class Line {

View File

@ -30,6 +30,7 @@ void ENCMap::load()
void ENCMap::unload()
{
cancelJobs(true);
_data.clear();
}
@ -56,7 +57,7 @@ int ENCMap::zoomFit(const QSize &size, const RectC &rect)
int ENCMap::zoomIn()
{
cancelJobs();
cancelJobs(false);
_zoom = qMin(_zoom + 1, ZOOMS.max());
updateTransform();
@ -65,7 +66,7 @@ int ENCMap::zoomIn()
int ENCMap::zoomOut()
{
cancelJobs();
cancelJobs(false);
_zoom = qMax(_zoom - 1, ZOOMS.min());
updateTransform();
@ -141,10 +142,10 @@ void ENCMap::jobFinished(ENCMapJob *job)
emit tilesLoaded();
}
void ENCMap::cancelJobs()
void ENCMap::cancelJobs(bool wait)
{
for (int i = 0; i < _jobs.size(); i++)
_jobs.at(i)->cancel();
_jobs.at(i)->cancel(wait);
}
QString ENCMap::key(int zoom, const QPoint &xy) const

View File

@ -23,7 +23,12 @@ public:
_future = QtConcurrent::map(_tiles, &ENC::RasterTile::render);
_watcher.setFuture(_future);
}
void cancel() {_future.cancel();}
void cancel(bool wait)
{
_future.cancel();
if (wait)
_future.waitForFinished();
}
const QList<ENC::RasterTile> &tiles() const {return _tiles;}
signals:
@ -82,7 +87,7 @@ private:
bool isRunning(int zoom, const QPoint &xy) const;
void runJob(ENCMapJob *job);
void removeJob(ENCMapJob *job);
void cancelJobs();
void cancelJobs(bool wait);
QString key(int zoom, const QPoint &xy) const;
ENC::MapData _data;