Tile download manager handles downloads of map tiles for the purpose of map rendering.
More...
Tile download manager handles downloads of map tiles for the purpose of map rendering.
The purpose of this class is to handle a couple of situations that may happen:
- a map rendering job starts which requests tiles from a remote server, then in a short while user zooms/pans map, which would normally mean that all pending requests get aborted and then restarted soon afterwards. The download manager allows the requests to finish to avoid excessive load on servers and needless aborts and repeated requests.
- multiple map rendering jobs start at a similar time, requesting the same map tiles. Normally they could be requested multiple times from the server - the download manager groups these requests and only does a single request at a time.
At this point, it is not recommended to use this class for other scenarios than map rendering: using it elsewhere could slow down map rendering or have some unexpected negative effects.
How do things work:
- Upon a request, a QgsTileDownloadManagerReply object (based on QObject) is returned, encapsulating the pending reply. Client can wait for its finished() signal - when it gets emitted, the request has finished with success or failure. Client can delete the reply object before the request is processed - download manager will finish its download (and it will get cached for a future use).
- All requests are done by QgsNetworkAccessManager
- A worker thread responsible for all network tile requests is started first time a tile is requested. Having a dedicated thread rather than reusing main thread makes things more predictable as we won't get stuck in case the main thread is doing some work or it is waiting for map rendering to finish.
- There is a shared download queue (protected by a mutex) with a list of active requests and requests waiting to be processed.
- Added in QGIS 3.26: If the request is an HTTP range request, the data may be cached into a local directory using QgsRangeRequestCache to avoid requesting the same data excessively. Caching will be disabled for requests with CacheLoadControlAttribute set to AlwaysNetwork or CacheSaveControlAttribute set to false
- Since
- QGIS 3.18
Definition at line 202 of file qgstiledownloadmanager.h.