Compare commits

..

No commits in common. "aab8b2c0486a9f086d12cd9cbfe2935d417dbac5" and "d91d2fa2ca5649f557304ab81ec5cc65703ff785" have entirely different histories.

2 changed files with 7 additions and 10 deletions

View File

@ -34,9 +34,7 @@ class Command(BaseKonovaCommand):
def recalculate_parcels(self, options: dict): def recalculate_parcels(self, options: dict):
force_all = options.get("force_all", False) force_all = options.get("force_all", False)
geometry_objects = Geometry.objects.all().exclude( geometry_objects = Geometry.objects.all()
geom=None
)
if not force_all: if not force_all:
# Fetch all intersections # Fetch all intersections
@ -48,17 +46,16 @@ class Command(BaseKonovaCommand):
"geometry__id", "geometry__id",
flat=True flat=True
) )
intersected_geom_objs = Geometry.objects.filter( # Filter those geometries out (they have intersections and do not need to be processed)
geometry_objects = geometry_objects.exclude(
id__in=geom_with_intersection_ids 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)
self._write_warning("=== Update parcels and districts ===") self._write_warning("=== Update parcels and districts ===")
# Order geometries by size to process smaller once at first # Order geometries by size to process smaller once at first
geometries = geometry_objects.annotate( geometries = geometry_objects.exclude(
area=Area("geom") geom=None
).order_by( ).annotate(area=Area("geom")).order_by(
'area' 'area'
) )
self._write_warning(f"Process parcels for {geometries.count()} geometry entries now ...") self._write_warning(f"Process parcels for {geometries.count()} geometry entries now ...")

View File

@ -159,6 +159,7 @@ class Parcel(UuidModel):
return f"{self.parcel_group} | {self.flr} | {self.flrstck_zhlr} | {self.flrstck_nnr}" return f"{self.parcel_group} | {self.flr} | {self.flrstck_zhlr} | {self.flrstck_nnr}"
@classmethod @classmethod
@transaction.atomic
def make_unique(cls, **kwargs): def make_unique(cls, **kwargs):
""" Checks for duplicates of a Parcel, choose a (now) unique one, """ Checks for duplicates of a Parcel, choose a (now) unique one,
repairs relations for ParcelIntersection and removes duplicates. repairs relations for ParcelIntersection and removes duplicates.
@ -187,7 +188,6 @@ class Parcel(UuidModel):
intersection_objs = ParcelIntersection.objects.filter( intersection_objs = ParcelIntersection.objects.filter(
parcel__in=parcel_objs parcel__in=parcel_objs
) )
# Change each intersection, so they point on the 'true one' parcel from now on # Change each intersection, so they point on the 'true one' parcel from now on
for intersection in intersection_objs: for intersection in intersection_objs:
intersection.parcel = unique_parcel intersection.parcel = unique_parcel