From 0224bddb744bf16f555f1fa01291fc99ac59d351 Mon Sep 17 00:00:00 2001 From: mpeltriaux Date: Wed, 13 Nov 2024 16:08:36 +0100 Subject: [PATCH] # Bugfix: Recalculate_parcels command * fixes a bug on recalculate_parcels if not --force-all is used --- konova/management/commands/recalculate_parcels.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/konova/management/commands/recalculate_parcels.py b/konova/management/commands/recalculate_parcels.py index da3c3269..42165c5f 100644 --- a/konova/management/commands/recalculate_parcels.py +++ b/konova/management/commands/recalculate_parcels.py @@ -48,11 +48,14 @@ class Command(BaseKonovaCommand): "geometry__id", flat=True ) + # ... and resolve into Geometry objects again ... intersected_geom_objs = Geometry.objects.filter( id__in=geom_with_intersection_ids ) - # Filter those geometries out (they have intersections and do not need to be processed) - geometry_objects = geometry_objects.difference(intersected_geom_objs) + # ... to be able to use the way more efficient difference() function ... + geometry_objects_ids = geometry_objects.difference(intersected_geom_objs).values_list("id", flat=True) + # ... so we can resolve these into proper Geometry objects again for further annotation usage + geometry_objects = Geometry.objects.filter(id__in=geometry_objects_ids) self._write_warning("=== Update parcels and districts ===") # Order geometries by size to process smaller once at first -- 2.45.2