Auto-update: Fri Nov 15 14:45:24 PST 2024
This commit is contained in:
parent
6349e6ed61
commit
2ed65c0960
1 changed files with 11 additions and 8 deletions
|
@ -125,10 +125,10 @@ async def get_last_location() -> Optional[Location]:
|
||||||
|
|
||||||
|
|
||||||
async def generate_and_save_heatmap(
|
async def generate_and_save_heatmap(
|
||||||
start_date: Union[str, int, datetime],
|
start_date: Union[str, int, datetime],
|
||||||
end_date: Optional[Union[str, int, datetime]] = None,
|
end_date: Optional[Union[str, int, datetime]] = None,
|
||||||
output_path: Optional[Path] = None
|
output_path: Optional[Path] = None
|
||||||
) -> Path:
|
) -> Path:
|
||||||
"""
|
"""
|
||||||
Generate a heatmap for the given date range and save it as a PNG file.
|
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)
|
lat_diff = max(lats) - min(lats)
|
||||||
lon_diff = max(lons) - min(lons)
|
lon_diff = max(lons) - min(lons)
|
||||||
|
|
||||||
# Calculate zoom level - lower number = more zoomed out
|
# Calculate zoom level using system config
|
||||||
zoom = min(
|
zoom = min(
|
||||||
Gis.map.max_zoom,
|
Gis.map.max_zoom,
|
||||||
int(math.log2(360 / max(lat_diff, lon_diff))) - 1
|
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(
|
m = StaticMap(
|
||||||
640, 360,
|
640, 360,
|
||||||
url_template='https://cartodb-basemaps-a.global.ssl.fastly.net/dark_all/{z}/{x}/{y}.png',
|
url_template='https://cartodb-basemaps-a.global.ssl.fastly.net/dark_all/{z}/{x}/{y}.png'
|
||||||
zoom=zoom
|
|
||||||
)
|
)
|
||||||
|
|
||||||
|
# Set zoom level after creation
|
||||||
|
m.zoom = zoom
|
||||||
|
|
||||||
# Add markers with heat effect
|
# Add markers with heat effect
|
||||||
for loc in locations:
|
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):
|
async def generate_map(start_date: datetime, end_date: datetime, max_points: int):
|
||||||
locations = await fetch_locations(start_date, end_date)
|
locations = await fetch_locations(start_date, end_date)
|
||||||
if not locations:
|
if not locations:
|
||||||
|
|
Loading…
Add table
Reference in a new issue