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

Limit ENC maps zooms

+ somemore style adjustments
This commit is contained in:
Martin Tůma 2022-11-10 23:53:34 +01:00
parent e4847ac243
commit 4f1f3e569b
5 changed files with 87 additions and 33 deletions

View File

@ -2,6 +2,7 @@
#define ENC_ATTRIBUTES_H #define ENC_ATTRIBUTES_H
#define CATACH 8 #define CATACH 8
#define CATBUA 10
#define CATHAF 30 #define CATHAF 30
#define CATLMK 35 #define CATLMK 35
#define CATMOR 40 #define CATMOR 40

View File

@ -2,6 +2,7 @@
#include "common/util.h" #include "common/util.h"
#include "objects.h" #include "objects.h"
#include "attributes.h" #include "attributes.h"
#include "style.h"
#include "mapdata.h" #include "mapdata.h"
using namespace ENC; using namespace ENC;
@ -19,29 +20,35 @@ static QMap<uint,uint> orderMapInit()
{ {
QMap<uint,uint> map; QMap<uint,uint> map;
map.insert(BUAARE, 1); map.insert(SUBTYPE(BUAARE, 1), 1);
map.insert(BCNISD, 2); map.insert(SUBTYPE(BUAARE, 5), 2);
map.insert(BCNLAT, 3); map.insert(SUBTYPE(BUAARE, 4), 2);
map.insert(BCNSAW, 4); map.insert(SUBTYPE(BUAARE, 3), 3);
map.insert(BCNSPP, 5); map.insert(SUBTYPE(BUAARE, 2), 4);
map.insert(BOYCAR, 6); map.insert(SUBTYPE(BUAARE, 6), 5);
map.insert(BOYINB, 7); map.insert(SUBTYPE(BUAARE, 0), 6);
map.insert(BOYISD, 8); map.insert(TYPE(BCNISD), 7);
map.insert(BOYLAT, 9); map.insert(TYPE(BCNLAT), 8);
map.insert(BOYSAW, 10); map.insert(TYPE(BCNSAW), 9);
map.insert(BOYSPP, 11); map.insert(TYPE(BCNSPP), 10);
map.insert(MORFAC, 12); map.insert(TYPE(BOYCAR), 11);
map.insert(OFSPLF, 13); map.insert(TYPE(BOYINB), 12);
map.insert(LIGHTS, 14); map.insert(TYPE(BOYISD), 13);
map.insert(OBSTRN, 15); map.insert(TYPE(BOYLAT), 14);
map.insert(WRECKS, 16); map.insert(TYPE(BOYSAW), 15);
map.insert(UWTROC, 17); map.insert(TYPE(BOYSPP), 16);
map.insert(HRBFAC, 18); map.insert(TYPE(MORFAC), 17);
map.insert(PILPNT, 19); map.insert(TYPE(OFSPLF), 18);
map.insert(ACHBRT, 20); map.insert(TYPE(LIGHTS), 19);
map.insert(LNDELV, 21); map.insert(TYPE(OBSTRN), 20);
map.insert(LNDMRK, 22); map.insert(TYPE(WRECKS), 21);
map.insert(SOUNDG, 0xFFFFFFFF); map.insert(TYPE(UWTROC), 22);
map.insert(TYPE(HRBFAC), 23);
map.insert(TYPE(PILPNT), 24);
map.insert(TYPE(ACHBRT), 25);
map.insert(TYPE(LNDELV), 26);
map.insert(TYPE(LNDMRK), 27);
map.insert(TYPE(SOUNDG), 0xFFFFFFFF);
return map; return map;
} }
@ -50,7 +57,8 @@ static QMap<uint,uint> orderMap = orderMapInit();
static uint order(uint type) static uint order(uint type)
{ {
QMap<uint, uint>::const_iterator it = orderMap.find(type); uint st = (type>>16 == BUAARE) ? type : type && 0xFFFF;
QMap<uint, uint>::const_iterator it = orderMap.find(st);
return (it == orderMap.constEnd()) ? type + 512 : it.value(); return (it == orderMap.constEnd()) ? type + 512 : it.value();
} }
@ -175,7 +183,7 @@ MapData::Point::Point(uint type, const Coordinates &c, const QString &label)
: _type(type), _pos(c), _label(label) : _type(type), _pos(c), _label(label)
{ {
uint hash = (uint)qHash(QPair<double,double>(c.lon(), c.lat())); uint hash = (uint)qHash(QPair<double,double>(c.lon(), c.lat()));
_id = ((quint64)order(type>>16))<<32 | hash; _id = ((quint64)order(type))<<32 | hash;
} }
QVector<MapData::Sounding> MapData::soundings(const ISO8211::Record &r, QVector<MapData::Sounding> MapData::soundings(const ISO8211::Record &r,
@ -417,7 +425,8 @@ MapData::Attr MapData::pointAttr(const ISO8211::Record &r, uint OBJL)
|| (OBJL == LNDMRK && key == CATLMK) || (OBJL == LNDMRK && key == CATLMK)
|| (OBJL == WRECKS && key == CATWRK) || (OBJL == WRECKS && key == CATWRK)
|| (OBJL == MORFAC && key == CATMOR) || (OBJL == MORFAC && key == CATMOR)
|| (OBJL == UWTROC && key == WATLEV)) || (OBJL == UWTROC && key == WATLEV)
|| (OBJL == BUAARE && key == CATBUA))
subtype = av.at(1).toString().toUInt(); subtype = av.at(1).toString().toUInt();
} }
@ -773,3 +782,41 @@ void MapData::polygons(const RectC &rect, QList<Poly*> *polygons)
rectcBounds(rect, min, max); rectcBounds(rect, min, max);
_areas.Search(min, max, polygonCb, polygons); _areas.Search(min, max, polygonCb, polygons);
} }
Range MapData::zooms() const
{
double size = qMin(_bounds.width(), _bounds.height());
if (size > 180)
return Range(0, 20);
else if (size > 90)
return Range(1, 20);
else if (size > 45)
return Range(2, 20);
else if (size > 22.5)
return Range(3, 20);
else if (size > 11.25)
return Range(4, 20);
else if (size > 5.625)
return Range(5, 20);
else if (size > 2.813)
return Range(6, 20);
else if (size > 1.406)
return Range(7, 20);
else if (size > 0.703)
return Range(8, 20);
else if (size > 0.352)
return Range(9, 20);
else if (size > 0.176)
return Range(10, 20);
else if (size > 0.088)
return Range(11, 20);
else if (size > 0.044)
return Range(12, 20);
else if (size > 0.022)
return Range(13, 20);
else if (size > 0.011)
return Range(14, 20);
else
return Range(15, 20);
}

