summaryrefslogtreecommitdiff
path: root/src/plugins/geoservices/nokia
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/nokia
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/nokia')
-rw-r--r--src/plugins/geoservices/nokia/qgeotiledmappingmanagerengine_nokia.cpp9
-rw-r--r--src/plugins/geoservices/nokia/qgeotilefetcher_nokia.cpp28
-rw-r--r--src/plugins/geoservices/nokia/qgeotilefetcher_nokia.h7
3 files changed, 29 insertions, 15 deletions
diff --git a/src/plugins/geoservices/nokia/qgeotiledmappingmanagerengine_nokia.cpp b/src/plugins/geoservices/nokia/qgeotiledmappingmanagerengine_nokia.cpp
index 4f44e5fd..64449d1d 100644
--- a/src/plugins/geoservices/nokia/qgeotiledmappingmanagerengine_nokia.cpp
+++ b/src/plugins/geoservices/nokia/qgeotiledmappingmanagerengine_nokia.cpp
@@ -95,7 +95,14 @@ QGeoTiledMappingManagerEngineNokia::QGeoTiledMappingManagerEngineNokia(
types << QGeoMapType(QGeoMapType::CarNavigationMap, tr("Car Navigation Map"), tr("Normal map view in daylight mode for car navigation"), false, false, 21);
setSupportedMapTypes(types);
- QGeoTileFetcherNokia *fetcher = new QGeoTileFetcherNokia(parameters, networkManager, this, tileSize());
+ int ppi = 250;
+ if (parameters.contains(QStringLiteral("here.mapping.highdpi_tiles"))) {
+ const QString param = parameters.value(QStringLiteral("here.mapping.highdpi_tiles")).toString().toLower();
+ if (param == "false")
+ ppi = 72;
+ }
+
+ QGeoTileFetcherNokia *fetcher = new QGeoTileFetcherNokia(parameters, networkManager, this, tileSize(), ppi);
setTileFetcher(fetcher);
// TODO: do this in a plugin-neutral way so that other tiled map plugins
diff --git a/src/plugins/geoservices/nokia/qgeotilefetcher_nokia.cpp b/src/plugins/geoservices/nokia/qgeotilefetcher_nokia.cpp
index 50acc2a0..a55f71c0 100644
--- a/src/plugins/geoservices/nokia/qgeotilefetcher_nokia.cpp
+++ b/src/plugins/geoservices/nokia/qgeotilefetcher_nokia.cpp
@@ -56,11 +56,11 @@ QT_BEGIN_NAMESPACE
namespace
{
- QString sizeToStr(const QSize &size)
+ QString sizeToStr(int size)
{
- if (size.height() >= 512 || size.width() >= 512)
+ if (size > 256)
return QStringLiteral("512");
- else if (size.height() >= 256 || size.width() >= 256)
+ else if (size > 128)
return QStringLiteral("256");
else
return QStringLiteral("128"); // 128 pixel tiles are deprecated.
@@ -74,13 +74,14 @@ namespace
QGeoTileFetcherNokia::QGeoTileFetcherNokia(const QVariantMap &parameters,
QGeoNetworkAccessManager *networkManager,
QGeoTiledMappingManagerEngineNokia *engine,
- const QSize &tileSize)
-: QGeoTileFetcher(engine), m_engineNokia(engine), m_networkManager(networkManager),
- m_tileSize(tileSize), m_copyrightsReply(0),
+ const QSize &tileSize,
+ int ppi)
+: QGeoTileFetcher(engine), m_engineNokia(engine), m_networkManager(networkManager), m_ppi(ppi), m_copyrightsReply(0),
m_baseUriProvider(new QGeoUriProvider(this, parameters, QStringLiteral("here.mapping.host"), MAP_TILES_HOST)),
m_aerialUriProvider(new QGeoUriProvider(this, parameters, QStringLiteral("here.mapping.host.aerial"), MAP_TILES_HOST_AERIAL))
{
Q_ASSERT(networkManager);
+ m_tileSize = qMax(tileSize.width(), tileSize.height());
m_networkManager->setParent(this);
m_applicationId = parameters.value(QStringLiteral("here.app_id")).toString();
@@ -94,7 +95,11 @@ QGeoTileFetcherNokia::~QGeoTileFetcherNokia()
QGeoTiledMapReply *QGeoTileFetcherNokia::getTileImage(const QGeoTileSpec &spec)
{
// TODO add error detection for if request.connectivityMode() != QGraphicsGeoMap::OnlineMode
- QString rawRequest = getRequestString(spec);
+ int ppi = m_ppi;
+ if ((spec.mapId() == 2) || (spec.mapId() == 12) || (spec.mapId() == 21))
+ ppi = 72; // HiDpi apparently not supported for these maps
+
+ QString rawRequest = getRequestString(spec, ppi);
if (rawRequest.isEmpty()) {
return new QGeoTiledMapReply(QGeoTiledMapReply::UnknownError,
tr("Mapping manager no longer exists"), this);
@@ -110,7 +115,7 @@ QGeoTiledMapReply *QGeoTileFetcherNokia::getTileImage(const QGeoTileSpec &spec)
return mapReply;
}
-QString QGeoTileFetcherNokia::getRequestString(const QGeoTileSpec &spec)
+QString QGeoTileFetcherNokia::getRequestString(const QGeoTileSpec &spec, int ppi)
{
if (!m_engineNokia)
return QString();
@@ -136,11 +141,11 @@ QString QGeoTileFetcherNokia::getRequestString(const QGeoTileSpec &spec)
requestString += slash;
requestString += QString::number(spec.y());
requestString += slash;
- requestString += sizeToStr(m_tileSize);
+ requestString += ((ppi > 72)) ? sizeToStr(m_tileSize * 2) : sizeToStr(m_tileSize);
static const QString slashpng("/png8");
requestString += slashpng;
- if (!m_token.isEmpty() && !m_applicationId.isEmpty()) {
+ if (!m_token.isEmpty() && !m_applicationId.isEmpty()) { // TODO: remove the if
requestString += "?token=";
requestString += m_token;
@@ -148,9 +153,10 @@ QString QGeoTileFetcherNokia::getRequestString(const QGeoTileSpec &spec)
requestString += m_applicationId;
}
+ requestString += "&ppi=" + QString::number(ppi);
+
requestString += "&lg=";
requestString += getLanguageString();
-
return requestString;
}
diff --git a/src/plugins/geoservices/nokia/qgeotilefetcher_nokia.h b/src/plugins/geoservices/nokia/qgeotilefetcher_nokia.h
index 44f2ad07..06d1bba9 100644
--- a/src/plugins/geoservices/nokia/qgeotilefetcher_nokia.h
+++ b/src/plugins/geoservices/nokia/qgeotilefetcher_nokia.h
@@ -57,7 +57,7 @@ class QGeoTileFetcherNokia : public QGeoTileFetcher
public:
QGeoTileFetcherNokia(const QVariantMap &parameters, QGeoNetworkAccessManager *networkManager,
- QGeoTiledMappingManagerEngineNokia *engine, const QSize &tileSize);
+ QGeoTiledMappingManagerEngineNokia *engine, const QSize &tileSize, int ppi);
~QGeoTileFetcherNokia();
QGeoTiledMapReply *getTileImage(const QGeoTileSpec &spec);
@@ -74,13 +74,14 @@ public Q_SLOTS:
private:
Q_DISABLE_COPY(QGeoTileFetcherNokia)
- QString getRequestString(const QGeoTileSpec &spec);
+ QString getRequestString(const QGeoTileSpec &spec, int ppi=72);
QString getLanguageString() const;
QPointer<QGeoTiledMappingManagerEngineNokia> m_engineNokia;
QGeoNetworkAccessManager *m_networkManager;
- QSize m_tileSize;
+ int m_tileSize;
+ int m_ppi;
QString m_token;
QNetworkReply *m_copyrightsReply;
QNetworkReply *m_versionReply;