1
0
mirror of https://github.com/tumic0/GPXSee.git synced 2024-11-28 05:34:47 +01:00

Make caching work for both IMG and GMAP maps

This commit is contained in:
Martin Tůma 2020-02-10 19:38:45 +01:00
parent dde8903013
commit 378fa8dc0e
3 changed files with 13 additions and 9 deletions

View File

@ -1,10 +1,8 @@
#include <QMap>
#include <QtEndian>
#include "vectortile.h"
#include "img.h"
#define CACHED_SUBDIVS_COUNT 2048 // ~32MB
typedef QMap<QByteArray, VectorTile*> 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;

View File

@ -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<MapData::Poly> *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;

View File

@ -53,7 +53,7 @@ public:
QList<Poly> 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<const SubDiv*, Polys> _polyCache;
QCache<const SubDiv*, QList<Point> > _pointCache;
bool _valid;
QString _errorString;
private:
QCache<const SubDiv*, Polys> _polyCache;
QCache<const SubDiv*, QList<Point> > _pointCache;
};
#ifndef QT_NO_DEBUG