1 #ifndef MAPDATA_H 2 #define MAPDATA_H 3 4 #include <QList> 5 #include <QPointF> 6 #include <QCache> 7 #include <QDebug> 8 #include "common/rectc.h" 9 #include "common/rtree.h" 10 #include "common/range.h" 11 #include "label.h" 12 13 class Style; 14 class SubDiv; 15 class SubFile; 16 class VectorTile; 17 18 class MapData 19 { 20 public: 21 struct Poly { 22 /* QPointF insted of Coordinates for performance reasons (no need to 23 duplicate all the vectors for drawing). Note, that we do not want to 24 ll2xy() the points in the IMG class as this can not be done in 25 parallel. */ 26 QVector<QPointF> points; 27 Label label; 28 quint32 type; 29 RectC boundingRect; 30 31 bool operator<(const Poly &other) const 32 {return type > other.type;} 33 }; 34 35 struct Point { PointPoint36 Point() : id(0) {} 37 38 Coordinates coordinates; 39 Label label; 40 quint32 type; 41 bool poi; 42 quint64 id; 43 44 bool operator<(const Point &other) const 45 {return id < other.id;} 46 }; 47 48 struct Polys { PolysPolys49 Polys() {} PolysPolys50 Polys(const QList<Poly> &polygons, const QList<Poly> &lines) 51 : polygons(polygons), lines(lines) {} 52 53 QList<Poly> polygons; 54 QList<Poly> lines; 55 }; 56 57 MapData(); 58 virtual ~MapData(); 59 name()60 const QString &name() const {return _name;} bounds()61 const RectC &bounds() const {return _bounds;} zooms()62 const Range &zooms() const {return _zooms;} style()63 const Style *style() const {return _style;} 64 void polys(const RectC &rect, int bits, QList<Poly> *polygons, 65 QList<Poly> *lines); 66 void points(const RectC &rect, int bits, QList<Point> *points); 67 68 void load(); 69 void clear(); 70 71 virtual QString fileName() const = 0; 72 isValid()73 bool isValid() const {return _valid;} errorString()74 QString errorString() const {return _errorString;} 75 76 protected: 77 typedef RTree<VectorTile*, double, 2> TileTree; 78 79 QString _name; 80 RectC _bounds; 81 SubFile *_typ; 82 Style *_style; 83 TileTree _tileTree; 84 Range _zooms; 85 bool _baseMap; 86 87 bool _valid; 88 QString _errorString; 89 90 private: 91 QCache<const SubDiv*, Polys> _polyCache; 92 QCache<const SubDiv*, QList<Point> > _pointCache; 93 }; 94 95 #ifndef QT_NO_DEBUG 96 inline QDebug operator<<(QDebug dbg, const MapData::Point &point) 97 { 98 dbg.nospace() << "Point(" << hex << point.type << ", " << point.label 99 << ", " << point.poi << ")"; 100 return dbg.space(); 101 } 102 103 inline QDebug operator<<(QDebug dbg, const MapData::Poly &poly) 104 { 105 dbg.nospace() << "Poly(" << hex << poly.type << ", " << poly.label << ")"; 106 return dbg.space(); 107 } 108 #endif // QT_NO_DEBUG 109 110 #endif // MAPDATA_H 111