1
0
mirror of https://github.com/tumic0/GPXSee.git synced 2024-11-24 11:45:53 +01:00

Added support for 0.5" (7201x7201) DEM tiles

+ DEM cache limit fix
This commit is contained in:
Martin Tůma 2023-02-28 23:59:52 +01:00
parent 00a349575c
commit 7be3a27196
2 changed files with 12 additions and 6 deletions

View File

@ -21,9 +21,11 @@
#include "common/rectc.h" #include "common/rectc.h"
#include "dem.h" #include "dem.h"
#define CACHE_SIZE 536870912 /* 512MB */
#define SRTM3_SAMPLES 1201 #define SRTM3_SAMPLES 1201
#define SRTM1_SAMPLES 3601 #define SRTM1_SAMPLES 3601
#define SRTM05_SAMPLES 7201
#define SRTM_SIZE(samples) \ #define SRTM_SIZE(samples) \
((samples) * (samples) * 2) ((samples) * (samples) * 2)
@ -51,6 +53,8 @@ static qreal height(const Coordinates &c, const QByteArray *data)
samples = SRTM3_SAMPLES; samples = SRTM3_SAMPLES;
else if (data->size() == SRTM_SIZE(SRTM1_SAMPLES)) else if (data->size() == SRTM_SIZE(SRTM1_SAMPLES))
samples = SRTM1_SAMPLES; samples = SRTM1_SAMPLES;
else if (data->size() == SRTM_SIZE(SRTM05_SAMPLES))
samples = SRTM05_SAMPLES;
else else
return NAN; return NAN;
@ -85,7 +89,7 @@ QString DEM::Tile::baseName() const
} }
QString DEM::_dir; QString DEM::_dir;
QCache<DEM::Tile, QByteArray> DEM::_data; DEM::TileCache DEM::_data = DEM::TileCache(CACHE_SIZE);
QString DEM::fileName(const QString &baseName) QString DEM::fileName(const QString &baseName)
{ {
@ -119,7 +123,7 @@ qreal DEM::elevation(const Coordinates &c)
QZipReader zip(zn, QIODevice::ReadOnly); QZipReader zip(zn, QIODevice::ReadOnly);
ba = new QByteArray(zip.fileData(bn)); ba = new QByteArray(zip.fileData(bn));
qreal ele = height(c, ba); qreal ele = height(c, ba);
_data.insert(tile, ba); _data.insert(tile, ba, ba->size());
return ele; return ele;
} else { } else {
QFile file(fn); QFile file(fn);
@ -131,7 +135,7 @@ qreal DEM::elevation(const Coordinates &c)
} else { } else {
ba = new QByteArray(file.readAll()); ba = new QByteArray(file.readAll());
qreal ele = height(c, ba); qreal ele = height(c, ba);
_data.insert(tile, ba); _data.insert(tile, ba, ba->size());
return ele; return ele;
} }
} }

View File

@ -41,10 +41,12 @@ public:
static QList<Area> tiles(); static QList<Area> tiles();
private: private:
typedef QCache<DEM::Tile, QByteArray> TileCache;
static QString fileName(const QString &baseName); static QString fileName(const QString &baseName);
static QString _dir; static QString _dir;
static QCache<Tile, QByteArray> _data; static TileCache _data;
}; };
inline HASH_T qHash(const DEM::Tile &tile) inline HASH_T qHash(const DEM::Tile &tile)