1
0
mirror of https://github.com/tumic0/GPXSee.git synced 2025-01-31 09:05:14 +01:00

Use the map name from the metadata table if available

This commit is contained in:
Martin Tůma 2018-09-21 00:19:30 +02:00
parent 0a74684713
commit 99ea19e35a
2 changed files with 11 additions and 8 deletions

View File

@ -76,22 +76,25 @@ MBTilesMap::MBTilesMap(const QString &fileName, QObject *parent)
qMax(0, query.value(3).toInt())) + 1, _zooms.min());
Coordinates tl(osm::m2ll(QPointF(minX, maxY)));
Coordinates br(osm::m2ll(QPointF(maxX, minY)));
// Workaround of broken zoom level 0 and 1 due to numerical instability
// Workaround of broken zoom levels 0 and 1 due to numerical instability
tl.rlat() = qMin(tl.lat(), 85.0511);
br.rlat() = qMax(br.lat(), -85.0511);
_bounds = RectC(tl, br);
}
{
QSqlQuery query("SELECT value FROM metadata WHERE name = 'name'", _db);
if (query.first())
_name = query.value(0).toString();
else
_name = QFileInfo(_fileName).fileName();
}
_db.close();
_valid = true;
}
QString MBTilesMap::name() const
{
return QFileInfo(_fileName).fileName();;
}
void MBTilesMap::load()
{
_db.open();

View File

@ -11,7 +11,7 @@ class MBTilesMap : public Map
public:
MBTilesMap(const QString &fileName, QObject *parent = 0);
QString name() const;
QString name() const {return _name;}
QRectF bounds();
qreal resolution(const QRectF &rect);
@ -43,7 +43,7 @@ private:
QSqlDatabase _db;
QString _fileName;
QString _fileName, _name;
RectC _bounds;
Range _zooms;
int _zoom;