summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaolo Angelelli <paolo.angelelli@qt.io>2016-11-23 14:08:21 +0100
committerPaolo Angelelli <paolo.angelelli@qt.io>2016-11-24 10:21:04 +0000
commita98315f652518cb6f2d0a2845dc1d1581c3dbbc0 (patch)
tree8ddd4ed956aa0e0463fedd864d317f8889fdad29
parenta7bc67e54c5dfc06893fdf87bf4565b8d4429f72 (diff)
downloadqtlocation-a98315f652518cb6f2d0a2845dc1d1581c3dbbc0.tar.gz
Add cache cost strategy parameters to all geoservice plugins
This patch adds the possibility to change the cost strategy on all the geoservice plugins Change-Id: I0903d931ea228cc468216780fb87b466bc383063 Reviewed-by: Alex Blasche <alexander.blasche@qt.io>
-rw-r--r--src/location/doc/src/plugins/esri.qdoc47
-rw-r--r--src/location/doc/src/plugins/nokia.qdoc38
-rw-r--r--src/location/doc/src/plugins/osm.qdoc36
-rw-r--r--src/plugins/geoservices/esri/geotiledmappingmanagerengine_esri.cpp69
-rw-r--r--src/plugins/geoservices/nokia/qgeotiledmappingmanagerengine_nokia.cpp40
-rw-r--r--src/plugins/geoservices/osm/qgeotiledmappingmanagerengineosm.cpp40
6 files changed, 260 insertions, 10 deletions
diff --git a/src/location/doc/src/plugins/esri.qdoc b/src/location/doc/src/plugins/esri.qdoc
index 71a7a3d5..6ac65910 100644
--- a/src/location/doc/src/plugins/esri.qdoc
+++ b/src/location/doc/src/plugins/esri.qdoc
@@ -104,6 +104,53 @@ or you can sign up for an \l {http://www.arcgis.com/features/plans/pricing.html}
\row
\li esri.mapping.maximumZoomLevel
\li The maximum level [double] at which the map is displayed
+\row
+ \li esri.mapping.cache.directory
+ \li Absolute path to map tile cache directory used as network disk cache.
+
+ The default place for the cache is \c{QtLocation/here} 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 esri.mapping.cache.disk.cost_strategy
+ \li The cost strategy to use to cache map tiles on disk.
+ Valid values are \b bytesize and \b unitary.
+ Using \b bytesize, the related size parameter (\b esri.mapping.cache.disk.size) will
+ be interpreted as bytes.
+ Using \b unitary, they will be interpreted as number of tiles.
+ The default value for this parameter is \b bytesize.
+\row
+ \li esri.mapping.cache.disk.size
+ \li Disk cache size for map tiles. The default size of the cache is 50 MiB when \b bytesize is the cost
+ strategy for this cache, or 1000 tiles, when \b unitary is the cost strategy.
+\row
+ \li esri.mapping.cache.memory.cost_strategy
+ \li The cost strategy to use to cache map tiles in memory.
+ Valid values are \b bytesize and \b unitary.
+ Using \b bytesize, the related size parameter (\b esri.mapping.cache.memory.size) will
+ be interpreted as bytes.
+ Using \b unitary, they will be interpreted as number of tiles.
+ The default value for this parameter is \b bytesize.
+\row
+ \li esri.mapping.cache.memory.size
+ \li Memory cache size for map tiles. The default size of the cache is 3 MiB when \b bytesize is the cost
+ strategy for this cache, or 100 tiles, when \b unitary is the cost strategy.
+\row
+ \li esri.mapping.cache.texture.cost_strategy
+ \li The cost strategy to use to cache decompressed map tiles in memory.
+ Valid values are \b bytesize and \b unitary.
+ Using \b bytesize, the related size parameter (\b esri.mapping.cache.texture.size) will
+ be interpreted as bytes.
+ Using \b unitary, they will be interpreted as number of tiles.
+ The default value for this parameter is \b bytesize.
+\row
+ \li esri.mapping.cache.texture.size
+ \li Texture cache size for map tiles. The default size of the cache is 6 MiB when \b bytesize is the cost
+ strategy for this cache, or 30 tiles, when \b unitary is the cost strategy.
+ 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
\section2 Directions language
diff --git a/src/location/doc/src/plugins/nokia.qdoc b/src/location/doc/src/plugins/nokia.qdoc
index 91a9fe9a..7e2fa512 100644
--- a/src/location/doc/src/plugins/nokia.qdoc
+++ b/src/location/doc/src/plugins/nokia.qdoc
@@ -96,14 +96,44 @@ a prefix.
On systems that have no concept of a shared cache, the application-specific \l{QStandardPaths::CacheLocation} is used instead.
\row
+ \li here.mapping.cache.disk.cost_strategy
+ \li The cost strategy to use to cache map tiles on disk.
+ Valid values are \b bytesize and \b unitary.
+ Using \b bytesize, the related size parameter (\b here.mapping.cache.disk.size) will
+ be interpreted as bytes.
+ Using \b unitary, they will be interpreted as number of tiles.
+ The default value for this parameter is \b bytesize.
+\row
\li here.mapping.cache.disk.size
- \li Map tile disk cache size in bytes. Default size of the cache is 20MB.
+ \li Disk cache size for map tiles. The default size of the cache is 50 MiB when \b bytesize is the cost
+ strategy for this cache, or 1000 tiles, when \b unitary is the cost strategy.
+\row
+ \li here.mapping.cache.memory.cost_strategy
+ \li The cost strategy to use to cache map tiles in memory.
+ Valid values are \b bytesize and \b unitary.
+ Using \b bytesize, the related size parameter (\b here.mapping.cache.memory.size) will
+ be interpreted as bytes.
+ Using \b unitary, they will be interpreted as number of tiles.
+ The default value for this parameter is \b bytesize.
\row
\li here.mapping.cache.memory.size
- \li Map tile memory cache size in bytes. Default size of the cache is 3MB.
+ \li Memory cache size for map tiles. The default size of the cache is 3 MiB when \b bytesize is the cost
+ strategy for this cache, or 100 tiles, when \b unitary is the cost strategy.
+\row
+ \li here.mapping.cache.texture.cost_strategy
+ \li The cost strategy to use to cache decompressed map tiles in memory.
+ Valid values are \b bytesize and \b unitary.
+ Using \b bytesize, the related size parameter (\b here.mapping.cache.texture.size) will
+ be interpreted as bytes.
+ Using \b unitary, they will be interpreted as number of tiles.
+ The default value for this parameter is \b bytesize.
\row
- \li here.mapping.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.
+ \li osm.mapping.cache.texture.size
+ \li Texture cache size for map tiles. The default size of the cache is 6 MiB when \b bytesize is the cost
+ strategy for this cache, or 30 tiles, when \b unitary is the cost strategy.
+ 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.
\row
\li here.mapping.highdpi_tiles
\li Whether or not to request high dpi tiles. Valid values are \b true and \b false. The default value is \b false.
diff --git a/src/location/doc/src/plugins/osm.qdoc b/src/location/doc/src/plugins/osm.qdoc
index c0ae48a7..bb520601 100644
--- a/src/location/doc/src/plugins/osm.qdoc
+++ b/src/location/doc/src/plugins/osm.qdoc
@@ -135,14 +135,44 @@ a prefix.
There is no default value, and if this property is not set, no directory will be indexed and only the network disk cache will be used
to reduce network usage or to act as an offline storage for the currently cached tiles.
\row
+ \li osm.mapping.cache.disk.cost_strategy
+ \li The cost strategy to use to cache map tiles on disk.
+ Valid values are \b bytesize and \b unitary.
+ Using \b bytesize, the related size parameter (\b osm.mapping.cache.disk.size) will
+ be interpreted as bytes.
+ Using \b unitary, they will be interpreted as number of tiles.
+ The default value for this parameter is \b bytesize.
+\row
\li osm.mapping.cache.disk.size
- \li Map tile disk cache size in bytes. Default size of the cache is 100MB.
+ \li Disk cache size for map tiles. The default size of the cache is 50 MiB when \b bytesize is the cost
+ strategy for this cache, or 1000 tiles, when \b unitary is the cost strategy.
+\row
+ \li osm.mapping.cache.memory.cost_strategy
+ \li The cost strategy to use to cache map tiles in memory.
+ Valid values are \b bytesize and \b unitary.
+ Using \b bytesize, the related size parameter (\b osm.mapping.cache.memory.size) will
+ be interpreted as bytes.
+ Using \b unitary, they will be interpreted as number of tiles.
+ The default value for this parameter is \b bytesize.
\row
\li osm.mapping.cache.memory.size
- \li Map tile memory cache size in bytes. Default size of the cache is 3MB.
+ \li Memory cache size for map tiles. The default size of the cache is 3 MiB when \b bytesize is the cost
+ strategy for this cache, or 100 tiles, when \b unitary is the cost strategy.
+\row
+ \li osm.mapping.cache.texture.cost_strategy
+ \li The cost strategy to use to cache decompressed map tiles in memory.
+ Valid values are \b bytesize and \b unitary.
+ Using \b bytesize, the related size parameter (\b osm.mapping.cache.texture.size) will
+ be interpreted as bytes.
+ Using \b unitary, they will be interpreted as number of tiles.
+ The default value for this parameter is \b bytesize.
\row
\li osm.mapping.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.
+ \li Texture cache size for map tiles. The default size of the cache is 6 MiB when \b bytesize is the cost
+ strategy for this cache, or 30 tiles, when \b unitary is the cost strategy.
+ 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/plugins/geoservices/esri/geotiledmappingmanagerengine_esri.cpp b/src/plugins/geoservices/esri/geotiledmappingmanagerengine_esri.cpp
index 396d0f57..abcb3779 100644
--- a/src/plugins/geoservices/esri/geotiledmappingmanagerengine_esri.cpp
+++ b/src/plugins/geoservices/esri/geotiledmappingmanagerengine_esri.cpp
@@ -127,6 +127,75 @@ GeoTiledMappingManagerEngineEsri::GeoTiledMappingManagerEngineEsri(const QVarian
setTileFetcher(tileFetcher);
+ /* TILE CACHE */
+ QString cacheDirectory;
+ if (parameters.contains(QStringLiteral("esri.mapping.cache.directory"))) {
+ cacheDirectory = parameters.value(QStringLiteral("esri.mapping.cache.directory")).toString();
+ } else {
+ // managerName() is not yet set, we have to hardcode the plugin name below
+ cacheDirectory = QAbstractGeoTileCache::baseLocationCacheDirectory() + QLatin1String("esri");
+ }
+ QGeoFileTileCache *tileCache = new QGeoFileTileCache(cacheDirectory);
+
+ /*
+ * Disk cache setup -- defaults to ByteSize (old behavior)
+ */
+ if (parameters.contains(QStringLiteral("esri.mapping.cache.disk.cost_strategy"))) {
+ QString cacheStrategy = parameters.value(QStringLiteral("esri.mapping.cache.disk.cost_strategy")).toString().toLower();
+ if (cacheStrategy == QLatin1String("bytesize"))
+ tileCache->setCostStrategyDisk(QGeoFileTileCache::ByteSize);
+ else
+ tileCache->setCostStrategyDisk(QGeoFileTileCache::Unitary);
+ } else {
+ tileCache->setCostStrategyDisk(QGeoFileTileCache::ByteSize);
+ }
+ if (parameters.contains(QStringLiteral("esri.mapping.cache.disk.size"))) {
+ bool ok = false;
+ int cacheSize = parameters.value(QStringLiteral("esri.mapping.cache.disk.size")).toString().toInt(&ok);
+ if (ok)
+ tileCache->setMaxDiskUsage(cacheSize);
+ }
+
+ /*
+ * Memory cache setup -- defaults to ByteSize (old behavior)
+ */
+ if (parameters.contains(QStringLiteral("esri.mapping.cache.memory.cost_strategy"))) {
+ QString cacheStrategy = parameters.value(QStringLiteral("esri.mapping.cache.memory.cost_strategy")).toString().toLower();
+ if (cacheStrategy == QLatin1String("bytesize"))
+ tileCache->setCostStrategyMemory(QGeoFileTileCache::ByteSize);
+ else
+ tileCache->setCostStrategyMemory(QGeoFileTileCache::Unitary);
+ } else {
+ tileCache->setCostStrategyMemory(QGeoFileTileCache::ByteSize);
+ }
+ if (parameters.contains(QStringLiteral("esri.mapping.cache.memory.size"))) {
+ bool ok = false;
+ int cacheSize = parameters.value(QStringLiteral("esri.mapping.cache.memory.size")).toString().toInt(&ok);
+ if (ok)
+ tileCache->setMaxMemoryUsage(cacheSize);
+ }
+
+ /*
+ * Texture cache setup -- defaults to ByteSize (old behavior)
+ */
+ if (parameters.contains(QStringLiteral("esri.mapping.cache.texture.cost_strategy"))) {
+ QString cacheStrategy = parameters.value(QStringLiteral("esri.mapping.cache.texture.cost_strategy")).toString().toLower();
+ if (cacheStrategy == QLatin1String("bytesize"))
+ tileCache->setCostStrategyTexture(QGeoFileTileCache::ByteSize);
+ else
+ tileCache->setCostStrategyTexture(QGeoFileTileCache::Unitary);
+ } else {
+ tileCache->setCostStrategyTexture(QGeoFileTileCache::ByteSize);
+ }
+ if (parameters.contains(QStringLiteral("esri.mapping.cache.texture.size"))) {
+ bool ok = false;
+ int cacheSize = parameters.value(QStringLiteral("esri.mapping.cache.texture.size")).toString().toInt(&ok);
+ if (ok)
+ tileCache->setExtraTextureUsage(cacheSize);
+ }
+
+
+ setTileCache(tileCache);
*error = QGeoServiceProvider::NoError;
errorString->clear();
}
diff --git a/src/plugins/geoservices/nokia/qgeotiledmappingmanagerengine_nokia.cpp b/src/plugins/geoservices/nokia/qgeotiledmappingmanagerengine_nokia.cpp
index 8fcaba6a..6548aa2b 100644
--- a/src/plugins/geoservices/nokia/qgeotiledmappingmanagerengine_nokia.cpp
+++ b/src/plugins/geoservices/nokia/qgeotiledmappingmanagerengine_nokia.cpp
@@ -105,9 +105,9 @@ QGeoTiledMappingManagerEngineNokia::QGeoTiledMappingManagerEngineNokia(
QGeoTileFetcherNokia *fetcher = new QGeoTileFetcherNokia(parameters, networkManager, this, tileSize(), ppi);
setTileFetcher(fetcher);
+ /* TILE CACHE */
// TODO: do this in a plugin-neutral way so that other tiled map plugins
// don't need this boilerplate or hardcode plugin name
-
if (parameters.contains(QStringLiteral("here.mapping.cache.directory"))) {
m_cacheDirectory = parameters.value(QStringLiteral("here.mapping.cache.directory")).toString();
} else {
@@ -116,8 +116,19 @@ QGeoTiledMappingManagerEngineNokia::QGeoTiledMappingManagerEngineNokia(
}
QGeoFileTileCache *tileCache = new QGeoFileTileCacheNokia(ppi, m_cacheDirectory);
- setTileCache(tileCache);
+ /*
+ * Disk cache setup -- defaults to ByteSize (old behavior)
+ */
+ if (parameters.contains(QStringLiteral("here.mapping.cache.disk.cost_strategy"))) {
+ QString cacheStrategy = parameters.value(QStringLiteral("here.mapping.cache.disk.cost_strategy")).toString().toLower();
+ if (cacheStrategy == QLatin1String("bytesize"))
+ tileCache->setCostStrategyDisk(QGeoFileTileCache::ByteSize);
+ else
+ tileCache->setCostStrategyDisk(QGeoFileTileCache::Unitary);
+ } else {
+ tileCache->setCostStrategyDisk(QGeoFileTileCache::ByteSize);
+ }
if (parameters.contains(QStringLiteral("here.mapping.cache.disk.size"))) {
bool ok = false;
int cacheSize = parameters.value(QStringLiteral("here.mapping.cache.disk.size")).toString().toInt(&ok);
@@ -125,6 +136,18 @@ QGeoTiledMappingManagerEngineNokia::QGeoTiledMappingManagerEngineNokia(
tileCache->setMaxDiskUsage(cacheSize);
}
+ /*
+ * Memory cache setup -- defaults to ByteSize (old behavior)
+ */
+ if (parameters.contains(QStringLiteral("here.mapping.cache.memory.cost_strategy"))) {
+ QString cacheStrategy = parameters.value(QStringLiteral("here.mapping.cache.memory.cost_strategy")).toString().toLower();
+ if (cacheStrategy == QLatin1String("bytesize"))
+ tileCache->setCostStrategyMemory(QGeoFileTileCache::ByteSize);
+ else
+ tileCache->setCostStrategyMemory(QGeoFileTileCache::Unitary);
+ } else {
+ tileCache->setCostStrategyMemory(QGeoFileTileCache::ByteSize);
+ }
if (parameters.contains(QStringLiteral("here.mapping.cache.memory.size"))) {
bool ok = false;
int cacheSize = parameters.value(QStringLiteral("here.mapping.cache.memory.size")).toString().toInt(&ok);
@@ -132,6 +155,18 @@ QGeoTiledMappingManagerEngineNokia::QGeoTiledMappingManagerEngineNokia(
tileCache->setMaxMemoryUsage(cacheSize);
}
+ /*
+ * Texture cache setup -- defaults to ByteSize (old behavior)
+ */
+ if (parameters.contains(QStringLiteral("here.mapping.cache.texture.cost_strategy"))) {
+ QString cacheStrategy = parameters.value(QStringLiteral("here.mapping.cache.texture.cost_strategy")).toString().toLower();
+ if (cacheStrategy == QLatin1String("bytesize"))
+ tileCache->setCostStrategyTexture(QGeoFileTileCache::ByteSize);
+ else
+ tileCache->setCostStrategyTexture(QGeoFileTileCache::Unitary);
+ } else {
+ tileCache->setCostStrategyTexture(QGeoFileTileCache::ByteSize);
+ }
if (parameters.contains(QStringLiteral("here.mapping.cache.texture.size"))) {
bool ok = false;
int cacheSize = parameters.value(QStringLiteral("here.mapping.cache.texture.size")).toString().toInt(&ok);
@@ -139,6 +174,7 @@ QGeoTiledMappingManagerEngineNokia::QGeoTiledMappingManagerEngineNokia(
tileCache->setExtraTextureUsage(cacheSize);
}
+ setTileCache(tileCache);
populateMapSchemes();
loadMapVersion();
QMetaObject::invokeMethod(fetcher, "fetchCopyrightsData", Qt::QueuedConnection);
diff --git a/src/plugins/geoservices/osm/qgeotiledmappingmanagerengineosm.cpp b/src/plugins/geoservices/osm/qgeotiledmappingmanagerengineosm.cpp
index 780874a3..ff79c261 100644
--- a/src/plugins/geoservices/osm/qgeotiledmappingmanagerengineosm.cpp
+++ b/src/plugins/geoservices/osm/qgeotiledmappingmanagerengineosm.cpp
@@ -236,13 +236,36 @@ QGeoTiledMappingManagerEngineOsm::QGeoTiledMappingManagerEngineOsm(const QVarian
m_offlineDirectory = parameters.value(QStringLiteral("osm.mapping.offline.directory")).toString();
QGeoFileTileCacheOsm *tileCache = new QGeoFileTileCacheOsm(m_providers, m_offlineDirectory, m_cacheDirectory);
+ /*
+ * Disk cache setup -- defaults to ByteSize (old behavior)
+ */
+ if (parameters.contains(QStringLiteral("osm.mapping.cache.disk.cost_strategy"))) {
+ QString cacheStrategy = parameters.value(QStringLiteral("osm.mapping.cache.disk.cost_strategy")).toString().toLower();
+ if (cacheStrategy == QLatin1String("bytesize"))
+ tileCache->setCostStrategyDisk(QGeoFileTileCache::ByteSize);
+ else
+ tileCache->setCostStrategyDisk(QGeoFileTileCache::Unitary);
+ } else {
+ tileCache->setCostStrategyDisk(QGeoFileTileCache::ByteSize);
+ }
if (parameters.contains(QStringLiteral("osm.mapping.cache.disk.size"))) {
bool ok = false;
int cacheSize = parameters.value(QStringLiteral("osm.mapping.cache.disk.size")).toString().toInt(&ok);
if (ok)
tileCache->setMaxDiskUsage(cacheSize);
+ }
+
+ /*
+ * Memory cache setup -- defaults to ByteSize (old behavior)
+ */
+ if (parameters.contains(QStringLiteral("osm.mapping.cache.memory.cost_strategy"))) {
+ QString cacheStrategy = parameters.value(QStringLiteral("osm.mapping.cache.memory.cost_strategy")).toString().toLower();
+ if (cacheStrategy == QLatin1String("bytesize"))
+ tileCache->setCostStrategyMemory(QGeoFileTileCache::ByteSize);
+ else
+ tileCache->setCostStrategyMemory(QGeoFileTileCache::Unitary);
} else {
- tileCache->setMaxDiskUsage(100 * 1024 * 1024);
+ tileCache->setCostStrategyMemory(QGeoFileTileCache::ByteSize);
}
if (parameters.contains(QStringLiteral("osm.mapping.cache.memory.size"))) {
bool ok = false;
@@ -250,12 +273,27 @@ QGeoTiledMappingManagerEngineOsm::QGeoTiledMappingManagerEngineOsm(const QVarian
if (ok)
tileCache->setMaxMemoryUsage(cacheSize);
}
+
+ /*
+ * Texture cache setup -- defaults to ByteSize (old behavior)
+ */
+ if (parameters.contains(QStringLiteral("osm.mapping.cache.texture.cost_strategy"))) {
+ QString cacheStrategy = parameters.value(QStringLiteral("osm.mapping.cache.texture.cost_strategy")).toString().toLower();
+ if (cacheStrategy == QLatin1String("bytesize"))
+ tileCache->setCostStrategyTexture(QGeoFileTileCache::ByteSize);
+ else
+ tileCache->setCostStrategyTexture(QGeoFileTileCache::Unitary);
+ } else {
+ tileCache->setCostStrategyTexture(QGeoFileTileCache::ByteSize);
+ }
if (parameters.contains(QStringLiteral("osm.mapping.cache.texture.size"))) {
bool ok = false;
int cacheSize = parameters.value(QStringLiteral("osm.mapping.cache.texture.size")).toString().toInt(&ok);
if (ok)
tileCache->setExtraTextureUsage(cacheSize);
}
+
+
setTileCache(tileCache);