gws.gis.cache.core¶
Tile cache inventory, filtering and maintenance.
Source code: gws.gis.cache.core
Module Contents¶
- gws.gis.cache.core.add_stats(inv: Inventory)¶
Read store statistics into the inventory.
Sets the number and size of stored tiles and the percentage cached for each level and cache.
- Parameters:
inv – Inventory to update.
- gws.gis.cache.core.apply_filter(inv: Inventory, flt: Filter)¶
Filter the inventory in place.
Selects caches by layer, cache name prefix and CRS, then restricts their levels to
flt.levelsand to the tile ranges coveringflt.bbox, which must be in the CRS of the caches. Caches without levels are removed.- Parameters:
inv – Inventory to filter.
flt – Filter.
- class gws.gis.cache.core.Cache(*args, **kwargs)¶
Bases:
gws.DataA tile cache, shared by all layers with the same cache name.
- grabber: gws.Grabber¶
Grabber of the first layer that uses this cache.
- gws.gis.cache.core.cleanup(root: gws.Root)¶
Remove orphan cache directories.
- Parameters:
root – Configuration root.
- gws.gis.cache.core.drop(root: gws.Root, flt: Filter | None = None)¶
Remove cached tiles.
If the filter has neither levels nor a bbox, the whole store of each selected cache is removed. Otherwise, the tile ranges covering the bbox, or the selected levels, are removed.
- Parameters:
root – Configuration root.
flt – Filter, selects all caches if omitted.
- class gws.gis.cache.core.Filter(*args, **kwargs)¶
Bases:
gws.DataSelects caches, levels and tiles from an inventory. Empty fields select everything.
- bbox: gws.Bounds | None¶
Select tiles in this area, which must be in the CRS of the caches.
- class gws.gis.cache.core.GlobalConfig(*args, **kwargs)¶
Bases:
gws.ConfigGlobal tile cache options.
- seedingMaxTime: gws.Duration = '10m'¶
Time limit for a cache seeding run.
- class gws.gis.cache.core.Inventory(*args, **kwargs)¶
Bases:
gws.DataAll tile caches of a configuration.
- gws.gis.cache.core.inventory(root: gws.Root) Inventory¶
Collect all tile caches of a configuration.
Caches are taken from the grabbers of all layers, skipping grabbers with a zero max. age. Each cache gets its levels up to the cache max. level and the existing cache directory. Directories in the cache directory that belong to no cache are listed as orphans. Statistics are not computed here, see
add_stats.- Parameters:
root – Configuration root.
- Returns:
The inventory, caches sorted by layer type, layer title and name.
- class gws.gis.cache.core.LayerConfig(*args, **kwargs)¶
Bases:
gws.ConfigTile cache settings of a layer.
- crs: list[gws.CrsName] | None¶
CRS to cache tiles in. (added in 8.5)
- maxAge: gws.Duration = '7d'¶
Max. age of cached tiles.
- class gws.gis.cache.core.Level(*args, **kwargs)¶
Bases:
gws.DataA zoom level of a cache, with statistics.
- cachedRange: gws.MapTileRange | None¶
Bounding tile range of the stored tiles.
- gridRange: gws.MapTileRange¶
Tile range of the level, possibly restricted by a filter.
- gws.gis.cache.core.percent_cached(lv: Level) int¶
Compute the percentage of cached and fetched tiles of a level.
- Parameters:
lv – Level.
- Returns:
A percentage from 0 to 100, at least 1 if any tile is present.
- gws.gis.cache.core.percentage_by_level(c: Cache) list[int]¶
Compute the cached percentages of all levels of a cache.
- Parameters:
c – Cache.
- Returns:
A list of percentages indexed by level, up to the cache max. level. Levels not in the cache are 0.