2022-11-04 09:03:36 +01:00
|
|
|
#ifndef ENCMAP_H
|
|
|
|
#define ENCMAP_H
|
|
|
|
|
2023-09-07 09:31:23 +02:00
|
|
|
#include <climits>
|
2022-11-06 15:26:28 +01:00
|
|
|
#include <QtConcurrent>
|
2023-09-07 09:31:23 +02:00
|
|
|
#include "common/range.h"
|
2022-11-04 09:03:36 +01:00
|
|
|
#include "map.h"
|
|
|
|
#include "projection.h"
|
|
|
|
#include "transform.h"
|
|
|
|
#include "ENC/mapdata.h"
|
2023-09-07 09:31:23 +02:00
|
|
|
#include "ENC/iso8211.h"
|
2022-11-04 09:03:36 +01:00
|
|
|
|
2023-09-07 09:31:23 +02:00
|
|
|
class ENCJob;
|
2022-11-04 09:03:36 +01:00
|
|
|
|
|
|
|
class ENCMap : public Map
|
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
|
|
|
|
public:
|
|
|
|
ENCMap(const QString &fileName, QObject *parent = 0);
|
2023-09-07 09:31:23 +02:00
|
|
|
~ENCMap() {delete _data;}
|
2022-11-04 09:03:36 +01:00
|
|
|
|
2023-09-07 09:31:23 +02:00
|
|
|
QString name() const {return _name;}
|
2022-11-04 09:03:36 +01:00
|
|
|
|
|
|
|
QRectF bounds() {return _bounds;}
|
2023-05-04 09:38:35 +02:00
|
|
|
RectC llBounds(const Projection &) {return _llBounds;}
|
2022-11-04 09:03:36 +01:00
|
|
|
|
|
|
|
int zoom() const {return _zoom;}
|
|
|
|
void setZoom(int zoom);
|
|
|
|
int zoomFit(const QSize &size, const RectC &rect);
|
|
|
|
int zoomIn();
|
|
|
|
int zoomOut();
|
|
|
|
|
2023-05-04 09:38:35 +02:00
|
|
|
void load(const Projection &in, const Projection &out, qreal deviceRatio,
|
|
|
|
bool hidpi);
|
2022-11-04 09:03:36 +01:00
|
|
|
void unload();
|
|
|
|
|
|
|
|
QPointF ll2xy(const Coordinates &c)
|
|
|
|
{return _transform.proj2img(_projection.ll2xy(c));}
|
|
|
|
Coordinates xy2ll(const QPointF &p)
|
|
|
|
{return _projection.xy2ll(_transform.img2proj(p));}
|
|
|
|
|
|
|
|
void draw(QPainter *painter, const QRectF &rect, Flags flags);
|
|
|
|
|
2023-09-07 09:31:23 +02:00
|
|
|
bool isValid() const {return _valid;}
|
|
|
|
QString errorString() const {return _errorString;}
|
2022-11-04 09:03:36 +01:00
|
|
|
|
2023-05-04 09:38:35 +02:00
|
|
|
static Map *create(const QString &path, bool *isMap);
|
2022-11-04 09:03:36 +01:00
|
|
|
|
2022-11-06 15:26:28 +01:00
|
|
|
private slots:
|
2023-09-07 09:31:23 +02:00
|
|
|
void jobFinished(ENCJob *job);
|
2022-11-06 15:26:28 +01:00
|
|
|
|
2022-11-04 09:03:36 +01:00
|
|
|
private:
|
2023-09-07 09:31:23 +02:00
|
|
|
class Rect {
|
|
|
|
public:
|
|
|
|
Rect()
|
|
|
|
: _minX(INT_MAX), _maxX(INT_MIN), _minY(INT_MAX), _maxY(INT_MIN) {}
|
|
|
|
Rect(int minX, int maxX, int minY, int maxY)
|
|
|
|
: _minX(minX), _maxX(maxX), _minY(minY), _maxY(maxY) {}
|
|
|
|
|
|
|
|
int minX() const {return _minX;}
|
|
|
|
int maxX() const {return _maxX;}
|
|
|
|
int minY() const {return _minY;}
|
|
|
|
int maxY() const {return _maxY;}
|
|
|
|
|
|
|
|
void unite(int x, int y) {
|
|
|
|
if (x < _minX)
|
|
|
|
_minX = x;
|
|
|
|
if (x > _maxX)
|
|
|
|
_maxX = x;
|
|
|
|
if (y < _minY)
|
|
|
|
_minY = y;
|
|
|
|
if (y > _maxY)
|
|
|
|
_maxY = y;
|
|
|
|
}
|
|
|
|
|
|
|
|
Rect &operator|=(const Rect &r) {*this = *this | r; return *this;}
|
|
|
|
Rect operator|(const Rect &r) const
|
|
|
|
{
|
|
|
|
return Rect(qMin(_minX, r._minX), qMax(_maxX, r._maxX),
|
|
|
|
qMin(_minY, r._minY), qMax(_maxY, r._maxY));
|
|
|
|
}
|
|
|
|
|
|
|
|
private:
|
|
|
|
int _minX, _maxX, _minY, _maxY;
|
|
|
|
};
|
|
|
|
|
2022-11-04 09:03:36 +01:00
|
|
|
Transform transform(int zoom) const;
|
|
|
|
void updateTransform();
|
2022-11-06 15:26:28 +01:00
|
|
|
bool isRunning(int zoom, const QPoint &xy) const;
|
2023-09-07 09:31:23 +02:00
|
|
|
void runJob(ENCJob *job);
|
|
|
|
void removeJob(ENCJob *job);
|
2022-11-09 21:37:05 +01:00
|
|
|
void cancelJobs(bool wait);
|
2022-11-04 09:03:36 +01:00
|
|
|
QString key(int zoom, const QPoint &xy) const;
|
|
|
|
|
2023-09-07 09:31:23 +02:00
|
|
|
static bool bounds(const ENC::ISO8211::Record &record, Rect &rect);
|
|
|
|
static bool bounds(const QVector<ENC::ISO8211::Record> &gv, Rect &b);
|
|
|
|
static bool processRecord(const ENC::ISO8211::Record &record,
|
|
|
|
QVector<ENC::ISO8211::Record> &rv, uint &COMF, QString &name);
|
|
|
|
|
|
|
|
QString _name;
|
|
|
|
ENC::MapData *_data;
|
2022-11-04 09:03:36 +01:00
|
|
|
Projection _projection;
|
|
|
|
Transform _transform;
|
|
|
|
qreal _tileRatio;
|
|
|
|
RectC _llBounds;
|
|
|
|
QRectF _bounds;
|
2023-09-07 09:31:23 +02:00
|
|
|
Range _zooms;
|
2022-11-04 09:03:36 +01:00
|
|
|
int _zoom;
|
|
|
|
|
2023-09-07 09:31:23 +02:00
|
|
|
QList<ENCJob*> _jobs;
|
2022-11-06 15:26:28 +01:00
|
|
|
|
2022-11-04 09:03:36 +01:00
|
|
|
bool _valid;
|
|
|
|
QString _errorString;
|
|
|
|
};
|
|
|
|
|
|
|
|
#endif // ENCMAP_H
|