diff options
author | Liang Qi <liang.qi@qt.io> | 2017-06-07 11:06:28 +0200 |
---|---|---|
committer | Liang Qi <liang.qi@qt.io> | 2017-06-07 11:06:28 +0200 |
commit | f55629245259ba7364e258f92408823024423caa (patch) | |
tree | f73063cf02dc175fbe9f0bfb48b3ddd686ea0f72 /src/plugins/geoservices | |
parent | 22d980c8124026eb712f563326d5a5c1b180c671 (diff) | |
parent | d89701c5c8646dedb0ebb2e011c4da796a6ae8a1 (diff) | |
download | qtlocation-f55629245259ba7364e258f92408823024423caa.tar.gz |
Merge remote-tracking branch 'origin/5.9' into dev
Conflicts:
.qmake.conf
src/plugins/geoservices/geoservices.pro
Change-Id: Ie82dd22c588e5cba409fc1ef31a65968ce9f719b
Diffstat (limited to 'src/plugins/geoservices')
33 files changed, 273 insertions, 115 deletions
diff --git a/src/plugins/geoservices/esri/esri.qrc b/src/plugins/geoservices/esri/esri.qrc index 43b0857f..d085b09f 100644 --- a/src/plugins/geoservices/esri/esri.qrc +++ b/src/plugins/geoservices/esri/esri.qrc @@ -1,5 +1,5 @@ <RCC> - <qresource prefix="/"> + <qresource prefix="/esri"> <file>maps.json</file> </qresource> </RCC> diff --git a/src/plugins/geoservices/esri/geomapsource.cpp b/src/plugins/geoservices/esri/geomapsource.cpp index 32fe1899..19f284e6 100644 --- a/src/plugins/geoservices/esri/geomapsource.cpp +++ b/src/plugins/geoservices/esri/geomapsource.cpp @@ -68,7 +68,7 @@ static const MapStyleData mapStyles[] = GeoMapSource::GeoMapSource(QGeoMapType::MapStyle style, const QString &name, const QString &description, bool mobile, bool night, int mapId, const QString &url, const QString ©right) : - QGeoMapType(style, name, description, mobile, night, mapId), + QGeoMapType(style, name, description, mobile, night, mapId, "esri"), m_url(url), m_copyright(copyright) { } diff --git a/src/plugins/geoservices/esri/geotiledmappingmanagerengine_esri.cpp b/src/plugins/geoservices/esri/geotiledmappingmanagerengine_esri.cpp index a0f00615..23783d7e 100644 --- a/src/plugins/geoservices/esri/geotiledmappingmanagerengine_esri.cpp +++ b/src/plugins/geoservices/esri/geotiledmappingmanagerengine_esri.cpp @@ -101,6 +101,7 @@ GeoTiledMappingManagerEngineEsri::GeoTiledMappingManagerEngineEsri(const QVarian cameraCaps.setMaximumTilt(80); cameraCaps.setMinimumFieldOfView(20.0); cameraCaps.setMaximumFieldOfView(120.0); + cameraCaps.setOverzoomEnabled(true); setCameraCapabilities(cameraCaps); setTileSize(QSize(256, 256)); @@ -117,7 +118,8 @@ GeoTiledMappingManagerEngineEsri::GeoTiledMappingManagerEngineEsri(const QVarian mapSource->description(), mapSource->mobile(), mapSource->night(), - mapSource->mapId()); + mapSource->mapId(), + "esri"); } setSupportedMapTypes(mapTypes); @@ -199,6 +201,16 @@ GeoTiledMappingManagerEngineEsri::GeoTiledMappingManagerEngineEsri(const QVarian tileCache->setExtraTextureUsage(cacheSize); } + /* PREFETCHING */ + if (parameters.contains(QStringLiteral("esri.mapping.prefetching_style"))) { + const QString prefetchingMode = parameters.value(QStringLiteral("esri.mapping.prefetching_style")).toString(); + if (prefetchingMode == QStringLiteral("TwoNeighbourLayers")) + m_prefetchStyle = QGeoTiledMap::PrefetchTwoNeighbourLayers; + else if (prefetchingMode == QStringLiteral("OneNeighbourLayer")) + m_prefetchStyle = QGeoTiledMap::PrefetchNeighbourLayer; + else if (prefetchingMode == QStringLiteral("NoPrefetching")) + m_prefetchStyle = QGeoTiledMap::NoPrefetching; + } setTileCache(tileCache); *error = QGeoServiceProvider::NoError; @@ -212,7 +224,9 @@ GeoTiledMappingManagerEngineEsri::~GeoTiledMappingManagerEngineEsri() QGeoMap *GeoTiledMappingManagerEngineEsri::createMap() { - return new GeoTiledMapEsri(this); + QGeoTiledMap *map = new GeoTiledMapEsri(this); + map->setPrefetchStyle(m_prefetchStyle); + return map; } // ${z} = Zoom @@ -226,7 +240,7 @@ bool GeoTiledMappingManagerEngineEsri::initializeMapSources(QGeoServiceProvider: QString *errorString) { initResources(); - QFile mapsFile(":/maps.json"); + QFile mapsFile(":/esri/maps.json"); if (!mapsFile.open(QIODevice::ReadOnly)) { *error = QGeoServiceProvider::NotSupportedError; diff --git a/src/plugins/geoservices/esri/geotilefetcher_esri.cpp b/src/plugins/geoservices/esri/geotilefetcher_esri.cpp index 62484bbb..8ceba374 100644 --- a/src/plugins/geoservices/esri/geotilefetcher_esri.cpp +++ b/src/plugins/geoservices/esri/geotilefetcher_esri.cpp @@ -48,7 +48,7 @@ QT_BEGIN_NAMESPACE -GeoTileFetcherEsri::GeoTileFetcherEsri(QObject *parent) : +GeoTileFetcherEsri::GeoTileFetcherEsri(QGeoTiledMappingManagerEngine *parent) : QGeoTileFetcher(parent), m_networkManager(new QNetworkAccessManager(this)), m_userAgent(QByteArrayLiteral("Qt Location based application")) { diff --git a/src/plugins/geoservices/esri/geotilefetcher_esri.h b/src/plugins/geoservices/esri/geotilefetcher_esri.h index 43dcfdfa..be948af1 100644 --- a/src/plugins/geoservices/esri/geotilefetcher_esri.h +++ b/src/plugins/geoservices/esri/geotilefetcher_esri.h @@ -52,7 +52,7 @@ class GeoTileFetcherEsri : public QGeoTileFetcher Q_OBJECT public: - explicit GeoTileFetcherEsri(QObject *parent = Q_NULLPTR); + explicit GeoTileFetcherEsri(QGeoTiledMappingManagerEngine *parent); inline const QByteArray &userAgent() const; inline void setUserAgent(const QByteArray &userAgent); diff --git a/src/plugins/geoservices/geoservices.pro b/src/plugins/geoservices/geoservices.pro index 11ef7c1e..459897a8 100644 --- a/src/plugins/geoservices/geoservices.pro +++ b/src/plugins/geoservices/geoservices.pro @@ -1,8 +1,12 @@ TEMPLATE = subdirs -SUBDIRS = nokia osm mapbox esri itemsoverlay +SUBDIRS = nokia mapbox esri itemsoverlay -qtConfig(c++14):qtConfig(opengl):!win32 { +qtConfig(concurrent) { + SUBDIRS += osm +} + +qtConfig(opengl):qtConfig(c++14):!win32|mingw:!qnx { !exists(../../3rdparty/mapbox-gl-native/CMakeLists.txt) { warning("Submodule mapbox-gl-native does not exist. Run 'git submodule update --init' on qtlocation.") } else { diff --git a/src/plugins/geoservices/itemsoverlay/itemsoverlay.pro b/src/plugins/geoservices/itemsoverlay/itemsoverlay.pro index 2a09a994..1f45de97 100644 --- a/src/plugins/geoservices/itemsoverlay/itemsoverlay.pro +++ b/src/plugins/geoservices/itemsoverlay/itemsoverlay.pro @@ -12,9 +12,10 @@ SOURCES += \ qgeomappingmanagerengineitemsoverlay.cpp \ qgeomapitemsoverlay.cpp +OTHER_FILES += \ + itemsoverlay_plugin.json + PLUGIN_TYPE = geoservices PLUGIN_CLASS_NAME = QGeoServiceProviderFactoryItemsOverlay load(qt_plugin) -DISTFILES += \ - itemsoverlay_plugin.json diff --git a/src/plugins/geoservices/itemsoverlay/qgeomappingmanagerengineitemsoverlay.cpp b/src/plugins/geoservices/itemsoverlay/qgeomappingmanagerengineitemsoverlay.cpp index bbb30164..955fbcae 100644 --- a/src/plugins/geoservices/itemsoverlay/qgeomappingmanagerengineitemsoverlay.cpp +++ b/src/plugins/geoservices/itemsoverlay/qgeomappingmanagerengineitemsoverlay.cpp @@ -62,7 +62,7 @@ QGeoMappingManagerEngineItemsOverlay::QGeoMappingManagerEngineItemsOverlay(const setCameraCapabilities(cameraCaps); QList<QGeoMapType> mapTypes; - mapTypes << QGeoMapType(QGeoMapType::NoMap, tr("Empty Map"), tr("Empty Map"), false, false, 1); + mapTypes << QGeoMapType(QGeoMapType::NoMap, tr("Empty Map"), tr("Empty Map"), false, false, 1, "itemsoverlay"); setSupportedMapTypes(mapTypes); engineInitialized(); diff --git a/src/plugins/geoservices/mapbox/qgeotiledmappingmanagerenginemapbox.cpp b/src/plugins/geoservices/mapbox/qgeotiledmappingmanagerenginemapbox.cpp index 4b62aece..3177b6c4 100644 --- a/src/plugins/geoservices/mapbox/qgeotiledmappingmanagerenginemapbox.cpp +++ b/src/plugins/geoservices/mapbox/qgeotiledmappingmanagerenginemapbox.cpp @@ -56,49 +56,51 @@ QGeoTiledMappingManagerEngineMapbox::QGeoTiledMappingManagerEngineMapbox(const Q cameraCaps.setMaximumTilt(80); cameraCaps.setMinimumFieldOfView(20.0); cameraCaps.setMaximumFieldOfView(120.0); + cameraCaps.setOverzoomEnabled(true); setCameraCapabilities(cameraCaps); setTileSize(QSize(256, 256)); + const QByteArray pluginName = "mapbox"; QList<QGeoMapType> mapTypes; // as index 0 to retain compatibility with the current API, that expects the passed map_id to be on by default. if (parameters.contains(QStringLiteral("mapbox.mapping.map_id"))) { const QString name = parameters.value(QStringLiteral("mapbox.mapping.map_id")).toString(); - mapTypes << QGeoMapType(QGeoMapType::CustomMap, name, name, false, false, mapTypes.size()); + mapTypes << QGeoMapType(QGeoMapType::CustomMap, name, name, false, false, mapTypes.size(), pluginName); } else if (parameters.contains(QStringLiteral("mapbox.map_id"))) { //deprecated const QString name = parameters.value(QStringLiteral("mapbox.map_id")).toString(); - mapTypes << QGeoMapType(QGeoMapType::CustomMap, name, name, false, false, mapTypes.size()); + mapTypes << QGeoMapType(QGeoMapType::CustomMap, name, name, false, false, mapTypes.size(), pluginName); } // As of 2016.06.15, valid mapbox map_ids are documented at https://www.mapbox.com/api-documentation/#maps //: Noun describing map type 'Street map' - mapTypes << QGeoMapType(QGeoMapType::StreetMap, QStringLiteral("mapbox.streets"), tr("Street"), false, false, mapTypes.size()); + mapTypes << QGeoMapType(QGeoMapType::StreetMap, QStringLiteral("mapbox.streets"), tr("Street"), false, false, mapTypes.size(), pluginName); //: Noun describing type of a map using light colors (weak contrast) - mapTypes << QGeoMapType(QGeoMapType::StreetMap, QStringLiteral("mapbox.light"), tr("Light"), false, false, mapTypes.size()); + mapTypes << QGeoMapType(QGeoMapType::StreetMap, QStringLiteral("mapbox.light"), tr("Light"), false, false, mapTypes.size(), pluginName); //: Noun describing type of a map using dark colors - mapTypes << QGeoMapType(QGeoMapType::StreetMap, QStringLiteral("mapbox.dark"), tr("Dark"), false, true, mapTypes.size()); + mapTypes << QGeoMapType(QGeoMapType::StreetMap, QStringLiteral("mapbox.dark"), tr("Dark"), false, true, mapTypes.size(), pluginName); //: Noun describing type of a map created by satellite - mapTypes << QGeoMapType(QGeoMapType::SatelliteMapDay, QStringLiteral("mapbox.satellite"), tr("Satellite"), false, false, mapTypes.size()); + mapTypes << QGeoMapType(QGeoMapType::SatelliteMapDay, QStringLiteral("mapbox.satellite"), tr("Satellite"), false, false, mapTypes.size(), pluginName); //: Noun describing type of a street map created by satellite - mapTypes << QGeoMapType(QGeoMapType::HybridMap, QStringLiteral("mapbox.streets-satellite"), tr("Streets Satellite"), false, false, mapTypes.size()); + mapTypes << QGeoMapType(QGeoMapType::HybridMap, QStringLiteral("mapbox.streets-satellite"), tr("Streets Satellite"), false, false, mapTypes.size(), pluginName); //: Noun describing type of a map using wheat paste colors - mapTypes << QGeoMapType(QGeoMapType::CustomMap, QStringLiteral("mapbox.wheatpaste"), tr("Wheatpaste"), false, false, mapTypes.size()); + mapTypes << QGeoMapType(QGeoMapType::CustomMap, QStringLiteral("mapbox.wheatpaste"), tr("Wheatpaste"), false, false, mapTypes.size(), pluginName); //: Noun describing type of a basic street map - mapTypes << QGeoMapType(QGeoMapType::StreetMap, QStringLiteral("mapbox.streets-basic"), tr("Streets Basic"), false, false, mapTypes.size()); + mapTypes << QGeoMapType(QGeoMapType::StreetMap, QStringLiteral("mapbox.streets-basic"), tr("Streets Basic"), false, false, mapTypes.size(), pluginName); //: Noun describing type of a map using cartoon-style fonts - mapTypes << QGeoMapType(QGeoMapType::CustomMap, QStringLiteral("mapbox.comic"), tr("Comic"), false, false, mapTypes.size()); + mapTypes << QGeoMapType(QGeoMapType::CustomMap, QStringLiteral("mapbox.comic"), tr("Comic"), false, false, mapTypes.size(), pluginName); //: Noun describing type of a map for outdoor activities - mapTypes << QGeoMapType(QGeoMapType::PedestrianMap, QStringLiteral("mapbox.outdoors"), tr("Outdoors"), false, false, mapTypes.size()); + mapTypes << QGeoMapType(QGeoMapType::PedestrianMap, QStringLiteral("mapbox.outdoors"), tr("Outdoors"), false, false, mapTypes.size(), pluginName); //: Noun describing type of a map for sports - mapTypes << QGeoMapType(QGeoMapType::CycleMap, QStringLiteral("mapbox.run-bike-hike"), tr("Run Bike Hike"), false, false, mapTypes.size()); + mapTypes << QGeoMapType(QGeoMapType::CycleMap, QStringLiteral("mapbox.run-bike-hike"), tr("Run Bike Hike"), false, false, mapTypes.size(), pluginName); //: Noun describing type of a map drawn by pencil - mapTypes << QGeoMapType(QGeoMapType::CustomMap, QStringLiteral("mapbox.pencil"), tr("Pencil"), false, false, mapTypes.size()); + mapTypes << QGeoMapType(QGeoMapType::CustomMap, QStringLiteral("mapbox.pencil"), tr("Pencil"), false, false, mapTypes.size(), pluginName); //: Noun describing type of a treasure map with pirate boat watermark - mapTypes << QGeoMapType(QGeoMapType::CustomMap, QStringLiteral("mapbox.pirates"), tr("Pirates"), false, false, mapTypes.size()); + mapTypes << QGeoMapType(QGeoMapType::CustomMap, QStringLiteral("mapbox.pirates"), tr("Pirates"), false, false, mapTypes.size(), pluginName); //: Noun describing type of a map using emerald colors - mapTypes << QGeoMapType(QGeoMapType::CustomMap, QStringLiteral("mapbox.emerald"), tr("Emerald"), false, false, mapTypes.size()); + mapTypes << QGeoMapType(QGeoMapType::CustomMap, QStringLiteral("mapbox.emerald"), tr("Emerald"), false, false, mapTypes.size(), pluginName); //: Noun describing type of a map with high contrast - mapTypes << QGeoMapType(QGeoMapType::CustomMap, QStringLiteral("mapbox.high-contrast"), tr("High Contrast"), false, false, mapTypes.size()); + mapTypes << QGeoMapType(QGeoMapType::CustomMap, QStringLiteral("mapbox.high-contrast"), tr("High Contrast"), false, false, mapTypes.size(), pluginName); // New way to specify multiple customized map_ids via additional_map_ids if (parameters.contains(QStringLiteral("mapbox.mapping.additional_map_ids"))) { @@ -107,7 +109,7 @@ QGeoTiledMappingManagerEngineMapbox::QGeoTiledMappingManagerEngineMapbox(const Q for (const QString &name: idList) { if (!name.isEmpty()) - mapTypes << QGeoMapType(QGeoMapType::CustomMap, name, name, false, false, mapTypes.size()); + mapTypes << QGeoMapType(QGeoMapType::CustomMap, name, name, false, false, mapTypes.size(), pluginName); } } @@ -152,7 +154,7 @@ QGeoTiledMappingManagerEngineMapbox::QGeoTiledMappingManagerEngineMapbox(const Q m_cacheDirectory = parameters.value(QStringLiteral("mapbox.mapping.cache.directory")).toString(); } else { // managerName() is not yet set, we have to hardcode the plugin name below - m_cacheDirectory = QAbstractGeoTileCache::baseLocationCacheDirectory() + QLatin1String("mapbox"); + m_cacheDirectory = QAbstractGeoTileCache::baseLocationCacheDirectory() + QLatin1String(pluginName); } QGeoFileTileCache *tileCache = new QGeoFileTileCacheMapbox(mapTypes, scaleFactor, m_cacheDirectory); @@ -221,6 +223,16 @@ QGeoTiledMappingManagerEngineMapbox::QGeoTiledMappingManagerEngineMapbox(const Q tileCache->setExtraTextureUsage(cacheSize); } + /* PREFETCHING */ + if (parameters.contains(QStringLiteral("mapbox.mapping.prefetching_style"))) { + const QString prefetchingMode = parameters.value(QStringLiteral("mapbox.mapping.prefetching_style")).toString(); + if (prefetchingMode == QStringLiteral("TwoNeighbourLayers")) + m_prefetchStyle = QGeoTiledMap::PrefetchTwoNeighbourLayers; + else if (prefetchingMode == QStringLiteral("OneNeighbourLayer")) + m_prefetchStyle = QGeoTiledMap::PrefetchNeighbourLayer; + else if (prefetchingMode == QStringLiteral("NoPrefetching")) + m_prefetchStyle = QGeoTiledMap::NoPrefetching; + } setTileCache(tileCache); @@ -234,7 +246,9 @@ QGeoTiledMappingManagerEngineMapbox::~QGeoTiledMappingManagerEngineMapbox() QGeoMap *QGeoTiledMappingManagerEngineMapbox::createMap() { - return new QGeoTiledMap(this, 0); + QGeoTiledMap *map = new QGeoTiledMap(this, 0); + map->setPrefetchStyle(m_prefetchStyle); + return map; } QT_END_NAMESPACE diff --git a/src/plugins/geoservices/mapbox/qgeotilefetchermapbox.cpp b/src/plugins/geoservices/mapbox/qgeotilefetchermapbox.cpp index 062b4f89..732d04e9 100644 --- a/src/plugins/geoservices/mapbox/qgeotilefetchermapbox.cpp +++ b/src/plugins/geoservices/mapbox/qgeotilefetchermapbox.cpp @@ -44,7 +44,7 @@ QT_BEGIN_NAMESPACE -QGeoTileFetcherMapbox::QGeoTileFetcherMapbox(int scaleFactor, QObject *parent) +QGeoTileFetcherMapbox::QGeoTileFetcherMapbox(int scaleFactor, QGeoTiledMappingManagerEngine *parent) : QGeoTileFetcher(parent), m_networkManager(new QNetworkAccessManager(this)), m_userAgent("Qt Location based application"), m_format("png"), diff --git a/src/plugins/geoservices/mapbox/qgeotilefetchermapbox.h b/src/plugins/geoservices/mapbox/qgeotilefetchermapbox.h index e52651e1..47f3a8aa 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(int scaleFactor = 2, QObject *parent = 0); + QGeoTileFetcherMapbox(int scaleFactor, QGeoTiledMappingManagerEngine *parent); void setUserAgent(const QByteArray &userAgent); void setMapIds(const QVector<QString> &mapIds); diff --git a/src/plugins/geoservices/mapboxgl/logo.png b/src/plugins/geoservices/mapboxgl/logo.png Binary files differindex 57410f79..9d6e90ef 100644 --- a/src/plugins/geoservices/mapboxgl/logo.png +++ b/src/plugins/geoservices/mapboxgl/logo.png diff --git a/src/plugins/geoservices/mapboxgl/mapboxgl.pro b/src/plugins/geoservices/mapboxgl/mapboxgl.pro index 37dd383c..f35f26dc 100644 --- a/src/plugins/geoservices/mapboxgl/mapboxgl.pro +++ b/src/plugins/geoservices/mapboxgl/mapboxgl.pro @@ -29,14 +29,23 @@ OTHER_FILES += \ INCLUDEPATH += ../../../3rdparty/mapbox-gl-native/platform/qt/include +include(../../../3rdparty/zlib_dependency.pri) + +load(qt_build_paths) +LIBS_PRIVATE += -L$$MODULE_BASE_OUTDIR/lib -lqmapboxgl$$qtPlatformTargetSuffix() + qtConfig(icu) { include(../../../3rdparty/icu_dependency.pri) } -include(../../../3rdparty/zlib_dependency.pri) - -load(qt_build_paths) -LIBS_PRIVATE += -L$$MODULE_BASE_OUTDIR/lib -lqmapboxgl +# When building for Windows with dynamic OpenGL, this plugin +# can only run with ANGLE because Mapbox GL requires at least +# OpenGL ES and does not use QOpenGLFunctions for resolving +# the OpenGL symbols. -lopengl32 only gives OpenGL 1.1. +win32:qtConfig(dynamicgl) { + qtConfig(combined-angle-lib): LIBS_PRIVATE += -l$${LIBQTANGLE_NAME} + else: LIBS_PRIVATE += -l$${LIBEGL_NAME} -l$${LIBGLESV2_NAME} +} PLUGIN_TYPE = geoservices PLUGIN_CLASS_NAME = QGeoServiceProviderFactoryMapboxGL diff --git a/src/plugins/geoservices/mapboxgl/qgeomapmapboxgl.cpp b/src/plugins/geoservices/mapboxgl/qgeomapmapboxgl.cpp index d76d5e7a..ad3ab375 100644 --- a/src/plugins/geoservices/mapboxgl/qgeomapmapboxgl.cpp +++ b/src/plugins/geoservices/mapboxgl/qgeomapmapboxgl.cpp @@ -91,13 +91,9 @@ QSGNode *QGeoMapMapboxGLPrivate::updateSceneGraph(QSGNode *node, QQuickWindow *w { Q_Q(QGeoMapMapboxGL); - if (!m_warned) { - if (window->openglContext()->thread() != QCoreApplication::instance()->thread()) { - qWarning() << "Threaded rendering is not supported by Mapbox GL plugin."; - QMetaObject::invokeMethod(&m_refresh, "start", Qt::QueuedConnection); - } - - m_warned = true; + if (m_viewportSize.isEmpty()) { + delete node; + return 0; } QMapboxGL *map = 0; @@ -151,6 +147,8 @@ QSGNode *QGeoMapMapboxGLPrivate::updateSceneGraph(QSGNode *node, QQuickWindow *w static_cast<QSGMapboxGLTextureNode *>(node)->render(window); } + threadedRenderingHack(window, map); + m_syncState = NoSync; return node; @@ -212,7 +210,7 @@ void QGeoMapMapboxGLPrivate::addMapItem(QDeclarativeGeoMapItemBase *item) QObject::connect(item, &QDeclarativeGeoMapItemBase::mapItemOpacityChanged, q, &QGeoMapMapboxGL::onMapItemPropertyChanged); - m_styleChanges << QMapboxGLStyleChange::addMapItem(item); + m_styleChanges << QMapboxGLStyleChange::addMapItem(item, m_mapItemsBefore); emit q->sgNodeChanged(); } @@ -278,6 +276,31 @@ void QGeoMapMapboxGLPrivate::syncStyleChanges(QMapboxGL *map) m_styleChanges.clear(); } +void QGeoMapMapboxGLPrivate::threadedRenderingHack(QQuickWindow *window, QMapboxGL *map) +{ + // FIXME: Optimal support for threaded rendering needs core changes + // in Mapbox GL Native. Meanwhile we need to set a timer to update + // the map until all the resources are loaded, which is not exactly + // battery friendly, because might trigger more paints than we need. + if (!m_warned) { + m_threadedRendering = window->openglContext()->thread() != QCoreApplication::instance()->thread(); + + if (m_threadedRendering) { + qWarning() << "Threaded rendering is not optimal in the Mapbox GL plugin."; + } + + m_warned = true; + } + + if (m_threadedRendering) { + if (!map->isFullyLoaded()) { + QMetaObject::invokeMethod(&m_refresh, "start", Qt::QueuedConnection); + } else { + QMetaObject::invokeMethod(&m_refresh, "stop", Qt::QueuedConnection); + } + } +} + /* * QGeoMapMapboxGL implementation */ @@ -319,6 +342,12 @@ void QGeoMapMapboxGL::setUseFBO(bool useFBO) d->m_useFBO = useFBO; } +void QGeoMapMapboxGL::setMapItemsBefore(const QString &before) +{ + Q_D(QGeoMapMapboxGL); + d->m_mapItemsBefore = before; +} + QSGNode *QGeoMapMapboxGL::updateSceneGraph(QSGNode *oldNode, QQuickWindow *window) { Q_D(QGeoMapMapboxGL); @@ -339,7 +368,7 @@ void QGeoMapMapboxGL::onMapChanged(QMapboxGL::MapChange change) d->m_styleChanges << QMapboxGLStyleChange::addMapParameter(param); for (QDeclarativeGeoMapItemBase *item : d->m_mapItems) - d->m_styleChanges << QMapboxGLStyleChange::addMapItem(item); + d->m_styleChanges << QMapboxGLStyleChange::addMapItem(item, d->m_mapItemsBefore); } } diff --git a/src/plugins/geoservices/mapboxgl/qgeomapmapboxgl.h b/src/plugins/geoservices/mapboxgl/qgeomapmapboxgl.h index 56b97e99..73cfd75a 100644 --- a/src/plugins/geoservices/mapboxgl/qgeomapmapboxgl.h +++ b/src/plugins/geoservices/mapboxgl/qgeomapmapboxgl.h @@ -56,6 +56,7 @@ public: QString copyrightsStyleSheet() const Q_DECL_OVERRIDE; void setMapboxGLSettings(const QMapboxGLSettings &); void setUseFBO(bool); + void setMapItemsBefore(const QString &); private Q_SLOTS: // QMapboxGL diff --git a/src/plugins/geoservices/mapboxgl/qgeomapmapboxgl_p.h b/src/plugins/geoservices/mapboxgl/qgeomapmapboxgl_p.h index b6527c01..598c9078 100644 --- a/src/plugins/geoservices/mapboxgl/qgeomapmapboxgl_p.h +++ b/src/plugins/geoservices/mapboxgl/qgeomapmapboxgl_p.h @@ -79,10 +79,12 @@ public: QMapboxGLSettings m_settings; bool m_useFBO = true; bool m_developmentMode = false; + QString m_mapItemsBefore; QTimer m_refresh; bool m_shouldRefresh = true; bool m_warned = false; + bool m_threadedRendering = false; bool m_styleLoaded = false; SyncStates m_syncState = NoSync; @@ -98,6 +100,7 @@ private: Q_DISABLE_COPY(QGeoMapMapboxGLPrivate); void syncStyleChanges(QMapboxGL *map); + void threadedRenderingHack(QQuickWindow *window, QMapboxGL *map); }; Q_DECLARE_OPERATORS_FOR_FLAGS(QGeoMapMapboxGLPrivate::SyncStates) diff --git a/src/plugins/geoservices/mapboxgl/qgeomappingmanagerenginemapboxgl.cpp b/src/plugins/geoservices/mapboxgl/qgeomappingmanagerenginemapboxgl.cpp index c87b458d..211c0bba 100644 --- a/src/plugins/geoservices/mapboxgl/qgeomappingmanagerenginemapboxgl.cpp +++ b/src/plugins/geoservices/mapboxgl/qgeomappingmanagerenginemapboxgl.cpp @@ -67,27 +67,28 @@ QGeoMappingManagerEngineMapboxGL::QGeoMappingManagerEngineMapboxGL(const QVarian QList<QGeoMapType> mapTypes; int mapId = 0; + const QByteArray pluginName = "mapboxgl"; - mapTypes << QGeoMapType(QGeoMapType::StreetMap, QStringLiteral("mapbox://styles/mapbox/streets-v9"), - tr("Streets"), false, false, ++mapId); + mapTypes << QGeoMapType(QGeoMapType::StreetMap, QStringLiteral("mapbox://styles/mapbox/streets-v10"), + tr("Streets"), false, false, ++mapId, pluginName); mapTypes << QGeoMapType(QGeoMapType::StreetMap, QStringLiteral("mapbox://styles/mapbox/basic-v9"), - tr("Basic"), false, false, ++mapId); + tr("Basic"), false, false, ++mapId, pluginName); mapTypes << QGeoMapType(QGeoMapType::StreetMap, QStringLiteral("mapbox://styles/mapbox/bright-v9"), - tr("Bright"), false, false, ++mapId); - mapTypes << QGeoMapType(QGeoMapType::TerrainMap, QStringLiteral("mapbox://styles/mapbox/outdoors-v9"), - tr("Outdoors"), false, false, ++mapId); + tr("Bright"), false, false, ++mapId, pluginName); + mapTypes << QGeoMapType(QGeoMapType::TerrainMap, QStringLiteral("mapbox://styles/mapbox/outdoors-v10"), + tr("Outdoors"), false, false, ++mapId, pluginName); mapTypes << QGeoMapType(QGeoMapType::SatelliteMapDay, QStringLiteral("mapbox://styles/mapbox/satellite-v9"), - tr("Satellite"), false, false, ++mapId); - mapTypes << QGeoMapType(QGeoMapType::HybridMap, QStringLiteral("mapbox://styles/mapbox/satellite-streets-v9"), - tr("Satellite Streets"), false, false, ++mapId); + tr("Satellite"), false, false, ++mapId, pluginName); + mapTypes << QGeoMapType(QGeoMapType::HybridMap, QStringLiteral("mapbox://styles/mapbox/satellite-streets-v10"), + tr("Satellite Streets"), false, false, ++mapId, pluginName); mapTypes << QGeoMapType(QGeoMapType::GrayStreetMap, QStringLiteral("mapbox://styles/mapbox/light-v9"), - tr("Light"), false, false, ++mapId); + tr("Light"), false, false, ++mapId, pluginName); mapTypes << QGeoMapType(QGeoMapType::GrayStreetMap, QStringLiteral("mapbox://styles/mapbox/dark-v9"), - tr("Dark"), false, false, ++mapId); + tr("Dark"), false, false, ++mapId, pluginName); mapTypes << QGeoMapType(QGeoMapType::TransitMap, QStringLiteral("mapbox://styles/mapbox/traffic-day-v1"), - tr("Streets Traffic Day"), false, false, ++mapId); + tr("Streets Traffic Day"), false, false, ++mapId, pluginName); mapTypes << QGeoMapType(QGeoMapType::TransitMap, QStringLiteral("mapbox://styles/mapbox/traffic-night-v1"), - tr("Streets Traffic Night"), false, true, ++mapId); + tr("Streets Traffic Night"), false, true, ++mapId, pluginName); if (parameters.contains(QStringLiteral("mapboxgl.mapping.additional_style_urls"))) { const QString ids = parameters.value(QStringLiteral("mapboxgl.mapping.additional_style_urls")).toString(); @@ -98,7 +99,7 @@ QGeoMappingManagerEngineMapboxGL::QGeoMappingManagerEngineMapboxGL(const QVarian continue; mapTypes.prepend(QGeoMapType(QGeoMapType::CustomMap, *it, - tr("User provided style"), false, false, ++mapId)); + tr("User provided style"), false, false, ++mapId, pluginName)); } } @@ -137,6 +138,10 @@ QGeoMappingManagerEngineMapboxGL::QGeoMappingManagerEngineMapboxGL(const QVarian m_useFBO = parameters.value(QStringLiteral("mapboxgl.mapping.use_fbo")).toBool(); } + if (parameters.contains(QStringLiteral("mapboxgl.mapping.items.insert_before"))) { + m_mapItemsBefore = parameters.value(QStringLiteral("mapboxgl.mapping.items.insert_before")).toString(); + } + engineInitialized(); } @@ -149,6 +154,7 @@ QGeoMap *QGeoMappingManagerEngineMapboxGL::createMap() QGeoMapMapboxGL* map = new QGeoMapMapboxGL(this, 0); map->setMapboxGLSettings(m_settings); map->setUseFBO(m_useFBO); + map->setMapItemsBefore(m_mapItemsBefore); return map; } diff --git a/src/plugins/geoservices/mapboxgl/qgeomappingmanagerenginemapboxgl.h b/src/plugins/geoservices/mapboxgl/qgeomappingmanagerenginemapboxgl.h index c5923cda..44096e60 100644 --- a/src/plugins/geoservices/mapboxgl/qgeomappingmanagerenginemapboxgl.h +++ b/src/plugins/geoservices/mapboxgl/qgeomappingmanagerenginemapboxgl.h @@ -59,6 +59,7 @@ public: private: QMapboxGLSettings m_settings; bool m_useFBO = true; + QString m_mapItemsBefore; }; QT_END_NAMESPACE diff --git a/src/plugins/geoservices/mapboxgl/qgeoserviceproviderpluginmapboxgl.cpp b/src/plugins/geoservices/mapboxgl/qgeoserviceproviderpluginmapboxgl.cpp index 30c01f8c..c7d5d3ee 100644 --- a/src/plugins/geoservices/mapboxgl/qgeoserviceproviderpluginmapboxgl.cpp +++ b/src/plugins/geoservices/mapboxgl/qgeoserviceproviderpluginmapboxgl.cpp @@ -38,9 +38,20 @@ #include "qgeoserviceproviderpluginmapboxgl.h" #include "qgeomappingmanagerenginemapboxgl.h" +#include <QtGui/QOpenGLContext> + +static void initResources() +{ + Q_INIT_RESOURCE(mapboxgl); +} QT_BEGIN_NAMESPACE +QGeoServiceProviderFactoryMapboxGL::QGeoServiceProviderFactoryMapboxGL() +{ + initResources(); +} + QGeoCodingManagerEngine *QGeoServiceProviderFactoryMapboxGL::createGeocodingManagerEngine( const QVariantMap ¶meters, QGeoServiceProvider::Error *error, QString *errorString) const { @@ -54,6 +65,15 @@ QGeoCodingManagerEngine *QGeoServiceProviderFactoryMapboxGL::createGeocodingMana QGeoMappingManagerEngine *QGeoServiceProviderFactoryMapboxGL::createMappingManagerEngine( const QVariantMap ¶meters, QGeoServiceProvider::Error *error, QString *errorString) const { +#ifdef Q_OS_WIN + if (QOpenGLContext::openGLModuleType() != QOpenGLContext::LibGLES) { + qWarning("The Mapbox GL plugin only supports OpenGL ES on Windows. \ + Try setting the environment variable QT_OPENGL to 'angle'."); + + return 0; + } +#endif + return new QGeoMappingManagerEngineMapboxGL(parameters, error, errorString); } diff --git a/src/plugins/geoservices/mapboxgl/qgeoserviceproviderpluginmapboxgl.h b/src/plugins/geoservices/mapboxgl/qgeoserviceproviderpluginmapboxgl.h index 2bba96f1..b9c0098a 100644 --- a/src/plugins/geoservices/mapboxgl/qgeoserviceproviderpluginmapboxgl.h +++ b/src/plugins/geoservices/mapboxgl/qgeoserviceproviderpluginmapboxgl.h @@ -51,6 +51,8 @@ class QGeoServiceProviderFactoryMapboxGL: public QObject, public QGeoServiceProv FILE "mapboxgl_plugin.json") public: + QGeoServiceProviderFactoryMapboxGL(); + QGeoCodingManagerEngine *createGeocodingManagerEngine(const QVariantMap ¶meters, QGeoServiceProvider::Error *error, QString *errorString) const; diff --git a/src/plugins/geoservices/mapboxgl/qmapboxglstylechange.cpp b/src/plugins/geoservices/mapboxgl/qmapboxglstylechange.cpp index eccc64b8..8229b784 100644 --- a/src/plugins/geoservices/mapboxgl/qmapboxglstylechange.cpp +++ b/src/plugins/geoservices/mapboxgl/qmapboxglstylechange.cpp @@ -175,7 +175,7 @@ QList<QSharedPointer<QMapboxGLStyleChange>> QMapboxGLStyleChange::addMapParamete return changes; } -QList<QSharedPointer<QMapboxGLStyleChange>> QMapboxGLStyleChange::addMapItem(QDeclarativeGeoMapItemBase *item) +QList<QSharedPointer<QMapboxGLStyleChange>> QMapboxGLStyleChange::addMapItem(QDeclarativeGeoMapItemBase *item, const QString &before) { QList<QSharedPointer<QMapboxGLStyleChange>> changes; @@ -191,7 +191,7 @@ QList<QSharedPointer<QMapboxGLStyleChange>> QMapboxGLStyleChange::addMapItem(QDe QMapbox::Feature feature = featureFromMapItem(item); - changes << QMapboxGLStyleAddLayer::fromFeature(feature); + changes << QMapboxGLStyleAddLayer::fromFeature(feature, before); changes << QMapboxGLStyleAddSource::fromFeature(feature); changes << QMapboxGLStyleSetPaintProperty::fromMapItem(item); changes << QMapboxGLStyleSetLayoutProperty::fromMapItem(item); @@ -390,7 +390,7 @@ QList<QSharedPointer<QMapboxGLStyleChange>> QMapboxGLStyleSetPaintProperty::from void QMapboxGLStyleAddLayer::apply(QMapboxGL *map) { - map->addLayer(m_params); + map->addLayer(m_params, m_before); } QSharedPointer<QMapboxGLStyleChange> QMapboxGLStyleAddLayer::fromMapParameter(QGeoMapParameter *param) @@ -406,10 +406,12 @@ QSharedPointer<QMapboxGLStyleChange> QMapboxGLStyleAddLayer::fromMapParameter(QG layer->m_params[QStringLiteral("source-layer")] = param->property("sourceLayer"); } + layer->m_before = param->property("before").toString(); + return QSharedPointer<QMapboxGLStyleChange>(layer); } -QSharedPointer<QMapboxGLStyleChange> QMapboxGLStyleAddLayer::fromFeature(const QMapbox::Feature &feature) +QSharedPointer<QMapboxGLStyleChange> QMapboxGLStyleAddLayer::fromFeature(const QMapbox::Feature &feature, const QString &before) { auto layer = new QMapboxGLStyleAddLayer(); layer->m_params[QStringLiteral("id")] = feature.id; @@ -427,6 +429,8 @@ QSharedPointer<QMapboxGLStyleChange> QMapboxGLStyleAddLayer::fromFeature(const Q break; } + layer->m_before = before; + return QSharedPointer<QMapboxGLStyleChange>(layer); } diff --git a/src/plugins/geoservices/mapboxgl/qmapboxglstylechange_p.h b/src/plugins/geoservices/mapboxgl/qmapboxglstylechange_p.h index a380660b..9164591a 100644 --- a/src/plugins/geoservices/mapboxgl/qmapboxglstylechange_p.h +++ b/src/plugins/geoservices/mapboxgl/qmapboxglstylechange_p.h @@ -58,7 +58,7 @@ public: virtual ~QMapboxGLStyleChange() = default; static QList<QSharedPointer<QMapboxGLStyleChange>> addMapParameter(QGeoMapParameter *); - static QList<QSharedPointer<QMapboxGLStyleChange>> addMapItem(QDeclarativeGeoMapItemBase *); + static QList<QSharedPointer<QMapboxGLStyleChange>> addMapItem(QDeclarativeGeoMapItemBase *, const QString &before); static QList<QSharedPointer<QMapboxGLStyleChange>> removeMapItem(QDeclarativeGeoMapItemBase *); virtual void apply(QMapboxGL *map) = 0; @@ -109,7 +109,7 @@ class QMapboxGLStyleAddLayer : public QMapboxGLStyleChange { public: static QSharedPointer<QMapboxGLStyleChange> fromMapParameter(QGeoMapParameter *); - static QSharedPointer<QMapboxGLStyleChange> fromFeature(const QMapbox::Feature &feature); + static QSharedPointer<QMapboxGLStyleChange> fromFeature(const QMapbox::Feature &feature, const QString &before); void apply(QMapboxGL *map) Q_DECL_OVERRIDE; @@ -117,6 +117,7 @@ private: QMapboxGLStyleAddLayer() = default; QVariantMap m_params; + QString m_before; }; class QMapboxGLStyleRemoveLayer : public QMapboxGLStyleChange diff --git a/src/plugins/geoservices/mapboxgl/qsgmapboxglnode.cpp b/src/plugins/geoservices/mapboxgl/qsgmapboxglnode.cpp index 4a76ac29..d338a51a 100644 --- a/src/plugins/geoservices/mapboxgl/qsgmapboxglnode.cpp +++ b/src/plugins/geoservices/mapboxgl/qsgmapboxglnode.cpp @@ -43,13 +43,15 @@ // QSGMapboxGLTextureNode +static const QSize minTextureSize = QSize(64, 64); + QSGMapboxGLTextureNode::QSGMapboxGLTextureNode(const QMapboxGLSettings &settings, const QSize &size, qreal pixelRatio, QGeoMapMapboxGL *geoMap) : QSGSimpleTextureNode() { setTextureCoordinatesTransform(QSGSimpleTextureNode::MirrorVertically); setFiltering(QSGTexture::Linear); - m_map.reset(new QMapboxGL(nullptr, settings, size, pixelRatio)); + m_map.reset(new QMapboxGL(nullptr, settings, size.expandedTo(minTextureSize), pixelRatio)); QObject::connect(m_map.data(), &QMapboxGL::needsRendering, geoMap, &QGeoMap::sgNodeChanged); QObject::connect(m_map.data(), &QMapboxGL::copyrightsChanged, geoMap, @@ -58,8 +60,9 @@ QSGMapboxGLTextureNode::QSGMapboxGLTextureNode(const QMapboxGLSettings &settings void QSGMapboxGLTextureNode::resize(const QSize &size, qreal pixelRatio) { - const QSize fbSize = size * pixelRatio; - m_map->resize(size, fbSize); + const QSize& minSize = size.expandedTo(minTextureSize); + const QSize fbSize = minSize * pixelRatio; + m_map->resize(minSize, fbSize); m_fbo.reset(new QOpenGLFramebufferObject(fbSize, QOpenGLFramebufferObject::CombinedDepthStencil)); @@ -75,14 +78,12 @@ void QSGMapboxGLTextureNode::resize(const QSize &size, qreal pixelRatio) setOwnsTexture(true); } - setRect(QRectF(QPointF(), size)); + setRect(QRectF(QPointF(), minSize)); markDirty(QSGNode::DirtyGeometry); } void QSGMapboxGLTextureNode::render(QQuickWindow *window) { - window->setClearBeforeRendering(false); - QOpenGLFunctions *f = window->openglContext()->functions(); f->glViewport(0, 0, m_fbo->width(), m_fbo->height()); diff --git a/src/plugins/geoservices/nokia/nokia.pro b/src/plugins/geoservices/nokia/nokia.pro index c60bc7af..c6dadd86 100644 --- a/src/plugins/geoservices/nokia/nokia.pro +++ b/src/plugins/geoservices/nokia/nokia.pro @@ -45,7 +45,7 @@ SOURCES += \ include(placesv2/placesv2.pri) -RESOURCES += resource.qrc +RESOURCES += nokia.qrc INCLUDEPATH += ../../../location/maps diff --git a/src/plugins/geoservices/nokia/resource.qrc b/src/plugins/geoservices/nokia/nokia.qrc index 41d973c5..41d973c5 100644 --- a/src/plugins/geoservices/nokia/resource.qrc +++ b/src/plugins/geoservices/nokia/nokia.qrc diff --git a/src/plugins/geoservices/nokia/qgeoserviceproviderplugin_nokia.cpp b/src/plugins/geoservices/nokia/qgeoserviceproviderplugin_nokia.cpp index 4deac4ee..f68a0d99 100644 --- a/src/plugins/geoservices/nokia/qgeoserviceproviderplugin_nokia.cpp +++ b/src/plugins/geoservices/nokia/qgeoserviceproviderplugin_nokia.cpp @@ -47,6 +47,11 @@ #include <QNetworkProxy> #include <QCoreApplication> +static void initResources() +{ + Q_INIT_RESOURCE(nokia); +} + QT_BEGIN_NAMESPACE namespace @@ -110,6 +115,11 @@ namespace } } +QGeoServiceProviderFactoryNokia::QGeoServiceProviderFactoryNokia() +{ + initResources(); +} + QGeoCodingManagerEngine *QGeoServiceProviderFactoryNokia::createGeocodingManagerEngine( const QVariantMap ¶meters, QGeoServiceProvider::Error *error, diff --git a/src/plugins/geoservices/nokia/qgeoserviceproviderplugin_nokia.h b/src/plugins/geoservices/nokia/qgeoserviceproviderplugin_nokia.h index bce65cbf..5ed2645e 100644 --- a/src/plugins/geoservices/nokia/qgeoserviceproviderplugin_nokia.h +++ b/src/plugins/geoservices/nokia/qgeoserviceproviderplugin_nokia.h @@ -52,6 +52,8 @@ class QGeoServiceProviderFactoryNokia : public QObject, public QGeoServiceProvid FILE "nokia_plugin.json") public: + QGeoServiceProviderFactoryNokia(); + QGeoCodingManagerEngine *createGeocodingManagerEngine(const QVariantMap ¶meters, QGeoServiceProvider::Error *error, QString *errorString) const; diff --git a/src/plugins/geoservices/nokia/qgeotiledmappingmanagerengine_nokia.cpp b/src/plugins/geoservices/nokia/qgeotiledmappingmanagerengine_nokia.cpp index ab6cd7ea..146071f7 100644 --- a/src/plugins/geoservices/nokia/qgeotiledmappingmanagerengine_nokia.cpp +++ b/src/plugins/geoservices/nokia/qgeotiledmappingmanagerengine_nokia.cpp @@ -85,32 +85,34 @@ QGeoTiledMappingManagerEngineNokia::QGeoTiledMappingManagerEngineNokia( capabilities.setMaximumTilt(80); capabilities.setMinimumFieldOfView(20.0); capabilities.setMaximumFieldOfView(120.0); + capabilities.setOverzoomEnabled(true); setCameraCapabilities(capabilities); setTileSize(QSize(256, 256)); + const QByteArray pluginName = "here"; QList<QGeoMapType> types; - types << QGeoMapType(QGeoMapType::StreetMap, tr("Street Map"), tr("Normal map view in daylight mode"), false, false, 1); - types << QGeoMapType(QGeoMapType::SatelliteMapDay, tr("Satellite Map"), tr("Satellite map view in daylight mode"), false, false, 2); - types << QGeoMapType(QGeoMapType::TerrainMap, tr("Terrain Map"), tr("Terrain map view in daylight mode"), false, false, 3); - types << QGeoMapType(QGeoMapType::HybridMap, tr("Hybrid Map"), tr("Satellite map view with streets in daylight mode"), false, false, 4); - types << QGeoMapType(QGeoMapType::TransitMap, tr("Transit Map"), tr("Color-reduced map view with public transport scheme in daylight mode"), false, false, 5); - types << QGeoMapType(QGeoMapType::GrayStreetMap, tr("Gray Street Map"), tr("Color-reduced map view in daylight mode"), false, false, 6); - types << QGeoMapType(QGeoMapType::StreetMap, tr("Mobile Street Map"), tr("Mobile normal map view in daylight mode"), true, false, 7); - types << QGeoMapType(QGeoMapType::TerrainMap, tr("Mobile Terrain Map"), tr("Mobile terrain map view in daylight mode"), true, false, 8); - types << QGeoMapType(QGeoMapType::HybridMap, tr("Mobile Hybrid Map"), tr("Mobile satellite map view with streets in daylight mode"), true, false, 9); - types << QGeoMapType(QGeoMapType::TransitMap, tr("Mobile Transit Map"), tr("Mobile color-reduced map view with public transport scheme in daylight mode"), true, false, 10); - types << QGeoMapType(QGeoMapType::GrayStreetMap, tr("Mobile Gray Street Map"), tr("Mobile color-reduced map view in daylight mode"), true, false, 11); - types << QGeoMapType(QGeoMapType::StreetMap, tr("Custom Street Map"), tr("Normal map view in daylight mode"), false, false, 12); - types << QGeoMapType(QGeoMapType::StreetMap, tr("Night Street Map"), tr("Normal map view in night mode"), false, true, 13); - types << QGeoMapType(QGeoMapType::StreetMap, tr("Mobile Night Street Map"), tr("Mobile normal map view in night mode"), true, true, 14); - types << QGeoMapType(QGeoMapType::GrayStreetMap, tr("Gray Night Street Map"), tr("Color-reduced map view in night mode (especially used for background maps)"), false, true, 15); - types << QGeoMapType(QGeoMapType::GrayStreetMap, tr("Mobile Gray Night Street Map"), tr("Mobile color-reduced map view in night mode (especially used for background maps)"), true, true, 16); - types << QGeoMapType(QGeoMapType::PedestrianMap, tr("Pedestrian Street Map"), tr("Pedestrian map view in daylight mode"), false, false, 17); - types << QGeoMapType(QGeoMapType::PedestrianMap, tr("Mobile Pedestrian Street Map"), tr("Mobile pedestrian map view in daylight mode for mobile usage"), true, false, 18); - types << QGeoMapType(QGeoMapType::PedestrianMap, tr("Pedestrian Night Street Map"), tr("Pedestrian map view in night mode"), false, true, 19); - types << QGeoMapType(QGeoMapType::PedestrianMap, tr("Mobile Pedestrian Night Street Map"), tr("Mobile pedestrian map view in night mode for mobile usage"), true, true, 20); - types << QGeoMapType(QGeoMapType::CarNavigationMap, tr("Car Navigation Map"), tr("Normal map view in daylight mode for car navigation"), false, false, 21); + types << QGeoMapType(QGeoMapType::StreetMap, tr("Street Map"), tr("Normal map view in daylight mode"), false, false, 1, pluginName); + types << QGeoMapType(QGeoMapType::SatelliteMapDay, tr("Satellite Map"), tr("Satellite map view in daylight mode"), false, false, 2, pluginName); + types << QGeoMapType(QGeoMapType::TerrainMap, tr("Terrain Map"), tr("Terrain map view in daylight mode"), false, false, 3, pluginName); + types << QGeoMapType(QGeoMapType::HybridMap, tr("Hybrid Map"), tr("Satellite map view with streets in daylight mode"), false, false, 4, pluginName); + types << QGeoMapType(QGeoMapType::TransitMap, tr("Transit Map"), tr("Color-reduced map view with public transport scheme in daylight mode"), false, false, 5, pluginName); + types << QGeoMapType(QGeoMapType::GrayStreetMap, tr("Gray Street Map"), tr("Color-reduced map view in daylight mode"), false, false, 6, pluginName); + types << QGeoMapType(QGeoMapType::StreetMap, tr("Mobile Street Map"), tr("Mobile normal map view in daylight mode"), true, false, 7, pluginName); + types << QGeoMapType(QGeoMapType::TerrainMap, tr("Mobile Terrain Map"), tr("Mobile terrain map view in daylight mode"), true, false, 8, pluginName); + types << QGeoMapType(QGeoMapType::HybridMap, tr("Mobile Hybrid Map"), tr("Mobile satellite map view with streets in daylight mode"), true, false, 9, pluginName); + types << QGeoMapType(QGeoMapType::TransitMap, tr("Mobile Transit Map"), tr("Mobile color-reduced map view with public transport scheme in daylight mode"), true, false, 10, pluginName); + types << QGeoMapType(QGeoMapType::GrayStreetMap, tr("Mobile Gray Street Map"), tr("Mobile color-reduced map view in daylight mode"), true, false, 11, pluginName); + types << QGeoMapType(QGeoMapType::StreetMap, tr("Custom Street Map"), tr("Normal map view in daylight mode"), false, false, 12, pluginName); + types << QGeoMapType(QGeoMapType::StreetMap, tr("Night Street Map"), tr("Normal map view in night mode"), false, true, 13, pluginName); + types << QGeoMapType(QGeoMapType::StreetMap, tr("Mobile Night Street Map"), tr("Mobile normal map view in night mode"), true, true, 14, pluginName); + types << QGeoMapType(QGeoMapType::GrayStreetMap, tr("Gray Night Street Map"), tr("Color-reduced map view in night mode (especially used for background maps)"), false, true, 15, pluginName); + types << QGeoMapType(QGeoMapType::GrayStreetMap, tr("Mobile Gray Night Street Map"), tr("Mobile color-reduced map view in night mode (especially used for background maps)"), true, true, 16, pluginName); + types << QGeoMapType(QGeoMapType::PedestrianMap, tr("Pedestrian Street Map"), tr("Pedestrian map view in daylight mode"), false, false, 17, pluginName); + types << QGeoMapType(QGeoMapType::PedestrianMap, tr("Mobile Pedestrian Street Map"), tr("Mobile pedestrian map view in daylight mode for mobile usage"), true, false, 18, pluginName); + types << QGeoMapType(QGeoMapType::PedestrianMap, tr("Pedestrian Night Street Map"), tr("Pedestrian map view in night mode"), false, true, 19, pluginName); + types << QGeoMapType(QGeoMapType::PedestrianMap, tr("Mobile Pedestrian Night Street Map"), tr("Mobile pedestrian map view in night mode for mobile usage"), true, true, 20, pluginName); + types << QGeoMapType(QGeoMapType::CarNavigationMap, tr("Car Navigation Map"), tr("Normal map view in daylight mode for car navigation"), false, false, 21, pluginName); setSupportedMapTypes(types); QGeoTileFetcherNokia *fetcher = new QGeoTileFetcherNokia(parameters, networkManager, this, tileSize(), ppi); @@ -123,7 +125,7 @@ QGeoTiledMappingManagerEngineNokia::QGeoTiledMappingManagerEngineNokia( m_cacheDirectory = parameters.value(QStringLiteral("here.mapping.cache.directory")).toString(); } else { // managerName() is not yet set, we have to hardcode the plugin name below - m_cacheDirectory = QAbstractGeoTileCache::baseLocationCacheDirectory() + QLatin1String("here"); + m_cacheDirectory = QAbstractGeoTileCache::baseLocationCacheDirectory() + QLatin1String(pluginName); } QGeoFileTileCache *tileCache = new QGeoFileTileCacheNokia(ppi, m_cacheDirectory); @@ -185,6 +187,17 @@ QGeoTiledMappingManagerEngineNokia::QGeoTiledMappingManagerEngineNokia( tileCache->setExtraTextureUsage(cacheSize); } + /* PREFETCHING */ + if (parameters.contains(QStringLiteral("here.mapping.prefetching_style"))) { + const QString prefetchingMode = parameters.value(QStringLiteral("here.mapping.prefetching_style")).toString(); + if (prefetchingMode == QStringLiteral("TwoNeighbourLayers")) + m_prefetchStyle = QGeoTiledMap::PrefetchTwoNeighbourLayers; + else if (prefetchingMode == QStringLiteral("OneNeighbourLayer")) + m_prefetchStyle = QGeoTiledMap::PrefetchNeighbourLayer; + else if (prefetchingMode == QStringLiteral("NoPrefetching")) + m_prefetchStyle = QGeoTiledMap::NoPrefetching; + } + setTileCache(tileCache); populateMapSchemes(); loadMapVersion(); @@ -431,7 +444,9 @@ QString QGeoTiledMappingManagerEngineNokia::evaluateCopyrightsText(const QGeoMap QGeoMap *QGeoTiledMappingManagerEngineNokia::createMap() { - return new QGeoTiledMapNokia(this); + QGeoTiledMap *map = new QGeoTiledMapNokia(this); + map->setPrefetchStyle(m_prefetchStyle); + return map; } QT_END_NAMESPACE diff --git a/src/plugins/geoservices/nokia/qgeotilefetcher_nokia.cpp b/src/plugins/geoservices/nokia/qgeotilefetcher_nokia.cpp index a55f71c0..d07a93ba 100644 --- a/src/plugins/geoservices/nokia/qgeotilefetcher_nokia.cpp +++ b/src/plugins/geoservices/nokia/qgeotilefetcher_nokia.cpp @@ -96,8 +96,15 @@ QGeoTiledMapReply *QGeoTileFetcherNokia::getTileImage(const QGeoTileSpec &spec) { // TODO add error detection for if request.connectivityMode() != QGraphicsGeoMap::OnlineMode int ppi = m_ppi; - if ((spec.mapId() == 2) || (spec.mapId() == 12) || (spec.mapId() == 21)) + if ((spec.mapId() == 2) || (spec.mapId() == 12) || (spec.mapId() == 21)) { ppi = 72; // HiDpi apparently not supported for these maps + } else if ((spec.mapId() >= 7 && spec.mapId() <= 11) + || (spec.mapId() == 14) + || (spec.mapId() == 16) + || (spec.mapId() == 18) + || (spec.mapId() == 20)) { + ppi = 250; // LoDpi apparently not supported for these maps + } QString rawRequest = getRequestString(spec, ppi); if (rawRequest.isEmpty()) { diff --git a/src/plugins/geoservices/osm/qgeotiledmappingmanagerengineosm.cpp b/src/plugins/geoservices/osm/qgeotiledmappingmanagerengineosm.cpp index 0e1fb356..da7b61d2 100644 --- a/src/plugins/geoservices/osm/qgeotiledmappingmanagerengineosm.cpp +++ b/src/plugins/geoservices/osm/qgeotiledmappingmanagerengineosm.cpp @@ -63,6 +63,7 @@ QGeoTiledMappingManagerEngineOsm::QGeoTiledMappingManagerEngineOsm(const QVarian cameraCaps.setMaximumTilt(80); cameraCaps.setMinimumFieldOfView(20.0); cameraCaps.setMaximumFieldOfView(120.0); + cameraCaps.setOverzoomEnabled(true); setCameraCapabilities(cameraCaps); setTileSize(QSize(256, 256)); @@ -161,26 +162,27 @@ QGeoTiledMappingManagerEngineOsm::QGeoTiledMappingManagerEngineOsm(const QVarian /* QGeoTileProviderOsms setup */ + const QByteArray pluginName = "osm"; m_providers.push_back( new QGeoTileProviderOsm( nm, - QGeoMapType(QGeoMapType::StreetMap, tr("Street Map"), tr("Street map view in daylight mode"), false, false, 1), + QGeoMapType(QGeoMapType::StreetMap, tr("Street Map"), tr("Street map view in daylight mode"), false, false, 1, pluginName), providers_street, cameraCaps )); m_providers.push_back( new QGeoTileProviderOsm( nm, - QGeoMapType(QGeoMapType::SatelliteMapDay, tr("Satellite Map"), tr("Satellite map view in daylight mode"), false, false, 2), + QGeoMapType(QGeoMapType::SatelliteMapDay, tr("Satellite Map"), tr("Satellite map view in daylight mode"), false, false, 2, pluginName), providers_satellite, cameraCaps )); m_providers.push_back( new QGeoTileProviderOsm( nm, - QGeoMapType(QGeoMapType::CycleMap, tr("Cycle Map"), tr("Cycle map view in daylight mode"), false, false, 3), + QGeoMapType(QGeoMapType::CycleMap, tr("Cycle Map"), tr("Cycle map view in daylight mode"), false, false, 3, pluginName), providers_cycle, cameraCaps )); m_providers.push_back( new QGeoTileProviderOsm( nm, - QGeoMapType(QGeoMapType::TransitMap, tr("Transit Map"), tr("Public transit map view in daylight mode"), false, false, 4), + QGeoMapType(QGeoMapType::TransitMap, tr("Transit Map"), tr("Public transit map view in daylight mode"), false, false, 4, pluginName), providers_transit, cameraCaps )); m_providers.push_back( new QGeoTileProviderOsm( nm, - QGeoMapType(QGeoMapType::TransitMap, tr("Night Transit Map"), tr("Public transit map view in night mode"), false, true, 5), + QGeoMapType(QGeoMapType::TransitMap, tr("Night Transit Map"), tr("Public transit map view in night mode"), false, true, 5, pluginName), providers_nighttransit, cameraCaps )); m_providers.push_back( new QGeoTileProviderOsm( nm, - QGeoMapType(QGeoMapType::TerrainMap, tr("Terrain Map"), tr("Terrain map view"), false, false, 6), + QGeoMapType(QGeoMapType::TerrainMap, tr("Terrain Map"), tr("Terrain map view"), false, false, 6, pluginName), providers_terrain, cameraCaps )); m_providers.push_back( new QGeoTileProviderOsm( nm, - QGeoMapType(QGeoMapType::PedestrianMap, tr("Hiking Map"), tr("Hiking map view"), false, false, 7), + QGeoMapType(QGeoMapType::PedestrianMap, tr("Hiking Map"), tr("Hiking map view"), false, false, 7, pluginName), providers_hiking, cameraCaps )); if (parameters.contains(QStringLiteral("osm.mapping.custom.host")) @@ -204,7 +206,7 @@ QGeoTiledMappingManagerEngineOsm::QGeoTiledMappingManagerEngineOsm(const QVarian m_providers.push_back( new QGeoTileProviderOsm( nm, - QGeoMapType(QGeoMapType::CustomMap, tr("Custom URL Map"), tr("Custom url map view set via urlprefix parameter"), false, false, 8), + QGeoMapType(QGeoMapType::CustomMap, tr("Custom URL Map"), tr("Custom url map view set via urlprefix parameter"), false, false, 8, pluginName), { new TileProvider(tmsServer + QStringLiteral("%z/%x/%y.png"), QStringLiteral("png"), mapCopyright, @@ -236,7 +238,7 @@ QGeoTiledMappingManagerEngineOsm::QGeoTiledMappingManagerEngineOsm(const QVarian m_cacheDirectory = parameters.value(QStringLiteral("osm.mapping.cache.directory")).toString(); } else { // managerName() is not yet set, we have to hardcode the plugin name below - m_cacheDirectory = QAbstractGeoTileCache::baseLocationCacheDirectory() + QLatin1String("osm"); + m_cacheDirectory = QAbstractGeoTileCache::baseLocationCacheDirectory() + QLatin1String(pluginName); } if (parameters.contains(QStringLiteral("osm.mapping.offline.directory"))) m_offlineDirectory = parameters.value(QStringLiteral("osm.mapping.offline.directory")).toString(); @@ -311,6 +313,17 @@ QGeoTiledMappingManagerEngineOsm::QGeoTiledMappingManagerEngineOsm(const QVarian } setTileFetcher(tileFetcher); + /* PREFETCHING */ + if (parameters.contains(QStringLiteral("osm.mapping.prefetching_style"))) { + const QString prefetchingMode = parameters.value(QStringLiteral("osm.mapping.prefetching_style")).toString(); + if (prefetchingMode == QStringLiteral("TwoNeighbourLayers")) + m_prefetchStyle = QGeoTiledMap::PrefetchTwoNeighbourLayers; + else if (prefetchingMode == QStringLiteral("OneNeighbourLayer")) + m_prefetchStyle = QGeoTiledMap::PrefetchNeighbourLayer; + else if (prefetchingMode == QStringLiteral("NoPrefetching")) + m_prefetchStyle = QGeoTiledMap::NoPrefetching; + } + *error = QGeoServiceProvider::NoError; errorString->clear(); } @@ -324,6 +337,7 @@ QGeoMap *QGeoTiledMappingManagerEngineOsm::createMap() QGeoTiledMap *map = new QGeoTiledMapOsm(this); connect(qobject_cast<QGeoFileTileCacheOsm *>(tileCache()), &QGeoFileTileCacheOsm::mapDataUpdated , map, &QGeoTiledMap::clearScene); + map->setPrefetchStyle(m_prefetchStyle); return map; } @@ -337,13 +351,13 @@ QString QGeoTiledMappingManagerEngineOsm::customCopyright() const return m_customCopyright; } -QGeoCameraCapabilities QGeoTiledMappingManagerEngineOsm::cameraCapabilities(const QGeoMapType &mapType) const +QGeoCameraCapabilities QGeoTiledMappingManagerEngineOsm::cameraCapabilities(int mapId) const { - if (mapType.mapId() == 0) - return QGeoMappingManagerEngine::cameraCapabilities(mapType); - int idx = mapType.mapId() - 1; + if (mapId == 0) + return QGeoMappingManagerEngine::cameraCapabilities(mapId); + int idx = mapId - 1; if (idx >= m_providers.size()) - return QGeoMappingManagerEngine::cameraCapabilities(QGeoMapType()); + return QGeoMappingManagerEngine::cameraCapabilities(mapId); return m_providers[idx]->cameraCapabilities(); } diff --git a/src/plugins/geoservices/osm/qgeotiledmappingmanagerengineosm.h b/src/plugins/geoservices/osm/qgeotiledmappingmanagerengineosm.h index db8b230c..c5f16c2b 100644 --- a/src/plugins/geoservices/osm/qgeotiledmappingmanagerengineosm.h +++ b/src/plugins/geoservices/osm/qgeotiledmappingmanagerengineosm.h @@ -59,10 +59,10 @@ public: QGeoServiceProvider::Error *error, QString *errorString); ~QGeoTiledMappingManagerEngineOsm(); - QGeoMap *createMap(); + QGeoMap *createMap() override; const QVector<QGeoTileProviderOsm *> &providers(); QString customCopyright() const; - QGeoCameraCapabilities cameraCapabilities(const QGeoMapType &mapType) const Q_DECL_OVERRIDE; + QGeoCameraCapabilities cameraCapabilities(int mapId) const override; protected Q_SLOTS: void onProviderResolutionFinished(const QGeoTileProviderOsm *provider); diff --git a/src/plugins/geoservices/osm/qgeotilefetcherosm.cpp b/src/plugins/geoservices/osm/qgeotilefetcherosm.cpp index f7c25d61..8c5778d1 100644 --- a/src/plugins/geoservices/osm/qgeotilefetcherosm.cpp +++ b/src/plugins/geoservices/osm/qgeotilefetcherosm.cpp @@ -78,7 +78,7 @@ QGeoTileFetcherOsmPrivate::~QGeoTileFetcherOsmPrivate() QGeoTileFetcherOsm::QGeoTileFetcherOsm(const QVector<QGeoTileProviderOsm *> &providers, QNetworkAccessManager *nm, - QObject *parent) + QGeoMappingManagerEngine *parent) : QGeoTileFetcher(*new QGeoTileFetcherOsmPrivate(), parent), m_userAgent("Qt Location based application"), m_providers(providers), m_nm(nm), m_ready(true) { diff --git a/src/plugins/geoservices/osm/qgeotilefetcherosm.h b/src/plugins/geoservices/osm/qgeotilefetcherosm.h index a7b89bad..859033cc 100644 --- a/src/plugins/geoservices/osm/qgeotilefetcherosm.h +++ b/src/plugins/geoservices/osm/qgeotilefetcherosm.h @@ -59,7 +59,7 @@ class QGeoTileFetcherOsm : public QGeoTileFetcher public: QGeoTileFetcherOsm(const QVector<QGeoTileProviderOsm *> &providers, QNetworkAccessManager *nm, - QObject *parent = 0); + QGeoMappingManagerEngine *parent); void setUserAgent(const QByteArray &userAgent); |