2018-09-20 07:59:47 +02:00
|
|
|
#ifndef MBTILESMAP_H
|
|
|
|
#define MBTILESMAP_H
|
|
|
|
|
|
|
|
#include <QSqlDatabase>
|
2022-02-19 17:52:18 +01:00
|
|
|
#include <QVector>
|
2018-09-20 07:59:47 +02:00
|
|
|
#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();
|
2023-09-14 18:36:03 +02:00
|
|
|
RectC llBounds() {return _bounds;}
|
2018-09-20 07:59:47 +02:00
|
|
|
qreal resolution(const QRectF &rect);
|
|
|
|
|
2022-02-19 17:52:18 +01:00
|
|
|
int zoom() const {return _zi;}
|
|
|
|
void setZoom(int zoom) {_zi = zoom;}
|
2018-09-20 07:59:47 +02:00
|
|
|
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);
|
|
|
|
|
2023-05-04 09:38:35 +02:00
|
|
|
void load(const Projection &in, const Projection &out, qreal deviceRatio,
|
|
|
|
bool hidpi);
|
2018-09-20 07:59:47 +02:00
|
|
|
void unload();
|
|
|
|
|
|
|
|
bool isValid() const {return _valid;}
|
|
|
|
QString errorString() const {return _errorString;}
|
|
|
|
|
2023-09-14 18:36:03 +02:00
|
|
|
static Map *create(const QString &path, const Projection &proj, bool *isDir);
|
2022-04-29 23:16:10 +02:00
|
|
|
|
2018-09-20 07:59:47 +02:00
|
|
|
private:
|
|
|
|
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;
|
|
|
|
|
2020-12-22 22:09:09 +01:00
|
|
|
QString _name;
|
2018-09-20 07:59:47 +02:00
|
|
|
RectC _bounds;
|
2022-02-19 17:52:18 +01:00
|
|
|
QVector<int> _zooms;
|
|
|
|
int _zi;
|
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
|