2018-09-20 07:59:47 +02:00
|
|
|
#ifndef MBTILESMAP_H
|
|
|
|
#define MBTILESMAP_H
|
|
|
|
|
|
|
|
#include <QSqlDatabase>
|
|
|
|
#include <QByteArray>
|
|
|
|
#include "common/range.h"
|
|
|
|
#include "map.h"
|
|
|
|
|
|
|
|
class MBTilesMap : public Map
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
MBTilesMap(const QString &fileName, QObject *parent = 0);
|
|
|
|
|
2018-09-21 00:19:30 +02:00
|
|
|
QString name() const {return _name;}
|
2018-09-20 07:59:47 +02:00
|
|
|
|
|
|
|
QRectF bounds();
|
|
|
|
qreal resolution(const QRectF &rect);
|
|
|
|
|
|
|
|
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);
|
|
|
|
|
|
|
|
void draw(QPainter *painter, const QRectF &rect, Flags flags);
|
|
|
|
|
|
|
|
void load();
|
|
|
|
void unload();
|
2018-11-17 10:10:35 +01:00
|
|
|
void setDevicePixelRatio(qreal deviceRatio, qreal mapRatio);
|
2018-09-20 07:59:47 +02:00
|
|
|
|
|
|
|
bool isValid() const {return _valid;}
|
|
|
|
QString errorString() const {return _errorString;}
|
|
|
|
|
|
|
|
private:
|
|
|
|
int limitZoom(int zoom) const;
|
|
|
|
qreal tileSize() const;
|
|
|
|
qreal coordinatesRatio() const;
|
|
|
|
qreal imageRatio() const;
|
|
|
|
QByteArray tileData(int zoom, const QPoint &tile) const;
|
2018-11-10 10:40:00 +01:00
|
|
|
void drawTile(QPainter *painter, QPixmap &pixmap, QPointF &tp);
|
2018-09-20 07:59:47 +02:00
|
|
|
|
|
|
|
QSqlDatabase _db;
|
|
|
|
|
2018-09-21 00:19:30 +02:00
|
|
|
QString _fileName, _name;
|
2018-09-20 07:59:47 +02:00
|
|
|
RectC _bounds;
|
|
|
|
Range _zooms;
|
|
|
|
int _zoom;
|
2018-09-21 23:18:05 +02:00
|
|
|
int _tileSize;
|
2018-11-17 10:10:35 +01:00
|
|
|
qreal _mapRatio, _tileRatio;
|
2018-11-15 00:38:03 +01:00
|
|
|
bool _scalable;
|
|
|
|
int _scaledSize;
|
2018-09-20 07:59:47 +02:00
|
|
|
|
|
|
|
bool _valid;
|
|
|
|
QString _errorString;
|
|
|
|
};
|
|
|
|
|
|
|
|
#endif // MBTILESMAP_H
|