zooui.tilesystem.tileproviders.dynamictileprovider module¶
Class for loading tiles into memory from somewhere other than the local filesystem (abstract base class).
- class zooui.tilesystem.tileproviders.dynamictileprovider.DynamicTileProvider(tilecache)[source]¶
Bases:
TileProvider- Constructor :
DynamicTileProvider(tilecache)
- Parameters :
tilecache : TileCache
DynamicTileProvider(tilecache) –> DynamicTileProvider
DynamicTileProvider objects are used for either generating tiles or loading them from a remote host, and then loading them into a TileCache.
This is an abstract base class for tile providers that create tiles dynamically (either by generation or remote retrieval) rather than loading pre-existing tiles from disk. Derived classes must implement the _load_dynamic() method.
- Implementation Notes:
Inherits from TileProvider base class
Provides default values for filext, tilesize, and aspect_ratio
_load() checks if tile exists locally before calling _load_dynamic()
Uses PIL for loading tiles after they are created
Derived classes should override _load_dynamic() to implement specific tile generation or retrieval logic
Dynamic Tile Provider Flow (Fern Example):
┌─────────────────────────┐ | ┌──────────┐ ┌────────────────────┐ │ FernDynamicTileProvider │ | │ Load │ │ Generate tile │ │ receives request │ | │ cached │ │ algorithmically │ └────────────┬────────────┘ | │ tile │ │ • Calculate fern │ │ | └────┬─────┘ │ parameters │ ▼ | │ │ • Draw fractal │ ┌─────────────────────────┐ | │ │ • Create image │ │ Parse tile ID │ | │ └─────┬──────────────┘ │ • Zoom level │ | │ │ │ • Tile coordinates │ | └─────┬───────┘ └────────────┬────────────┘ | │ │ | ▼ ▼ | ┌─────────────────────────┐ ┌─────────────────────────┐ | │ Wrap in Tile object │ │ Check TileStore │ | └────────────┬────────────┘ │ (may have been │ | │ │ generated before) │ | ▼ └────────────┬────────────┘ | ┌─────────────────────────┐ │ | │ Store in TileCache │ ┌────┴────┐ | └────────────┬────────────┘ │ │ | │ EXISTS NEW TILE | ▼ │ │ | ┌─────────────────────────┐ ▼ ▼ | │ Save to TileStore │ | └────────────┬────────────┘ | │ | ▼ | ┌─────────────────────────┐ | │ Return to TileManager │ | └─────────────────────────┘- Constructor :
DynamicTileProvider(tilecache)
- Parameters :
tilecache : Any
DynamicTileProvider(tilecache) –> None
Create a new DynamicTileProvider with the given TileCache.
The tilecache parameter is the TileCache instance that this provider will use to store dynamically generated or retrieved tiles.
- filext = 'png'¶
- tilesize = 256¶
- aspect_ratio = 1.0¶
- _load_dynamic(tile_id, outfile)[source]¶
- Method :
DynamicTileProvider._load_dynamic(tile_id, outfile)
- Parameters :
tile_id : Tuple[str, int, int, int] outfile : str
DynamicTileProvider._load_dynamic(tile_id, outfile) –> None
Perform whatever actions necessary to load the tile identified by the given tile_id into the location given by outfile.
- _load(tile_id)[source]¶
- Method :
DynamicTileProvider._load(tile_id)
- Parameters :
tile_id : Tuple[str, int, int, int]
DynamicTileProvider._load(tile_id) –> PIL Image or None
Load a tile, generating it dynamically if it doesn’t exist locally.
The tile_id tuple contains (media_id, tilelevel, row, col). This method first checks if the tile exists in the local tilestore. If not, it calls _load_dynamic() to generate or retrieve the tile. Finally, it loads the tile as a PIL Image and returns it.
- Implementation Notes:
Gets tile path from TileStore with create=True flag
Only calls _load_dynamic() if tile file doesn’t exist
Uses PIL to load the tile after creation (safe in non-GUI threads)
Returns None if tile loading fails (logs exception)
Assumes tile is unavailable if any exception occurs