1
0
mirror of https://github.com/tumic0/GPXSee.git synced 2025-02-21 18:20:47 +01:00

Compare commits

..

4 Commits

Author SHA1 Message Date
7de180d580 Cache size limits update
Allow caches up to 4GB (usefull for 0.5' DEM tiles)
Do not allow smaller pixmap cache than 64MB (minimum for async maps to work on
4K displays is ~34MB of tile image data!)
2024-04-27 12:30:07 +02:00
bd37521ca0 Use kB in the chache size arithmetics to prevent integer overflow 2024-04-27 12:15:06 +02:00
4445976cb9 Use a more strict regular expression to match the tiles 2024-04-27 11:46:00 +02:00
76b14c23c6 Do not show local DEM tiles with unsupported file names 2024-04-27 11:42:37 +02:00
4 changed files with 19 additions and 19 deletions

View File

@ -727,14 +727,14 @@ QWidget *OptionsDialog::createSystemPage()
_enableHTTP2->setChecked(_options.enableHTTP2); _enableHTTP2->setChecked(_options.enableHTTP2);
_pixmapCache = new QSpinBox(); _pixmapCache = new QSpinBox();
_pixmapCache->setMinimum(16); _pixmapCache->setMinimum(64);
_pixmapCache->setMaximum(2048); _pixmapCache->setMaximum(4096);
_pixmapCache->setSuffix(UNIT_SPACE + tr("MB")); _pixmapCache->setSuffix(UNIT_SPACE + tr("MB"));
_pixmapCache->setValue(_options.pixmapCache); _pixmapCache->setValue(_options.pixmapCache);
_demCache = new QSpinBox(); _demCache = new QSpinBox();
_demCache->setMinimum(64); _demCache->setMinimum(64);
_demCache->setMaximum(2048); _demCache->setMaximum(4096);
_demCache->setSuffix(UNIT_SPACE + tr("MB")); _demCache->setSuffix(UNIT_SPACE + tr("MB"));
_demCache->setValue(_options.demCache); _demCache->setValue(_options.demCache);

View File

@ -65,7 +65,7 @@ QString DEM::Tile::lonStr() const
return QString("%1%2").arg(ew).arg(qAbs(_lon), 3, 10, QChar('0')); return QString("%1%2").arg(ew).arg(qAbs(_lon), 3, 10, QChar('0'));
} }
QString DEM::Tile::baseName() const QString DEM::Tile::fileName() const
{ {
return QString("%1%2.hgt").arg(latStr(), lonStr()); return QString("%1%2.hgt").arg(latStr(), lonStr());
} }
@ -75,7 +75,7 @@ DEM::TileCache DEM::_data;
void DEM::setCacheSize(int size) void DEM::setCacheSize(int size)
{ {
_data.setMaxCost(size * 1024); _data.setMaxCost(size);
} }
void DEM::setDir(const QString &path) void DEM::setDir(const QString &path)
@ -108,15 +108,15 @@ double DEM::height(const Coordinates &c, const Entry *e)
DEM::Entry *DEM::loadTile(const Tile &tile) DEM::Entry *DEM::loadTile(const Tile &tile)
{ {
QString bn(tile.baseName()); QString fileName(tile.fileName());
QString fn(QDir(_dir).absoluteFilePath(bn)); QString path(QDir(_dir).absoluteFilePath(fileName));
QString zn(fn + ".zip"); QString zipPath(path + ".zip");
if (QFileInfo::exists(zn)) { if (QFileInfo::exists(zipPath)) {
QZipReader zip(zn, QIODevice::ReadOnly); QZipReader zip(zipPath, QIODevice::ReadOnly);
return new Entry(zip.fileData(bn)); return new Entry(zip.fileData(fileName));
} else { } else {
QFile file(fn); QFile file(path);
if (!file.open(QIODevice::ReadOnly)) { if (!file.open(QIODevice::ReadOnly)) {
qWarning("%s: %s", qPrintable(file.fileName()), qWarning("%s: %s", qPrintable(file.fileName()),
qPrintable(file.errorString())); qPrintable(file.errorString()));
@ -138,7 +138,7 @@ double DEM::elevation(const Coordinates &c)
if (!e) { if (!e) {
e = loadTile(tile); e = loadTile(tile);
ele = height(c, e); ele = height(c, e);
_data.insert(tile, e, e->data().size()); _data.insert(tile, e, e->data().size() / 1024);
} else } else
ele = height(c, e); ele = height(c, e);
@ -147,15 +147,15 @@ double DEM::elevation(const Coordinates &c)
QList<Area> DEM::tiles() QList<Area> DEM::tiles()
{ {
static const QRegularExpression re("([NS])([0-9]{2})([EW])([0-9]{3})"); static const QRegularExpression re(
"^([NS])([0-9]{2})([EW])([0-9]{3})(\\.hgt|\\.hgt\\.zip)$");
QDir dir(_dir); QDir dir(_dir);
QFileInfoList files(dir.entryInfoList(QDir::Files | QDir::Readable)); QFileInfoList files(dir.entryInfoList(QDir::Files | QDir::Readable));
QLocale l(QLocale::system()); QLocale l(QLocale::system());
QList<Area> list; QList<Area> list;
for (int i = 0; i < files.size(); i++) { for (int i = 0; i < files.size(); i++) {
QString basename(files.at(i).baseName()); QRegularExpressionMatch match(re.match(files.at(i).fileName()));
QRegularExpressionMatch match(re.match(basename));
if (!match.hasMatch()) if (!match.hasMatch())
continue; continue;
@ -167,7 +167,7 @@ QList<Area> DEM::tiles()
lon = -lon; lon = -lon;
Area area(RectC(Coordinates(lon, lat + 1), Coordinates(lon + 1, lat))); Area area(RectC(Coordinates(lon, lat + 1), Coordinates(lon + 1, lat)));
area.setName(basename); area.setName(files.at(i).baseName());
area.setDescription(files.at(i).suffix().toUpper() + ", " area.setDescription(files.at(i).suffix().toUpper() + ", "
+ l.formattedDataSize(files.at(i).size())); + l.formattedDataSize(files.at(i).size()));
area.setStyle(PolygonStyle(QColor(0xFF, 0, 0, 0x40), area.setStyle(PolygonStyle(QColor(0xFF, 0, 0, 0x40),

View File

@ -22,7 +22,7 @@ public:
QString lonStr() const; QString lonStr() const;
QString latStr() const; QString latStr() const;
QString baseName() const; QString fileName() const;
bool operator==(const Tile &other) const bool operator==(const Tile &other) const
{ {

View File

@ -110,7 +110,7 @@ QUrl DEMLoader::tileUrl(const DEM::Tile &tile) const
QString DEMLoader::tileFile(const DEM::Tile &tile) const QString DEMLoader::tileFile(const DEM::Tile &tile) const
{ {
return _dir.absoluteFilePath(tile.baseName()); return _dir.absoluteFilePath(tile.fileName());
} }
void DEMLoader::setAuthorization(const Authorization &authorization) void DEMLoader::setAuthorization(const Authorization &authorization)