Skip to content

Commit

Permalink
got it working
Browse files Browse the repository at this point in the history
  • Loading branch information
kruegercharles committed Mar 27, 2024
1 parent 34edfcc commit 784c10e
Show file tree
Hide file tree
Showing 4 changed files with 46 additions and 15 deletions.
27 changes: 16 additions & 11 deletions backend/construction/management/commands/import_constructions.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,17 @@ class Command(BaseCommand):
},
"""

def get_name(self, feature):
return feature["id"] # example: DE.HH.UP_TNS_STECKBRIEF_VISUALISIERUNG_18083

def get_point(self, feature):
point = Point(
feature["geometry"]["coordinates"][0],
feature["geometry"]["coordinates"][1],
srid=4326,
)
return point

def handle(self, *args, **options):
"""
Fetch construction data from priobike-map-data.
Expand All @@ -60,6 +71,11 @@ def handle(self, *args, **options):

print(f"Found {len(data['features'])} construction sites.")

try:
Construction.objects.all().delete()
except Exception as e:
print("Failed to delete existing construction sites: " + str(e))

new_construction_sites = []

for feature in data["features"]:
Expand All @@ -82,14 +98,3 @@ def handle(self, *args, **options):
print(
f"Successfully created {len(new_construction_sites)} new construction sites."
)

def get_name(self, feature):
return feature["id"] # example: DE.HH.UP_TNS_STECKBRIEF_VISUALISIERUNG_18083

def get_point(self, feature):
point = Point(
feature["geometry"]["coordinates"][0],
feature["geometry"]["coordinates"][1],
srid=25832,
).transform(settings.LONLAT, clone=True)
return point
27 changes: 27 additions & 0 deletions backend/construction/migrations/0001_initial.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# Generated by Django 4.2.11 on 2024-03-27 15:03

import django.contrib.gis.db.models.fields
from django.db import migrations, models


class Migration(migrations.Migration):

initial = True

dependencies = [
]

operations = [
migrations.CreateModel(
name='Construction',
fields=[
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('name', models.CharField(max_length=255)),
('coordinate', django.contrib.gis.db.models.fields.PointField(geography=True, srid=4326)),
],
options={
'verbose_name': 'Construction',
'verbose_name_plural': 'Constructions',
},
),
]
Empty file.
7 changes: 3 additions & 4 deletions nginx_inner/conf.d/default.conf
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,12 @@ server {
add_header 'Access-Control-Expose-Headers' 'Content-Length,Content-Range';
add_header 'Access-Control-Max-Age' 1728000;

# TODO: Das muss noch angepasst werden
location /dangers-service/static/ {
location /poi-service/static/ {
autoindex on;
alias /dangers-service/backend/static/;
alias /poi-service/backend/static/;
}

location /dangers-service/ {
location /poi-service/ {
proxy_pass http://backend/;

include /etc/nginx/proxy_params;
Expand Down

0 comments on commit 784c10e

Please sign in to comment.