added compass direction finding

This commit is contained in:
Joren de Graaf
2026-10-01 16:38:13 +02:00
parent 9ebf24e028
commit 8f838715dd
80 changed files with 3369 additions and 64 deletions
+1
View File
@@ -0,0 +1 @@
"""Management commands for fireworks detection."""
@@ -0,0 +1 @@
"""Fireworks detection management commands."""
@@ -0,0 +1,25 @@
from django.core.management.base import BaseCommand
from fireworks_detect.h3_utils import cell_from_coordinates, h3_resolution
from fireworks_detect.models import Event, PendingEvent
class Command(BaseCommand):
help = "Populate H3 cells for coordinate-bearing Pending and approved events."
def handle(self, *args, **options):
updated = 0
for model in (PendingEvent, Event):
for record in model.objects.exclude(latitude__isnull=True).exclude(longitude__isnull=True):
h3_cell = cell_from_coordinates(record.latitude, record.longitude)
if record.h3_cell == h3_cell:
continue
record.h3_cell = h3_cell
record.save(update_fields=["h3_cell"])
updated += 1
self.stdout.write(
self.style.SUCCESS(
f"Updated {updated} record(s) at H3 resolution {h3_resolution()}."
)
)