From 378fa8dc0ee21f8d00a7df2816d413642414f4ad Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20T=C5=AFma?= Date: Mon, 10 Feb 2020 19:38:45 +0100 Subject: [PATCH] Make caching work for both IMG and GMAP maps --- src/map/IMG/img.cpp | 5 ----- src/map/IMG/mapdata.cpp | 8 ++++++++ src/map/IMG/mapdata.h | 9 +++++---- 3 files changed, 13 insertions(+), 9 deletions(-) diff --git a/src/map/IMG/img.cpp b/src/map/IMG/img.cpp index dbfa179c..371c52e8 100644 --- a/src/map/IMG/img.cpp +++ b/src/map/IMG/img.cpp @@ -1,10 +1,8 @@ #include #include - #include "vectortile.h" #include "img.h" -#define CACHED_SUBDIVS_COUNT 2048 // ~32MB typedef QMap TileMap; @@ -63,9 +61,6 @@ IMG::IMG(const QString &fileName) : _file(fileName) _name = QString::fromLatin1(nba.constData(), nba.size()-1).trimmed(); _blockSize = 1 << (e1 + e2); - _polyCache.setMaxCost(CACHED_SUBDIVS_COUNT); - _pointCache.setMaxCost(CACHED_SUBDIVS_COUNT); - // Read the FAT table quint8 flag; quint64 offset = 0x200; diff --git a/src/map/IMG/mapdata.cpp b/src/map/IMG/mapdata.cpp index 801fe78d..8d50a138 100644 --- a/src/map/IMG/mapdata.cpp +++ b/src/map/IMG/mapdata.cpp @@ -4,6 +4,8 @@ #include "mapdata.h" +#define CACHED_SUBDIVS_COUNT 2048 // ~32MB for both caches together + struct PolyCTX { PolyCTX(const RectC &rect, int bits, QList *polygons, @@ -45,6 +47,12 @@ inline bool pointCb(VectorTile *tile, void *context) } +MapData::MapData() : _typ(0), _style(0), _valid(false) +{ + _polyCache.setMaxCost(CACHED_SUBDIVS_COUNT); + _pointCache.setMaxCost(CACHED_SUBDIVS_COUNT); +} + MapData::~MapData() { TileTree::Iterator it; diff --git a/src/map/IMG/mapdata.h b/src/map/IMG/mapdata.h index ac14becb..e998183d 100644 --- a/src/map/IMG/mapdata.h +++ b/src/map/IMG/mapdata.h @@ -53,7 +53,7 @@ public: QList lines; }; - MapData() : _typ(0), _style(0), _valid(false) {} + MapData(); virtual ~MapData(); const QString &name() const {return _name;} @@ -78,13 +78,14 @@ protected: RectC _bounds; SubFile *_typ; Style *_style; - TileTree _tileTree; - QCache _polyCache; - QCache > _pointCache; bool _valid; QString _errorString; + +private: + QCache _polyCache; + QCache > _pointCache; }; #ifndef QT_NO_DEBUG