Skip to content

Commit

Permalink
Add popups for wind potential areas 2018 and 2024
Browse files Browse the repository at this point in the history
  • Loading branch information
nesnoj committed Nov 26, 2024
1 parent 41d84b6 commit d88f57f
Show file tree
Hide file tree
Showing 9 changed files with 215 additions and 0 deletions.
8 changes: 8 additions & 0 deletions config/settings/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -601,6 +601,14 @@ def __getitem__(self, item): # noqa: D105, ANN001, ANN204
f"rpg_ols_pv_ground_planned{'_distilled' if DISTILL else ''}",
popup_at_default_layer=True,
),
setup.Popup(
f"potentialarea_wind_stp_2018_eg{'_distilled' if DISTILL else ''}",
popup_at_default_layer=True,
),
setup.Popup(
f"potentialarea_wind_stp_2024_vr{'_distilled' if DISTILL else ''}",
popup_at_default_layer=True,
),
setup.Popup(
"pvground",
popup_at_default_layer=True,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# Generated by Django 4.2.16 on 2024-11-26 08:22

from django.db import migrations, models
import django.db.models.deletion


class Migration(migrations.Migration):

dependencies = [
('map', '0056_alter_waterfirstorder_geom'),
]

operations = [
migrations.AddField(
model_name='potentialareawindstp2024vr',
name='municipality_id',
field=models.ForeignKey(null=True, on_delete=django.db.models.deletion.DO_NOTHING, to='map.municipality'),
),
migrations.AddField(
model_name='potentialareawindstp2024vr',
name='vr_wen_nr',
field=models.CharField(max_length=255, null=True),
),
]
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# Generated by Django 4.2.16 on 2024-11-26 08:43

from django.db import migrations


class Migration(migrations.Migration):

dependencies = [
('map', '0057_potentialareawindstp2024vr_municipality_id_and_more'),
]

operations = [
migrations.AlterModelOptions(
name='potentialareawindstp2024vr',
options={'verbose_name': 'Vorranggebiet 1. Entwurf 2024', 'verbose_name_plural': 'Vorranggebiete 1. Entwurf 2024'},
),
]
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Generated by Django 4.2.16 on 2024-11-26 08:53

from django.db import migrations


class Migration(migrations.Migration):

dependencies = [
('map', '0058_alter_potentialareawindstp2024vr_options'),
]

operations = [
migrations.RenameField(
model_name='potentialareawindstp2024vr',
old_name='municipality_id',
new_name='mun_id',
),
]
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# Generated by Django 4.2.16 on 2024-11-26 08:57

from django.db import migrations


class Migration(migrations.Migration):

dependencies = [
('map', '0059_rename_municipality_id_potentialareawindstp2024vr_mun_id'),
]

operations = [
migrations.AlterModelOptions(
name='potentialareawindstp2024vr',
options={'verbose_name': 'Windvorranggebiet 1. Entwurf 2024', 'verbose_name_plural': 'Windvorranggebiete 1. Entwurf 2024'},
),
]
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# Generated by Django 4.2.16 on 2024-11-26 09:11

from django.db import migrations, models
import django.db.models.deletion


class Migration(migrations.Migration):

dependencies = [
('map', '0060_alter_potentialareawindstp2024vr_options'),
]

operations = [
migrations.AlterModelOptions(
name='potentialareawindstp2018eg',
options={'verbose_name': 'Windeignungsgebiet 2018', 'verbose_name_plural': 'Windeignungsgebiete 2018'},
),
migrations.AddField(
model_name='potentialareawindstp2018eg',
name='mun_id',
field=models.ForeignKey(null=True, on_delete=django.db.models.deletion.DO_NOTHING, to='map.municipality'),
),
migrations.AddField(
model_name='potentialareawindstp2018eg',
name='weg_name',
field=models.CharField(max_length=255, null=True),
),
]
18 changes: 18 additions & 0 deletions digiplan/map/migrations/0062_potentialareawindstp2018eg_weg_nr.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Generated by Django 4.2.16 on 2024-11-26 09:25

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
('map', '0061_alter_potentialareawindstp2018eg_options_and_more'),
]

operations = [
migrations.AddField(
model_name='potentialareawindstp2018eg',
name='weg_nr',
field=models.IntegerField(null=True),
),
]
28 changes: 28 additions & 0 deletions digiplan/map/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -705,11 +705,39 @@ class PotentialAreaWindSTP2018EG(StaticRegionModel): # noqa: D101
data_file = "potentialarea_wind_stp_2018_eg"
layer = "potentialarea_wind_stp_2018_eg"

