summaryrefslogtreecommitdiffstats
path: root/src/plugins/geoservices/osm/qgeotiledmappingmanagerengineosm.cpp
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 /src/plugins/geoservices/osm/qgeotiledmappingmanagerengineosm.cpp
parenta7bc67e54c5dfc06893fdf87bf4565b8d4429f72 (diff)
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>
Diffstat (limited to 'src/plugins/geoservices/osm/qgeotiledmappingmanagerengineosm.cpp')
-rw-r--r--src/plugins/geoservices/osm/qgeotiledmappingmanagerengineosm.cpp40
1 files changed, 39 insertions, 1 deletions
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);