added compass direction finding
This commit is contained in:
@@ -0,0 +1 @@
|
||||
"""Management commands for fireworks detection."""
|
||||
Binary file not shown.
@@ -0,0 +1 @@
|
||||
"""Fireworks detection management commands."""
|
||||
Binary file not shown.
@@ -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()}."
|
||||
)
|
||||
)
|
||||
Reference in New Issue
Block a user