Geometry calculation fix
* fixes bug where geometry parcels could not be calculated properly due to small buffering of points and lines * fixes bug where race condition would prevent proper parcel calculation * adds migrater specifically for migration recording of interventions after all data has been migrated
This commit is contained in:
parent
eb2aa5cf2c
commit
a33a420765
@ -47,12 +47,12 @@ class BaseMigrater:
|
||||
db_result_geom = MultiPolygon.from_ewkt(db_result[2])
|
||||
elif db_result[3] is not None:
|
||||
db_result_geom = MultiLineString.from_ewkt(db_result[3])
|
||||
db_result_geom = db_result_geom.buffer(0.00001, 1)
|
||||
db_result_geom = db_result_geom.buffer(0.5, 1)
|
||||
if isinstance(db_result_geom, Polygon):
|
||||
db_result_geom = MultiPolygon(db_result_geom)
|
||||
elif db_result[4] is not None:
|
||||
db_result_geom = MultiPoint.from_ewkt(db_result[4])
|
||||
db_result_geom = db_result_geom.buffer(0.00001, 1)
|
||||
db_result_geom = db_result_geom.buffer(0.5, 1)
|
||||
if isinstance(db_result_geom, Polygon):
|
||||
db_result_geom = MultiPolygon(db_result_geom)
|
||||
else:
|
||||
|
@ -67,7 +67,6 @@ class CompensationMigrater(BaseMigrater):
|
||||
continue
|
||||
|
||||
compensation = self._migrate_par_7_data(compensation, kom)
|
||||
compensation = self._migrate_geometry(compensation, kom)
|
||||
compensation = self._migrate_responsibility(compensation, kom)
|
||||
compensation = self._migrate_compensation_type(compensation, kom)
|
||||
compensation = self._migrate_states(compensation, kom)
|
||||
@ -78,6 +77,9 @@ class CompensationMigrater(BaseMigrater):
|
||||
compensation = self._migrate_documents(compensation, CompensationDocument, kom)
|
||||
compensation.save()
|
||||
num_processed += 1
|
||||
|
||||
compensation = self._migrate_geometry(compensation, kom)
|
||||
compensation.save()
|
||||
print("The following KOMs could not be migrated: ")
|
||||
for kom, val in unsuccessfull_compensations.items():
|
||||
print(kom)
|
||||
|
@ -66,7 +66,6 @@ class EcoAccountMigrater(CompensationMigrater):
|
||||
eco_account.comment = oek_comment
|
||||
eco_account = self._migrate_legal(eco_account, oek)
|
||||
eco_account = self._migrate_states(eco_account, oek)
|
||||
eco_account = self._migrate_geometry(eco_account, oek)
|
||||
eco_account = self._migrate_responsibility(eco_account, oek)
|
||||
eco_account = self._migrate_deadlines(eco_account, oek)
|
||||
eco_account = self._migrate_action_control_deadlines(eco_account, oek)
|
||||
@ -78,6 +77,9 @@ class EcoAccountMigrater(CompensationMigrater):
|
||||
eco_account.save()
|
||||
|
||||
num_processed += 1
|
||||
|
||||
eco_account = self._migrate_geometry(eco_account, oek)
|
||||
eco_account.save()
|
||||
cursor.close()
|
||||
|
||||
def _migrate_geometry(self, instance, db_result: tuple):
|
||||
|
@ -56,7 +56,6 @@ class EmaMigrater(CompensationMigrater):
|
||||
|
||||
ema_obj.title = ema_title
|
||||
ema_obj.comment = ema_comment
|
||||
ema_obj = self._migrate_geometry(ema_obj, ema)
|
||||
ema_obj = self._migrate_responsibility(ema_obj, ema)
|
||||
ema_obj = self._migrate_compensation_type(ema_obj, ema)
|
||||
ema_obj = self._migrate_states(ema_obj, ema)
|
||||
@ -70,6 +69,10 @@ class EmaMigrater(CompensationMigrater):
|
||||
ema_obj.save()
|
||||
|
||||
num_processed += 1
|
||||
|
||||
ema_obj = self._migrate_geometry(ema_obj, ema)
|
||||
ema_obj.save()
|
||||
|
||||
cursor.close()
|
||||
|
||||
def _migrate_deadlines(self, ema_obj, ema_result):
|
||||
|
@ -197,17 +197,17 @@ class InterventionMigrater(BaseMigrater):
|
||||
)[0]
|
||||
intervention.title = eiv[1]
|
||||
intervention.comment = eiv_comment
|
||||
intervention = self._migrate_geometry(intervention, eiv)
|
||||
intervention = self._migrate_intervention_legal(intervention, eiv)
|
||||
intervention = self._migrate_intervention_responsibility(intervention, eiv)
|
||||
intervention = self._migrate_intervention_payment(intervention, eiv)
|
||||
intervention = self._migrate_documents(intervention, InterventionDocument, eiv)
|
||||
intervention = self._migrate_log(intervention, eiv)
|
||||
intervention = self._migrate_revocation(intervention, eiv)
|
||||
intervention = self._migrate_recorded(intervention, eiv)
|
||||
|
||||
intervention.save()
|
||||
|
||||
intervention = self._migrate_geometry(intervention, eiv)
|
||||
intervention.save()
|
||||
|
||||
num_processed += 1
|
||||
|
||||
cursor.close()
|
||||
@ -304,3 +304,24 @@ class InterventionMigrater(BaseMigrater):
|
||||
|
||||
tmp_cursor.close()
|
||||
return instance
|
||||
|
||||
|
||||
class InterventionRecordedMigrater(InterventionMigrater):
|
||||
|
||||
def migrate(self):
|
||||
""" Migration focuses only on recording of interventions
|
||||
|
||||
"""
|
||||
interventions = Intervention.objects.filter(
|
||||
deleted=None
|
||||
)
|
||||
interventions_count = interventions.count()
|
||||
num_processed = 0
|
||||
print(f"Migrate recording of interventions...")
|
||||
print(f"--Found {interventions_count} entries. Process now...")
|
||||
for eiv in interventions:
|
||||
num_processed = num_processed + 1
|
||||
if num_processed % 500 == 0:
|
||||
print(f"----{num_processed}/{interventions_count} processed")
|
||||
self._migrate_recorded(eiv, [eiv.identifier])
|
||||
|
||||
|
@ -1,7 +1,8 @@
|
||||
from konova.management.commands.kspMigrater.compensation_migrater import CompensationMigrater
|
||||
from konova.management.commands.kspMigrater.eco_account_migrater import EcoAccountMigrater
|
||||
from konova.management.commands.kspMigrater.ema_migrater import EmaMigrater
|
||||
from konova.management.commands.kspMigrater.intervention_migrater import InterventionMigrater
|
||||
from konova.management.commands.kspMigrater.intervention_migrater import InterventionMigrater, \
|
||||
InterventionRecordedMigrater
|
||||
from konova.management.commands.kspMigrater.user_migrater import UserMigrater
|
||||
from konova.management.commands.setup import BaseKonovaCommand
|
||||
|
||||
@ -18,10 +19,11 @@ class Command(BaseKonovaCommand):
|
||||
def handle(self, *args, **options):
|
||||
try:
|
||||
migraters = [
|
||||
#InterventionMigrater(options),
|
||||
#CompensationMigrater(options),
|
||||
#EmaMigrater(options),
|
||||
#EcoAccountMigrater(options),
|
||||
InterventionMigrater(options),
|
||||
CompensationMigrater(options),
|
||||
EmaMigrater(options),
|
||||
EcoAccountMigrater(options),
|
||||
InterventionRecordedMigrater(options),
|
||||
UserMigrater(options),
|
||||
]
|
||||
for migrater in migraters:
|
||||
|
Loading…
Reference in New Issue
Block a user