From a6c848032251356abf43f477191ec68a2638f403 Mon Sep 17 00:00:00 2001 From: sanj <67624670+iodrift@users.noreply.github.com> Date: Fri, 15 Nov 2024 13:17:13 -0800 Subject: [PATCH] Auto-update: Fri Nov 15 13:17:13 PST 2024 --- sijapi/routers/gis.py | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/sijapi/routers/gis.py b/sijapi/routers/gis.py index 6d074c3..44443ce 100644 --- a/sijapi/routers/gis.py +++ b/sijapi/routers/gis.py @@ -124,7 +124,6 @@ async def get_last_location() -> Optional[Location]: - async def generate_and_save_heatmap( start_date: Union[str, int, datetime], end_date: Optional[Union[str, int, datetime]] = None, @@ -139,6 +138,8 @@ Generate a heatmap for the given date range and save it as a PNG file. :return: The path where the PNG file was saved """ try: + from staticmap import StaticMap, CircleMarker + start_date = await dt(start_date) if end_date: end_date = await dt(end_date) @@ -149,12 +150,15 @@ Generate a heatmap for the given date range and save it as a PNG file. if not locations: raise ValueError("No locations found for the given date range") - # Create map - m = StaticMap(640, 360, url_template='https://cartodb-basemaps-{s}.global.ssl.fastly.net/dark_all/{z}/{x}/{y}.png') + # Create map with correct URL template + m = StaticMap( + 640, 360, + url_template='https://cartodb-basemaps-a.global.ssl.fastly.net/dark_all/{z}/{x}/{y}.png' + ) # Add markers with heat effect for loc in locations: - marker = CircleMarker((loc.longitude, loc.latitude), 'red', 12) + marker = CircleMarker((loc.longitude, loc.latitude), '#ff0000', 12) m.add_marker(marker) # Render the image