From 982da35321450814925d471c3c14771366f52759 Mon Sep 17 00:00:00 2001
From: csae8092
Date: Mon, 9 Dec 2024 13:55:44 +0100
Subject: [PATCH] adds lat/lng for edges
---
network/management/commands/edges.py | 6 +++
...dge_source_lng_edge_target_lat_and_more.py | 33 +++++++++++++++
...urce_lat_alter_edge_source_lng_and_more.py | 41 +++++++++++++++++++
network/models.py | 4 ++
4 files changed, 84 insertions(+)
create mode 100644 network/migrations/0003_edge_source_lat_edge_source_lng_edge_target_lat_and_more.py
create mode 100644 network/migrations/0004_alter_edge_source_lat_alter_edge_source_lng_and_more.py
diff --git a/network/management/commands/edges.py b/network/management/commands/edges.py
index c7cd42e..95eb06d 100644
--- a/network/management/commands/edges.py
+++ b/network/management/commands/edges.py
@@ -41,6 +41,12 @@ def handle(self, *args, **kwargs):
"start_date": x.start_date,
"end_date": x.end_date,
}
+ if source_kind == "place":
+ item["source_lat"] = source_obj.lat
+ item["source_lng"] = source_obj.lng
+ if target_kind == "place":
+ item["target_lat"] = target_obj.lat
+ item["target_lng"] = target_obj.lng
try:
Edge.objects.create(**item)
except Exception as e:
diff --git a/network/migrations/0003_edge_source_lat_edge_source_lng_edge_target_lat_and_more.py b/network/migrations/0003_edge_source_lat_edge_source_lng_edge_target_lat_and_more.py
new file mode 100644
index 0000000..2b689f2
--- /dev/null
+++ b/network/migrations/0003_edge_source_lat_edge_source_lng_edge_target_lat_and_more.py
@@ -0,0 +1,33 @@
+# Generated by Django 5.1.3 on 2024-12-09 12:18
+
+from django.db import migrations, models
+
+
+class Migration(migrations.Migration):
+
+ dependencies = [
+ ("network", "0002_alter_edge_options_alter_edge_source_kind_and_more"),
+ ]
+
+ operations = [
+ migrations.AddField(
+ model_name="edge",
+ name="source_lat",
+ field=models.FloatField(blank=True, null=True, verbose_name="Breitengrad"),
+ ),
+ migrations.AddField(
+ model_name="edge",
+ name="source_lng",
+ field=models.FloatField(blank=True, null=True, verbose_name="Längengrad"),
+ ),
+ migrations.AddField(
+ model_name="edge",
+ name="target_lat",
+ field=models.FloatField(blank=True, null=True, verbose_name="Breitengrad"),
+ ),
+ migrations.AddField(
+ model_name="edge",
+ name="target_lng",
+ field=models.FloatField(blank=True, null=True, verbose_name="Längengrad"),
+ ),
+ ]
diff --git a/network/migrations/0004_alter_edge_source_lat_alter_edge_source_lng_and_more.py b/network/migrations/0004_alter_edge_source_lat_alter_edge_source_lng_and_more.py
new file mode 100644
index 0000000..c20d51a
--- /dev/null
+++ b/network/migrations/0004_alter_edge_source_lat_alter_edge_source_lng_and_more.py
@@ -0,0 +1,41 @@
+# Generated by Django 5.1.3 on 2024-12-09 12:32
+
+from django.db import migrations, models
+
+
+class Migration(migrations.Migration):
+
+ dependencies = [
+ ("network", "0003_edge_source_lat_edge_source_lng_edge_target_lat_and_more"),
+ ]
+
+ operations = [
+ migrations.AlterField(
+ model_name="edge",
+ name="source_lat",
+ field=models.FloatField(
+ blank=True, null=True, verbose_name="Breitengrad (Start)"
+ ),
+ ),
+ migrations.AlterField(
+ model_name="edge",
+ name="source_lng",
+ field=models.FloatField(
+ blank=True, null=True, verbose_name="Längengrad (Start)"
+ ),
+ ),
+ migrations.AlterField(
+ model_name="edge",
+ name="target_lat",
+ field=models.FloatField(
+ blank=True, null=True, verbose_name="Breitengrad (Ziel)"
+ ),
+ ),
+ migrations.AlterField(
+ model_name="edge",
+ name="target_lng",
+ field=models.FloatField(
+ blank=True, null=True, verbose_name="Längengrad (Ziel)"
+ ),
+ ),
+ ]
diff --git a/network/models.py b/network/models.py
index 765e282..3c336ec 100644
--- a/network/models.py
+++ b/network/models.py
@@ -47,6 +47,8 @@ class Edge(models.Model):
verbose_name="Art der Quelle",
help_text="Art der Quelle (Person, Ort, Werk, Institution, Ereignis)",
)
+ source_lat = models.FloatField(blank=True, null=True, verbose_name="Breitengrad (Start)")
+ source_lng = models.FloatField(blank=True, null=True, verbose_name="Längengrad (Start)")
source_id = models.IntegerField(
verbose_name="ID der Quelle", help_text="ID der Quelle"
)
@@ -66,6 +68,8 @@ class Edge(models.Model):
verbose_name="Art des Ziels",
help_text="Art des Ziels (Person, Ort, Werk, Institution, Ereignis)",
)
+ target_lat = models.FloatField(blank=True, null=True, verbose_name="Breitengrad (Ziel)")
+ target_lng = models.FloatField(blank=True, null=True, verbose_name="Längengrad (Ziel)")
target_id = models.IntegerField(
verbose_name="ID des Ziels", help_text="ID des Ziels"
)