AmonRaNet / QGeoView

QGeoView is a Qt / C ++ widget for visualizing geographic data.
GNU Lesser General Public License v3.0
149 stars 56 forks source link

Add Cache for Online Tile #25

Closed muby closed 1 year ago

muby commented 2 years ago

First of all ! Nice work !

I can suggest you to add a cache :

It could be nice to be able when you have already downloaded some tile, to be able to access it offline.

AmonRaNet commented 2 years ago

Thanks! Depends what you understand under cache.


You can create own instance of QAbstractNetworkCache and store data as you want it.

- offline tiles, which are used to make system fully offline. Here is no direct solution. 

If you want to do it without changes in QGeoView: for example you can define custom "offline" url scheme and create custom QNetworkAccessManager, which will use custom scheme as sign for "offline" files. Then you can define as layer QGVLayerOSM with QGVLayerOSM::setUrl("offline://${z}/${x}/${y}.png"). Simplest is to use files directly on disk, in this case no custom scheme needed: QGVLayerOSM::setUrl("file://path/to/${z}/${x}/${y}.png").

Other way is create new `class QGVLayerTilesOffline : public QGVLayerTiles` (please look to QGVLayerTilesOnline) and override QGVLayerTiles::request. Then you can load image for tile from any source and call after QGVLayerTiles::onTile with image item.

P.S.
In any case you need somehow create offline cache of tiles - and this is completely other topic. QGeoView will not help much with this. Please, be careful about legacy aspects and copyright. Especially about Google, Bing.