2020-02-09 23:24:48 +01:00
|
|
|
#ifndef MAPDATA_H
|
|
|
|
#define MAPDATA_H
|
|
|
|
|
|
|
|
#include <QList>
|
|
|
|
#include <QPointF>
|
|
|
|
#include <QCache>
|
|
|
|
#include <QDebug>
|
|
|
|
#include "common/rectc.h"
|
|
|
|
#include "common/rtree.h"
|
2020-02-15 21:49:00 +01:00
|
|
|
#include "common/range.h"
|
2020-02-09 23:24:48 +01:00
|
|
|
#include "label.h"
|
|
|
|
|
|
|
|
class Style;
|
|
|
|
class SubDiv;
|
|
|
|
class SubFile;
|
|
|
|
class VectorTile;
|
|
|
|
|
|
|
|
class MapData
|
|
|
|
{
|
|
|
|
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;
|
|
|
|
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;
|
|
|
|
quint64 id;
|
|
|
|
|
|
|
|
bool operator<(const Point &other) const
|
|
|
|
{return id < other.id;}
|
|
|
|
};
|
|
|
|
|
|
|
|
struct Polys {
|
|
|
|
Polys() {}
|
|
|
|
Polys(const QList<Poly> &polygons, const QList<Poly> &lines)
|
|
|
|
: polygons(polygons), lines(lines) {}
|
|
|
|
|
|
|
|
QList<Poly> polygons;
|
|
|
|
QList<Poly> lines;
|
|
|
|
};
|
|
|
|
|
2020-02-10 19:38:45 +01:00
|
|
|
MapData();
|
2020-02-09 23:24:48 +01:00
|
|
|
virtual ~MapData();
|
|
|
|
|
|
|
|
const QString &name() const {return _name;}
|
|
|
|
const RectC &bounds() const {return _bounds;}
|
2020-02-15 21:49:00 +01:00
|
|
|
const Range &zooms() const {return _zooms;}
|
2020-02-09 23:24:48 +01:00
|
|
|
const Style *style() const {return _style;}
|
|
|
|
void polys(const RectC &rect, int bits, QList<Poly> *polygons,
|
|
|
|
QList<Poly> *lines);
|
|
|
|
void points(const RectC &rect, int bits, QList<Point> *points);
|
|
|
|
|
|
|
|
void load();
|
|
|
|
void clear();
|
|
|
|
|
|
|
|
virtual QString fileName() const = 0;
|
|
|
|
|
|
|
|
bool isValid() const {return _valid;}
|
|
|
|
QString errorString() const {return _errorString;}
|
|
|
|
|
|
|
|
protected:
|
|
|
|
typedef RTree<VectorTile*, double, 2> TileTree;
|
|
|
|
|
|
|
|
QString _name;
|
|
|
|
RectC _bounds;
|
|
|
|
SubFile *_typ;
|
|
|
|
Style *_style;
|
|
|
|
TileTree _tileTree;
|
2020-02-15 21:49:00 +01:00
|
|
|
Range _zooms;
|
2020-02-11 21:03:55 +01:00
|
|
|
bool _baseMap;
|
2020-02-09 23:24:48 +01:00
|
|
|
|
|
|
|
bool _valid;
|
|
|
|
QString _errorString;
|
2020-02-10 19:38:45 +01:00
|
|
|
|
|
|
|
private:
|
|
|
|
QCache<const SubDiv*, Polys> _polyCache;
|
|
|
|
QCache<const SubDiv*, QList<Point> > _pointCache;
|
2020-02-09 23:24:48 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
#ifndef QT_NO_DEBUG
|
|
|
|
inline QDebug operator<<(QDebug dbg, const MapData::Point &point)
|
|
|
|
{
|
2020-10-16 00:03:26 +02:00
|
|
|
dbg.nospace() << "Point(" << hex << point.type << ", " << point.label << ")";
|
2020-02-09 23:24:48 +01:00
|
|
|
return dbg.space();
|
|
|
|
}
|
|
|
|
|
|
|
|
inline QDebug operator<<(QDebug dbg, const MapData::Poly &poly)
|
|
|
|
{
|
|
|
|
dbg.nospace() << "Poly(" << hex << poly.type << ", " << poly.label << ")";
|
|
|
|
return dbg.space();
|
|
|
|
}
|
|
|
|
#endif // QT_NO_DEBUG
|
|
|
|
|
|
|
|
#endif // MAPDATA_H
|