diff --git a/src/common/coordinates.h b/src/common/coordinates.h index 5e5439d9..bc9998cd 100644 --- a/src/common/coordinates.h +++ b/src/common/coordinates.h @@ -3,6 +3,7 @@ #include #include +#include "hash.h" #define deg2rad(d) (((d)*M_PI)/180.0) #define rad2deg(d) (((d)*180.0)/M_PI) @@ -48,6 +49,11 @@ inline bool operator<(const Coordinates &c1, const Coordinates &c2) return (c1.lat() < c2.lat()); } +inline HASH_T qHash(const Coordinates &c) +{ + return qHash(QPair(c.lon(), c.lat())); +} + #ifndef QT_NO_DEBUG QDebug operator<<(QDebug dbg, const Coordinates &c); #endif // QT_NO_DEBUG diff --git a/src/map/mapsforge/mapdata.cpp b/src/map/mapsforge/mapdata.cpp index 911ff697..bc3d03e7 100644 --- a/src/map/mapsforge/mapdata.cpp +++ b/src/map/mapsforge/mapdata.cpp @@ -584,8 +584,10 @@ bool MapData::readPaths(const VectorTile *tile, int zoom, QList *list) if (!subfile.seek(subfile.pos() + val)) return false; + paths.reserve(paths[zoom - info.min]); + for (unsigned i = 0; i < paths[zoom - info.min]; i++) { - Path p(subfile.offset() + subfile.pos()); + Path p; qint32 lon = 0, lat = 0; if (!(subfile.readVUInt32(unused) && subfile.readUInt16(bitmap) @@ -665,6 +667,8 @@ bool MapData::readPoints(const VectorTile *tile, int zoom, QList *list) if (!subfile.readVUInt32(unused)) return false; + list->reserve(points[zoom - info.min]); + for (unsigned i = 0; i < points[zoom - info.min]; i++) { qint32 lat, lon; diff --git a/src/map/mapsforge/mapdata.h b/src/map/mapsforge/mapdata.h index 064fb10a..a8bffa0a 100644 --- a/src/map/mapsforge/mapdata.h +++ b/src/map/mapsforge/mapdata.h @@ -36,10 +36,7 @@ public: }; struct Point { - Point(const Coordinates &c) : coordinates(c) - { - id = (quint64)qHash(QPair(c.lon(), c.lat())); - } + Point(const Coordinates &c) : id(qHash(c)), coordinates(c) {} quint64 id; Coordinates coordinates; @@ -48,9 +45,6 @@ public: }; struct Path { - Path(quint64 id) : id(id) {} - - quint64 id; Polygon poly; QVector tags; Coordinates labelPos; @@ -59,8 +53,6 @@ public: bool operator<(const Path &other) const {return layer < other.layer;} - bool operator==(const Path &other) const - {return (id == other.id);} }; RectC bounds() const; @@ -190,11 +182,6 @@ inline HASH_T qHash(const MapData::Tag &tag) return ::qHash(tag.key) ^ ::qHash(tag.value); } -inline HASH_T qHash(const MapData::Path &path) -{ - return ::qHash(path.id); -} - } #ifndef QT_NO_DEBUG diff --git a/src/map/mapsforge/rastertile.cpp b/src/map/mapsforge/rastertile.cpp index 84c7d5ad..35bf8daf 100644 --- a/src/map/mapsforge/rastertile.cpp +++ b/src/map/mapsforge/rastertile.cpp @@ -224,9 +224,10 @@ QPainterPath RasterTile::painterPath(const Polygon &polygon, bool curve) const } path.quadTo(p2, p3); } else { - path.moveTo(ll2xy(subpath.first())); - for (int j = 1; j < subpath.size(); j++) - path.lineTo(ll2xy(subpath.at(j))); + QVector p(subpath.size()); + for (int j = 0; j < subpath.size(); j++) + p[j] = ll2xy(subpath.at(j)); + path.addPolygon(p); } } diff --git a/src/map/mapsforge/subfile.h b/src/map/mapsforge/subfile.h index 948ebd53..956d2b31 100644 --- a/src/map/mapsforge/subfile.h +++ b/src/map/mapsforge/subfile.h @@ -14,7 +14,6 @@ public: : _file(file), _offset(offset), _size(size), _pos(-1), _blockNum(-1), _blockPos(-1) {} - quint64 offset() const {return _offset;} quint64 pos() const {return _pos;} bool seek(quint64 pos);