# 139 Parcel reference improved
* improves frontend layout to display more details on district, municipal and parce group * improves ordering of parcels * refactors parcel related models * improves parcel fetching * extends and simplifies sanitize_db parcel related code
This commit is contained in:
+70
-39
@@ -10,8 +10,64 @@ from django.db import models
|
||||
from konova.models import UuidModel
|
||||
|
||||
|
||||
class AdministrativeSpatialReference(models.Model):
|
||||
key = models.CharField(
|
||||
max_length=255,
|
||||
help_text="Represents Kreisschlüssel",
|
||||
null=True,
|
||||
blank=True
|
||||
)
|
||||
name = models.CharField(
|
||||
max_length=1000,
|
||||
help_text="Kreis",
|
||||
null=True,
|
||||
blank=True,
|
||||
)
|
||||
|
||||
class Meta:
|
||||
abstract = True
|
||||
|
||||
def __str__(self):
|
||||
return f"{self.name} ({self.key})"
|
||||
|
||||
@property
|
||||
def table_str(self):
|
||||
return f"{self.name} ({self.key})"
|
||||
|
||||
|
||||
class District(UuidModel, AdministrativeSpatialReference):
|
||||
""" The model District refers to "Kreis"
|
||||
|
||||
"""
|
||||
pass
|
||||
|
||||
|
||||
class Municipal(UuidModel, AdministrativeSpatialReference):
|
||||
""" The model Municipal refers to "Gemeinde"
|
||||
|
||||
"""
|
||||
district = models.ForeignKey(
|
||||
District,
|
||||
on_delete=models.SET_NULL,
|
||||
null=True,
|
||||
blank=True,
|
||||
)
|
||||
|
||||
|
||||
class ParcelGroup(UuidModel, AdministrativeSpatialReference):
|
||||
""" The model ParcelGroup refers to "Gemarkung", which is defined as a loose group of parcels
|
||||
|
||||
"""
|
||||
municipal = models.ForeignKey(
|
||||
Municipal,
|
||||
on_delete=models.SET_NULL,
|
||||
null=True,
|
||||
blank=True,
|
||||
)
|
||||
|
||||
|
||||
class Parcel(UuidModel):
|
||||
""" The Parcel model holds administrative data on the covered properties.
|
||||
""" The Parcel model holds administrative data on covered properties.
|
||||
|
||||
Due to the unique but relevant naming of the administrative data, we have to use these namings as field
|
||||
names in german. Any try to translate them to English result in strange or insufficient translations.
|
||||
@@ -24,59 +80,34 @@ class Parcel(UuidModel):
|
||||
"""
|
||||
geometries = models.ManyToManyField("konova.Geometry", blank=True, related_name="parcels", through='ParcelIntersection')
|
||||
district = models.ForeignKey("konova.District", on_delete=models.SET_NULL, null=True, blank=True, related_name="parcels")
|
||||
gmrkng = models.CharField(
|
||||
max_length=1000,
|
||||
municipal = models.ForeignKey("konova.Municipal", on_delete=models.SET_NULL, null=True, blank=True, related_name="parcels")
|
||||
parcel_group = models.ForeignKey(
|
||||
"konova.ParcelGroup",
|
||||
on_delete=models.SET_NULL,
|
||||
help_text="Gemarkung",
|
||||
null=True,
|
||||
blank=True,
|
||||
related_name="parcels"
|
||||
)
|
||||
flrstck_nnr = models.CharField(
|
||||
max_length=1000,
|
||||
flr = models.IntegerField(
|
||||
help_text="Flur",
|
||||
null=True,
|
||||
blank=True,
|
||||
)
|
||||
flrstck_nnr = models.IntegerField(
|
||||
help_text="Flurstücksnenner",
|
||||
null=True,
|
||||
blank=True,
|
||||
)
|
||||
flrstck_zhlr = models.CharField(
|
||||
max_length=1000,
|
||||
flrstck_zhlr = models.IntegerField(
|
||||
help_text="Flurstückszähler",
|
||||
null=True,
|
||||
blank=True,
|
||||
)
|
||||
flr = models.CharField(
|
||||
max_length=1000,
|
||||
help_text="Flur",
|
||||
null=True,
|
||||
blank=True,
|
||||
)
|
||||
updated_on = models.DateTimeField(auto_now_add=True)
|
||||
|
||||
def __str__(self):
|
||||
return f"{self.gmrkng} | {self.flr} | {self.flrstck_zhlr} | {self.flrstck_nnr}"
|
||||
|
||||
|
||||
class District(UuidModel):
|
||||
""" The model District holds more coarse information, such as Kreis, Verbandsgemeinde and Gemeinde.
|
||||
|
||||
There might be the case that a geometry lies on a hundred Parcel entries but only on one District entry.
|
||||
Therefore a geometry can have a lot of relations to Parcel entries but only a few or only a single one to one
|
||||
District.
|
||||
|
||||
"""
|
||||
gmnd = models.CharField(
|
||||
max_length=1000,
|
||||
help_text="Gemeinde",
|
||||
null=True,
|
||||
blank=True,
|
||||
)
|
||||
krs = models.CharField(
|
||||
max_length=1000,
|
||||
help_text="Kreis",
|
||||
null=True,
|
||||
blank=True,
|
||||
)
|
||||
|
||||
def __str__(self):
|
||||
return f"{self.gmnd} | {self.krs}"
|
||||
return f"{self.parcel_group} | {self.flr} | {self.flrstck_zhlr} | {self.flrstck_nnr}"
|
||||
|
||||
|
||||
class ParcelIntersection(UuidModel):
|
||||
|
||||
Reference in New Issue
Block a user