From 0fc75cbba486f95018546b20dd353c34bcb1e443 Mon Sep 17 00:00:00 2001 From: SJiB Date: Fri, 14 Jun 2024 23:07:38 +0200 Subject: [PATCH] correct check_fk_in_subsetid qgepdss --- qgepqwat2ili/qgepdss/export.py | 29 +++++++++++++++-------------- 1 file changed, 15 insertions(+), 14 deletions(-) diff --git a/qgepqwat2ili/qgepdss/export.py b/qgepqwat2ili/qgepdss/export.py index 0fc72b93..55d4703c 100644 --- a/qgepqwat2ili/qgepdss/export.py +++ b/qgepqwat2ili/qgepdss/export.py @@ -45,6 +45,7 @@ def get_tid(relation): """ if relation is None: return None + return tid_maker.tid_for_row(relation) def get_vl(relation): @@ -91,6 +92,7 @@ def truncate(val, max_length): logger.warning(f"Value '{val}' exceeds expected length ({max_length})") return val[0:max_length] + def modulo_angle(val): """ Returns an angle between 0 and 359.9 (for Orientierung in Base_d-20181005.ili) @@ -108,23 +110,24 @@ def modulo_angle(val): logger.info(f"modulo_angle - added orientation: {labelorientation}") print("modulo_angle - added orientation: ", str(labelorientation)) - return val - def check_fk_in_subsetid (foreignkey2, subset): + def check_fk_in_subsetid (subset, relation): """ checks, whether foreignkey is in the subset_ids - if yes it return the foreignkey, if no it will return NULL """ logger.info(f"check_fk_in_subsetid - Subset ID's '{subset}'") - logger.info(f"check_fk_in_subsetid - foreignkey '{foreignkey2}'") - - if foreignkey2 in subset: - logger.info(f"check_fk_in_subsetid - '{foreignkey2}' is in subset ") + # get the value of the fk_ attribute as str out of the relation to be able to check whether it is in the subset + fremdschluesselstr = getattr(relation, "obj_id") + logger.info(f"check_fk_in_subsetid - fremdschluesselstr '{fremdschluesselstr}'") + + if fremdschluesselstr in subset: + logger.info(f"check_fk_in_subsetid - '{fremdschluesselstr}' is in subset ") + logger.info(f"check_fk_in_subsetid - tid = '{tid_maker.tid_for_row(relation)}' ") + return tid_maker.tid_for_row(relation) else: - logger.info(f"check_fk_in_subsetid - '{foreignkey2}' is not in subset - replaced with None instead!") - foreignkey2 = None - return foreignkey2 - + logger.info(f"check_fk_in_subsetid - '{fremdschluesselstr}' is not in subset - replaced with None instead!") + return None def create_metaattributes(row): metaattribute = ABWASSER.metaattribute( @@ -1971,9 +1974,6 @@ def textpos_common(row, t_type, geojson_crs_def): ).filter(QGEP.wastewater_networkelement.obj_id.in_(subset_ids)) for row in query: - - logger.info(f" fk_wastewater_networkelement = {(row.fk_wastewater_networkelement__REL)}") - # AVAILABLE FIELDS IN QGEP.reach_point # --- reach_point --- @@ -1992,7 +1992,8 @@ def textpos_common(row, t_type, geojson_crs_def): # --- haltungspunkt --- #abwassernetzelementref=get_tid(row.fk_wastewater_networkelement__REL), - abwassernetzelementref=get_tid(check_fk_in_subsetid((row.fk_wastewater_networkelement__REL), subset_ids)), + # abwassernetzelementref=get_tid(check_fk_in_subsetid(subset_ids, row.fk_wastewater_networkelement__REL)), + abwassernetzelementref=check_fk_in_subsetid(subset_ids, row.fk_wastewater_networkelement__REL), auslaufform=get_vl(row.outlet_shape__REL), bemerkung=truncate(emptystr_to_null(row.remark), 80), bezeichnung=null_to_emptystr(row.identifier),