step 4: add async tiles and persistent cache
This commit is contained in:
@@ -14,6 +14,7 @@ from .commands import MapCommandQueue
|
||||
from .exceptions import InvalidProviderError, MapNotFoundError
|
||||
from .overlays import LayerState, Overlay
|
||||
from .providers import TileProvider, get_default_provider, get_provider
|
||||
from .tiles import TileManager
|
||||
from .types import LatLon, Tag
|
||||
|
||||
|
||||
@@ -44,16 +45,6 @@ class DpgMapConfig:
|
||||
debug: bool = False
|
||||
|
||||
|
||||
@dataclass(slots=True)
|
||||
class TileManagerState:
|
||||
"""Logical tile/cache counters until the tile manager is implemented."""
|
||||
|
||||
queued_tiles: int = 0
|
||||
loading_tiles: int = 0
|
||||
failed_tiles: int = 0
|
||||
visible_tile_count: int = 0
|
||||
|
||||
|
||||
@dataclass(slots=True)
|
||||
class InteractionState:
|
||||
"""Logical interaction state until GUI interaction is implemented."""
|
||||
@@ -103,7 +94,7 @@ class MapState:
|
||||
overlays: dict[Tag, Overlay] = field(default_factory=dict)
|
||||
layers: dict[str, LayerState] = field(default_factory=default_layers)
|
||||
command_queue: MapCommandQueue = field(default_factory=MapCommandQueue)
|
||||
tile_manager: TileManagerState = field(default_factory=TileManagerState)
|
||||
tile_manager: TileManager = field(default_factory=TileManager)
|
||||
renderer: object | None = None
|
||||
interaction: InteractionState = field(default_factory=InteractionState)
|
||||
lock: RLock = field(default_factory=RLock)
|
||||
@@ -238,6 +229,12 @@ def create_map_state(
|
||||
cache_dir=resolved_cache_dir,
|
||||
user_agent=user_agent if user_agent is not None else config.user_agent,
|
||||
)
|
||||
state.tile_manager = TileManager(
|
||||
memory_cache_max_tiles=config.memory_cache_max_tiles,
|
||||
disk_cache_max_bytes=config.disk_cache_max_bytes,
|
||||
worker_count=config.tile_worker_count,
|
||||
user_agent=state.user_agent,
|
||||
)
|
||||
with _maps_lock:
|
||||
_maps[map_tag] = state
|
||||
return state
|
||||
|
||||
Reference in New Issue
Block a user