Compare commits

...

3 Commits

Author SHA1 Message Date
69a8139601 # Fixes
* drops unused methods
* fixes typos
* updates comments
* drops unused model attribute
2024-02-16 08:41:03 +01:00
590a510880 # CONN_MAX_AGE
* dropping conn_max_age due to problems with usage in gunicorn
2024-02-16 08:23:14 +01:00
689a2d6acb # Typo
* fixes typo
2024-02-16 08:14:42 +01:00
9 changed files with 25 additions and 48 deletions

View File

@ -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)

View File

@ -225,11 +225,11 @@ class Command(BaseKonovaCommand):
all_geometries = Geometry.objects.all()
kom_geometry_ids = self._get_all_geometry_ids(Compensation)
self._write_warning(f" EMA: {kom_geometry_ids.count()} attached geometries")
self._write_warning(f" KOM: {kom_geometry_ids.count()} attached geometries")
eiv_geometry_ids = self._get_all_geometry_ids(Intervention)
self._write_warning(f" EMA: {eiv_geometry_ids.count()} attached geometries")
self._write_warning(f" EIV: {eiv_geometry_ids.count()} attached geometries")
oek_geometry_ids = self._get_all_geometry_ids(EcoAccount)
self._write_warning(f" EMA: {oek_geometry_ids.count()} attached geometries")
self._write_warning(f" OEK: {oek_geometry_ids.count()} attached geometries")
ema_geometry_ids = self._get_all_geometry_ids(Ema)
self._write_warning(f" EMA: {ema_geometry_ids.count()} attached geometries")

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")
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

View File

@ -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

View File

@ -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)

View File

@ -135,7 +135,6 @@ DATABASES = {
'USER': 'postgres',
'HOST': '127.0.0.1',
'PORT': '5432',
'CONN_MAX_AGE': 120,
}
}
DEFAULT_AUTO_FIELD = "django.db.models.BigAutoField"

View File

@ -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)

View File

@ -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 = []