# Fixes
* drops unused methods * fixes typos * updates comments * drops unused model attribute
This commit is contained in:
parent
590a510880
commit
69a8139601
@ -151,7 +151,7 @@ class ResubmissionAdmin(BaseResourceAdmin):
|
||||
|
||||
|
||||
# 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(District, DistrictAdmin)
|
||||
#admin.site.register(Municipal, MunicipalAdmin)
|
||||
|
@ -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',
|
||||
),
|
||||
]
|
@ -303,17 +303,6 @@ class Geometry(BaseResource):
|
||||
municipals = Municipal.objects.filter(id__in=municipals).order_by("name")
|
||||
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):
|
||||
""" Returns a FeatureCollection structure holding all polygons of the MultiPolygon as single features
|
||||
|
||||
|
@ -672,17 +672,6 @@ class GeoReferencedMixin(models.Model):
|
||||
result = self.geometry.get_underlying_parcels()
|
||||
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):
|
||||
if self.geometry is None:
|
||||
return request
|
||||
|
@ -160,19 +160,9 @@ class Parcel(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.
|
||||
|
||||
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)
|
||||
geometry = models.ForeignKey("konova.Geometry", on_delete=models.CASCADE)
|
||||
calculated_on = models.DateTimeField(auto_now_add=True, null=True, blank=True)
|
||||
|
@ -11,15 +11,8 @@ def celery_update_parcels(geometry_id: str, recheck: bool = True):
|
||||
try:
|
||||
geom = Geometry.objects.get(id=geometry_id)
|
||||
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()
|
||||
|
||||
except ObjectDoesNotExist:
|
||||
if recheck:
|
||||
sleep(5)
|
||||
|
@ -31,7 +31,7 @@ class ParcelFetcher:
|
||||
buffer_threshold = 0.001
|
||||
geom = geometry.geom.buffer(-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
|
||||
self.geojson = geom.ewkt
|
||||
self.results = []
|
||||
|
Loading…
Reference in New Issue
Block a user