2021-04-10 15:27:40 +02:00
|
|
|
#ifndef IMG_MAPDATA_H
|
|
|
|
#define IMG_MAPDATA_H
|
2020-02-09 23:24:48 +01:00
|
|
|
|
|
|
|
#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"
|
2021-01-25 21:37:07 +01:00
|
|
|
#include "raster.h"
|
2020-02-09 23:24:48 +01:00
|
|
|
|
2021-04-10 15:27:40 +02:00
|
|
|
|
|
|
|
namespace IMG {
|
|
|
|
|
2020-02-09 23:24:48 +01:00
|
|
|
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
|
2020-11-10 20:14:59 +01:00
|
|
|
ll2xy() the points in the MapData class as this can not be done in
|
2020-02-09 23:24:48 +01:00
|
|
|
parallel. */
|
|
|
|
QVector<QPointF> points;
|
|
|
|
Label label;
|
2021-01-25 21:37:07 +01:00
|
|
|
Raster raster;
|
2020-02-09 23:24:48 +01:00
|
|
|
quint32 type;
|
|
|
|
RectC boundingRect;
|
|
|
|
|
|
|
|
bool operator<(const Poly &other) const
|
|
|
|
{return type > other.type;}
|
|
|
|
};
|
|
|
|
|
|
|
|
struct Point {
|
2022-02-06 02:42:37 +01:00
|
|
|
Point() : id(0), classLabel(false) {}
|
2020-02-09 23:24:48 +01:00
|
|
|
|
|
|
|
Coordinates coordinates;
|
|
|
|
Label label;
|
|
|
|
quint32 type;
|
|
|
|
quint64 id;
|
2022-02-06 02:42:37 +01:00
|
|
|
bool classLabel;
|
2020-02-09 23:24:48 +01:00
|
|
|
|
|
|
|
bool operator<(const Point &other) const
|
|
|
|
{return id < other.id;}
|
|
|
|
};
|
|
|
|
|
2021-10-02 09:24:00 +02:00
|
|
|
MapData(const QString &fileName);
|
2021-10-02 11:59:11 +02:00
|
|
|
virtual ~MapData();
|
2020-02-09 23:24:48 +01:00
|
|
|
|
|
|
|
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();
|
|
|
|
|
2021-10-02 09:24:00 +02:00
|
|
|
const QString &fileName() const {return _fileName;}
|
2020-02-09 23:24:48 +01:00
|
|
|
|
|
|
|
bool isValid() const {return _valid;}
|
|
|
|
QString errorString() const {return _errorString;}
|
|
|
|
|
|
|
|
protected:
|
|
|
|
typedef RTree<VectorTile*, double, 2> TileTree;
|
|
|
|
|
2021-10-02 09:24:00 +02:00
|
|
|
QString _fileName;
|
2020-02-09 23:24:48 +01:00
|
|
|
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:
|
2020-11-10 20:14:59 +01:00
|
|
|
struct Polys {
|
|
|
|
Polys() {}
|
|
|
|
Polys(const QList<Poly> &polygons, const QList<Poly> &lines)
|
|
|
|
: polygons(polygons), lines(lines) {}
|
|
|
|
|
|
|
|
QList<Poly> polygons;
|
|
|
|
QList<Poly> lines;
|
|
|
|
};
|
|
|
|
|
2021-04-10 15:27:40 +02:00
|
|
|
struct PolyCTX
|
|
|
|
{
|
|
|
|
PolyCTX(const RectC &rect, int bits, bool baseMap,
|
|
|
|
QList<MapData::Poly> *polygons, QList<MapData::Poly> *lines,
|
|
|
|
QCache<const SubDiv*, MapData::Polys> *polyCache)
|
|
|
|
: rect(rect), bits(bits), baseMap(baseMap), polygons(polygons),
|
|
|
|
lines(lines), polyCache(polyCache) {}
|
|
|
|
|
|
|
|
const RectC ▭
|
|
|
|
int bits;
|
|
|
|
bool baseMap;
|
|
|
|
QList<MapData::Poly> *polygons;
|
|
|
|
QList<MapData::Poly> *lines;
|
|
|
|
QCache<const SubDiv*, MapData::Polys> *polyCache;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct PointCTX
|
|
|
|
{
|
|
|
|
PointCTX(const RectC &rect, int bits, bool baseMap,
|
|
|
|
QList<MapData::Point> *points,
|
|
|
|
QCache<const SubDiv*, QList<MapData::Point> > *pointCache)
|
|
|
|
: rect(rect), bits(bits), baseMap(baseMap), points(points),
|
|
|
|
pointCache(pointCache) {}
|
|
|
|
|
|
|
|
const RectC ▭
|
|
|
|
int bits;
|
|
|
|
bool baseMap;
|
|
|
|
QList<MapData::Point> *points;
|
|
|
|
QCache<const SubDiv*, QList<MapData::Point> > *pointCache;
|
|
|
|
};
|
|
|
|
|
|
|
|
static bool polyCb(VectorTile *tile, void *context);
|
|
|
|
static bool pointCb(VectorTile *tile, void *context);
|
|
|
|
|
2020-02-10 19:38:45 +01:00
|
|
|
QCache<const SubDiv*, Polys> _polyCache;
|
|
|
|
QCache<const SubDiv*, QList<Point> > _pointCache;
|
2020-11-10 20:14:59 +01:00
|
|
|
|
|
|
|
friend class VectorTile;
|
2020-11-11 23:15:12 +01:00
|
|
|
friend struct PolyCTX;
|
2020-02-09 23:24:48 +01:00
|
|
|
};
|
|
|
|
|
2021-04-10 15:27:40 +02:00
|
|
|
}
|
|
|
|
|
2020-02-09 23:24:48 +01:00
|
|
|
#ifndef QT_NO_DEBUG
|
2021-04-10 15:27:40 +02:00
|
|
|
inline QDebug operator<<(QDebug dbg, const IMG::MapData::Point &point)
|
2020-02-09 23:24:48 +01:00
|
|
|
{
|
2020-12-22 22:09:09 +01:00
|
|
|
dbg.nospace() << "Point(" << point.type << ", " << point.label << ")";
|
2020-02-09 23:24:48 +01:00
|
|
|
return dbg.space();
|
|
|
|
}
|
|
|
|
|
2021-04-10 15:27:40 +02:00
|
|
|
inline QDebug operator<<(QDebug dbg, const IMG::MapData::Poly &poly)
|
2020-02-09 23:24:48 +01:00
|
|
|
{
|
2020-12-22 22:09:09 +01:00
|
|
|
dbg.nospace() << "Poly(" << poly.type << ", " << poly.label << ")";
|
2020-02-09 23:24:48 +01:00
|
|
|
return dbg.space();
|
|
|
|
}
|
|
|
|
#endif // QT_NO_DEBUG
|
|
|
|
|
2021-04-10 15:27:40 +02:00
|
|
|
#endif // IMG_MAPDATA_H
|