diff options
author | Paolo Angelelli <paolo.angelelli@theqtcompany.com> | 2016-06-15 22:50:21 +0200 |
---|---|---|
committer | Paolo Angelelli <paolo.angelelli@theqtcompany.com> | 2016-06-30 11:40:05 +0000 |
commit | 706f97d93b7e0e01bc287d9379e692ffd1bd08a6 (patch) | |
tree | 5d9d9aa54abee0902eae1e6f3a38adc9b2454fc5 /src/location | |
parent | e729fabed1b78729f65503ed3a7e0d5fddb13947 (diff) | |
download | qtlocation-706f97d93b7e0e01bc287d9379e692ffd1bd08a6.tar.gz |
Improve Mapbox geoservice plugin
This patch adds standard mapbox map modes so that they could be used
out of the box without the need for specifying it as parameter, and
also adds a QGeoFileTileCache to the plugin, since the Mapbox TOS allow
a limited caching even in the free plan.
The default cache max disk usage has been set accordingly.
The mapbox.map_id parameter is now optional, meaning that things will
work like before if present, but will work with the default mapbox
styles if not.
Change-Id: I4056a3706f47d7f5c46a873c135b743106647fc0
Reviewed-by: Topi Reiniƶ <topi.reinio@theqtcompany.com>
Reviewed-by: Michal Klocek <michal.klocek@theqtcompany.com>
Diffstat (limited to 'src/location')
-rw-r--r-- | src/location/doc/src/plugins/mapbox.qdoc | 31 | ||||
-rw-r--r-- | src/location/maps/qgeofiletilecache.cpp | 4 | ||||
-rw-r--r-- | src/location/maps/qgeofiletilecache_p.h | 6 |
3 files changed, 33 insertions, 8 deletions
diff --git a/src/location/doc/src/plugins/mapbox.qdoc b/src/location/doc/src/plugins/mapbox.qdoc index 6cd326ba..0b989218 100644 --- a/src/location/doc/src/plugins/mapbox.qdoc +++ b/src/location/doc/src/plugins/mapbox.qdoc @@ -53,9 +53,6 @@ The following table lists mandatory parameters that \e must be passed to the Map \row \li mapbox.access_token \li \l{https://www.mapbox.com/help/define-access-token/}{Access token} provided by Mapbox. -\row - \li mapbox.map_id - \li \l{https://www.mapbox.com/help/define-map-id/}{ID} of the Mapbox map to show. An example ID is "examples.map-zr0njcqy". \endtable The Mapbox geo services plugin requires an access token and map ID to use the @@ -69,6 +66,14 @@ The following table lists optional parameters that can be passed to the Mapbox p \li Parameter \li Description \row + \li mapbox.map_id + \li \l{https://www.mapbox.com/help/define-map-id/}{ID} of the Mapbox map to show. An example ID is "examples.map-zr0njcqy". + If this parameter is present, the specified map type will be used by default, unless another is selected. + If not present, the default Mapbox map ID is "mapbox.streets". +\row + \li mapbox.additional_map_ids + \li Additional, comma separated, Mapbox map IDs to be added to the available map types. +\row \li mapbox.format \li Data format to download tiles in, available values are "png", "png32", "png64", "png128", "png256", (PNG with full, 32, 64, 128 and 256 color palette) @@ -77,5 +82,25 @@ The following table lists optional parameters that can be passed to the Mapbox p \row \li useragent \li User agent string set when making network requests. +\row + \li mapbox.cache.directory + \li Absolute path to map tile cache directory used as network disk cache. + + The default place for the cache is \c{QtLocation/mapbox} directory in \l {QStandardPaths::writableLocation()} {QStandardPaths::writableLocation}(\l{QStandardPaths::GenericCacheLocation}). + On systems that have no concept of a shared cache, the application-specific \l{QStandardPaths::CacheLocation} is used instead. +\row + \li mapbox.cache.disk.size + \li Map tile disk cache size in bytes. Default size of the cache is 300MB. + Note that this is the maximum amount of data that the Mapbox free plan allows to cache. + Make sure to comply with Mapbox Terms of Service before increasing this value. +\row + \li mapbox.cache.memory.size + \li Map tile memory cache size in bytes. Default size of the cache is 3MB. +\row + \li mapbox.cache.texture.size + \li Map tile texture cache size in bytes. Default size of the cache is 6MB. + Note that the texture cache has a hard minimum size which depends on the size of the map viewport + (it must contain enough data to display the tiles currently visible on the display). + This value is the amount of cache to be used in addition to the bare minimum. \endtable */ diff --git a/src/location/maps/qgeofiletilecache.cpp b/src/location/maps/qgeofiletilecache.cpp index 3d381dc2..73c9fe29 100644 --- a/src/location/maps/qgeofiletilecache.cpp +++ b/src/location/maps/qgeofiletilecache.cpp @@ -390,7 +390,7 @@ QSharedPointer<QGeoTileTexture> QGeoFileTileCache::addToTextureCache(const QGeoT return tt; } -QString QGeoFileTileCache::tileSpecToFilename(const QGeoTileSpec &spec, const QString &format, const QString &directory) +QString QGeoFileTileCache::tileSpecToFilename(const QGeoTileSpec &spec, const QString &format, const QString &directory) const { QString filename = spec.plugin(); filename += QLatin1String("-"); @@ -416,7 +416,7 @@ QString QGeoFileTileCache::tileSpecToFilename(const QGeoTileSpec &spec, const QS return dir.filePath(filename); } -QGeoTileSpec QGeoFileTileCache::filenameToTileSpec(const QString &filename) +QGeoTileSpec QGeoFileTileCache::filenameToTileSpec(const QString &filename) const { QGeoTileSpec emptySpec; diff --git a/src/location/maps/qgeofiletilecache_p.h b/src/location/maps/qgeofiletilecache_p.h index bd3e684b..caaa0b07 100644 --- a/src/location/maps/qgeofiletilecache_p.h +++ b/src/location/maps/qgeofiletilecache_p.h @@ -128,7 +128,7 @@ public: const QString &format, QGeoTiledMappingManagerEngine::CacheAreas areas = QGeoTiledMappingManagerEngine::AllCaches) Q_DECL_OVERRIDE; -private: +protected: void printStats() Q_DECL_OVERRIDE; void loadTiles(); @@ -138,8 +138,8 @@ private: QSharedPointer<QGeoCachedTileMemory> addToMemoryCache(const QGeoTileSpec &spec, const QByteArray &bytes, const QString &format); QSharedPointer<QGeoTileTexture> addToTextureCache(const QGeoTileSpec &spec, const QImage &image); - static QString tileSpecToFilename(const QGeoTileSpec &spec, const QString &format, const QString &directory); - static QGeoTileSpec filenameToTileSpec(const QString &filename); + virtual QString tileSpecToFilename(const QGeoTileSpec &spec, const QString &format, const QString &directory) const; + virtual QGeoTileSpec filenameToTileSpec(const QString &filename) const; QCache3Q<QGeoTileSpec, QGeoCachedTileDisk, QCache3QTileEvictionPolicy > diskCache_; QCache3Q<QGeoTileSpec, QGeoCachedTileMemory > memoryCache_; |