From 139ea6d06bbd092da8b38c99989c8e124c10cea6 Mon Sep 17 00:00:00 2001 From: josihoppe <116898820+josihoppe@users.noreply.github.com> Date: Tue, 2 Apr 2024 13:21:07 +0200 Subject: [PATCH] added new layer for clearer region boundaries --- config/settings/base.py | 3 +++ .../map/migrations/0045_regionboundaries.py | 25 +++++++++++++++++++ digiplan/map/models.py | 17 +++++++++++++ digiplan/static/config/layer_styles.json | 7 ++++++ digiplan/utils/data_processing.py | 1 + 5 files changed, 53 insertions(+) create mode 100644 digiplan/map/migrations/0045_regionboundaries.py diff --git a/config/settings/base.py b/config/settings/base.py index ef999a4f..270c5cf9 100644 --- a/config/settings/base.py +++ b/config/settings/base.py @@ -316,6 +316,7 @@ def __getitem__(self, item): # noqa: D105, ANN001, ANN204 setup.MVTAPI("potentialarea_pv_roof", "map", "PotentialareaPVRoof"), ], "static": [ + setup.MVTAPI("region_boundaries", "map", "RegionBoundaries"), setup.MVTAPI("landscape_protection_area", "map", "LandscapeProtectionArea"), setup.MVTAPI("forest", "map", "Forest"), setup.MVTAPI("special_protection_area", "map", "SpecialProtectionArea"), @@ -359,6 +360,8 @@ def __getitem__(self, item): # noqa: D105, ANN001, ANN204 setup.ClusterAPI("storage", "map", "Storage", properties=["id", "unit_count"]), ] +MAP_ENGINE_LAYERS_AT_STARTUP = [("region_boundaries", "map", "RegionBoundaries")] + MAP_ENGINE_STYLES_FOLDER = "digiplan/static/config/" MAP_ENGINE_ZOOM_LEVELS = { "municipality": setup.Zoom(8, 14), diff --git a/digiplan/map/migrations/0045_regionboundaries.py b/digiplan/map/migrations/0045_regionboundaries.py new file mode 100644 index 00000000..40db7c65 --- /dev/null +++ b/digiplan/map/migrations/0045_regionboundaries.py @@ -0,0 +1,25 @@ +# Generated by Django 3.2.25 on 2024-03-28 10:53 + +import django.contrib.gis.db.models.fields +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('map', '0044_merge_20240318_1859'), + ] + + operations = [ + migrations.CreateModel( + name='RegionBoundaries', + fields=[ + ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), + ('geom', django.contrib.gis.db.models.fields.MultiPolygonField(srid=4326)), + ], + options={ + 'verbose_name': 'RegionBoundaries', + 'verbose_name_plural': 'RegionBoundaries', + }, + ), + ] diff --git a/digiplan/map/models.py b/digiplan/map/models.py index 98a62113..cf5310b9 100644 --- a/digiplan/map/models.py +++ b/digiplan/map/models.py @@ -98,6 +98,23 @@ def quantity_per_municipality_per_year(cls) -> pd.DataFrame: return population_per_year +class RegionBoundaries(models.Model): + """Region Boundaries model.""" + + geom = models.MultiPolygonField(srid=4326) + + objects = models.Manager() + vector_tiles = StaticMVTManager(columns=[]) + + data_file = "bkg_vg250_region" + layer = "bkg_vg250_region" + mapping = {"geom": "MULTIPOLYGON"} + + class Meta: # noqa: D106 + verbose_name = _("RegionBoundaries") + verbose_name_plural = _("RegionBoundaries") + + class RenewableModel(models.Model): """Base class for renewable cluster models.""" diff --git a/digiplan/static/config/layer_styles.json b/digiplan/static/config/layer_styles.json index 407fac11..167c642b 100644 --- a/digiplan/static/config/layer_styles.json +++ b/digiplan/static/config/layer_styles.json @@ -67,6 +67,13 @@ ] } }, + "region_boundaries": { + "type": "line", + "paint": { + "line-color": "rgb(250, 174, 29)", + "line-width": 3 + } + }, "wind": { "type": "symbol", "filter": ["!", ["has", "point_count"]], diff --git a/digiplan/utils/data_processing.py b/digiplan/utils/data_processing.py index d36f1349..63915c68 100644 --- a/digiplan/utils/data_processing.py +++ b/digiplan/utils/data_processing.py @@ -15,6 +15,7 @@ REGIONS = [models.Municipality] MODELS = [ + models.RegionBoundaries, # Clusters models.WindTurbine, models.PVroof,