#49 Parcels and Districts

* fixes bug in GeometryConflict conflict checking
* WIP: introduces new konova/utils/wfs/spatial holding SpatialWFSFetcher, which can be fed any geometry and it returns found features
* WIP: adds tests for wfs fetching
* updates requirements.txt
This commit is contained in:
2021-12-17 17:30:12 +01:00
parent 93d1cb9330
commit 46e237f0e2
5 changed files with 131 additions and 9 deletions

View File

@@ -21,6 +21,7 @@ class Geometry(BaseResource):
def save(self, *args, **kwargs):
super().save(*args, **kwargs)
self.check_for_conflicts()
self.update_parcels()
def check_for_conflicts(self):
""" Checks for new geometry overlaps
@@ -31,7 +32,7 @@ class Geometry(BaseResource):
"""
# If no geometry is given or important data is missing, we can not perform any checks
if self.geom is None or (self.created is None and self.modified is None):
if self.geom is None:
return None
self.recheck_existing_conflicts()
@@ -43,7 +44,10 @@ class Geometry(BaseResource):
).distinct()
for match in overlapping_geoms:
GeometryConflict.objects.get_or_create(conflicting_geometry=self, affected_geometry=match)
# Make sure this conflict is not already known but in a swapped constellation
conflict_exists_swapped = GeometryConflict.objects.filter(conflicting_geometry=match, affected_geometry=self).exists()
if not conflict_exists_swapped:
GeometryConflict.objects.get_or_create(conflicting_geometry=self, affected_geometry=match)
def recheck_existing_conflicts(self):
""" Rechecks GeometryConflict entries
@@ -88,6 +92,10 @@ class Geometry(BaseResource):
objs += set_objs
return objs
def update_parcels(self):
# ToDo
pass
class GeometryConflict(UuidModel):
"""

View File

@@ -40,6 +40,7 @@ class Parcel(UuidModel):
max_length=1000,
help_text="Gemarkung"
)
updated_on = models.DateTimeField(auto_now_add=True)
def __str__(self):
return f"{self.gmrkng} | {self.flr} | {self.flrstck_nnr} | {self.flrstck_zhlr}"