mirror of
https://github.com/tumic0/GPXSee.git
synced 2024-11-27 21:24:47 +01:00
Do not show local DEM tiles with unsupported file names
This commit is contained in:
parent
3b4376cc03
commit
76b14c23c6
@ -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());
|
||||||
}
|
}
|
||||||
@ -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()));
|
||||||
@ -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),
|
||||||
|
@ -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
|
||||||
{
|
{
|
||||||
|
@ -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)
|
||||||
|
Loading…
Reference in New Issue
Block a user