Skip to content

Commit

Permalink
correct check_fk_in_subsetid qgepdss
Browse files Browse the repository at this point in the history
  • Loading branch information
sjib committed Jun 14, 2024
1 parent 14401aa commit 0fc75cb
Showing 1 changed file with 15 additions and 14 deletions.
29 changes: 15 additions & 14 deletions qgepqwat2ili/qgepdss/export.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down Expand Up @@ -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)
Expand All @@ -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(
Expand Down Expand Up @@ -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 ---
Expand All @@ -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),
Expand Down

0 comments on commit 0fc75cb

Please sign in to comment.