summaryrefslogtreecommitdiff
path: root/src/plugins/geoservices/osm
diff options
context:
space:
mode:
authorLaszlo Agocs <laszlo.agocs@theqtcompany.com>2015-09-04 14:02:09 +0200
committerAlex Blasche <alexander.blasche@theqtcompany.com>2015-09-07 17:58:16 +0000
commitdcac944e0bf04e8fbe56c0c00d5ceb6d22980494 (patch)
treee2d3d0b39fc1393d25ddb502910a2bdf828671c2 /src/plugins/geoservices/osm
parent8fb58aa448de42ebeb17bc5d9c74e6ee78319292 (diff)
downloadqtlocation-dcac944e0bf04e8fbe56c0c00d5ceb6d22980494.tar.gz
Fix disfunctional disk cache with OSM
The MapQuest servers use JPEG, not PNG. The disk cache, unlike the memory one, passed in the extension as the format to loadFromData(). This failed for JPEG files with an extension of .png. In addition, using split('.')[1] to determine the file extension is bogus. On Linux for example, a directory of "$HOME/.cache/QtLocation/..." results in putting "cache/..." into format which is then conveniently ignored by QImageReader. On OS X however there is no dot, so it "correctly" picks "png" for the JPEG data, hence the console is flooded with warnings about failed tile loading. On top of the above, the disk cache is made more robust by not relying on the format string. As long as only formats supported by QImageReader are in use, it can recognize the correct format from the data. (the memory cache does this already anyway) Change-Id: I90ece5bd157d457afa0025527c84070427a60313 Reviewed-by: Alex Blasche <alexander.blasche@theqtcompany.com>
Diffstat (limited to 'src/plugins/geoservices/osm')
-rw-r--r--src/plugins/geoservices/osm/qgeomapreplyosm.cpp6
-rw-r--r--src/plugins/geoservices/osm/qgeotilefetcherosm.cpp5
2 files changed, 9 insertions, 2 deletions
diff --git a/src/plugins/geoservices/osm/qgeomapreplyosm.cpp b/src/plugins/geoservices/osm/qgeomapreplyosm.cpp
index b540683b..d020716e 100644
--- a/src/plugins/geoservices/osm/qgeomapreplyosm.cpp
+++ b/src/plugins/geoservices/osm/qgeomapreplyosm.cpp
@@ -75,7 +75,11 @@ void QGeoMapReplyOsm::networkReplyFinished()
QByteArray a = m_reply->readAll();
setMapImageData(a);
- setMapImageFormat("png");
+ int mapId = tileSpec().mapId();
+ if (mapId == 1 || mapId == 2)
+ setMapImageFormat(QStringLiteral("jpg"));
+ else
+ setMapImageFormat(QStringLiteral("png"));
setFinished(true);
diff --git a/src/plugins/geoservices/osm/qgeotilefetcherosm.cpp b/src/plugins/geoservices/osm/qgeotilefetcherosm.cpp
index 95a4355e..9d2a83fa 100644
--- a/src/plugins/geoservices/osm/qgeotilefetcherosm.cpp
+++ b/src/plugins/geoservices/osm/qgeotilefetcherosm.cpp
@@ -62,13 +62,16 @@ QGeoTiledMapReply *QGeoTileFetcherOsm::getTileImage(const QGeoTileSpec &spec)
request.setRawHeader("User-Agent", m_userAgent);
QString urlPrefix;
+ QString suffix = QStringLiteral(".png");
switch (spec.mapId()) {
case 1:
urlPrefix = QStringLiteral("http://otile1.mqcdn.com/tiles/1.0.0/map/");
+ suffix = QStringLiteral(".jpg");
break;
case 2:
urlPrefix = QStringLiteral("http://otile1.mqcdn.com/tiles/1.0.0/sat/");
+ suffix = QStringLiteral(".jpg");
break;
case 3:
urlPrefix = QStringLiteral("http://a.tile.thunderforest.com/cycle/");
@@ -94,7 +97,7 @@ QGeoTiledMapReply *QGeoTileFetcherOsm::getTileImage(const QGeoTileSpec &spec)
request.setUrl(QUrl(urlPrefix + QString::number(spec.zoom()) + QLatin1Char('/') +
QString::number(spec.x()) + QLatin1Char('/') +
- QString::number(spec.y()) + QStringLiteral(".png")));
+ QString::number(spec.y()) + suffix));
QNetworkReply *reply = m_networkManager->get(request);