1
0
mirror of https://github.com/tumic0/GPXSee.git synced 2024-11-28 21:51:17 +01:00
GPXSee/src/map/ozimap.h

102 lines
2.4 KiB
C
Raw Normal View History

#ifndef OZIMAP_H
#define OZIMAP_H
2018-03-22 20:00:30 +01:00
#include "transform.h"
2017-11-26 18:54:03 +01:00
#include "projection.h"
#include "calibrationpoint.h"
#include "map.h"
2018-03-08 02:24:10 +01:00
class Tar;
class OZF;
2018-08-23 20:26:10 +02:00
class Image;
class OziMap : public Map
{
Q_OBJECT
public:
enum CalibrationType {
Unknown, MAP, GMI
};
OziMap(const QString &fileName, CalibrationType type, const Projection &proj,
QObject *parent = 0);
OziMap(const QString &dirName, Tar &tar, const Projection &proj,
QObject *parent = 0);
~OziMap();
2018-07-13 09:51:41 +02:00
QString name() const {return _name;}
2018-07-13 09:51:41 +02:00
QRectF bounds();
int zoom() const {return _zoom;}
2018-04-28 22:18:11 +02:00
void setZoom(int zoom) {_zoom = zoom;}
2018-03-22 20:00:30 +01:00
int zoomFit(const QSize &size, const RectC &rect);
int zoomIn();
int zoomOut();
QPointF ll2xy(const Coordinates &c);
Coordinates xy2ll(const QPointF &p);
2018-08-23 20:26:10 +02:00
void draw(QPainter *painter, const QRectF &rect, Flags flags);
void load(const Projection &in, const Projection &out, qreal deviceRatio,
bool hidpi);
void unload();
bool isValid() const {return _valid;}
2018-02-20 23:37:19 +01:00
QString errorString() const {return _errorString;}
2017-04-01 05:59:55 +02:00
2018-04-15 17:32:25 +02:00
PointD ll2pp(const Coordinates &c) const
{return _projection.ll2xy(c);}
PointD xy2pp(const QPointF &p) const
{return _transform.img2proj(p * _mapRatio);}
2018-04-15 17:32:25 +02:00
QPointF pp2xy(const PointD &p) const
{return _transform.proj2img(p) / _mapRatio;}
static Map *createTAR(const QString &path, const Projection &proj,
bool *isDir);
static Map *createMAP(const QString &path, const Projection &proj,
bool *isDir);
static Map *createGMI(const QString &path, const Projection &proj,
bool *isDir);
private:
2018-03-08 02:24:10 +01:00
struct ImageInfo {
QSize size;
QString path;
bool isValid() const {return size.isValid() && !path.isEmpty();}
};
2018-03-08 19:08:39 +01:00
bool setTileInfo(const QStringList &tiles, const QString &path = QString());
bool setImageInfo(const QString &path);
2018-03-08 19:08:39 +01:00
void drawTiled(QPainter *painter, const QRectF &rect) const;
void drawOZF(QPainter *painter, const QRectF &rect) const;
2018-08-23 20:26:10 +02:00
void drawImage(QPainter *painter, const QRectF &rect, Flags flags) const;
2017-04-15 08:59:31 +02:00
2017-08-11 00:22:21 +02:00
void rescale(int zoom);
void computeTransform();
2017-08-11 00:22:21 +02:00
static QString calibrationFile(const QStringList &files, const QString path,
CalibrationType &type);
QString _name;
Projection _projection;
2018-03-22 20:00:30 +01:00
Transform _transform;
2018-08-23 20:26:10 +02:00
Image *_img;
2018-03-08 02:24:10 +01:00
Tar *_tar;
OZF *_ozf;
ImageInfo _map, _tile;
2017-08-11 00:22:21 +02:00
int _zoom;
QPointF _scale;
qreal _mapRatio;
QList<CalibrationPoint> _calibrationPoints;
2018-01-08 23:47:45 +01:00
bool _valid;
QString _errorString;
};
#endif // OZIMAP_H