Map API refactoring
[GPXSee.git] / src / map / mbtilesmap.h
blob0b3a8b416995b946f6e3bb15c2572fbc33cced4f
1 #ifndef MBTILESMAP_H
2 #define MBTILESMAP_H
4 #include <QSqlDatabase>
5 #include <QVector>
6 #include "map.h"
8 class MBTilesMap : public Map
10 public:
11 MBTilesMap(const QString &fileName, QObject *parent = 0);
13 QString name() const {return _name;}
15 QRectF bounds();
16 RectC llBounds(const Projection &) {return _bounds;}
17 qreal resolution(const QRectF &rect);
19 int zoom() const {return _zi;}
20 void setZoom(int zoom) {_zi = zoom;}
21 int zoomFit(const QSize &size, const RectC &rect);
22 int zoomIn();
23 int zoomOut();
25 QPointF ll2xy(const Coordinates &c);
26 Coordinates xy2ll(const QPointF &p);
28 void draw(QPainter *painter, const QRectF &rect, Flags flags);
30 void load(const Projection &in, const Projection &out, qreal deviceRatio,
31 bool hidpi);
32 void unload();
34 bool isValid() const {return _valid;}
35 QString errorString() const {return _errorString;}
37 static Map *create(const QString &path, bool *isDir);
39 private:
40 qreal tileSize() const;
41 qreal coordinatesRatio() const;
42 qreal imageRatio() const;
43 QByteArray tileData(int zoom, const QPoint &tile) const;
44 void drawTile(QPainter *painter, QPixmap &pixmap, QPointF &tp);
46 QSqlDatabase _db;
48 QString _name;
49 RectC _bounds;
50 QVector<int> _zooms;
51 int _zi;
52 int _tileSize;
53 qreal _mapRatio, _tileRatio;
54 bool _scalable;
55 int _scaledSize;
57 bool _valid;
58 QString _errorString;
61 #endif // MBTILESMAP_H