From 1104a11c9c93df8b52cdd0b62b5eae74cf5e2ba8 Mon Sep 17 00:00:00 2001
From: sanj <67624670+iodrift@users.noreply.github.com>
Date: Fri, 15 Nov 2024 14:45:24 -0800
Subject: [PATCH] Auto-update: Fri Nov 15 14:45:24 PST 2024

---
 sijapi/routers/gis.py | 19 +++++++++++--------
 1 file changed, 11 insertions(+), 8 deletions(-)

diff --git a/sijapi/routers/gis.py b/sijapi/routers/gis.py
index 0f35598..b9c43ee 100644
--- a/sijapi/routers/gis.py
+++ b/sijapi/routers/gis.py
@@ -125,10 +125,10 @@ 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,
-    output_path: Optional[Path] = None
-) -> Path:
+        start_date: Union[str, int, datetime],
+        end_date: Optional[Union[str, int, datetime]] = None,
+        output_path: Optional[Path] = None
+    ) -> Path:
     """
 Generate a heatmap for the given date range and save it as a PNG file.
 
@@ -157,18 +157,20 @@ Generate a heatmap for the given date range and save it as a PNG file.
         lat_diff = max(lats) - min(lats)
         lon_diff = max(lons) - min(lons)
         
-        # Calculate zoom level - lower number = more zoomed out
+        # Calculate zoom level using system config
         zoom = min(
             Gis.map.max_zoom,
             int(math.log2(360 / max(lat_diff, lon_diff))) - 1
         )
 
-        # Create map with correct URL template and zoom
+        # 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',
-            zoom=zoom
+            url_template='https://cartodb-basemaps-a.global.ssl.fastly.net/dark_all/{z}/{x}/{y}.png'
         )
+        
+        # Set zoom level after creation
+        m.zoom = zoom
 
         # Add markers with heat effect
         for loc in locations:
@@ -191,6 +193,7 @@ Generate a heatmap for the given date range and save it as a PNG file.
 
 
 
+
 async def generate_map(start_date: datetime, end_date: datetime, max_points: int):
     locations = await fetch_locations(start_date, end_date)
     if not locations: