From 7be3a271969993fabf96d6d7093b3755402a69ef Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20T=C5=AFma?= Date: Tue, 28 Feb 2023 23:59:52 +0100 Subject: [PATCH] Added support for 0.5" (7201x7201) DEM tiles + DEM cache limit fix --- src/data/dem.cpp | 14 +++++++++----- src/data/dem.h | 4 +++- 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/src/data/dem.cpp b/src/data/dem.cpp index 47f097ff..7e31fb8c 100644 --- a/src/data/dem.cpp +++ b/src/data/dem.cpp @@ -21,9 +21,11 @@ #include "common/rectc.h" #include "dem.h" +#define CACHE_SIZE 536870912 /* 512MB */ -#define SRTM3_SAMPLES 1201 -#define SRTM1_SAMPLES 3601 +#define SRTM3_SAMPLES 1201 +#define SRTM1_SAMPLES 3601 +#define SRTM05_SAMPLES 7201 #define SRTM_SIZE(samples) \ ((samples) * (samples) * 2) @@ -51,6 +53,8 @@ static qreal height(const Coordinates &c, const QByteArray *data) samples = SRTM3_SAMPLES; else if (data->size() == SRTM_SIZE(SRTM1_SAMPLES)) samples = SRTM1_SAMPLES; + else if (data->size() == SRTM_SIZE(SRTM05_SAMPLES)) + samples = SRTM05_SAMPLES; else return NAN; @@ -85,7 +89,7 @@ QString DEM::Tile::baseName() const } QString DEM::_dir; -QCache DEM::_data; +DEM::TileCache DEM::_data = DEM::TileCache(CACHE_SIZE); QString DEM::fileName(const QString &baseName) { @@ -119,7 +123,7 @@ qreal DEM::elevation(const Coordinates &c) QZipReader zip(zn, QIODevice::ReadOnly); ba = new QByteArray(zip.fileData(bn)); qreal ele = height(c, ba); - _data.insert(tile, ba); + _data.insert(tile, ba, ba->size()); return ele; } else { QFile file(fn); @@ -131,7 +135,7 @@ qreal DEM::elevation(const Coordinates &c) } else { ba = new QByteArray(file.readAll()); qreal ele = height(c, ba); - _data.insert(tile, ba); + _data.insert(tile, ba, ba->size()); return ele; } } diff --git a/src/data/dem.h b/src/data/dem.h index eb5e4a25..1d62d168 100644 --- a/src/data/dem.h +++ b/src/data/dem.h @@ -41,10 +41,12 @@ public: static QList tiles(); private: + typedef QCache TileCache; + static QString fileName(const QString &baseName); static QString _dir; - static QCache _data; + static TileCache _data; }; inline HASH_T qHash(const DEM::Tile &tile)