env-canada 0.11.1__py3-none-any.whl → 0.11.2__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
env_canada/constants.py CHANGED
@@ -1 +1 @@
1
- USER_AGENT = "env_canada/0.11.1"
1
+ USER_AGENT = "env_canada/0.11.2"
env_canada/ec_map.py CHANGED
@@ -168,15 +168,20 @@ class ECMap:
168
168
  self._font = None
169
169
  self.timestamp = None
170
170
 
171
+ def _get_cache_prefix(self):
172
+ """Generate a location-specific cache prefix based on bounding box."""
173
+ return f"{self.bbox[0]:.3f},{self.bbox[1]:.3f},{self.bbox[2]:.3f},{self.bbox[3]:.3f}"
174
+
171
175
  async def _get_basemap(self):
172
176
  """Fetch the background map image."""
173
- if base_bytes := Cache.get("basemap"):
177
+ basemap_cache_key = f"{self._get_cache_prefix()}-basemap"
178
+ if base_bytes := Cache.get(basemap_cache_key):
174
179
  return base_bytes
175
180
 
176
181
  basemap_params.update(self.map_params)
177
182
  try:
178
183
  base_bytes = await _get_resource(basemap_url, basemap_params)
179
- return Cache.add("basemap", base_bytes, timedelta(days=7))
184
+ return Cache.add(basemap_cache_key, base_bytes, timedelta(days=7))
180
185
  except ClientConnectorError as e:
181
186
  LOG.warning("Map from %s could not be retrieved: %s", basemap_url, e)
182
187
  return None
@@ -220,7 +225,7 @@ class ECMap:
220
225
  async def _get_legend(self):
221
226
  """Fetch legend image for the layer."""
222
227
 
223
- legend_cache_key = f"legend-{self.layer}"
228
+ legend_cache_key = f"{self._get_cache_prefix()}-legend-{self.layer}"
224
229
  if legend := Cache.get(legend_cache_key):
225
230
  return legend
226
231
 
@@ -269,7 +274,7 @@ class ECMap:
269
274
  async def _get_layer_image(self, frame_time):
270
275
  """Fetch image for the layer at a specific time."""
271
276
  time = frame_time.strftime("%Y-%m-%dT%H:%M:00Z")
272
- layer_cache_key = f"layer-{self.layer}-{time}"
277
+ layer_cache_key = f"{self._get_cache_prefix()}-layer-{self.layer}-{time}"
273
278
 
274
279
  if img := Cache.get(layer_cache_key):
275
280
  return img
@@ -362,11 +367,13 @@ class ECMap:
362
367
  composite.save(img_byte_arr, format="PNG")
363
368
 
364
369
  return Cache.add(
365
- f"composite-{time}", img_byte_arr.getvalue(), timedelta(minutes=200)
370
+ f"{self._get_cache_prefix()}-composite-{time}",
371
+ img_byte_arr.getvalue(),
372
+ timedelta(minutes=200),
366
373
  )
367
374
 
368
375
  time = frame_time.strftime("%Y-%m-%dT%H:%M:00Z")
369
- cache_key = f"composite-{time}"
376
+ cache_key = f"{self._get_cache_prefix()}-composite-{time}"
370
377
 
371
378
  if img := Cache.get(cache_key):
372
379
  return img
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: env_canada
3
- Version: 0.11.1
3
+ Version: 0.11.2
4
4
  Summary: A package to access meteorological data from Environment Canada
5
5
  Author-email: Michael Davie <michael.davie@gmail.com>
6
6
  Maintainer-email: Michael Davie <michael.davie@gmail.com>
@@ -1,17 +1,17 @@
1
1
  env_canada/10x20.pbm,sha256=ClKTs2WUmhUhTHAQzPuGwPTICGVBzCvos5l-vHRBE5M,2463
2
2
  env_canada/10x20.pil,sha256=Oki6-TD7b0xFtfm6vxCKsmpEpsZ5Jaia_0v_aDz8bfE,5143
3
3
  env_canada/__init__.py,sha256=EXzGEHwon-usFzLzuJeISKHlfJdV3DBa0_rR9b_XfvE,405
4
- env_canada/constants.py,sha256=LIgDz8EI__wlzoI4yz5D9tl-XPoCel8vKk45VON0DIs,33
4
+ env_canada/constants.py,sha256=pB3ld_VBSAL8c6LAUF0U2VgKhhkOmP7U6T5kLJvo938,33
5
5
  env_canada/ec_aqhi.py,sha256=oE52qfk-AKbHdhTSl5RP3vsWL-50eMRCCRVy9RW-pP4,8080
6
6
  env_canada/ec_cache.py,sha256=zb3n79ul7hUTE0IohDfZbRBLY-siOHPjYzWldMbuPVk,798
7
7
  env_canada/ec_exc.py,sha256=SBJwzmLf94lTx7KYVLfQYrMXYNYUoIxeVXc-BLkuXoE,67
8
8
  env_canada/ec_historical.py,sha256=qMr4RE6vfNiNa_zFolQ0PQGraok8bQtIVjs_o6sJKD4,16276
9
9
  env_canada/ec_hydro.py,sha256=JoBe-QVV8GEeZXCNFscIs2R_spgkbxCZpLt7tL6-NUI,4889
10
- env_canada/ec_map.py,sha256=936CN6G9ZAY9zQjuph0Xp4f9OwNnHb6qXMnk6M6bE68,15134
10
+ env_canada/ec_map.py,sha256=HIyCZ8j9EbuLX3-YhvMKjYPiE2AH_behL6IaOXjXpaQ,15564
11
11
  env_canada/ec_radar.py,sha256=dKZqWJyb66R2EJzAy4K7pii7vPK9FxDKmuW9vA1ADbw,3330
12
12
  env_canada/ec_weather.py,sha256=pFcVKBbYKLj01ocjZmy8RiQaf7YVSQOo4id_BbZ7gds,23421
13
- env_canada-0.11.1.dist-info/licenses/LICENSE,sha256=BkgGIGgy9sv-OsI7mRi9dIQ3Su0m4IbjpZlfxv8oBbM,1073
14
- env_canada-0.11.1.dist-info/METADATA,sha256=c9TtVd3BBxg1sWEdIW9kQBaceHgBWaHSS52tl4ZYsLI,13678
15
- env_canada-0.11.1.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
16
- env_canada-0.11.1.dist-info/top_level.txt,sha256=fw7Pcl9ULBXYvqnAdyBdmwPXW8GSRFmhO0sLZWVfOCc,11
17
- env_canada-0.11.1.dist-info/RECORD,,
13
+ env_canada-0.11.2.dist-info/licenses/LICENSE,sha256=BkgGIGgy9sv-OsI7mRi9dIQ3Su0m4IbjpZlfxv8oBbM,1073
14
+ env_canada-0.11.2.dist-info/METADATA,sha256=uWS4H6dImil9koOPvBxkdSJKut2gmOzsqLwjIyE2sOc,13678
15
+ env_canada-0.11.2.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
16
+ env_canada-0.11.2.dist-info/top_level.txt,sha256=fw7Pcl9ULBXYvqnAdyBdmwPXW8GSRFmhO0sLZWVfOCc,11
17
+ env_canada-0.11.2.dist-info/RECORD,,