View File

@ -5,6 +5,7 @@
#include "common/rectc.h" #include "common/rectc.h"
#include "common/rtree.h" #include "common/rtree.h"
#include "common/polygon.h" #include "common/polygon.h"
#include "common/range.h"
#include "iso8211.h" #include "iso8211.h"
namespace ENC { namespace ENC {
@ -73,6 +74,7 @@ public:
const QString &name() const {return _name;} const QString &name() const {return _name;}
RectC bounds() const {return _bounds;} RectC bounds() const {return _bounds;}
Range zooms() const;
void polygons(const RectC &rect, QList<Poly*> *polygons); void polygons(const RectC &rect, QList<Poly*> *polygons);
void lines(const RectC &rect, QList<Line*> *lines); void lines(const RectC &rect, QList<Line*> *lines);

View File

@ -101,7 +101,11 @@ void Style::defaultLineStyle()
void Style::defaultPointStyle() void Style::defaultPointStyle()
{ {
_points[TYPE(BUAARE)].setTextFontSize(Large); _points[SUBTYPE(BUAARE, 1)].setTextFontSize(Large);
_points[SUBTYPE(BUAARE, 5)].setTextFontSize(Large);
_points[SUBTYPE(BUAARE, 3)].setTextFontSize(Small);
_points[SUBTYPE(BUAARE, 6)].setTextFontSize(Small);
_points[SUBTYPE(BUAARE, 0)].setTextFontSize(Small);
_points[TYPE(SOUNDG)].setTextFontSize(Small); _points[TYPE(SOUNDG)].setTextFontSize(Small);
_points[TYPE(LIGHTS)] = Point(QImage(":/marine/light-major.png"), Small); _points[TYPE(LIGHTS)] = Point(QImage(":/marine/light-major.png"), Small);
_points[TYPE(BOYCAR)] = Point(QImage(":/marine/buoy.png"), Small); _points[TYPE(BOYCAR)] = Point(QImage(":/marine/buoy.png"), Small);
@ -140,6 +144,7 @@ void Style::defaultPointStyle()
_points[TYPE(OFSPLF)] = Point(QImage(":/marine/platform.png")); _points[TYPE(OFSPLF)] = Point(QImage(":/marine/platform.png"));
_points[TYPE(PILPNT)] = Point(QImage(":/marine/pile.png"), Small); _points[TYPE(PILPNT)] = Point(QImage(":/marine/pile.png"), Small);
_points[SUBTYPE(MORFAC, 1)] = Point(QImage(":/marine/pile.png"), Small); _points[SUBTYPE(MORFAC, 1)] = Point(QImage(":/marine/pile.png"), Small);
_points[SUBTYPE(MORFAC, 3)] = Point(QImage(":/marine/pile.png"), Small);
_points[SUBTYPE(MORFAC, 5)] = 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"), _points[SUBTYPE(MORFAC, 7)] = Point(QImage(":/marine/mooring-buoy.png"),
Small); Small);

View File

@ -11,7 +11,6 @@
using namespace ENC; using namespace ENC;
static Range ZOOMS = Range(0, 20);
ENCMap::ENCMap(const QString &fileName, QObject *parent) ENCMap::ENCMap(const QString &fileName, QObject *parent)
: Map(fileName, parent), _data(fileName), _projection(PCS::pcs(3857)), : Map(fileName, parent), _data(fileName), _projection(PCS::pcs(3857)),
@ -39,8 +38,8 @@ int ENCMap::zoomFit(const QSize &size, const RectC &rect)
if (rect.isValid()) { if (rect.isValid()) {
RectD pr(rect, _projection, 10); RectD pr(rect, _projection, 10);
_zoom = ZOOMS.min(); _zoom = _data.zooms().min();
for (int i = ZOOMS.min() + 1; i <= ZOOMS.max(); i++) { for (int i = _data.zooms().min() + 1; i <= _data.zooms().max(); i++) {
Transform t(transform(i)); Transform t(transform(i));
QRectF r(t.proj2img(pr.topLeft()), t.proj2img(pr.bottomRight())); QRectF r(t.proj2img(pr.topLeft()), t.proj2img(pr.bottomRight()));
if (size.width() < r.width() || size.height() < r.height()) if (size.width() < r.width() || size.height() < r.height())
@ -48,7 +47,7 @@ int ENCMap::zoomFit(const QSize &size, const RectC &rect)
_zoom = i; _zoom = i;
} }
} else } else
_zoom = ZOOMS.max(); _zoom = _data.zooms().max();
updateTransform(); updateTransform();
@ -59,7 +58,7 @@ int ENCMap::zoomIn()
{ {
cancelJobs(false); cancelJobs(false);
_zoom = qMin(_zoom + 1, ZOOMS.max()); _zoom = qMin(_zoom + 1, _data.zooms().max());
updateTransform(); updateTransform();
return _zoom; return _zoom;
} }
@ -68,7 +67,7 @@ int ENCMap::zoomOut()
{ {
cancelJobs(false); cancelJobs(false);
_zoom = qMax(_zoom - 1, ZOOMS.min()); _zoom = qMax(_zoom - 1, _data.zooms().min());
updateTransform(); updateTransform();
return _zoom; return _zoom;
} }