Select to view content in your preferred language

Persistent Tile Cache

786
2
08-25-2020 07:02 AM
TomNorby
New Contributor II

Hi, I'm wanting to persist map tiles locally for access while internet access is poor. This will work such that closing the application and reopening it without internet displays locations previously viewed.

QMapControl has a simple implementation using something like:

p->map_control = new QMapControl(this);

p->map_control->enablePersistentCache(

std::chrono::minutes(30 * 24 * 60),
QDir(Settings::instance()->workspace().append("/").append("images")));

I suppose the implementation logic would be akin to ImageManager::getImage()

Is there something similar available in ArcGIS Runtime 100.8 Qt C++?

Many thanks!

0 Kudos
2 Replies
LucasDanzinger
Esri Frequent Contributor

If you are simply trying to cache tiles for when you intermittently lose connection, you could try modifying the network cache. You can access it through this static method - RequestConfiguration Class | ArcGIS for Developers 

This will return a NetworkCacheConfiguration, which will let you change different options - NetworkCacheConfiguration Class | ArcGIS for Developers 

This of course will only cache requests that have gone out from the device, so if you lose connection, then move to a brand new place, the tiles will not be there.

If you know your users are going to be going into areas with bad connection, you could also preemptively take an entire area offline.

Here is some doc- Work offline—ArcGIS Runtime SDK for Qt | ArcGIS for Developers 

Here is an example - arcgis-runtime-samples-qt/ArcGISRuntimeSDKQt_CppSamples/Layers/ExportTiles at master · Esri/arcgis-r... 

0 Kudos
TomNorby
New Contributor II

Thank you, seems to be exactly what I was looking for, but couldn't find it in the sdk samples.

NetworkCacheConfiguration *cache = RequestConfiguration::globalNetworkCacheConfiguration();

cache->setCacheDirectory(QDir(Settings::instance()->workspace().append("/").append("images")).path());

cache->setMaximumCacheSize(1e9);

cache->setCachePolicy(NetworkCachePolicy::PreferCache);

cache->setNetworkCachingEnabled(true);

Since workers might be working anywhere in CONUS it is a lot easier for them to just view their target location while in service and have it saved than to take the time to create an offline map specific to their need. This just works!

0 Kudos