Map API refactoring
[GPXSee.git] / src / map / oruxmap.h
blobfc3f36f76bbade70a09b76f3e0eab9c2f2e01c1b
1 #ifndef ORUXMAP_H
2 #define ORUXMAP_H
4 #include <QDebug>
5 #include <QSqlDatabase>
6 #include <QDir>
7 #include "map.h"
8 #include "projection.h"
9 #include "transform.h"
10 #include "calibrationpoint.h"
12 class QXmlStreamReader;
14 class OruxMap : public Map
16 Q_OBJECT
18 public:
19 OruxMap(const QString &fileName, QObject *parent = 0);
21 QString name() const {return _name;}
23 QRectF bounds();
25 int zoom() const {return _zoom;}
26 void setZoom(int zoom) {_zoom = zoom;}
27 int zoomFit(const QSize &size, const RectC &rect);
28 int zoomIn();
29 int zoomOut();
31 QPointF ll2xy(const Coordinates &c);
32 Coordinates xy2ll(const QPointF &p);
34 void draw(QPainter *painter, const QRectF &rect, Flags flags);
36 void load(const Projection &in, const Projection &out, qreal deviceRatio,
37 bool hidpi);
38 void unload();
40 bool isValid() const {return _valid;}
41 QString errorString() const {return _errorString;}
43 static Map *create(const QString &path, bool *isDir);
45 private:
46 struct Zoom {
47 Zoom(int zoom, const QSize &tileSize, const QSize &size,
48 const Projection &proj, const Transform &transform,
49 const QString &fileName, const QString &set)
50 : zoom(zoom), tileSize(tileSize), size(size), projection(proj),
51 transform(transform), fileName(fileName), set(set) {}
52 bool operator<(const Zoom &other) const
53 {return zoom < other.zoom;}
55 int zoom;
56 QSize tileSize;
57 QSize size;
58 Projection projection;
59 Transform transform;
60 QString fileName;
61 QDir set;
64 bool readXML(const QString &path, const QString &dir = QString());
65 void oruxTracker(QXmlStreamReader &reader, const QString &dir, int level);
66 void mapCalibration(QXmlStreamReader &reader, const QString &dir, int level);
67 void calibrationPoints(QXmlStreamReader &reader, const QSize &size,
68 QList<CalibrationPoint> &points);
69 QPixmap tile(const Zoom &z, int x, int y) const;
71 friend QDebug operator<<(QDebug dbg, const Zoom &zoom);
73 QString _name;
74 QList<Zoom> _zooms;
75 QSqlDatabase _db;
76 int _zoom;
77 qreal _mapRatio;
79 bool _valid;
80 QString _errorString;
83 #endif // ORUXMAP_H