summaryrefslogtreecommitdiff
path: root/src/plugins/geoservices/mapbox
diff options
context:
space:
mode:
authorPaolo Angelelli <paolo.angelelli@theqtcompany.com>2016-06-28 16:27:09 +0200
committerPaolo Angelelli <paolo.angelelli@theqtcompany.com>2016-07-01 09:29:11 +0000
commitc2329ca8fb48aac7da1694f4b9c3d28924feae63 (patch)
tree4031363229220cf4617f689799340013b9fa091a /src/plugins/geoservices/mapbox
parenta10b6b5bf6ed29f705c2e3dd85c1206a96171f60 (diff)
downloadqtlocation-c2329ca8fb48aac7da1694f4b9c3d28924feae63.tar.gz
Use HiDpi tiles to produce crisper maps at fractional zoom levels
The current QtLocation renderer uses geotiles of specified size for each specific zoom level, and show them using nearest neighbor interpolation when the camera is at that specific zoom level. Interpolation is changed to linear when the zoom level is in between two neighboring tile layers, but hasn't reached the next yet, so that the previous layer can be magnified smoothly. While this is the correct approach, it produces blurry images most of the time, while the previous camera mechanics, not allowing continuous zoom, was able to show crisp images all the time. To retain the continuous zoom and produce crisp images, this patch makes use of HiDpi tiles from providers that offer them (HERE and mapbox). The way these two providers offer HiDpi is different: HERE scales the map elements (text, mostly), to address a specific dpi (supported dpis are 72, the standard, 250, 320, 500), while mapbox returns the same tile at double resolution. The way the patch deals with this is by taking the image requested as is, but setting the tile size in the renderer to be half of that, while at the same time enabling mip mapping for QSGImageNodes. In this way, at integer zoom level, texture LOD 1 is shown, that is an OpenGL-scaled-down version of the downloaded tile, while at the other fractional zoom levels trilinear interpolation is used to produce a good image. This approach was not possible for the openstreetmap geoservice provider because mapquest (the currently used data provider) does not offer HiDpi tiles, and a scaled version of the standard tile would make the text unreadable half of the times. Further scaling would be possible, e.g., with HERE maps, offering 500ppi maps, to look good during scaling also on HiDpi devices. This can be addressed in a future patch. Task-number: QTBUG-53318 Task-number: QTBUG-48868 Task-number: QTBUG-36949 Change-Id: Iaa6f5b1ece9d37a0c85e73efaf1bd3b50b1d5950 Reviewed-by: Alex Blasche <alexander.blasche@theqtcompany.com>
Diffstat (limited to 'src/plugins/geoservices/mapbox')
-rw-r--r--src/plugins/geoservices/mapbox/qgeotiledmappingmanagerenginemapbox.cpp9
-rw-r--r--src/plugins/geoservices/mapbox/qgeotilefetchermapbox.cpp7
-rw-r--r--src/plugins/geoservices/mapbox/qgeotilefetchermapbox.h3
3 files changed, 13 insertions, 6 deletions
diff --git a/src/plugins/geoservices/mapbox/qgeotiledmappingmanagerenginemapbox.cpp b/src/plugins/geoservices/mapbox/qgeotiledmappingmanagerenginemapbox.cpp
index ea679afc..eb1ad866 100644
--- a/src/plugins/geoservices/mapbox/qgeotiledmappingmanagerenginemapbox.cpp
+++ b/src/plugins/geoservices/mapbox/qgeotiledmappingmanagerenginemapbox.cpp
@@ -116,8 +116,13 @@ QGeoTiledMappingManagerEngineMapbox::QGeoTiledMappingManagerEngineMapbox(const Q
setSupportedMapTypes(mapTypes);
- QGeoTileFetcherMapbox *tileFetcher = new QGeoTileFetcherMapbox(this);
- tileFetcher->setMapIds(mapIds);
+ bool doubleRes = true;
+ if (parameters.contains(QStringLiteral("mapbox.highdpi_tiles"))) {
+ const QString param = parameters.value(QStringLiteral("mapbox.highdpi_tiles")).toString().toLower();
+ if (param == "false")
+ doubleRes = false;
+ }
+ QGeoTileFetcherMapbox *tileFetcher = new QGeoTileFetcherMapbox(this, doubleRes);
if (parameters.contains(QStringLiteral("useragent"))) {
const QByteArray ua = parameters.value(QStringLiteral("useragent")).toString().toLatin1();
diff --git a/src/plugins/geoservices/mapbox/qgeotilefetchermapbox.cpp b/src/plugins/geoservices/mapbox/qgeotilefetchermapbox.cpp
index 7a082006..6b7fc06b 100644
--- a/src/plugins/geoservices/mapbox/qgeotilefetchermapbox.cpp
+++ b/src/plugins/geoservices/mapbox/qgeotilefetchermapbox.cpp
@@ -44,12 +44,13 @@
QT_BEGIN_NAMESPACE
-QGeoTileFetcherMapbox::QGeoTileFetcherMapbox(QObject *parent)
+QGeoTileFetcherMapbox::QGeoTileFetcherMapbox(QObject *parent, bool highDpiTiles)
: QGeoTileFetcher(parent), m_networkManager(new QNetworkAccessManager(this)),
m_userAgent("Qt Location based application"),
m_format("png"),
m_replyFormat("png"),
- m_accessToken("")
+ m_accessToken(""),
+ m_highDpiTiles(highDpiTiles)
{
}
@@ -89,7 +90,7 @@ QGeoTiledMapReply *QGeoTileFetcherMapbox::getTileImage(const QGeoTileSpec &spec)
((spec.mapId() >= m_mapIds.size()) ? QStringLiteral("mapbox.streets") : m_mapIds[spec.mapId()]) + QLatin1Char('/') +
QString::number(spec.zoom()) + QLatin1Char('/') +
QString::number(spec.x()) + QLatin1Char('/') +
- QString::number(spec.y()) + QLatin1Char('.') +
+ QString::number(spec.y()) + ((m_highDpiTiles) ? QStringLiteral("@2x.") : QStringLiteral(".")) +
m_format + QLatin1Char('?') +
QStringLiteral("access_token=") + m_accessToken));
diff --git a/src/plugins/geoservices/mapbox/qgeotilefetchermapbox.h b/src/plugins/geoservices/mapbox/qgeotilefetchermapbox.h
index a1ab7dcc..1263b237 100644
--- a/src/plugins/geoservices/mapbox/qgeotilefetchermapbox.h
+++ b/src/plugins/geoservices/mapbox/qgeotilefetchermapbox.h
@@ -50,7 +50,7 @@ class QGeoTileFetcherMapbox : public QGeoTileFetcher
Q_OBJECT
public:
- QGeoTileFetcherMapbox(QObject *parent = 0);
+ QGeoTileFetcherMapbox(QObject *parent = 0, bool highDpiTiles = true);
void setUserAgent(const QByteArray &userAgent);
void setMapIds(const QVector<QString> &mapIds);
@@ -66,6 +66,7 @@ private:
QString m_replyFormat;
QString m_accessToken;
QVector<QString> m_mapIds;
+ bool m_highDpiTiles;
};
QT_END_NAMESPACE