1
0
mirror of https://github.com/tumic0/GPXSee.git synced 2024-11-27 21:24: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);
_pixmapCache = new QSpinBox();
_pixmapCache->setMinimum(16);
_pixmapCache->setMaximum(2048);
_pixmapCache->setMinimum(64);
_pixmapCache->setMaximum(4096);
_pixmapCache->setSuffix(UNIT_SPACE + tr("MB"));
_pixmapCache->setValue(_options.pixmapCache);
_demCache = new QSpinBox();
_demCache->setMinimum(64);
_demCache->setMaximum(2048);
_demCache->setMaximum(4096);
_demCache->setSuffix(UNIT_SPACE + tr("MB"));
_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'));
}
QString DEM::Tile::baseName() const
QString DEM::Tile::fileName() const
{
return QString("%1%2.hgt").arg(latStr(), lonStr());
}
@ -75,7 +75,7 @@ DEM::TileCache DEM::_data;
void DEM::setCacheSize(int size)
{
_data.setMaxCost(size * 1024);
_data.setMaxCost(size);
}
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)
{
QString bn(tile.baseName());
QString fn(QDir(_dir).absoluteFilePath(bn));
QString zn(fn + ".zip");
QString fileName(tile.fileName());
QString path(QDir(_dir).absoluteFilePath(fileName));
QString zipPath(path + ".zip");
if (QFileInfo::exists(zn)) {
QZipReader zip(zn, QIODevice::ReadOnly);
return new Entry(zip.fileData(bn));
if (QFileInfo::exists(zipPath)) {
QZipReader zip(zipPath, QIODevice::ReadOnly);
return new Entry(zip.fileData(fileName));
} else {
QFile file(fn);
QFile file(path);
if (!file.open(QIODevice::ReadOnly)) {
qWarning("%s: %s", qPrintable(file.fileName()),
qPrintable(file.errorString()));
@ -138,7 +138,7 @@ double DEM::elevation(const Coordinates &c)
if (!e) {
e = loadTile(tile);
ele = height(c, e);
_data.insert(tile, e, e->data().size());
_data.insert(tile, e, e->data().size() / 1024);
} else
ele = height(c, e);
@ -147,15 +147,15 @@ double DEM::elevation(const Coordinates &c)
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);
QFileInfoList files(dir.entryInfoList(QDir::Files | QDir::Readable));
QLocale l(QLocale::system());
QList<Area> list;
for (int i = 0; i < files.size(); i++) {
QString basename(files.at(i).baseName());
QRegularExpressionMatch match(re.match(basename));
QRegularExpressionMatch match(re.match(files.at(i).fileName()));
if (!match.hasMatch())
continue;
@ -167,7 +167,7 @@ QList<Area> DEM::tiles()
lon = -lon;
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() + ", "
+ l.formattedDataSize(files.at(i).size()));
area.setStyle(PolygonStyle(QColor(0xFF, 0, 0, 0x40),

View File

@ -22,7 +22,7 @@ public:
QString lonStr() const;
QString latStr() const;
QString baseName() const;
QString fileName() 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
{
return _dir.absoluteFilePath(tile.baseName());
return _dir.absoluteFilePath(tile.fileName());
}
void DEMLoader::setAuthorization(const Authorization &authorization)