weg_nr = models.IntegerField(null=True)
weg_name = models.CharField(max_length=255, null=True)
mun_id = models.ForeignKey(Municipality, on_delete=models.DO_NOTHING, null=True)

mapping = {
"geom": "MULTIPOLYGON",
"weg_nr": "weg_nr",
"weg_name": "weg_name",
"mun_id": {"id": "municipality_id"},
}

class Meta: # noqa: D106
verbose_name = _("Windeignungsgebiet 2018")
verbose_name_plural = _("Windeignungsgebiete 2018")


class PotentialAreaWindSTP2024VR(StaticRegionModel): # noqa: D101
data_file = "potentialarea_wind_stp_2024_vr"
layer = "potentialarea_wind_stp_2024_vr"

vr_wen_nr = models.CharField(max_length=255, null=True)
mun_id = models.ForeignKey(Municipality, on_delete=models.DO_NOTHING, null=True)

mapping = {
"geom": "MULTIPOLYGON",
"vr_wen_nr": "vr_wen_nr",
"mun_id": {"id": "municipality_id"},
}

class Meta: # noqa: D106
verbose_name = _("Windvorranggebiet 1. Entwurf 2024")
verbose_name_plural = _("Windvorranggebiete 1. Entwurf 2024")


class PVgroundAreas(StaticRegionModel):
"""Model holding PV on ground (dataset by RPG with areas)."""
Expand Down
57 changes: 57 additions & 0 deletions digiplan/map/popups.py
Original file line number Diff line number Diff line change
Expand Up @@ -1030,6 +1030,61 @@ class WindTurbine2PlannedPopup(WindTurbine2ClusterPopup):
description = _("Geplante Windenergieanlagen (Daten: RPG Oderland-Spree, Stand: 08.10.2024)")


class WindAreaPopup(popups.Popup):
"""Wind area popup."""

description: str = None

def __init__(self, lookup: str, selected_id: int, **kwargs) -> None: # noqa: ARG002
"""Initialize popup with table template."""
self.model_lookup = lookup
super().__init__(lookup="base", selected_id=selected_id)

def get_context_data(self) -> dict:
"""Return cluster data as context data."""
model = {
"potentialarea_wind_stp_2018_eg": models.PotentialAreaWindSTP2018EG,
"potentialarea_wind_stp_2024_vr": models.PotentialAreaWindSTP2024VR,
}[self.model_lookup]
default_attributes = {}
specific_attributes = {
"mun_id": "Gemeinde",
"weg_nr": "Nr. Eignungsgebiet",
"vr_wen_nr": "Name Vorranggebiet",
}
instance = model.objects.annotate(mun_name=F("mun_id")).get(pk=self.selected_id)
data_dict = {
"title": model._meta.verbose_name, # noqa: SLF001
"description": self.description,
"data": {name: getattr(instance, key) for key, name in default_attributes.items()},
}

for key, name in specific_attributes.items():
if hasattr(instance, key):
value = getattr(instance, key)
data_dict["data"][name] = value

return data_dict


class PotentialAreaWindSTP2018EG(WindAreaPopup):
"""Popup for planned wind turbines (dataset by RPG with areas)."""

description = _(
"Windeignungsgebiet aus Sachlichem Teilregionalplan Windenergienutzung 2018. Daten: RPG Oderland-Spree",
)


class PotentialAreaWindSTP2024VRPopup(WindAreaPopup):
"""Popup for planned wind turbines (dataset by RPG with areas)."""

description = _(
"Windvorranggebiet aus 1. Entwurf des Sachlichen Teilplans Erneuerbare Energien 2024 der Regionalen "
"Planungsgemeinschaft (nicht rechtskräftig). "
"Daten: RPG Oderland-Spree, Stand: Januar 2024",
)


POPUPS: dict[str, type(popups.Popup)] = {
"wind": ClusterPopup,
"pvroof": ClusterPopup,
Expand Down Expand Up @@ -1075,4 +1130,6 @@ class WindTurbine2PlannedPopup(WindTurbine2ClusterPopup):
"rpg_ols_wind_approved": WindTurbine2ApprovedPopup,
"rpg_ols_wind_operating": WindTurbine2OperatingPopup,
"rpg_ols_wind_planned": WindTurbine2PlannedPopup,
"potentialarea_wind_stp_2018_eg": PotentialAreaWindSTP2018EG,
"potentialarea_wind_stp_2024_vr": PotentialAreaWindSTP2024VRPopup,
}

0 comments on commit d88f57f

Please sign in to comment.