* drops unused methods
* fixes typos
* updates comments
* drops unused model attribute
This commit is contained in:
mpeltriaux 2024-02-16 08:41:03 +01:00
parent 590a510880
commit 69a8139601
7 changed files with 22 additions and 44 deletions

View File

@ -151,7 +151,7 @@ class ResubmissionAdmin(BaseResourceAdmin):
# Outcommented for a cleaner admin backend on production # Outcommented for a cleaner admin backend on production
#admin.site.register(Geometry, GeometryAdmin) admin.site.register(Geometry, GeometryAdmin)
#admin.site.register(Parcel, ParcelAdmin) #admin.site.register(Parcel, ParcelAdmin)
#admin.site.register(District, DistrictAdmin) #admin.site.register(District, DistrictAdmin)
#admin.site.register(Municipal, MunicipalAdmin) #admin.site.register(Municipal, MunicipalAdmin)

View File

@ -0,0 +1,17 @@
# Generated by Django 5.0.1 on 2024-02-16 07:34
from django.db import migrations
class Migration(migrations.Migration):
dependencies = [
('konova', '0015_geometry_parcel_calculation_end_and_more'),
]
operations = [
migrations.RemoveField(
model_name='parcelintersection',
name='calculated_on',
),
]

View File

@ -303,17 +303,6 @@ class Geometry(BaseResource):
municipals = Municipal.objects.filter(id__in=municipals).order_by("name") municipals = Municipal.objects.filter(id__in=municipals).order_by("name")
return municipals return municipals
def count_underlying_parcels(self):
""" Getter for number of underlying parcels
Returns:
"""
num_parcels = self.parcels.filter(
parcelintersection__calculated_on__isnull=False,
).count()
return num_parcels
def as_feature_collection(self, srid=DEFAULT_SRID_RLP): def as_feature_collection(self, srid=DEFAULT_SRID_RLP):
""" Returns a FeatureCollection structure holding all polygons of the MultiPolygon as single features """ Returns a FeatureCollection structure holding all polygons of the MultiPolygon as single features

View File

@ -672,17 +672,6 @@ class GeoReferencedMixin(models.Model):
result = self.geometry.get_underlying_parcels() result = self.geometry.get_underlying_parcels()
return result return result
def count_underlying_parcels(self):
""" Getter for number of underlying parcels
Returns:
"""
result = 0
if self.geometry is not None:
result = self.geometry.count_underlying_parcels()
return result
def set_geometry_conflict_message(self, request: HttpRequest): def set_geometry_conflict_message(self, request: HttpRequest):
if self.geometry is None: if self.geometry is None:
return request return request

View File

@ -160,19 +160,9 @@ class Parcel(UuidModel):
class ParcelIntersection(UuidModel): class ParcelIntersection(UuidModel):
""" ParcelIntersection is an intermediary model, which is used to configure the """
ParcelIntersection is an intermediary model, which is used to add extras to the
M2M relation between Parcel and Geometry. M2M relation between Parcel and Geometry.
Based on uuids, we will not have (practically) any problems on outrunning primary keys
and extending the model with calculated_on timestamp, we can 'hide' entries while they
are being recalculated and keep track on the last time they have been calculated this
way.
Please note: The calculated_on describes when the relation between the Parcel and the Geometry
has been established. The updated_on field of Parcel describes when this Parcel has been
changed the last time.
""" """
parcel = models.ForeignKey(Parcel, on_delete=models.CASCADE) parcel = models.ForeignKey(Parcel, on_delete=models.CASCADE)
geometry = models.ForeignKey("konova.Geometry", on_delete=models.CASCADE) geometry = models.ForeignKey("konova.Geometry", on_delete=models.CASCADE)
calculated_on = models.DateTimeField(auto_now_add=True, null=True, blank=True)

View File

@ -11,15 +11,8 @@ def celery_update_parcels(geometry_id: str, recheck: bool = True):
try: try:
geom = Geometry.objects.get(id=geometry_id) geom = Geometry.objects.get(id=geometry_id)
geom.parcels.clear() geom.parcels.clear()
#objs = geom.parcelintersection_set.all()
#for obj in objs:
# obj.calculated_on = None
#ParcelIntersection.objects.bulk_update(
# objs,
# ["calculated_on"]
#)
geom.update_parcels() geom.update_parcels()
except ObjectDoesNotExist: except ObjectDoesNotExist:
if recheck: if recheck:
sleep(5) sleep(5)

View File

@ -31,7 +31,7 @@ class ParcelFetcher:
buffer_threshold = 0.001 buffer_threshold = 0.001
geom = geometry.geom.buffer(-buffer_threshold) geom = geometry.geom.buffer(-buffer_threshold)
if geom.area < buffer_threshold: if geom.area < buffer_threshold:
# Fallback for malicious geometries which are way too small but would disappear on buffering # Fallback for malicious geometries which are way too small and would disappear on negative buffering
geom = geometry.geom geom = geometry.geom
self.geojson = geom.ewkt self.geojson = geom.ewkt
self.results = [] self.results = []