1
0
mirror of https://github.com/tumic0/GPXSee.git synced 2024-10-07 07:13:21 +02:00
GPXSee/src/offlinemap.h

111 lines
2.6 KiB
C
Raw Normal View History

2017-03-21 09:27:44 +01:00
#ifndef OFFLINEMAP_H
#define OFFLINEMAP_H
#include <QTransform>
#include "map.h"
2017-03-21 01:15:29 +01:00
#include "tar.h"
2017-04-14 22:39:33 +02:00
#include "ozf.h"
#include "coordinates.h"
2017-04-04 22:03:42 +02:00
#include "projection.h"
class QIODevice;
class QImage;
2017-03-21 09:27:44 +01:00
class OfflineMap : public Map
{
Q_OBJECT
public:
OfflineMap(const QString &fileName, QObject *parent = 0);
OfflineMap(const QString &fileName, Tar &tar, QObject *parent = 0);
~OfflineMap();
const QString &name() const {return _name;}
2017-08-11 00:22:21 +02:00
QRectF bounds() const;
qreal resolution(const QPointF &p) const;
2017-08-11 00:22:21 +02:00
qreal zoom() const {return _zoom;}
qreal zoomFit(const QSize &size, const RectC &br);
qreal zoomFit(qreal resolution, const Coordinates &c);
qreal zoomIn();
qreal zoomOut();
2017-08-11 00:22:21 +02:00
QPointF ll2xy(const Coordinates &c);
Coordinates xy2ll(const QPointF &p);
void draw(QPainter *painter, const QRectF &rect);
void load();
void unload();
bool isValid() const {return _valid;}
const QString &errorString() const {return _errorString;}
2017-04-01 05:59:55 +02:00
2017-04-04 22:03:42 +02:00
QPointF ll2pp(const Coordinates &c) const
{return _projection->ll2xy(c);}
QPointF xy2pp(const QPointF &p) const
{return _inverted.map(p);}
QPointF pp2xy(const QPointF &p) const
{return _transform.map(p);}
private:
2017-08-10 08:58:21 +02:00
struct ReferencePoint {
QPoint xy;
Coordinates ll;
QPointF pp;
2017-08-10 08:58:21 +02:00
};
2017-08-10 08:58:21 +02:00
struct ProjectionSetup {
2017-04-09 10:26:09 +02:00
double latitudeOrigin;
double longitudeOrigin;
double scale;
double falseEasting;
double falseNorthing;
double standardParallel1;
double standardParallel2;
int zone;
2017-08-10 08:58:21 +02:00
};
int parse(QIODevice &device, QList<ReferencePoint> &points,
QString &projection, ProjectionSetup &setup, QString &datum);
bool parseMapFile(QIODevice &device, QList<ReferencePoint> &points,
QString &projection, ProjectionSetup &setup, QString &datum);
2017-03-27 10:31:41 +02:00
bool totalSizeSet();
bool createProjection(const QString &datum, const QString &projection,
const ProjectionSetup &setup, QList<ReferencePoint> &points);
bool computeTransformation(const QList<ReferencePoint> &points);
bool computeResolution(QList<ReferencePoint> &points);
bool getTileInfo(const QStringList &tiles, const QString &path = QString());
bool getImageInfo(const QString &path);
2017-04-15 08:59:31 +02:00
void drawTiled(QPainter *painter, const QRectF &rect);
void drawOZF(QPainter *painter, const QRectF &rect);
void drawImage(QPainter *painter, const QRectF &rect);
2017-08-11 00:22:21 +02:00
void rescale(int zoom);
QString _name;
bool _valid;
QString _errorString;
QSize _size;
Projection *_projection;
2017-04-04 22:03:42 +02:00
QTransform _transform, _inverted;
qreal _resolution;
2017-04-14 22:39:33 +02:00
OZF _ozf;
2017-03-21 01:15:29 +01:00
Tar _tar;
2017-03-27 02:41:30 +02:00
QString _tarPath;
QImage *_img;
2017-03-21 09:27:44 +01:00
QString _imgPath;
2017-03-20 10:05:07 +01:00
QSize _tileSize;
QString _tileName;
2017-08-11 00:22:21 +02:00
int _zoom;
QPointF _scale;
};
2017-03-21 09:27:44 +01:00
#endif // OFFLINEMAP_H