Mahmudm commited on
Commit
571406a
·
verified ·
1 Parent(s): 1dc4911

Update ash_animator/basemaps.py

Browse files
Files changed (1) hide show
  1. ash_animator/basemaps.py +5 -10
ash_animator/basemaps.py CHANGED
@@ -1,3 +1,4 @@
 
1
 
2
  # import contextily as ctx
3
  # from mpl_toolkits.basemap import Basemap
@@ -42,17 +43,11 @@ import matplotlib.pyplot as plt
42
  # Optional: Set tile cache directory (must be done before contextily downloads tiles)
43
  os.environ["XDG_CACHE_HOME"] = os.path.expanduser("~/.contextily_cache")
44
 
45
- #CTX_TILE_CACHE_DIR = os.path.expanduser("~/.contextily_cache")
46
- #BASEMAP_TILE_CACHE_DIR = os.path.expanduser("~/.basemap_cache")
47
-
48
- import tempfile
49
-
50
- CTX_TILE_CACHE_DIR = os.path.join(tempfile.gettempdir(), "contextily_cache")
51
- os.makedirs(CTX_TILE_CACHE_DIR, exist_ok=True)
52
-
53
 
54
  os.makedirs(CTX_TILE_CACHE_DIR, exist_ok=True)
55
- os.makedirs(BASEMAP_TILE_CACHE_DIR, exist_ok=True)
56
 
57
  def draw_etopo_basemap(ax, mode="basemap", zoom=11):
58
  """
@@ -99,7 +94,7 @@ def draw_etopo_basemap(ax, mode="basemap", zoom=11):
99
  # Create a hash key for this extent
100
  extent_str = f"{extent[0]:.4f}_{extent[1]:.4f}_{extent[2]:.4f}_{extent[3]:.4f}"
101
  cache_key = hashlib.md5(extent_str.encode()).hexdigest()
102
- cache_file = os.path.join(BASEMAP_TILE_CACHE_DIR, f"{cache_key}_highres.png")
103
 
104
  if os.path.exists(cache_file):
105
  img = Image.open(cache_file)
 
1
+ import tempfile
2
 
3
  # import contextily as ctx
4
  # from mpl_toolkits.basemap import Basemap
 
43
  # Optional: Set tile cache directory (must be done before contextily downloads tiles)
44
  os.environ["XDG_CACHE_HOME"] = os.path.expanduser("~/.contextily_cache")
45
 
46
+ CTX_TILE_CACHE_DIR = os.path.expanduser("~/.contextily_cache")
47
+ os.path.join(tempfile.gettempdir(), 'contextily_cache') = os.path.expanduser("~/.basemap_cache")
 
 
 
 
 
 
48
 
49
  os.makedirs(CTX_TILE_CACHE_DIR, exist_ok=True)
50
+ os.makedirs(os.path.join(tempfile.gettempdir(), 'contextily_cache'), exist_ok=True)
51
 
52
  def draw_etopo_basemap(ax, mode="basemap", zoom=11):
53
  """
 
94
  # Create a hash key for this extent
95
  extent_str = f"{extent[0]:.4f}_{extent[1]:.4f}_{extent[2]:.4f}_{extent[3]:.4f}"
96
  cache_key = hashlib.md5(extent_str.encode()).hexdigest()
97
+ cache_file = os.path.join(os.path.join(tempfile.gettempdir(), 'contextily_cache'), f"{cache_key}_highres.png")
98
 
99
  if os.path.exists(cache_file):
100
  img = Image.open(cache_file)