1
0
mirror of https://github.com/tumic0/GPXSee.git synced 2024-11-25 04:05:53 +01:00
GPXSee/src/map/jnxmap.h

101 lines
1.9 KiB
C
Raw Normal View History

2018-05-22 22:40:15 +02:00
#ifndef JNXMAP_H
#define JNXMAP_H
#include <QFile>
#include <QVector>
#include "common/rtree.h"
#include "common/rectc.h"
#include "transform.h"
#include "projection.h"
2018-05-22 22:40:15 +02:00
#include "map.h"
class JNXMap : public Map
{
public:
Q_OBJECT
public:
JNXMap(const QString &fileName, QObject *parent = 0);
2021-03-21 21:23:00 +01:00
~JNXMap();
2018-05-22 22:40:15 +02:00
2018-07-13 09:51:41 +02:00
QRectF bounds();
RectC llBounds(const Projection &) {return _bounds;}
2018-05-22 22:40:15 +02:00
int zoom() const {return _zoom;}
void setZoom(int zoom) {_zoom = zoom;}
int zoomFit(const QSize &size, const RectC &rect);
int zoomIn();
int zoomOut();
QPointF ll2xy(const Coordinates &c);
Coordinates xy2ll(const QPointF &p);
2018-05-22 22:40:15 +02:00
void load(const Projection &in, const Projection &out, qreal deviceRatio,
bool hidpi);
void unload();
2018-08-23 20:26:10 +02:00
void draw(QPainter *painter, const QRectF &rect, Flags flags);
2018-05-22 22:40:15 +02:00
bool isValid() const {return _valid;}
QString errorString() const {return _errorString;}
static Map *create(const QString &path, bool *isDir);
2018-05-22 22:40:15 +02:00
private:
struct Tile {
qint32 top, right, bottom, left;
quint16 width, height;
2018-05-22 22:40:15 +02:00
quint32 size;
quint32 offset;
QPointF pos;
2018-05-22 22:40:15 +02:00
};
struct Level {
quint32 count;
quint32 offset;
quint32 scale;
};
2018-05-22 22:40:15 +02:00
struct Zoom {
Zoom() {}
Zoom(const Level &level) : level(level) {}
Level level;
2018-05-22 22:40:15 +02:00
Transform transform;
QVector<Tile> tiles;
RTree<Tile*, qreal, 2> tree;
};
struct Ctx {
QPainter *painter;
QFile *file;
qreal ratio;
Ctx(QPainter *painter, QFile *file, qreal ratio)
: painter(painter), file(file), ratio(ratio) {}
};
2018-05-22 22:40:15 +02:00
template<class T> bool readValue(T &val);
bool readString(QByteArray &ba);
bool readHeader();
2018-05-22 22:40:15 +02:00
bool readTiles();
void clearTiles();
2018-05-22 22:40:15 +02:00
static bool cb(Tile *tile, void *context);
static QPixmap pixmap(const Tile *tile, QFile *file);
QFile _file;
2021-03-21 21:23:00 +01:00
QList<Zoom*> _zooms;
2018-05-22 22:40:15 +02:00
int _zoom;
RectC _bounds;
Projection _projection;
qreal _mapRatio;
2018-05-22 22:40:15 +02:00
bool _valid;
QString _errorString;
};
#endif // JNXMAP_H