diff options
author | Alex Blasche <alexander.blasche@qt.io> | 2016-12-05 12:43:52 +0100 |
---|---|---|
committer | Alex Blasche <alexander.blasche@qt.io> | 2016-12-05 12:43:52 +0100 |
commit | 335116ea024f51e1693bba39f78e15131870f1b0 (patch) | |
tree | 148ccdb4703b4a35afb1b0e3875573b1eb90d0ce /src/plugins/geoservices/mapbox | |
parent | 5e4bc1fe908896e9b90e8ad9c3896f35b5ec37be (diff) | |
parent | ba9b7b9ef674d93680070f6c4bb1053d0d2325dd (diff) | |
download | qtlocation-335116ea024f51e1693bba39f78e15131870f1b0.tar.gz |
Merge remote-tracking branch 'gerrit/5.8' into dev
Conflicts:
src/imports/location/qdeclarativegeomap.cpp
src/location/maps/maps.pri
src/location/maps/qgeomap_p_p.h
src/plugins/geoservices/nokia/qgeocodereply_nokia.cpp
src/plugins/geoservices/osm/qgeoroutereplyosm.cpp
Change-Id: I18d31cff9233648178fe3e2636ce294026dfaeb7
Diffstat (limited to 'src/plugins/geoservices/mapbox')
-rw-r--r-- | src/plugins/geoservices/mapbox/qgeofiletilecachemapbox.cpp | 4 | ||||
-rw-r--r-- | src/plugins/geoservices/mapbox/qgeotiledmappingmanagerenginemapbox.cpp | 53 |
2 files changed, 45 insertions, 12 deletions
diff --git a/src/plugins/geoservices/mapbox/qgeofiletilecachemapbox.cpp b/src/plugins/geoservices/mapbox/qgeofiletilecachemapbox.cpp index 6ce41a2b..8cc3622b 100644 --- a/src/plugins/geoservices/mapbox/qgeofiletilecachemapbox.cpp +++ b/src/plugins/geoservices/mapbox/qgeofiletilecachemapbox.cpp @@ -87,10 +87,10 @@ QGeoTileSpec QGeoFileTileCacheMapbox::filenameToTileSpec(const QString &filename { QStringList parts = filename.split('.'); - if (parts.length() != 2) + if (parts.length() != 3) return QGeoTileSpec(); - QString name = parts.at(0); + QString name = parts.at(0) + parts.at(1); QStringList fields = name.split('-'); int length = fields.length(); diff --git a/src/plugins/geoservices/mapbox/qgeotiledmappingmanagerenginemapbox.cpp b/src/plugins/geoservices/mapbox/qgeotiledmappingmanagerenginemapbox.cpp index 3dccca4b..5404eb30 100644 --- a/src/plugins/geoservices/mapbox/qgeotiledmappingmanagerenginemapbox.cpp +++ b/src/plugins/geoservices/mapbox/qgeotiledmappingmanagerenginemapbox.cpp @@ -149,26 +149,46 @@ QGeoTiledMappingManagerEngineMapbox::QGeoTiledMappingManagerEngineMapbox(const Q m_cacheDirectory = QAbstractGeoTileCache::baseLocationCacheDirectory() + QLatin1String("mapbox"); } - // The Mapbox free plan allows for 6000 tiles to be stored for offline uses - // As of 2016.06.15, according to https://www.mapbox.com/help/mobile-offline/ , - // this translates into 45-315 MiB, depending on the map and the area. - // Setting a default limit of 300MiB, which can be overridden via parameters, if - // the plan allows for more data to be stored offline. - // NOTE: - // It is illegal to violate Mapbox Terms of Service, setting a limit that exceeds - // what the plan the token belongs to allows. - QGeoFileTileCache *tileCache = new QGeoFileTileCacheMapbox(mapTypes, scaleFactor, m_cacheDirectory); + /* + * Disk cache setup -- defaults to Unitary since: + * + * The Mapbox free plan allows for 6000 tiles to be stored for offline uses, + * As of 2016.06.15, according to https://www.mapbox.com/help/mobile-offline/ . + * Thus defaulting to Unitary strategy, and setting 6000 tiles as default cache disk size + */ + if (parameters.contains(QStringLiteral("mapbox.mapping.cache.disk.cost_strategy"))) { + QString cacheStrategy = parameters.value(QStringLiteral("mapbox.mapping.cache.disk.cost_strategy")).toString().toLower(); + if (cacheStrategy == QLatin1String("bytesize")) + tileCache->setCostStrategyDisk(QGeoFileTileCache::ByteSize); + else + tileCache->setCostStrategyDisk(QGeoFileTileCache::Unitary); + } else { + tileCache->setCostStrategyDisk(QGeoFileTileCache::Unitary); + } if (parameters.contains(QStringLiteral("mapbox.mapping.cache.disk.size"))) { bool ok = false; int cacheSize = parameters.value(QStringLiteral("mapbox.mapping.cache.disk.size")).toString().toInt(&ok); if (ok) tileCache->setMaxDiskUsage(cacheSize); } else { - tileCache->setMaxDiskUsage(300 * 1024 * 1024); + if (tileCache->costStrategyDisk() == QGeoFileTileCache::Unitary) + tileCache->setMaxDiskUsage(6000); // The maximum allowed with the free tier } + /* + * Memory cache setup -- defaults to ByteSize (old behavior) + */ + if (parameters.contains(QStringLiteral("mapbox.mapping.cache.memory.cost_strategy"))) { + QString cacheStrategy = parameters.value(QStringLiteral("mapbox.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("mapbox.mapping.cache.memory.size"))) { bool ok = false; int cacheSize = parameters.value(QStringLiteral("mapbox.mapping.cache.memory.size")).toString().toInt(&ok); @@ -176,6 +196,18 @@ QGeoTiledMappingManagerEngineMapbox::QGeoTiledMappingManagerEngineMapbox(const Q tileCache->setMaxMemoryUsage(cacheSize); } + /* + * Texture cache setup -- defaults to ByteSize (old behavior) + */ + if (parameters.contains(QStringLiteral("mapbox.mapping.cache.texture.cost_strategy"))) { + QString cacheStrategy = parameters.value(QStringLiteral("mapbox.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("mapbox.mapping.cache.texture.size"))) { bool ok = false; int cacheSize = parameters.value(QStringLiteral("mapbox.mapping.cache.texture.size")).toString().toInt(&ok); @@ -183,6 +215,7 @@ QGeoTiledMappingManagerEngineMapbox::QGeoTiledMappingManagerEngineMapbox(const Q tileCache->setExtraTextureUsage(cacheSize); } + setTileCache(tileCache); *error = QGeoServiceProvider::NoError; |