#ifndef IMG_H #define IMG_H #include #include #include #include #include "common/rtree.h" #include "common/rectc.h" #include "style.h" #include "label.h" class VectorTile; class SubFile; class SubDiv; class IMG { public: struct Poly { /* QPointF insted of Coordinates for performance reasons (no need to duplicate all the vectors for drawing). Note, that we do not want to ll2xy() the points in the IMG class as this can not be done in parallel. */ QVector points; Label label; quint32 type; RectC boundingRect; bool operator<(const Poly &other) const {return type > other.type;} }; struct Point { Point() : id(0) {} Coordinates coordinates; Label label; quint32 type; bool poi; quint64 id; bool operator<(const Point &other) const {return id < other.id;} }; struct Polys { Polys() {} Polys(const QList &polygons, const QList &lines) : polygons(polygons), lines(lines) {} QList polygons; QList lines; }; IMG(const QString &fileName); ~IMG(); void load(); void clear(); QString fileName() const {return _file.fileName();} const QString &name() const {return _name;} const RectC &bounds() const {return _bounds;} void polys(const RectC &rect, int bits, QList *polygons, QList *lines); void points(const RectC &rect, int bits, QList *points); const Style *style() const {return _style;} bool isValid() const {return _valid;} const QString &errorString() const {return _errorString;} private: friend class SubFile; typedef RTree TileTree; int blockSize() const {return _blockSize;} bool readBlock(int blockNum, QByteArray &data); qint64 read(char *data, qint64 maxSize); template bool readValue(T &val); QFile _file; quint8 _key; int _blockSize; QString _name; RectC _bounds; TileTree _tileTree; SubFile *_typ; Style *_style; QCache _polyCache; QCache > _pointCache; bool _valid; QString _errorString; }; #ifndef QT_NO_DEBUG QDebug operator<<(QDebug dbg, const IMG::Point &point); QDebug operator<<(QDebug dbg, const IMG::Poly &poly); #endif // QT_NO_DEBUG #endif // IMG_H