-
Notifications
You must be signed in to change notification settings - Fork 100
Open
Description
File: map_widget.py
Problem:
When caching offline map tiles, the library uses unsafe key generation by concatenating zoom, x, and y without separators:
# Broken code (map_widget.py)
def get_tile_image_from_cache(self, zoom: int, x: int, y: int):
if f"{zoom}{x}{y}" not in self.tile_image_cache: # ← Collision risk!
return False
return self.tile_image_cache[f"{zoom}{x}{y}"]
This causes cache collisions for coordinates like (1, 10) → "110" and (11, 0) → "110", rendering wrong tiles in offline mode.
Solution:
Added separators (|) to ensure unique keys:
# Fixed code
def get_tile_image_from_cache(self, zoom: int, x: int, y: int):
if f"{zoom}|{x}|{y}" not in self.tile_image_cache:
return False
return self.tile_image_cache[f"{zoom}|{x}|{y}"]
Why It Works:
Keys now distinguish "1|10" vs "11|0"
Tested with: TkinterMapView 1.29
Metadata
Metadata
Assignees
Labels
No labels