2019-05-10 18:56:19 +02:00
|
|
|
#ifndef IMG_H
|
|
|
|
#define IMG_H
|
|
|
|
|
|
|
|
#include <QRect>
|
|
|
|
#include <QFile>
|
|
|
|
#include <QByteArray>
|
|
|
|
#include <QCache>
|
|
|
|
#include <QDebug>
|
|
|
|
#include "common/rtree.h"
|
|
|
|
#include "common/rectc.h"
|
|
|
|
#include "common/range.h"
|
|
|
|
#include "style.h"
|
2019-06-30 20:39:22 +02:00
|
|
|
#include "label.h"
|
2019-05-10 18:56:19 +02:00
|
|
|
|
|
|
|
class VectorTile;
|
|
|
|
class SubFile;
|
|
|
|
|
|
|
|
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<QPointF> points;
|
2019-06-30 20:39:22 +02:00
|
|
|
Label label;
|
2019-05-10 18:56:19 +02:00
|
|
|
quint32 type;
|
|
|
|
|
|
|
|
bool operator<(const Poly &other) const
|
|
|
|
{return type > other.type;}
|
|
|
|
};
|
|
|
|
|
|
|
|
struct Point {
|
|
|
|
Point() : id(0) {}
|
|
|
|
|
|
|
|
Coordinates coordinates;
|
2019-06-30 20:39:22 +02:00
|
|
|
Label label;
|
2019-05-10 18:56:19 +02:00
|
|
|
quint32 type;
|
|
|
|
bool poi;
|
|
|
|
quint64 id;
|
|
|
|
|
|
|
|
bool operator<(const Point &other) const
|
2019-06-07 09:37:10 +02:00
|
|
|
{return id > other.id;}
|
2019-05-10 18:56:19 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
IMG(const QString &fileName);
|
|
|
|
~IMG();
|
|
|
|
|
|
|
|
const QString &name() const {return _name;}
|
|
|
|
const RectC &bounds() const {return _bounds;}
|
|
|
|
Range zooms() const {return Range(_bits.first(), _bits.last());}
|
|
|
|
void objects(const RectC &rect, int bits, QList<Poly> *polygons,
|
|
|
|
QList<Poly> *lines, QList<Point> *points) const;
|
|
|
|
const Style &style() const {return _style;}
|
|
|
|
|
2019-05-16 20:23:37 +02:00
|
|
|
bool isValid() const {return _valid;}
|
|
|
|
const QString &errorString() const {return _errorString;}
|
|
|
|
|
2019-05-10 18:56:19 +02:00
|
|
|
private:
|
|
|
|
friend class SubFile;
|
|
|
|
|
|
|
|
typedef RTree<VectorTile*, double, 2> TileTree;
|
|
|
|
|
2019-05-16 20:23:37 +02:00
|
|
|
QString fileName() const {return _file.fileName();}
|
2019-05-10 18:56:19 +02:00
|
|
|
int blockSize() const {return _blockSize;}
|
2019-05-12 01:23:18 +02:00
|
|
|
bool readBlock(int blockNum, QByteArray &data);
|
2019-05-10 18:56:19 +02:00
|
|
|
qint64 read(char *data, qint64 maxSize);
|
|
|
|
template<class T> bool readValue(T &val);
|
|
|
|
|
|
|
|
QFile _file;
|
|
|
|
quint8 _key;
|
|
|
|
int _blockSize;
|
|
|
|
QCache<int, QByteArray> _blockCache;
|
|
|
|
|
|
|
|
TileTree _tileTree;
|
|
|
|
|
|
|
|
QString _name;
|
|
|
|
RectC _bounds;
|
|
|
|
QList<int> _bits;
|
|
|
|
Style _style;
|
|
|
|
|
|
|
|
bool _valid;
|
|
|
|
QString _errorString;
|
|
|
|
};
|
|
|
|
|
2019-06-07 09:37:10 +02:00
|
|
|
#ifndef QT_NO_DEBUG
|
|
|
|
QDebug operator<<(QDebug dbg, const IMG::Point &point);
|
|
|
|
QDebug operator<<(QDebug dbg, const IMG::Poly &poly);
|
|
|
|
#endif // QT_NO_DEBUG
|
|
|
|
|
2019-05-10 18:56:19 +02:00
|
|
|
#endif // IMG_H
|