From cff053424c411cc3b7ceba5471a87fb525d9dd84 Mon Sep 17 00:00:00 2001 From: SJiB Date: Tue, 14 May 2024 17:44:54 +0200 Subject: [PATCH 001/111] qgepdss/export.py - rohrprofil_geometry add if filtered --- qgepqwat2ili/qgepdss/export.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/qgepqwat2ili/qgepdss/export.py b/qgepqwat2ili/qgepdss/export.py index 41545c03..c800ff1f 100644 --- a/qgepqwat2ili/qgepdss/export.py +++ b/qgepqwat2ili/qgepdss/export.py @@ -2082,6 +2082,10 @@ def textpos_common(row, t_type, geojson_crs_def): logger.info("Exporting QGEP.profile_geometry -> ABWASSER.rohrprofil_geometrie, ABWASSER.metaattribute") query = qgep_session.query(QGEP.profile_geometry) + if filtered: + query = query.join( + QGEP.reach, + ).filter(QGEP.wastewater_networkelement.obj_id.in_(subset_ids)) for row in query: # AVAILABLE FIELDS IN QGEP.profile_geometry From 534c8b5f9bbba3060ff7f942ccbd80e480e856cb Mon Sep 17 00:00:00 2001 From: SJiB Date: Wed, 15 May 2024 22:15:19 +0200 Subject: [PATCH 002/111] Adapt if filtered QGEP.pipe_profile, QGEP.reach Add whole line of references to wastewater_networkelement --- qgepqwat2ili/qgepdss/export.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/qgepqwat2ili/qgepdss/export.py b/qgepqwat2ili/qgepdss/export.py index c800ff1f..f6d1a676 100644 --- a/qgepqwat2ili/qgepdss/export.py +++ b/qgepqwat2ili/qgepdss/export.py @@ -2084,7 +2084,7 @@ def textpos_common(row, t_type, geojson_crs_def): query = qgep_session.query(QGEP.profile_geometry) if filtered: query = query.join( - QGEP.reach, + QGEP.pipe_profile, QGEP.reach ).filter(QGEP.wastewater_networkelement.obj_id.in_(subset_ids)) for row in query: From fe217e9bc62c25cd1012dfa79e6946b966e89ca6 Mon Sep 17 00:00:00 2001 From: SJiB Date: Thu, 16 May 2024 13:24:29 +0200 Subject: [PATCH 003/111] Add filter for Subclasses of Anschlussobjekt --- qgepqwat2ili/qgepdss/export.py | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/qgepqwat2ili/qgepdss/export.py b/qgepqwat2ili/qgepdss/export.py index f6d1a676..65d86528 100644 --- a/qgepqwat2ili/qgepdss/export.py +++ b/qgepqwat2ili/qgepdss/export.py @@ -2568,6 +2568,10 @@ def textpos_common(row, t_type, geojson_crs_def): logger.info("Exporting QGEP.building -> ABWASSER.gebaeude, ABWASSER.metaattribute") query = qgep_session.query(QGEP.building) + if filtered: + query = query.join(QGEP.wastewater_networkelement).filter( + QGEP.wastewater_networkelement.obj_id.in_(subset_ids) + ) for row in query: # AVAILABLE FIELDS IN QGEP.building @@ -2606,6 +2610,10 @@ def textpos_common(row, t_type, geojson_crs_def): logger.info("Exporting QGEP.reservoir -> ABWASSER.reservoir, ABWASSER.metaattribute") query = qgep_session.query(QGEP.reservoir) + if filtered: + query = query.join(QGEP.wastewater_networkelement).filter( + QGEP.wastewater_networkelement.obj_id.in_(subset_ids) + ) for row in query: # AVAILABLE FIELDS IN QGEP.reservoir @@ -2642,6 +2650,10 @@ def textpos_common(row, t_type, geojson_crs_def): logger.info("Exporting QGEP.individual_surface -> ABWASSER.einzelflaeche, ABWASSER.metaattribute") query = qgep_session.query(QGEP.individual_surface) + if filtered: + query = query.join(QGEP.wastewater_networkelement).filter( + QGEP.wastewater_networkelement.obj_id.in_(subset_ids) + ) for row in query: # AVAILABLE FIELDS IN QGEP.individual_surface @@ -2680,6 +2692,10 @@ def textpos_common(row, t_type, geojson_crs_def): logger.info("Exporting QGEP.fountain -> ABWASSER.brunnen, ABWASSER.metaattribute") query = qgep_session.query(QGEP.fountain) + if filtered: + query = query.join(QGEP.wastewater_networkelement).filter( + QGEP.wastewater_networkelement.obj_id.in_(subset_ids) + ) for row in query: # AVAILABLE FIELDS IN QGEP.fountain From c73046331e62e35bc6ed8d5e22412905783cfaf2 Mon Sep 17 00:00:00 2001 From: SJiB Date: Thu, 16 May 2024 14:53:50 +0200 Subject: [PATCH 004/111] adjust filter criteria reach_point, take out reach_point_to statement --- qgepqwat2ili/qgepdss/export.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/qgepqwat2ili/qgepdss/export.py b/qgepqwat2ili/qgepdss/export.py index 65d86528..a0954efd 100644 --- a/qgepqwat2ili/qgepdss/export.py +++ b/qgepqwat2ili/qgepdss/export.py @@ -1947,7 +1947,7 @@ def textpos_common(row, t_type, geojson_crs_def): QGEP.reach, or_( QGEP.reach_point.obj_id == QGEP.reach.fk_reach_point_from, - QGEP.reach_point.obj_id == QGEP.reach.fk_reach_point_to, + # QGEP.reach_point.obj_id == QGEP.reach.fk_reach_point_to, ), ).filter(QGEP.wastewater_networkelement.obj_id.in_(subset_ids)) for row in query: From b0b499885f7cca811ca62be412a47c7dc9214082 Mon Sep 17 00:00:00 2001 From: SJiB Date: Thu, 16 May 2024 15:10:18 +0200 Subject: [PATCH 005/111] filter for hydr_geometry and hydr_geomrelation --- qgepqwat2ili/qgepdss/export.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/qgepqwat2ili/qgepdss/export.py b/qgepqwat2ili/qgepdss/export.py index a0954efd..bf67c6a9 100644 --- a/qgepqwat2ili/qgepdss/export.py +++ b/qgepqwat2ili/qgepdss/export.py @@ -1907,6 +1907,8 @@ def textpos_common(row, t_type, geojson_crs_def): logger.info("Exporting QGEP.hydr_geometry -> ABWASSER.hydr_geometrie, ABWASSER.metaattribute") query = qgep_session.query(QGEP.hydr_geometry) + if filtered: + query = query.join(QGEP.wastewater_node).filter(QGEP.wastewater_networkelement.obj_id.in_(subset_ids)) for row in query: # AVAILABLE FIELDS IN QGEP.hydr_geometry @@ -2118,6 +2120,8 @@ def textpos_common(row, t_type, geojson_crs_def): logger.info("Exporting QGEP.hydr_geom_relation -> ABWASSER.hydr_geomrelation, ABWASSER.metaattribute") query = qgep_session.query(QGEP.hydr_geom_relation) + if filtered: + query = query.join(QGEP.hydr_geometry, QGEP.wastewater_node).filter(QGEP.wastewater_networkelement.obj_id.in_(subset_ids)) for row in query: # AVAILABLE FIELDS IN QGEP.hydr_geom_relation From d828c0e305cddab8a41d0598470cd46c8536bd8e Mon Sep 17 00:00:00 2001 From: SJiB Date: Thu, 16 May 2024 15:15:34 +0200 Subject: [PATCH 006/111] filter for param_ca_general and param_ca_mouse1 --- qgepqwat2ili/qgepdss/export.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/qgepqwat2ili/qgepdss/export.py b/qgepqwat2ili/qgepdss/export.py index bf67c6a9..19bad5f1 100644 --- a/qgepqwat2ili/qgepdss/export.py +++ b/qgepqwat2ili/qgepdss/export.py @@ -3429,6 +3429,10 @@ def textpos_common(row, t_type, geojson_crs_def): logger.info("Exporting QGEP.param_ca_general -> ABWASSER.ezg_parameter_allg, ABWASSER.metaattribute") query = qgep_session.query(QGEP.param_ca_general) + if filtered: + query = query.join(QGEP.catchment_area).filter( + QGEP.wastewater_networkelement.obj_id.in_(subset_ids) + ) for row in query: # AVAILABLE FIELDS IN QGEP.param_ca_general @@ -3468,6 +3472,10 @@ def textpos_common(row, t_type, geojson_crs_def): logger.info("Exporting QGEP.param_ca_mouse1 -> ABWASSER.ezg_parameter_mouse1, ABWASSER.metaattribute") query = qgep_session.query(QGEP.param_ca_mouse1) + if filtered: + query = query.join(QGEP.catchment_area).filter( + QGEP.wastewater_networkelement.obj_id.in_(subset_ids) + ) for row in query: # AVAILABLE FIELDS IN QGEP.param_ca_mouse1 From dc7f826e46e7ab1fca07561b7ee325432d52fb42 Mon Sep 17 00:00:00 2001 From: SJiB Date: Thu, 16 May 2024 15:22:28 +0200 Subject: [PATCH 007/111] filters for catchment areas - 4 different fk --- qgepqwat2ili/qgepdss/export.py | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/qgepqwat2ili/qgepdss/export.py b/qgepqwat2ili/qgepdss/export.py index 19bad5f1..48ea1e04 100644 --- a/qgepqwat2ili/qgepdss/export.py +++ b/qgepqwat2ili/qgepdss/export.py @@ -2837,6 +2837,15 @@ def textpos_common(row, t_type, geojson_crs_def): logger.info("Exporting QGEP.catchment_area -> ABWASSER.einzugsgebiet, ABWASSER.metaattribute") query = qgep_session.query(QGEP.catchment_area) + if filtered: + query = query.join( + or_( + QGEP.wastewater_networkelement.obj_id == QGEP.catchment_area.fk_wastewater_networkelement_rw_planned, + QGEP.wastewater_networkelement.obj_id == QGEP.catchment_area.fk_wastewater_networkelement_rw_current, + QGEP.wastewater_networkelement.obj_id == QGEP.catchment_area.fk_wastewater_networkelement_ww_planned, + QGEP.wastewater_networkelement.obj_id == QGEP.catchment_area.fk_wastewater_networkelement_ww_current, + ), + ).filter(QGEP.wastewater_networkelement.obj_id.in_(subset_ids)) for row in query: # AVAILABLE FIELDS IN QGEP.catchment_area From e4f89848d426e83329c6a6e2ff76f74b0e3c3a55 Mon Sep 17 00:00:00 2001 From: SJiB Date: Mon, 3 Jun 2024 15:55:50 +0200 Subject: [PATCH 008/111] Add filter control_center --- qgepqwat2ili/qgepdss/export.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/qgepqwat2ili/qgepdss/export.py b/qgepqwat2ili/qgepdss/export.py index 48ea1e04..4dbdde2e 100644 --- a/qgepqwat2ili/qgepdss/export.py +++ b/qgepqwat2ili/qgepdss/export.py @@ -1566,6 +1566,10 @@ def textpos_common(row, t_type, geojson_crs_def): logger.info("Exporting QGEP.control_center -> ABWASSER.steuerungszentrale, ABWASSER.metaattribute") query = qgep_session.query(QGEP.control_center) + if filtered: + query = query.join(QGEP.throttle_shut_off_unit, QGEP.wastewater_node).filter( + QGEP.wastewater_networkelement.obj_id.in_(subset_ids) + ) for row in query: # AVAILABLE FIELDS IN QGEP.control_center From 48c8bc52138675a71931fdc30dafab839a7d95e2 Mon Sep 17 00:00:00 2001 From: SJiB Date: Mon, 3 Jun 2024 16:00:55 +0200 Subject: [PATCH 009/111] Add filter mechanical_pretreatment --- qgepqwat2ili/qgepdss/export.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/qgepqwat2ili/qgepdss/export.py b/qgepqwat2ili/qgepdss/export.py index 4dbdde2e..f29a2b2e 100644 --- a/qgepqwat2ili/qgepdss/export.py +++ b/qgepqwat2ili/qgepdss/export.py @@ -2158,6 +2158,10 @@ def textpos_common(row, t_type, geojson_crs_def): logger.info("Exporting QGEP.mechanical_pretreatment -> ABWASSER.mechanischevorreinigung, ABWASSER.metaattribute") query = qgep_session.query(QGEP.mechanical_pretreatment) + if filtered: + query = query.join(QGEP.wastewater_structure, QGEP.wastewater_networkelement).filter( + QGEP.wastewater_networkelement.obj_id.in_(subset_ids) + ) for row in query: # AVAILABLE FIELDS IN QGEP.mechanical_pretreatment From d4d310be17fe14a2dea8e9f68caead9e3d2f34ad Mon Sep 17 00:00:00 2001 From: SJiB Date: Mon, 3 Jun 2024 16:02:04 +0200 Subject: [PATCH 010/111] Add filter retention_body --- qgepqwat2ili/qgepdss/export.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/qgepqwat2ili/qgepdss/export.py b/qgepqwat2ili/qgepdss/export.py index f29a2b2e..6094c9ee 100644 --- a/qgepqwat2ili/qgepdss/export.py +++ b/qgepqwat2ili/qgepdss/export.py @@ -2195,6 +2195,10 @@ def textpos_common(row, t_type, geojson_crs_def): logger.info("Exporting QGEP.retention_body -> ABWASSER.retentionskoerper, ABWASSER.metaattribute") query = qgep_session.query(QGEP.retention_body) + if filtered: + query = query.join(QGEP.infiltration_installation, QGEP.wastewater_networkelement).filter( + QGEP.wastewater_networkelement.obj_id.in_(subset_ids) + ) for row in query: # AVAILABLE FIELDS IN QGEP.retention_body From 78212894394a61a89a8e14dd7db002e2323648df Mon Sep 17 00:00:00 2001 From: SJiB Date: Mon, 3 Jun 2024 16:08:17 +0200 Subject: [PATCH 011/111] add filter hazard_source --- qgepqwat2ili/qgepdss/export.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/qgepqwat2ili/qgepdss/export.py b/qgepqwat2ili/qgepdss/export.py index 6094c9ee..0c05d86a 100644 --- a/qgepqwat2ili/qgepdss/export.py +++ b/qgepqwat2ili/qgepdss/export.py @@ -2748,6 +2748,10 @@ def textpos_common(row, t_type, geojson_crs_def): logger.info("Exporting QGEP.hazard_source -> ABWASSER.gefahrenquelle, ABWASSER.metaattribute") query = qgep_session.query(QGEP.hazard_source) + if filtered: + query = query.join(QGEP.connection_object, QGEP.wastewater_networkelement).filter( + QGEP.wastewater_networkelement.obj_id.in_(subset_ids) + ) for row in query: # AVAILABLE FIELDS IN QGEP.hazard_source From 3ced51b9f5bd136c1dafd5ff713a24f953bf781e Mon Sep 17 00:00:00 2001 From: SJiB Date: Mon, 3 Jun 2024 16:50:58 +0200 Subject: [PATCH 012/111] add filter accident --- qgepqwat2ili/qgepdss/export.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/qgepqwat2ili/qgepdss/export.py b/qgepqwat2ili/qgepdss/export.py index 0c05d86a..b5eb4b8a 100644 --- a/qgepqwat2ili/qgepdss/export.py +++ b/qgepqwat2ili/qgepdss/export.py @@ -2785,6 +2785,10 @@ def textpos_common(row, t_type, geojson_crs_def): logger.info("Exporting QGEP.accident -> ABWASSER.unfall, ABWASSER.metaattribute") query = qgep_session.query(QGEP.accident) + if filtered: + query = query.join(QGEP.hazard_source, QGEP.connection_object, QGEP.wastewater_networkelement).filter( + QGEP.wastewater_networkelement.obj_id.in_(subset_ids) + ) for row in query: # AVAILABLE FIELDS IN QGEP.accident From 0caafce11db2106c32de6573023361c9d68feabb Mon Sep 17 00:00:00 2001 From: SJiB Date: Mon, 3 Jun 2024 16:51:23 +0200 Subject: [PATCH 013/111] add filter substance --- qgepqwat2ili/qgepdss/export.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/qgepqwat2ili/qgepdss/export.py b/qgepqwat2ili/qgepdss/export.py index b5eb4b8a..2b4b9c97 100644 --- a/qgepqwat2ili/qgepdss/export.py +++ b/qgepqwat2ili/qgepdss/export.py @@ -2824,6 +2824,10 @@ def textpos_common(row, t_type, geojson_crs_def): logger.info("Exporting QGEP.substance -> ABWASSER.stoff, ABWASSER.metaattribute") query = qgep_session.query(QGEP.substance) + if filtered: + query = query.join(QGEP.hazard_source, QGEP.connection_object, QGEP.wastewater_networkelement).filter( + QGEP.wastewater_networkelement.obj_id.in_(subset_ids) + ) for row in query: # AVAILABLE FIELDS IN QGEP.substance From bc7b0750726426776922e8f8a10809278e6ccf8d Mon Sep 17 00:00:00 2001 From: SJiB Date: Mon, 3 Jun 2024 17:15:00 +0200 Subject: [PATCH 014/111] add filter measuring_point to review if or_ statement is correct --- qgepqwat2ili/qgepdss/export.py | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/qgepqwat2ili/qgepdss/export.py b/qgepqwat2ili/qgepdss/export.py index 2b4b9c97..92963107 100644 --- a/qgepqwat2ili/qgepdss/export.py +++ b/qgepqwat2ili/qgepdss/export.py @@ -2935,6 +2935,17 @@ def textpos_common(row, t_type, geojson_crs_def): logger.info("Exporting QGEP.measuring_point -> ABWASSER.messstelle, ABWASSER.metaattribute") query = qgep_session.query(QGEP.measuring_point) + if filtered: + query = query.query.join( + or_( + (QGEP.waste_water_treatment_plant, QGEP.wastewater_networkelement), + (QGEP.wastewater_structure, QGEP.wastewater_networkelement), + (QGEP.water_course_segment, QGEP.river, QGEP.sector_water_body, QGEP.discharge_point, QGEP.wastewater_networkelement), + ) + ). + filter( + QGEP.wastewater_networkelement.obj_id.in_(subset_ids) + ) for row in query: # AVAILABLE FIELDS IN QGEP.measuring_point From 14e5c6ef3a78ce2f184304c5db246c11993cf6ea Mon Sep 17 00:00:00 2001 From: SJiB Date: Mon, 3 Jun 2024 17:18:14 +0200 Subject: [PATCH 015/111] add filter measuring_device and measurement_series --- qgepqwat2ili/qgepdss/export.py | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/qgepqwat2ili/qgepdss/export.py b/qgepqwat2ili/qgepdss/export.py index 92963107..b7edcff8 100644 --- a/qgepqwat2ili/qgepdss/export.py +++ b/qgepqwat2ili/qgepdss/export.py @@ -2985,6 +2985,17 @@ def textpos_common(row, t_type, geojson_crs_def): logger.info("Exporting QGEP.measuring_device -> ABWASSER.messgeraet, ABWASSER.metaattribute") query = qgep_session.query(QGEP.measuring_device) + if filtered: + query = query.query.join( + or_( + (QGEP.measuring_point, QGEP.waste_water_treatment_plant, QGEP.wastewater_networkelement), + (QGEP.measuring_point, QGEP.wastewater_structure, QGEP.wastewater_networkelement), + (QGEP.measuring_point, QGEP.water_course_segment, QGEP.river, QGEP.sector_water_body, QGEP.discharge_point, QGEP.wastewater_networkelement), + ) + ). + filter( + QGEP.wastewater_networkelement.obj_id.in_(subset_ids) + ) for row in query: # AVAILABLE FIELDS IN QGEP.measuring_device @@ -3019,6 +3030,17 @@ def textpos_common(row, t_type, geojson_crs_def): logger.info("Exporting QGEP.measurement_series -> ABWASSER.messreihe, ABWASSER.metaattribute") query = qgep_session.query(QGEP.measurement_series) + if filtered: + query = query.query.join( + or_( + (QGEP.measuring_point, QGEP.waste_water_treatment_plant, QGEP.wastewater_networkelement), + (QGEP.measuring_point, QGEP.wastewater_structure, QGEP.wastewater_networkelement), + (QGEP.measuring_point, QGEP.water_course_segment, QGEP.river, QGEP.sector_water_body, QGEP.discharge_point, QGEP.wastewater_networkelement), + ) + ). + filter( + QGEP.wastewater_networkelement.obj_id.in_(subset_ids) + ) for row in query: # AVAILABLE FIELDS IN QGEP.measurement_series From 015122c189849d62f5988781f42fe2468cd6d6c3 Mon Sep 17 00:00:00 2001 From: SJiB Date: Mon, 3 Jun 2024 17:22:32 +0200 Subject: [PATCH 016/111] add filter measurement_result --- qgepqwat2ili/qgepdss/export.py | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/qgepqwat2ili/qgepdss/export.py b/qgepqwat2ili/qgepdss/export.py index b7edcff8..194bea56 100644 --- a/qgepqwat2ili/qgepdss/export.py +++ b/qgepqwat2ili/qgepdss/export.py @@ -3075,6 +3075,21 @@ def textpos_common(row, t_type, geojson_crs_def): logger.info("Exporting QGEP.measurement_result -> ABWASSER.messresultat, ABWASSER.metaattribute") query = qgep_session.query(QGEP.measurement_result) + if filtered: + query = query.query.join( + or_( + (QGEP.measurement_series, QGEP.measuring_point, QGEP.waste_water_treatment_plant, QGEP.wastewater_networkelement), + (QGEP.measurement_series, QGEP.measuring_point, QGEP.wastewater_structure, QGEP.wastewater_networkelement), + (QGEP.measurement_series, QGEP.measuring_point, QGEP.water_course_segment, QGEP.river, QGEP.sector_water_body, QGEP.discharge_point, QGEP.wastewater_networkelement), + + (QGEP.measuring_device, QGEP.measuring_point, QGEP.waste_water_treatment_plant, QGEP.wastewater_networkelement), + (QGEP.measuring_device, QGEP.measuring_point, QGEP.wastewater_structure, QGEP.wastewater_networkelement), + (QGEP.measuring_device, QGEP.measuring_point, QGEP.water_course_segment, QGEP.river, QGEP.sector_water_body, QGEP.discharge_point, QGEP.wastewater_networkelement), + ) + ). + filter( + QGEP.wastewater_networkelement.obj_id.in_(subset_ids) + ) for row in query: # AVAILABLE FIELDS IN QGEP.measurement_result From 25a7a5fef919712e170d8cbe6d4efb79ebfe4a28 Mon Sep 17 00:00:00 2001 From: SJiB Date: Mon, 3 Jun 2024 17:24:59 +0200 Subject: [PATCH 017/111] add filter throttle_shut_off_unit --- qgepqwat2ili/qgepdss/export.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/qgepqwat2ili/qgepdss/export.py b/qgepqwat2ili/qgepdss/export.py index 194bea56..bfd5013a 100644 --- a/qgepqwat2ili/qgepdss/export.py +++ b/qgepqwat2ili/qgepdss/export.py @@ -3126,6 +3126,11 @@ def textpos_common(row, t_type, geojson_crs_def): logger.info("Exporting QGEP.throttle_shut_off_unit -> ABWASSER.absperr_drosselorgan, ABWASSER.metaattribute") query = qgep_session.query(QGEP.throttle_shut_off_unit) + # to check if fk_control_center__REL has also to be considered + if filtered: + query = query.join(QGEP.wastewater_networkelement).filter( + QGEP.wastewater_networkelement.obj_id.in_(subset_ids) + ) for row in query: # AVAILABLE FIELDS IN QGEP.throttle_shut_off_unit From 5e3fc299dd9557d5b0df7bd9409dec148ab6941b Mon Sep 17 00:00:00 2001 From: SJiB Date: Mon, 3 Jun 2024 17:30:09 +0200 Subject: [PATCH 018/111] add filter prank_weir --- qgepqwat2ili/qgepdss/export.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/qgepqwat2ili/qgepdss/export.py b/qgepqwat2ili/qgepdss/export.py index bfd5013a..d8984b20 100644 --- a/qgepqwat2ili/qgepdss/export.py +++ b/qgepqwat2ili/qgepdss/export.py @@ -3176,6 +3176,14 @@ def textpos_common(row, t_type, geojson_crs_def): logger.info("Exporting QGEP.prank_weir -> ABWASSER.streichwehr, ABWASSER.metaattribute") query = qgep_session.query(QGEP.prank_weir) + # to check if fk_overflow_char also has to be considered + if filtered: + query = query.join( + or_( + QGEP.wastewater_node.obj_id == QGEP.prank_weir.fk_wastewater_node, + QGEP.wastewater_node.obj_id == QGEP.prank_weir.fk_overflow_to, + ), + ).filter(QGEP.wastewater_networkelement.obj_id.in_(subset_ids)) for row in query: # AVAILABLE FIELDS IN QGEP.prank_weir From 1e73b7295d6f7c98e524646b6b0855b102c95792 Mon Sep 17 00:00:00 2001 From: SJiB Date: Mon, 3 Jun 2024 17:30:45 +0200 Subject: [PATCH 019/111] add filter pump --- qgepqwat2ili/qgepdss/export.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/qgepqwat2ili/qgepdss/export.py b/qgepqwat2ili/qgepdss/export.py index d8984b20..4e5409ab 100644 --- a/qgepqwat2ili/qgepdss/export.py +++ b/qgepqwat2ili/qgepdss/export.py @@ -3223,7 +3223,15 @@ def textpos_common(row, t_type, geojson_crs_def): logger.info("Exporting QGEP.pump -> ABWASSER.foerderaggregat, ABWASSER.metaattribute") query = qgep_session.query(QGEP.pump) - for row in query: + # to check if fk_overflow_char also has to be considered + if filtered: + query = query.join( + or_( + QGEP.wastewater_node.obj_id == QGEP.prank_weir.fk_wastewater_node, + QGEP.wastewater_node.obj_id == QGEP.prank_weir.fk_overflow_to, + ), + ).filter(QGEP.wastewater_networkelement.obj_id.in_(subset_ids)) + for row in query: # AVAILABLE FIELDS IN QGEP.pump # --- overflow --- From 26a9d75aa2b7db1073990c9810c4462456fcf72a Mon Sep 17 00:00:00 2001 From: SJiB Date: Mon, 3 Jun 2024 17:35:21 +0200 Subject: [PATCH 020/111] add filter leapingweir --- qgepqwat2ili/qgepdss/export.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/qgepqwat2ili/qgepdss/export.py b/qgepqwat2ili/qgepdss/export.py index 4e5409ab..d72dec51 100644 --- a/qgepqwat2ili/qgepdss/export.py +++ b/qgepqwat2ili/qgepdss/export.py @@ -3274,6 +3274,14 @@ def textpos_common(row, t_type, geojson_crs_def): logger.info("Exporting QGEP.leapingweir -> ABWASSER.leapingwehr, ABWASSER.metaattribute") query = qgep_session.query(QGEP.leapingweir) + # to check if fk_overflow_char also has to be considered + if filtered: + query = query.join( + or_( + QGEP.wastewater_node.obj_id == QGEP.prank_weir.fk_wastewater_node, + QGEP.wastewater_node.obj_id == QGEP.prank_weir.fk_overflow_to, + ), + ).filter(QGEP.wastewater_networkelement.obj_id.in_(subset_ids)) for row in query: # AVAILABLE FIELDS IN QGEP.leapingweir From dc4698d6b8fe77a5ecd7bfcb8e327e674b851777 Mon Sep 17 00:00:00 2001 From: SJiB Date: Mon, 3 Jun 2024 17:44:21 +0200 Subject: [PATCH 021/111] add filter hydraulic_char_data --- qgepqwat2ili/qgepdss/export.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/qgepqwat2ili/qgepdss/export.py b/qgepqwat2ili/qgepdss/export.py index d72dec51..33d80a1f 100644 --- a/qgepqwat2ili/qgepdss/export.py +++ b/qgepqwat2ili/qgepdss/export.py @@ -3319,6 +3319,11 @@ def textpos_common(row, t_type, geojson_crs_def): logger.info("Exporting QGEP.hydraulic_char_data -> ABWASSER.hydr_kennwerte, ABWASSER.metaattribute") query = qgep_session.query(QGEP.hydraulic_char_data) + # side overflow_char not considered + if filtered: + query = query.join(QGEP.wastewater_node).filter( + QGEP.wastewater_networkelement.obj_id.in_(subset_ids) + ) for row in query: # AVAILABLE FIELDS IN QGEP.hydraulic_char_data From b1b75941ebd7f950ebbd8acb895a838f641ccbea Mon Sep 17 00:00:00 2001 From: SJiB Date: Mon, 3 Jun 2024 17:47:33 +0200 Subject: [PATCH 022/111] comment on filter hydraulic_char_data and backflow_prevention --- qgepqwat2ili/qgepdss/export.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/qgepqwat2ili/qgepdss/export.py b/qgepqwat2ili/qgepdss/export.py index 33d80a1f..8ad31f99 100644 --- a/qgepqwat2ili/qgepdss/export.py +++ b/qgepqwat2ili/qgepdss/export.py @@ -3319,7 +3319,7 @@ def textpos_common(row, t_type, geojson_crs_def): logger.info("Exporting QGEP.hydraulic_char_data -> ABWASSER.hydr_kennwerte, ABWASSER.metaattribute") query = qgep_session.query(QGEP.hydraulic_char_data) - # side overflow_char not considered + # side fk_overflow_char not considered in filter query if filtered: query = query.join(QGEP.wastewater_node).filter( QGEP.wastewater_networkelement.obj_id.in_(subset_ids) @@ -3373,6 +3373,7 @@ def textpos_common(row, t_type, geojson_crs_def): logger.info("Exporting QGEP.backflow_prevention -> ABWASSER.rueckstausicherung, ABWASSER.metaattribute") query = qgep_session.query(QGEP.backflow_prevention) + # side fk_throttle_shut_off_unit and fk_overflow not considered in filter query - they are usually added only for log_cards and then the corresponding nodes exist anyway thru the direct relation. if filtered: query = query.join(QGEP.wastewater_structure, QGEP.wastewater_networkelement).filter( QGEP.wastewater_networkelement.obj_id.in_(subset_ids) From 2fe230b211d6d9150409af20337f2ab7618b1287 Mon Sep 17 00:00:00 2001 From: SJiB Date: Mon, 3 Jun 2024 17:48:23 +0200 Subject: [PATCH 023/111] comment on filter tank_cleaning --- qgepqwat2ili/qgepdss/export.py | 1 + 1 file changed, 1 insertion(+) diff --git a/qgepqwat2ili/qgepdss/export.py b/qgepqwat2ili/qgepdss/export.py index 8ad31f99..bf49bfdf 100644 --- a/qgepqwat2ili/qgepdss/export.py +++ b/qgepqwat2ili/qgepdss/export.py @@ -3460,6 +3460,7 @@ def textpos_common(row, t_type, geojson_crs_def): logger.info("Exporting QGEP.tank_cleaning -> ABWASSER.beckenreinigung, ABWASSER.metaattribute") query = qgep_session.query(QGEP.tank_cleaning) + # side fk_throttle_shut_off_unit and fk_overflow not considered in filter query - they are usually added only for log_cards and then the corresponding nodes exist anyway thru the direct relation. if filtered: query = query.join(QGEP.wastewater_structure, QGEP.wastewater_networkelement).filter( QGEP.wastewater_networkelement.obj_id.in_(subset_ids) From c3ae924acf6141a4b7f93feacf3ccffd7b2469cb Mon Sep 17 00:00:00 2001 From: SJiB Date: Mon, 3 Jun 2024 17:49:10 +0200 Subject: [PATCH 024/111] moved comment to tank_emptying --- qgepqwat2ili/qgepdss/export.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/qgepqwat2ili/qgepdss/export.py b/qgepqwat2ili/qgepdss/export.py index bf49bfdf..2d80be04 100644 --- a/qgepqwat2ili/qgepdss/export.py +++ b/qgepqwat2ili/qgepdss/export.py @@ -3460,7 +3460,6 @@ def textpos_common(row, t_type, geojson_crs_def): logger.info("Exporting QGEP.tank_cleaning -> ABWASSER.beckenreinigung, ABWASSER.metaattribute") query = qgep_session.query(QGEP.tank_cleaning) - # side fk_throttle_shut_off_unit and fk_overflow not considered in filter query - they are usually added only for log_cards and then the corresponding nodes exist anyway thru the direct relation. if filtered: query = query.join(QGEP.wastewater_structure, QGEP.wastewater_networkelement).filter( QGEP.wastewater_networkelement.obj_id.in_(subset_ids) @@ -3502,6 +3501,7 @@ def textpos_common(row, t_type, geojson_crs_def): logger.info("Exporting QGEP.tank_emptying -> ABWASSER.beckenentleerung, ABWASSER.metaattribute") query = qgep_session.query(QGEP.tank_emptying) + # side fk_throttle_shut_off_unit and fk_overflow not considered in filter query - they are usually added only for log_cards and then the corresponding nodes exist anyway thru the direct relation. if filtered: query = query.join(QGEP.wastewater_structure, QGEP.wastewater_networkelement).filter( QGEP.wastewater_networkelement.obj_id.in_(subset_ids) From 08430e8051d229d849f61cc636e3ee24a62170de Mon Sep 17 00:00:00 2001 From: SJiB Date: Mon, 3 Jun 2024 17:56:44 +0200 Subject: [PATCH 025/111] add filter re_maintenance_event_wastewater_structure --- qgepqwat2ili/qgepdss/export.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/qgepqwat2ili/qgepdss/export.py b/qgepqwat2ili/qgepdss/export.py index 2d80be04..8c1e49d7 100644 --- a/qgepqwat2ili/qgepdss/export.py +++ b/qgepqwat2ili/qgepdss/export.py @@ -3774,7 +3774,11 @@ def textpos_common(row, t_type, geojson_crs_def): # -- adapted 24.9.2022 to do adjust in MD code logger.info("Exporting QGEP.re_maintenance_event_wastewater_structure -> ABWASSER.erhaltungsereignis_abwasserbauwerkassoc") query = qgep_session.query(QGEP.re_maintenance_event_wastewater_structure) - for row in query: + if filtered: + query = query.join(QGEP.wastewater_structure, QGEP.wastewater_networkelement).filter( + QGEP.wastewater_networkelement.obj_id.in_(subset_ids) + ) + for row in query: # AVAILABLE FIELDS IN QGEP.maintenance_event_wastewater_structure From e17a46888bff884870f921ca337a80b513a5abff Mon Sep 17 00:00:00 2001 From: SJiB Date: Mon, 3 Jun 2024 18:23:02 +0200 Subject: [PATCH 026/111] add filter maintenance_event --- qgepqwat2ili/qgepdss/export.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/qgepqwat2ili/qgepdss/export.py b/qgepqwat2ili/qgepdss/export.py index 8c1e49d7..4a6304bd 100644 --- a/qgepqwat2ili/qgepdss/export.py +++ b/qgepqwat2ili/qgepdss/export.py @@ -3634,7 +3634,11 @@ def textpos_common(row, t_type, geojson_crs_def): # neu 17.4.2022 class maintenance_event as class, is not superclass in VSA-DSS 2015 logger.info("Exporting QGEP.maintenance_event -> ABWASSER.maintenance_event, ABWASSER.metaattribute") query = qgep_session.query(QGEP.maintenance_event) - + # to check if join is correct like this n:m re_maintenance_event_wastewater_structure + if filtered: + query = query.join(QGEP.re_maintenance_event_wastewater_structure, QGEP.wastewater_structure, QGEP.wastewater_networkelement).filter( + QGEP.wastewater_networkelement.obj_id.in_(subset_ids) + ) for row in query: # AVAILABLE FIELDS IN QGEP.maintenance_event From a0c45a17728f27dad14d01652a1dae0647105bdd Mon Sep 17 00:00:00 2001 From: SJiB Date: Mon, 3 Jun 2024 18:24:00 +0200 Subject: [PATCH 027/111] adjust intend --- qgepqwat2ili/qgepdss/export.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/qgepqwat2ili/qgepdss/export.py b/qgepqwat2ili/qgepdss/export.py index 4a6304bd..d6d4d87c 100644 --- a/qgepqwat2ili/qgepdss/export.py +++ b/qgepqwat2ili/qgepdss/export.py @@ -3782,7 +3782,7 @@ def textpos_common(row, t_type, geojson_crs_def): query = query.join(QGEP.wastewater_structure, QGEP.wastewater_networkelement).filter( QGEP.wastewater_networkelement.obj_id.in_(subset_ids) ) - for row in query: + for row in query: # AVAILABLE FIELDS IN QGEP.maintenance_event_wastewater_structure From f27356a68719ef213cbf6b560332b3d92f5cbc69 Mon Sep 17 00:00:00 2001 From: SJiB Date: Mon, 3 Jun 2024 19:14:46 +0200 Subject: [PATCH 028/111] correct syntax --- qgepqwat2ili/qgepdss/export.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/qgepqwat2ili/qgepdss/export.py b/qgepqwat2ili/qgepdss/export.py index d6d4d87c..4b4326c4 100644 --- a/qgepqwat2ili/qgepdss/export.py +++ b/qgepqwat2ili/qgepdss/export.py @@ -2942,8 +2942,7 @@ def textpos_common(row, t_type, geojson_crs_def): (QGEP.wastewater_structure, QGEP.wastewater_networkelement), (QGEP.water_course_segment, QGEP.river, QGEP.sector_water_body, QGEP.discharge_point, QGEP.wastewater_networkelement), ) - ). - filter( + ).filter( QGEP.wastewater_networkelement.obj_id.in_(subset_ids) ) for row in query: From f81d641fa0ec6897eb0f8f19759216d59a66ceec Mon Sep 17 00:00:00 2001 From: SJiB Date: Mon, 3 Jun 2024 19:16:00 +0200 Subject: [PATCH 029/111] correct syntax --- qgepqwat2ili/qgepdss/export.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/qgepqwat2ili/qgepdss/export.py b/qgepqwat2ili/qgepdss/export.py index 4b4326c4..a182fe39 100644 --- a/qgepqwat2ili/qgepdss/export.py +++ b/qgepqwat2ili/qgepdss/export.py @@ -2991,8 +2991,7 @@ def textpos_common(row, t_type, geojson_crs_def): (QGEP.measuring_point, QGEP.wastewater_structure, QGEP.wastewater_networkelement), (QGEP.measuring_point, QGEP.water_course_segment, QGEP.river, QGEP.sector_water_body, QGEP.discharge_point, QGEP.wastewater_networkelement), ) - ). - filter( + ).filter( QGEP.wastewater_networkelement.obj_id.in_(subset_ids) ) for row in query: From 7aca4b8d98d2a78862ecd0f300f21e7e6483d9ec Mon Sep 17 00:00:00 2001 From: SJiB Date: Mon, 3 Jun 2024 19:17:24 +0200 Subject: [PATCH 030/111] correct syntax --- qgepqwat2ili/qgepdss/export.py | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/qgepqwat2ili/qgepdss/export.py b/qgepqwat2ili/qgepdss/export.py index a182fe39..211c919b 100644 --- a/qgepqwat2ili/qgepdss/export.py +++ b/qgepqwat2ili/qgepdss/export.py @@ -3035,8 +3035,7 @@ def textpos_common(row, t_type, geojson_crs_def): (QGEP.measuring_point, QGEP.wastewater_structure, QGEP.wastewater_networkelement), (QGEP.measuring_point, QGEP.water_course_segment, QGEP.river, QGEP.sector_water_body, QGEP.discharge_point, QGEP.wastewater_networkelement), ) - ). - filter( + ).filter( QGEP.wastewater_networkelement.obj_id.in_(subset_ids) ) for row in query: @@ -3084,8 +3083,7 @@ def textpos_common(row, t_type, geojson_crs_def): (QGEP.measuring_device, QGEP.measuring_point, QGEP.wastewater_structure, QGEP.wastewater_networkelement), (QGEP.measuring_device, QGEP.measuring_point, QGEP.water_course_segment, QGEP.river, QGEP.sector_water_body, QGEP.discharge_point, QGEP.wastewater_networkelement), ) - ). - filter( + ).filter( QGEP.wastewater_networkelement.obj_id.in_(subset_ids) ) for row in query: From 4dbf1cffe601994003c726e3680fad43d50ef3c9 Mon Sep 17 00:00:00 2001 From: SJiB Date: Mon, 3 Jun 2024 19:20:52 +0200 Subject: [PATCH 031/111] correct intend --- qgepqwat2ili/qgepdss/export.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/qgepqwat2ili/qgepdss/export.py b/qgepqwat2ili/qgepdss/export.py index 211c919b..2208c5d4 100644 --- a/qgepqwat2ili/qgepdss/export.py +++ b/qgepqwat2ili/qgepdss/export.py @@ -3227,7 +3227,7 @@ def textpos_common(row, t_type, geojson_crs_def): QGEP.wastewater_node.obj_id == QGEP.prank_weir.fk_overflow_to, ), ).filter(QGEP.wastewater_networkelement.obj_id.in_(subset_ids)) - for row in query: + for row in query: # AVAILABLE FIELDS IN QGEP.pump # --- overflow --- @@ -3241,7 +3241,7 @@ def textpos_common(row, t_type, geojson_crs_def): # --- _rel_ --- # to do extra funktion schreiben wo alle fk auf diese klasse erzeugt werden z.B. # accessibility__REL, bedding_encasement__REL, - + foerderaggregat = ABWASSER.foerderaggregat( # FIELDS TO MAP TO ABWASSER.foerderaggregat # --- baseclass --- From 6952f6914b6ff7aafef1babc35c97f65294f2feb Mon Sep 17 00:00:00 2001 From: SJiB Date: Tue, 4 Jun 2024 17:51:54 +0200 Subject: [PATCH 032/111] correct join if also _or --- qgepqwat2ili/qgepdss/export.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/qgepqwat2ili/qgepdss/export.py b/qgepqwat2ili/qgepdss/export.py index 2208c5d4..3fe38708 100644 --- a/qgepqwat2ili/qgepdss/export.py +++ b/qgepqwat2ili/qgepdss/export.py @@ -2863,6 +2863,7 @@ def textpos_common(row, t_type, geojson_crs_def): query = qgep_session.query(QGEP.catchment_area) if filtered: query = query.join( + QGEP.wastewater_networkelement, or_( QGEP.wastewater_networkelement.obj_id == QGEP.catchment_area.fk_wastewater_networkelement_rw_planned, QGEP.wastewater_networkelement.obj_id == QGEP.catchment_area.fk_wastewater_networkelement_rw_current, @@ -3175,6 +3176,7 @@ def textpos_common(row, t_type, geojson_crs_def): # to check if fk_overflow_char also has to be considered if filtered: query = query.join( + QGEP.wastewater_node, or_( QGEP.wastewater_node.obj_id == QGEP.prank_weir.fk_wastewater_node, QGEP.wastewater_node.obj_id == QGEP.prank_weir.fk_overflow_to, @@ -3222,6 +3224,7 @@ def textpos_common(row, t_type, geojson_crs_def): # to check if fk_overflow_char also has to be considered if filtered: query = query.join( + QGEP.wastewater_node, or_( QGEP.wastewater_node.obj_id == QGEP.prank_weir.fk_wastewater_node, QGEP.wastewater_node.obj_id == QGEP.prank_weir.fk_overflow_to, @@ -3273,6 +3276,7 @@ def textpos_common(row, t_type, geojson_crs_def): # to check if fk_overflow_char also has to be considered if filtered: query = query.join( + QGEP.wastewater_node, or_( QGEP.wastewater_node.obj_id == QGEP.prank_weir.fk_wastewater_node, QGEP.wastewater_node.obj_id == QGEP.prank_weir.fk_overflow_to, From de245beea325e6dd16eed2c7c6708ea2ef6eaed9 Mon Sep 17 00:00:00 2001 From: SJiB Date: Tue, 4 Jun 2024 19:24:17 +0200 Subject: [PATCH 033/111] debugging if filtered statements --- qgepqwat2ili/qgepdss/export.py | 89 +++++++++++++++++++--------------- 1 file changed, 49 insertions(+), 40 deletions(-) diff --git a/qgepqwat2ili/qgepdss/export.py b/qgepqwat2ili/qgepdss/export.py index 3fe38708..67a3e2af 100644 --- a/qgepqwat2ili/qgepdss/export.py +++ b/qgepqwat2ili/qgepdss/export.py @@ -1953,7 +1953,8 @@ def textpos_common(row, t_type, geojson_crs_def): QGEP.reach, or_( QGEP.reach_point.obj_id == QGEP.reach.fk_reach_point_from, - # QGEP.reach_point.obj_id == QGEP.reach.fk_reach_point_to, + # 4.6.2024 again added + QGEP.reach_point.obj_id == QGEP.reach.fk_reach_point_to, ), ).filter(QGEP.wastewater_networkelement.obj_id.in_(subset_ids)) for row in query: @@ -2937,15 +2938,17 @@ def textpos_common(row, t_type, geojson_crs_def): logger.info("Exporting QGEP.measuring_point -> ABWASSER.messstelle, ABWASSER.metaattribute") query = qgep_session.query(QGEP.measuring_point) if filtered: - query = query.query.join( - or_( - (QGEP.waste_water_treatment_plant, QGEP.wastewater_networkelement), - (QGEP.wastewater_structure, QGEP.wastewater_networkelement), - (QGEP.water_course_segment, QGEP.river, QGEP.sector_water_body, QGEP.discharge_point, QGEP.wastewater_networkelement), - ) - ).filter( - QGEP.wastewater_networkelement.obj_id.in_(subset_ids) - ) + query = query.join(QGEP.wastewater_structure, QGEP.wastewater_networkelement).filter(QGEP.wastewater_networkelement.obj_id.in_(subset_ids) + ) + # QGEP.wastewater_networkelement, + # or does not work with this - currently do not support other connections + # or_( + # (QGEP.waste_water_treatment_plant, QGEP.wastewater_networkelement), + # (QGEP.wastewater_structure, QGEP.wastewater_networkelement), + # currently do not support other connections + # (QGEP.water_course_segment, QGEP.river, QGEP.sector_water_body, QGEP.discharge_point, QGEP.wastewater_networkelement), + # ) + for row in query: # AVAILABLE FIELDS IN QGEP.measuring_point @@ -2986,15 +2989,16 @@ def textpos_common(row, t_type, geojson_crs_def): logger.info("Exporting QGEP.measuring_device -> ABWASSER.messgeraet, ABWASSER.metaattribute") query = qgep_session.query(QGEP.measuring_device) if filtered: - query = query.query.join( - or_( - (QGEP.measuring_point, QGEP.waste_water_treatment_plant, QGEP.wastewater_networkelement), - (QGEP.measuring_point, QGEP.wastewater_structure, QGEP.wastewater_networkelement), - (QGEP.measuring_point, QGEP.water_course_segment, QGEP.river, QGEP.sector_water_body, QGEP.discharge_point, QGEP.wastewater_networkelement), - ) - ).filter( - QGEP.wastewater_networkelement.obj_id.in_(subset_ids) + query = query.join(QGEP.measuring_point, QGEP.wastewater_structure, QGEP.wastewater_networkelement).filter(QGEP.wastewater_networkelement.obj_id.in_(subset_ids) ) + # or does not work with this - currently do not support + # QGEP.wastewater_networkelement, + # or_( + # (QGEP.measuring_point, QGEP.waste_water_treatment_plant, QGEP.wastewater_networkelement), + # (QGEP.measuring_point, QGEP.wastewater_structure, QGEP.wastewater_networkelement), + # (QGEP.measuring_point, QGEP.water_course_segment, QGEP.river, QGEP.sector_water_body, QGEP.discharge_point, QGEP.wastewater_networkelement), + # ) + for row in query: # AVAILABLE FIELDS IN QGEP.measuring_device @@ -3030,15 +3034,14 @@ def textpos_common(row, t_type, geojson_crs_def): logger.info("Exporting QGEP.measurement_series -> ABWASSER.messreihe, ABWASSER.metaattribute") query = qgep_session.query(QGEP.measurement_series) if filtered: - query = query.query.join( - or_( - (QGEP.measuring_point, QGEP.waste_water_treatment_plant, QGEP.wastewater_networkelement), - (QGEP.measuring_point, QGEP.wastewater_structure, QGEP.wastewater_networkelement), - (QGEP.measuring_point, QGEP.water_course_segment, QGEP.river, QGEP.sector_water_body, QGEP.discharge_point, QGEP.wastewater_networkelement), - ) - ).filter( - QGEP.wastewater_networkelement.obj_id.in_(subset_ids) - ) + query = query.join(QGEP.measuring_point, QGEP.wastewater_structure, QGEP.wastewater_networkelement).filter(QGEP.wastewater_networkelement.obj_id.in_(subset_ids) + ) + # QGEP.wastewater_networkelement, + # or_( + # (QGEP.measuring_point, QGEP.waste_water_treatment_plant, QGEP.wastewater_networkelement), + # (QGEP.measuring_point, QGEP.wastewater_structure, QGEP.wastewater_networkelement), + # (QGEP.measuring_point, QGEP.water_course_segment, QGEP.river, QGEP.sector_water_body, QGEP.discharge_point, QGEP.wastewater_networkelement), + # ) for row in query: # AVAILABLE FIELDS IN QGEP.measurement_series @@ -3074,19 +3077,19 @@ def textpos_common(row, t_type, geojson_crs_def): logger.info("Exporting QGEP.measurement_result -> ABWASSER.messresultat, ABWASSER.metaattribute") query = qgep_session.query(QGEP.measurement_result) if filtered: - query = query.query.join( - or_( - (QGEP.measurement_series, QGEP.measuring_point, QGEP.waste_water_treatment_plant, QGEP.wastewater_networkelement), - (QGEP.measurement_series, QGEP.measuring_point, QGEP.wastewater_structure, QGEP.wastewater_networkelement), - (QGEP.measurement_series, QGEP.measuring_point, QGEP.water_course_segment, QGEP.river, QGEP.sector_water_body, QGEP.discharge_point, QGEP.wastewater_networkelement), - - (QGEP.measuring_device, QGEP.measuring_point, QGEP.waste_water_treatment_plant, QGEP.wastewater_networkelement), - (QGEP.measuring_device, QGEP.measuring_point, QGEP.wastewater_structure, QGEP.wastewater_networkelement), - (QGEP.measuring_device, QGEP.measuring_point, QGEP.water_course_segment, QGEP.river, QGEP.sector_water_body, QGEP.discharge_point, QGEP.wastewater_networkelement), - ) - ).filter( + query = query.join(QGEP.measurement_series, QGEP.measuring_point, QGEP.wastewater_structure, QGEP.wastewater_networkelement).filter( QGEP.wastewater_networkelement.obj_id.in_(subset_ids) ) + # or_( + # (QGEP.measurement_series, QGEP.measuring_point, QGEP.waste_water_treatment_plant, QGEP.wastewater_networkelement), + # (QGEP.measurement_series, QGEP.measuring_point, QGEP.wastewater_structure, QGEP.wastewater_networkelement), + # (QGEP.measurement_series, QGEP.measuring_point, QGEP.water_course_segment, QGEP.river, QGEP.sector_water_body, QGEP.discharge_point, QGEP.wastewater_networkelement), + + # (QGEP.measuring_device, QGEP.measuring_point, QGEP.waste_water_treatment_plant, QGEP.wastewater_networkelement), + # (QGEP.measuring_device, QGEP.measuring_point, QGEP.wastewater_structure, QGEP.wastewater_networkelement), + # (QGEP.measuring_device, QGEP.measuring_point, QGEP.water_course_segment, QGEP.river, QGEP.sector_water_body, QGEP.discharge_point, QGEP.wastewater_networkelement), + # ) + for row in query: # AVAILABLE FIELDS IN QGEP.measurement_result @@ -3123,9 +3126,15 @@ def textpos_common(row, t_type, geojson_crs_def): logger.info("Exporting QGEP.throttle_shut_off_unit -> ABWASSER.absperr_drosselorgan, ABWASSER.metaattribute") query = qgep_session.query(QGEP.throttle_shut_off_unit) - # to check if fk_control_center__REL has also to be considered + # sqlalchemy.exc.InvalidRequestError: Don't know how to join to . Please use the .select_from() method to establish an explicit left side, as well as providing an explcit ON clause if not present already to help resolve the ambiguity. + # fk_control_center has also to be NOT considered if filtered: - query = query.join(QGEP.wastewater_networkelement).filter( + query = query.join( + QGEP.wastewater_node, + or_( + QGEP.wastewater_node.obj_id == QGEP.throttle_shut_off_unit.fk_wastewater_node, + ), + ).filter( QGEP.wastewater_networkelement.obj_id.in_(subset_ids) ) for row in query: From 821926ed71939859364cabe1b5f7f315e57b29d3 Mon Sep 17 00:00:00 2001 From: SJiB Date: Wed, 5 Jun 2024 13:38:18 +0200 Subject: [PATCH 034/111] added query.union to measuring_point --- qgepqwat2ili/qgepdss/export.py | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/qgepqwat2ili/qgepdss/export.py b/qgepqwat2ili/qgepdss/export.py index 67a3e2af..9db3192a 100644 --- a/qgepqwat2ili/qgepdss/export.py +++ b/qgepqwat2ili/qgepdss/export.py @@ -2938,7 +2938,24 @@ def textpos_common(row, t_type, geojson_crs_def): logger.info("Exporting QGEP.measuring_point -> ABWASSER.messstelle, ABWASSER.metaattribute") query = qgep_session.query(QGEP.measuring_point) if filtered: - query = query.join(QGEP.wastewater_structure, QGEP.wastewater_networkelement).filter(QGEP.wastewater_networkelement.obj_id.in_(subset_ids) + query1=query.join(QGEP.wastewater_structure, QGEP.wastewater_networkelement) + # needs to add QGEP.wastewater_structure as waste_water_treatment_plant is a subclass of organisation that has a relation to wastewater_structure and then wastewater_networkelement + #variant1 for query2 + # query2=query.join(QGEP.waste_water_treatment_plant, (QGEP.wastewater_structure, QGEP.waste_water_treatment_plant.obj_id == QGEP.wastewater_structure.fk_owner), (QGEP.wastewater_structure, QGEP.waste_water_treatment_plant.obj_id == QGEP.wastewater_structure.fk_provider),QGEP.wastewater_networkelement, + # ) + #variant2 for query2 + # try with extra or_ + # or_( + # QGEP.waste_water_treatment_plant.obj_id == QGEP.wastewater_structure.fk_owner, + # QGEP.waste_water_treatment_plant.obj_id == QGEP.wastewater_structure.fk_provider, + # ), + # QGEP.wastewater_networkelement, + + # ) + query3=query.join(QGEP.water_course_segment, QGEP.river, QGEP.sector_water_body, QGEP.discharge_point, QGEP.wastewater_networkelement) + # query=union(query1, query2, query3) + query=query.union(query1, query3) + query = query.filter(QGEP.wastewater_networkelement.obj_id.in_(subset_ids) ) # QGEP.wastewater_networkelement, # or does not work with this - currently do not support other connections From 5f7c77c0c7fa324924896cc500475e572cf80ca6 Mon Sep 17 00:00:00 2001 From: SJiB Date: Wed, 12 Jun 2024 15:34:27 +0200 Subject: [PATCH 035/111] cleanup qgep export --- qgepqwat2ili/qgep/export.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/qgepqwat2ili/qgep/export.py b/qgepqwat2ili/qgep/export.py index 7fb27d24..f45a17ac 100644 --- a/qgepqwat2ili/qgep/export.py +++ b/qgepqwat2ili/qgep/export.py @@ -96,7 +96,7 @@ def modulo_angle(val): if val is None: return None - # 5.4.2023 add orientation + # add orientation val = val + float(labelorientation) val = val % 360.0 From c8b7ca95a368e2a26c1ffb552d6da8b4d75f27a9 Mon Sep 17 00:00:00 2001 From: SJiB Date: Wed, 12 Jun 2024 15:42:53 +0200 Subject: [PATCH 036/111] cleanup qgepsia405 --- qgepqwat2ili/qgepsia405/export.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/qgepqwat2ili/qgepsia405/export.py b/qgepqwat2ili/qgepsia405/export.py index 90e5e58a..a8a8cf48 100644 --- a/qgepqwat2ili/qgepsia405/export.py +++ b/qgepqwat2ili/qgepsia405/export.py @@ -97,7 +97,7 @@ def modulo_angle(val): if val is None: return None - # 5.4.2023 add orientation + # add orientation val = val + float(labelorientation) val = val % 360.0 @@ -114,10 +114,11 @@ def create_metaattributes(row): # FIELDS TO MAP TO ABWASSER.metaattribute # --- metaattribute --- - # 31.3.2023 obj_id instead of name + # datenherr=getattr(row.fk_dataowner__REL, "name", "unknown"), # TODO : is unknown ok ? # datenlieferant=getattr(row.fk_provider__REL, "name", "unknown"), # TODO : is unknown ok ? - + + # obj_id instead of name datenherr=getattr(row.fk_dataowner__REL, "obj_id", "unknown"), # TODO : is unknown ok ? datenlieferant=getattr(row.fk_provider__REL, "obj_id", "unknown"), # TODO : is unknown ok ? From 4650fa66dbad5f4e249f53978b1dc407f5ea78c6 Mon Sep 17 00:00:00 2001 From: SJiB Date: Wed, 12 Jun 2024 15:56:07 +0200 Subject: [PATCH 037/111] cleanup gepdss export --- qgepqwat2ili/qgepdss/export.py | 52 +++++++++++++--------------------- 1 file changed, 20 insertions(+), 32 deletions(-) diff --git a/qgepqwat2ili/qgepdss/export.py b/qgepqwat2ili/qgepdss/export.py index 9db3192a..db9e04dd 100644 --- a/qgepqwat2ili/qgepdss/export.py +++ b/qgepqwat2ili/qgepdss/export.py @@ -1,5 +1,3 @@ -# version von hand 13.3.2023 - import json from geoalchemy2.functions import ST_Force2D, ST_GeomFromGeoJSON @@ -11,9 +9,7 @@ from .model_abwasser import get_abwasser_model from .model_qgep import get_qgep_model -# 18.3.2023 adapted as in /qgep version -# def qgep_export(selection=None): -#def qgep_export(selection=None, labels_file=None): + def qgep_export(selection=None, labels_file=None, orientation=None): """ Export data from the QGEP model into the ili2pg model. @@ -102,7 +98,7 @@ def modulo_angle(val): if val is None: return None - # 5.4.2023 add orientation + # add orientation val = val + float(labelorientation) val = val % 360.0 @@ -120,11 +116,11 @@ def create_metaattributes(row): # FIELDS TO MAP TO ABWASSER.metaattribute # --- metaattribute --- - # 31.3.2023 obj_id instead of name + # datenherr=getattr(row.fk_dataowner__REL, "name", "unknown"), # TODO : is unknown ok ? # datenlieferant=getattr(row.fk_provider__REL, "name", "unknown"), # TODO : is unknown ok ? - + # obj_id instead of name datenherr=getattr(row.fk_dataowner__REL, "obj_id", "unknown"), # TODO : is unknown ok ? datenlieferant=getattr(row.fk_provider__REL, "obj_id", "unknown"), # TODO : is unknown ok ? @@ -155,7 +151,7 @@ def organisation_common(row): return { "bemerkung": truncate(emptystr_to_null(row.remark), 80), "bezeichnung": row.identifier, - # 5.9.2022 doppelt - erst in release 2020 bei organisation + # attribute organisation.gemeindenummer will be added with release 2020 # "gemeindenummer": row.municipality_number, # not supported in model qgep 2015 # "teil_vonref": get_tid(row.fk_part_of__REL), @@ -332,7 +328,8 @@ def textpos_common(row, t_type, geojson_crs_def): "textinhalt": row["properties"]["LabelText"], "bemerkung": None, } -# -- 25.9.2022 re_maintenance_event_wastewater_structure moved to end, as wastewater_structure and maintenance_event are not yet added + +# re_maintenance_event_wastewater_structure moved to end, as wastewater_structure and maintenance_event are not yet added logger.info("Exporting QGEP.mutation -> ABWASSER.mutation, ABWASSER.metaattribute") query = qgep_session.query(QGEP.mutation) @@ -360,8 +357,9 @@ def textpos_common(row, t_type, geojson_crs_def): aufnahmedatum=row.date_time, aufnehmer=row.recorded_by, bemerkung=truncate(emptystr_to_null(row.remark), 80), - # 21.7.2022 zuerst qgep datenmodell anpassen + # Model adapted with delta/delta_1.5.8_dss_upddate_attributes_class.sql #klasse=row.class, + klasse=row.classname, letzter_wert=row.last_value, mutationsdatum=row.date_mutation, objekt=null_to_emptystr(row.object), @@ -663,7 +661,7 @@ def textpos_common(row, t_type, geojson_crs_def): oberflaechengewaesserref=get_tid(row.fk_surface_water_body__REL), reflaenge=row.ref_length, verlauf=ST_Force2D(row.progression_geometry), - # 6.9.2022 to do md rausnehmen da auf gleiche klasse + # reference to own class not supported in qgep # vorherigersektorref=get_tid(row.fk_sector_previous__REL), ) abwasser_session.add(gewaessersektor) @@ -1953,7 +1951,6 @@ def textpos_common(row, t_type, geojson_crs_def): QGEP.reach, or_( QGEP.reach_point.obj_id == QGEP.reach.fk_reach_point_from, - # 4.6.2024 again added QGEP.reach_point.obj_id == QGEP.reach.fk_reach_point_to, ), ).filter(QGEP.wastewater_networkelement.obj_id.in_(subset_ids)) @@ -2919,7 +2916,7 @@ def textpos_common(row, t_type, geojson_crs_def): perimeter=ST_Force2D(row.perimeter_geometry), retention_geplant=get_vl(row.retention_planned__REL), retention_ist=get_vl(row.retention_current__REL), - # 6.9.2022 only in Release 2020 to do in code von MD abfangen + # sbw_*ref will be added with release 2020 # sbw_rw_geplantref=get_tid(row.fk_special_building_rw_planned__REL), # sbw_rw_istref=get_tid(row.fk_special_building_rw_current__REL), # sbw_sw_geplantref=get_tid(row.fk_special_building_ww_planned__REL), @@ -3378,7 +3375,7 @@ def textpos_common(row, t_type, geojson_crs_def): foerderstrommin=row.pump_flow_min, hauptwehrart=get_vl(row.main_weir_kind__REL), mehrbelastung=row.overcharge, - # 6.9.2022 erst in release 2020 md anpassen + # primaerrichtungref will be added with release 2020 #primaerrichtungref=get_tid(row.fk_primary_direction__REL), pumpenregime=get_vl(row.pump_characteristics__REL), qab=row.q_discharge, @@ -3657,7 +3654,7 @@ def textpos_common(row, t_type, geojson_crs_def): logger.info("done") abwasser_session.flush() -# neu 17.4.2022 class maintenance_event as class, is not superclass in VSA-DSS 2015 +# class maintenance_event as class, is not superclass in VSA-DSS 2015 logger.info("Exporting QGEP.maintenance_event -> ABWASSER.maintenance_event, ABWASSER.metaattribute") query = qgep_session.query(QGEP.maintenance_event) # to check if join is correct like this n:m re_maintenance_event_wastewater_structure @@ -3795,13 +3792,11 @@ def textpos_common(row, t_type, geojson_crs_def): # -- extra commit abwasser_session.commit() -# -- extra session2 +# -- extra session2 for re_maintenance_event_wastewater_structure abwasser_session2 = Session(utils.sqlalchemy.create_engine(), autocommit=False, autoflush=False) -# -- logger.info("Exporting QGEP.re_maintenance_event_wastewater_structure -> ABWASSER.erhaltungsereignis_abwasserbauwerk, ABWASSER.metaattribute") -# -- adapted 24.9.2022 to do adjust in MD code logger.info("Exporting QGEP.re_maintenance_event_wastewater_structure -> ABWASSER.erhaltungsereignis_abwasserbauwerkassoc") query = qgep_session.query(QGEP.re_maintenance_event_wastewater_structure) if filtered: @@ -3820,34 +3815,27 @@ def textpos_common(row, t_type, geojson_crs_def): # --- _rel_ --- # to do add relations fk_dataowner__REL, fk_provider__REL, profile_type__REL -# -- erhaltungsereignis_abwasserbauwerk = ABWASSER.erhaltungsereignis_abwasserbauwerk( -# -- adapted 24.9.2022 to do adjust in MD code + erhaltungsereignis_abwasserbauwerk = ABWASSER.erhaltungsereignis_abwasserbauwerkassoc( # FIELDS TO MAP TO ABWASSER.erhaltungsereignis_abwasserbauwerk # --- baseclass --- # --- sia405_baseclass --- -# -- **base_common(row, "erhaltungsereignis_abwasserbauwerk"), -# -- adapted 24.9.2022 to do adjust in MD code -# -- adapted2 24.9.2022 no base for erhaltungsereignis_abwasserbauwerkassoc -# -- **base_common(row, "erhaltungsereignis_abwasserbauwerkassoc"), + # --- erhaltungsereignis_abwasserbauwerk --- abwasserbauwerkref=get_tid(row.fk_wastewater_structure__REL), -# -- erhaltungsereignisref=get_tid(row.fk_maintenance_event__REL), -# -- adapted 24.9.2022 to do adjust in MD code erhaltungsereignis_abwasserbauwerkassocref=get_tid(row.fk_maintenance_event__REL), ) -# abwasser_session.add(erhaltungsereignis_abwasserbauwerk) + abwasser_session2.add(erhaltungsereignis_abwasserbauwerk) -# -- 24.9.2022 adapted to do MD code - no metaattributes -# -- create_metaattributes(row) + print(".", end="") logger.info("done") -# -- 25.9.22 abwasser_session.flush() + abwasser_session2.flush() -# -- 25.9.22 abwasser_session.commit() + abwasser_session2.commit() qgep_session.close() From 14401aac56c5ad44e779b9af858ec2361780707f Mon Sep 17 00:00:00 2001 From: SJiB Date: Wed, 12 Jun 2024 17:30:54 +0200 Subject: [PATCH 038/111] adding check_fk_in_subsetid --- qgepqwat2ili/qgepdss/export.py | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/qgepqwat2ili/qgepdss/export.py b/qgepqwat2ili/qgepdss/export.py index db9e04dd..0fc72b93 100644 --- a/qgepqwat2ili/qgepdss/export.py +++ b/qgepqwat2ili/qgepdss/export.py @@ -110,7 +110,22 @@ def modulo_angle(val): return val + + def check_fk_in_subsetid (foreignkey2, subset): + """ + 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 ") + else: + logger.info(f"check_fk_in_subsetid - '{foreignkey2}' is not in subset - replaced with None instead!") + foreignkey2 = None + return foreignkey2 + + def create_metaattributes(row): metaattribute = ABWASSER.metaattribute( # FIELDS TO MAP TO ABWASSER.metaattribute @@ -1956,6 +1971,9 @@ 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 --- @@ -1973,7 +1991,8 @@ def textpos_common(row, t_type, geojson_crs_def): **base_common(row, "haltungspunkt"), # --- haltungspunkt --- - abwassernetzelementref=get_tid(row.fk_wastewater_networkelement__REL), + #abwassernetzelementref=get_tid(row.fk_wastewater_networkelement__REL), + abwassernetzelementref=get_tid(check_fk_in_subsetid((row.fk_wastewater_networkelement__REL), subset_ids)), auslaufform=get_vl(row.outlet_shape__REL), bemerkung=truncate(emptystr_to_null(row.remark), 80), bezeichnung=null_to_emptystr(row.identifier), From 0fc75cbba486f95018546b20dd353c34bcb1e443 Mon Sep 17 00:00:00 2001 From: SJiB Date: Fri, 14 Jun 2024 23:07:38 +0200 Subject: [PATCH 039/111] 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), From 1c137521b4d6089acc8e8c81de1b0173309b1d89 Mon Sep 17 00:00:00 2001 From: SJiB Date: Fri, 14 Jun 2024 23:08:54 +0200 Subject: [PATCH 040/111] change description of check_fk_in_subsetid --- qgepqwat2ili/qgepdss/export.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/qgepqwat2ili/qgepdss/export.py b/qgepqwat2ili/qgepdss/export.py index 55d4703c..313beb07 100644 --- a/qgepqwat2ili/qgepdss/export.py +++ b/qgepqwat2ili/qgepdss/export.py @@ -114,7 +114,7 @@ def modulo_angle(val): 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 + checks, whether foreignkey is in the subset_ids - if yes it return the tid of the foreignkey, if no it will return None """ logger.info(f"check_fk_in_subsetid - Subset ID's '{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 From 63fec54a594cc86d320cb2e1ecc800e571314881 Mon Sep 17 00:00:00 2001 From: SJiB Date: Fri, 14 Jun 2024 23:15:54 +0200 Subject: [PATCH 041/111] add check_fk_in_subsetid to qgep and qgepsia405 --- qgepqwat2ili/qgep/export.py | 23 +++++++++++++++++++++-- qgepqwat2ili/qgepdss/export.py | 2 +- qgepqwat2ili/qgepsia405/export.py | 22 +++++++++++++++++++++- 3 files changed, 43 insertions(+), 4 deletions(-) diff --git a/qgepqwat2ili/qgep/export.py b/qgepqwat2ili/qgep/export.py index f45a17ac..aa681acd 100644 --- a/qgepqwat2ili/qgep/export.py +++ b/qgepqwat2ili/qgep/export.py @@ -9,7 +9,6 @@ from .model_abwasser import get_abwasser_model from .model_qgep import get_qgep_model -#def qgep_export(selection=None, labels_file=None): def qgep_export(selection=None, labels_file=None, orientation=None): """ Export data from the QGEP model into the ili2pg model. @@ -108,6 +107,23 @@ def modulo_angle(val): return val + def check_fk_in_subsetid (subset, relation): + """ + checks, whether foreignkey is in the subset_ids - if yes it return the tid of the foreignkey, if no it will return None + """ + logger.info(f"check_fk_in_subsetid - Subset ID's '{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 - '{fremdschluesselstr}' is not in subset - replaced with None instead!") + return None + def create_metaattributes(row): metaattribute = ABWASSER.metaattribute( # FIELDS TO MAP TO ABWASSER.metaattribute @@ -507,7 +523,10 @@ def textpos_common(row, t_type, geojson_crs_def): # --- sia405_baseclass --- **base_common(row, "haltungspunkt"), # --- haltungspunkt --- - abwassernetzelementref=get_tid(row.fk_wastewater_networkelement__REL), + + # changed call from get_tid to check_fk_in_subsetid so it does not wirte foreignkeys on elements that do not exist + #abwassernetzelementref=get_tid(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), diff --git a/qgepqwat2ili/qgepdss/export.py b/qgepqwat2ili/qgepdss/export.py index 313beb07..a77a030a 100644 --- a/qgepqwat2ili/qgepdss/export.py +++ b/qgepqwat2ili/qgepdss/export.py @@ -1991,8 +1991,8 @@ def textpos_common(row, t_type, geojson_crs_def): **base_common(row, "haltungspunkt"), # --- haltungspunkt --- + # changed call from get_tid to check_fk_in_subsetid so it does not wirte foreignkeys on elements that do not exist #abwassernetzelementref=get_tid(row.fk_wastewater_networkelement__REL), - # 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), diff --git a/qgepqwat2ili/qgepsia405/export.py b/qgepqwat2ili/qgepsia405/export.py index a8a8cf48..d7ffae0e 100644 --- a/qgepqwat2ili/qgepsia405/export.py +++ b/qgepqwat2ili/qgepsia405/export.py @@ -109,6 +109,23 @@ def modulo_angle(val): return val + def check_fk_in_subsetid (subset, relation): + """ + checks, whether foreignkey is in the subset_ids - if yes it return the tid of the foreignkey, if no it will return None + """ + logger.info(f"check_fk_in_subsetid - Subset ID's '{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 - '{fremdschluesselstr}' is not in subset - replaced with None instead!") + return None + def create_metaattributes(row): metaattribute = ABWASSER.metaattribute( # FIELDS TO MAP TO ABWASSER.metaattribute @@ -506,7 +523,10 @@ def textpos_common(row, t_type, geojson_crs_def): # --- sia405_baseclass --- **base_common(row, "haltungspunkt"), # --- haltungspunkt --- - abwassernetzelementref=get_tid(row.fk_wastewater_networkelement__REL), + + # changed call from get_tid to check_fk_in_subsetid so it does not wirte foreignkeys on elements that do not exist + #abwassernetzelementref=get_tid(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), From 4c8f9937475538b4e85f7654c78ab18554662a8f Mon Sep 17 00:00:00 2001 From: SJiB Date: Fri, 14 Jun 2024 23:23:40 +0200 Subject: [PATCH 042/111] add first check for None, --- qgepqwat2ili/qgep/export.py | 4 ++++ qgepqwat2ili/qgepdss/export.py | 4 ++++ qgepqwat2ili/qgepsia405/export.py | 4 ++++ 3 files changed, 12 insertions(+) diff --git a/qgepqwat2ili/qgep/export.py b/qgepqwat2ili/qgep/export.py index aa681acd..2fd6b1b9 100644 --- a/qgepqwat2ili/qgep/export.py +++ b/qgepqwat2ili/qgep/export.py @@ -111,6 +111,10 @@ def check_fk_in_subsetid (subset, relation): """ checks, whether foreignkey is in the subset_ids - if yes it return the tid of the foreignkey, if no it will return None """ + # first check for None, as is get_tid + if relation is None: + return None + logger.info(f"check_fk_in_subsetid - Subset ID's '{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") diff --git a/qgepqwat2ili/qgepdss/export.py b/qgepqwat2ili/qgepdss/export.py index a77a030a..bba24db4 100644 --- a/qgepqwat2ili/qgepdss/export.py +++ b/qgepqwat2ili/qgepdss/export.py @@ -116,6 +116,10 @@ def check_fk_in_subsetid (subset, relation): """ checks, whether foreignkey is in the subset_ids - if yes it return the tid of the foreignkey, if no it will return None """ + # first check for None, as is get_tid + if relation is None: + return None + logger.info(f"check_fk_in_subsetid - Subset ID's '{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") diff --git a/qgepqwat2ili/qgepsia405/export.py b/qgepqwat2ili/qgepsia405/export.py index d7ffae0e..f45a9c1f 100644 --- a/qgepqwat2ili/qgepsia405/export.py +++ b/qgepqwat2ili/qgepsia405/export.py @@ -113,6 +113,10 @@ def check_fk_in_subsetid (subset, relation): """ checks, whether foreignkey is in the subset_ids - if yes it return the tid of the foreignkey, if no it will return None """ + # first check for None, as is get_tid + if relation is None: + return None + logger.info(f"check_fk_in_subsetid - Subset ID's '{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") From d8ee3a6b532fdb99c321807837626c869ae52c5c Mon Sep 17 00:00:00 2001 From: SJiB Date: Mon, 17 Jun 2024 11:19:55 +0200 Subject: [PATCH 043/111] catchment_area - changed from get_tid to check_fk_in_subsetid --- qgepqwat2ili/qgepdss/export.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/qgepqwat2ili/qgepdss/export.py b/qgepqwat2ili/qgepdss/export.py index bba24db4..30c45c59 100644 --- a/qgepqwat2ili/qgepdss/export.py +++ b/qgepqwat2ili/qgepdss/export.py @@ -2918,10 +2918,10 @@ def textpos_common(row, t_type, geojson_crs_def): abflussbeiwert_rw_ist=row.discharge_coefficient_rw_current, abflussbeiwert_sw_geplant=row.discharge_coefficient_ww_planned, abflussbeiwert_sw_ist=row.discharge_coefficient_ww_current, - abwassernetzelement_rw_geplantref=get_tid(row.fk_wastewater_networkelement_rw_planned__REL), - abwassernetzelement_rw_istref=get_tid(row.fk_wastewater_networkelement_rw_current__REL), - abwassernetzelement_sw_geplantref=get_tid(row.fk_wastewater_networkelement_ww_planned__REL), - abwassernetzelement_sw_istref=get_tid(row.fk_wastewater_networkelement_ww_current__REL), + abwassernetzelement_rw_geplantref=check_fk_in_subsetid(row.fk_wastewater_networkelement_rw_planned__REL), + abwassernetzelement_rw_istref=check_fk_in_subsetid(row.fk_wastewater_networkelement_rw_current__REL), + abwassernetzelement_sw_geplantref=check_fk_in_subsetid(row.fk_wastewater_networkelement_ww_planned__REL), + abwassernetzelement_sw_istref=check_fk_in_subsetid(row.fk_wastewater_networkelement_ww_current__REL), befestigungsgrad_rw_geplant=row.seal_factor_rw_planned, befestigungsgrad_rw_ist=row.seal_factor_rw_current, befestigungsgrad_sw_geplant=row.seal_factor_ww_planned, From 15f64341af5eaa9b60f67f863793b373f4833f7b Mon Sep 17 00:00:00 2001 From: SJiB Date: Mon, 17 Jun 2024 19:49:23 +0200 Subject: [PATCH 044/111] add ALL DEFERRED --- qgepqwat2ili/qgep/export.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/qgepqwat2ili/qgep/export.py b/qgepqwat2ili/qgep/export.py index 7fb27d24..73963818 100644 --- a/qgepqwat2ili/qgep/export.py +++ b/qgepqwat2ili/qgep/export.py @@ -28,6 +28,9 @@ def qgep_export(selection=None, labels_file=None, orientation=None): abwasser_session = Session(utils.sqlalchemy.create_engine(), autocommit=False, autoflush=False) tid_maker = utils.ili2db.TidMaker(id_attribute="obj_id") + # backport from tww https://github.com/teksi/wastewater/blob/3acfba249866d299f8a22e249d9f1e475fe7b88d/plugin/teksi_wastewater/interlis/interlis_model_mapping/interlis_exporter_to_intermediate_schema.py#L83 + abwasser_session.execute(text("SET CONSTRAINTS ALL DEFERRED;")) + # Filtering filtered = selection is not None subset_ids = selection if selection is not None else [] From a1f3bf890385e0d0ff05e234f65f59d53535b2e7 Mon Sep 17 00:00:00 2001 From: SJiB Date: Mon, 17 Jun 2024 19:58:50 +0200 Subject: [PATCH 045/111] same to qgepdss and qgepsia405 --- qgepqwat2ili/qgepdss/export.py | 3 +++ qgepqwat2ili/qgepsia405/export.py | 3 +++ 2 files changed, 6 insertions(+) diff --git a/qgepqwat2ili/qgepdss/export.py b/qgepqwat2ili/qgepdss/export.py index fe81abb1..1d137aa1 100644 --- a/qgepqwat2ili/qgepdss/export.py +++ b/qgepqwat2ili/qgepdss/export.py @@ -32,6 +32,9 @@ def qgep_export(selection=None, labels_file=None, orientation=None): abwasser_session = Session(utils.sqlalchemy.create_engine(), autocommit=False, autoflush=False) tid_maker = utils.ili2db.TidMaker(id_attribute="obj_id") + # backport from tww https://github.com/teksi/wastewater/blob/3acfba249866d299f8a22e249d9f1e475fe7b88d/plugin/teksi_wastewater/interlis/interlis_model_mapping/interlis_exporter_to_intermediate_schema.py#L83 + abwasser_session.execute(text("SET CONSTRAINTS ALL DEFERRED;")) + # Filtering filtered = selection is not None subset_ids = selection if selection is not None else [] diff --git a/qgepqwat2ili/qgepsia405/export.py b/qgepqwat2ili/qgepsia405/export.py index 90e5e58a..bd8b3772 100644 --- a/qgepqwat2ili/qgepsia405/export.py +++ b/qgepqwat2ili/qgepsia405/export.py @@ -29,6 +29,9 @@ def qgep_export(selection=None, labels_file=None, orientation=None): abwasser_session = Session(utils.sqlalchemy.create_engine(), autocommit=False, autoflush=False) tid_maker = utils.ili2db.TidMaker(id_attribute="obj_id") + # backport from tww https://github.com/teksi/wastewater/blob/3acfba249866d299f8a22e249d9f1e475fe7b88d/plugin/teksi_wastewater/interlis/interlis_model_mapping/interlis_exporter_to_intermediate_schema.py#L83 + abwasser_session.execute(text("SET CONSTRAINTS ALL DEFERRED;")) + # Filtering filtered = selection is not None subset_ids = selection if selection is not None else [] From 3e37f9a666c98726a78de4d4a347e3054acaaf5a Mon Sep 17 00:00:00 2001 From: SJiB Date: Tue, 18 Jun 2024 17:27:26 +0200 Subject: [PATCH 046/111] debug add logger info --- qgepqwat2ili/qgepdss/export.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/qgepqwat2ili/qgepdss/export.py b/qgepqwat2ili/qgepdss/export.py index 30c45c59..87dfeca1 100644 --- a/qgepqwat2ili/qgepdss/export.py +++ b/qgepqwat2ili/qgepdss/export.py @@ -30,8 +30,15 @@ def qgep_export(selection=None, labels_file=None, orientation=None): # Filtering filtered = selection is not None + + # Logging for debugging + logger.info(f"print filtered '{filtered}'") + subset_ids = selection if selection is not None else [] + # Logging for debugging + logger.info(f"print subset_ids '{subset_ids}'") + # Orientation oriented = orientation is not None if oriented: From 1c5407399f46ee8b642f432aba895a9f34f0d808 Mon Sep 17 00:00:00 2001 From: SJiB Date: Tue, 18 Jun 2024 18:44:00 +0200 Subject: [PATCH 047/111] add extra logger.info to check the passed on selection --- qgepqwat2ili/gui/__init__.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/qgepqwat2ili/gui/__init__.py b/qgepqwat2ili/gui/__init__.py index 2bc2f723..97e7f949 100644 --- a/qgepqwat2ili/gui/__init__.py +++ b/qgepqwat2ili/gui/__init__.py @@ -599,6 +599,10 @@ def action_do_export(): #18.3.2023 # 22.3.2023 added try - seems not to work # try: + + # add logger info to check what selection is used + logger.info(f"Start Exporting with selection {str(export_dialog.selected_ids)}") + if emodel == "VSA_KEK_2019_LV95": logger.info("Start Exporting VSA_KEK_2019_LV95 - qgep_export") #qgep_export(selection=export_dialog.selected_ids, labels_file=labels_file_path) From f186ebd910a6aadf2c0a1fcb29ad308053d42171 Mon Sep 17 00:00:00 2001 From: SJiB Date: Wed, 19 Jun 2024 11:33:06 +0200 Subject: [PATCH 048/111] turn on flag_test to allow subclass test for wastewater_structures --- qgepqwat2ili/gui/__init__.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/qgepqwat2ili/gui/__init__.py b/qgepqwat2ili/gui/__init__.py index 97e7f949..d7ae73fe 100644 --- a/qgepqwat2ili/gui/__init__.py +++ b/qgepqwat2ili/gui/__init__.py @@ -440,7 +440,8 @@ def action_do_export(): return # 2. check wastewater_structure for all data models - flag_test = False + # flag_test - set to true if this test should be applied also + flag_test = True if flag_test: check_wastewater_structure = False check_wastewater_structure = check_wastewater_structure_subclass_data() From 78043f7ef57adbcc480243ffc0b0b53b625965f1 Mon Sep 17 00:00:00 2001 From: SJiB Date: Wed, 19 Jun 2024 16:22:31 +0200 Subject: [PATCH 049/111] from sqlalchemy.sql import text --- qgepqwat2ili/qgep/export.py | 2 ++ qgepqwat2ili/qgepdss/export.py | 1 + qgepqwat2ili/qgepsia405/export.py | 1 + 3 files changed, 4 insertions(+) diff --git a/qgepqwat2ili/qgep/export.py b/qgepqwat2ili/qgep/export.py index 73963818..6e8add4f 100644 --- a/qgepqwat2ili/qgep/export.py +++ b/qgepqwat2ili/qgep/export.py @@ -3,12 +3,14 @@ from geoalchemy2.functions import ST_Force2D, ST_GeomFromGeoJSON from sqlalchemy import or_ from sqlalchemy.orm import Session +from sqlalchemy.sql import text from .. import utils from ..utils.various import logger from .model_abwasser import get_abwasser_model from .model_qgep import get_qgep_model + #def qgep_export(selection=None, labels_file=None): def qgep_export(selection=None, labels_file=None, orientation=None): """ diff --git a/qgepqwat2ili/qgepdss/export.py b/qgepqwat2ili/qgepdss/export.py index 1d137aa1..4061e0d2 100644 --- a/qgepqwat2ili/qgepdss/export.py +++ b/qgepqwat2ili/qgepdss/export.py @@ -5,6 +5,7 @@ from geoalchemy2.functions import ST_Force2D, ST_GeomFromGeoJSON from sqlalchemy import or_ from sqlalchemy.orm import Session +from sqlalchemy.sql import text from .. import utils from ..utils.various import logger diff --git a/qgepqwat2ili/qgepsia405/export.py b/qgepqwat2ili/qgepsia405/export.py index bd8b3772..64597daa 100644 --- a/qgepqwat2ili/qgepsia405/export.py +++ b/qgepqwat2ili/qgepsia405/export.py @@ -3,6 +3,7 @@ from geoalchemy2.functions import ST_Force2D, ST_GeomFromGeoJSON from sqlalchemy import or_ from sqlalchemy.orm import Session +from sqlalchemy.sql import text from .. import utils from ..utils.various import logger From 7efbcde1c0379bdeb6309e2735f2ff4b06cab4c5 Mon Sep 17 00:00:00 2001 From: SJiB Date: Fri, 21 Jun 2024 15:19:26 +0200 Subject: [PATCH 050/111] backporting symbology update queries see https://github.com/teksi/wastewater/pull/263 --- qgepqwat2ili/postimport.py | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/qgepqwat2ili/postimport.py b/qgepqwat2ili/postimport.py index 2c8f994c..f254a2d8 100644 --- a/qgepqwat2ili/postimport.py +++ b/qgepqwat2ili/postimport.py @@ -41,6 +41,17 @@ def qgep_postimport(): post_session.execute("SELECT qgep_od.wastewater_structure_update_fk_main_wastewater_node('', True);" ) + # add symbology update queries - backporting from tww https://github.com/teksi/wastewater/pull/263 + logger.info("update_wastewater_node_symbology for all datasets - please be patient") + post_session.execute("SELECT qgep_od.update_wastewater_node_symbology(NULL, True);") + logger.info("update_wastewater_node_symbology for all datasets - please be patient") + logger.info("update_wastewater_structure_label for all datasets - please be patient") + post_session.execute("SELECT qgep_od.update_wastewater_structure_label(NULL, True);") + logger.info("update_wastewater_node_symbology for all datasets - please be patient") + logger.info("update_wn_symbology_by_overflow for all datasets - please be patient") + post_session.execute("SELECT qgep_od.update_wn_symbology_by_overflow(NULL, True);") + + logger.info("Refresh materialized views") post_session.execute("SELECT qgep_network.refresh_network_simple();") From fa57414b25899ac986306da65005168ddd307f74 Mon Sep 17 00:00:00 2001 From: SJiB Date: Wed, 26 Jun 2024 22:24:42 +0200 Subject: [PATCH 051/111] corrections qgepdss export.py --- qgepqwat2ili/qgepdss/export.py | 45 ++++++++++++++++++++-------------- 1 file changed, 26 insertions(+), 19 deletions(-) diff --git a/qgepqwat2ili/qgepdss/export.py b/qgepqwat2ili/qgepdss/export.py index 10f51a57..b64b1129 100644 --- a/qgepqwat2ili/qgepdss/export.py +++ b/qgepqwat2ili/qgepdss/export.py @@ -2925,10 +2925,11 @@ def textpos_common(row, t_type, geojson_crs_def): abflussbeiwert_rw_ist=row.discharge_coefficient_rw_current, abflussbeiwert_sw_geplant=row.discharge_coefficient_ww_planned, abflussbeiwert_sw_ist=row.discharge_coefficient_ww_current, - abwassernetzelement_rw_geplantref=check_fk_in_subsetid(row.fk_wastewater_networkelement_rw_planned__REL), - abwassernetzelement_rw_istref=check_fk_in_subsetid(row.fk_wastewater_networkelement_rw_current__REL), - abwassernetzelement_sw_geplantref=check_fk_in_subsetid(row.fk_wastewater_networkelement_ww_planned__REL), - abwassernetzelement_sw_istref=check_fk_in_subsetid(row.fk_wastewater_networkelement_ww_current__REL), + # changed call from get_tid to check_fk_in_subsetid so it does not write foreignkeys on elements that do not exist + abwassernetzelement_rw_geplantref=check_fk_in_subsetid(subset_ids, row.fk_wastewater_networkelement_rw_planned__REL), + abwassernetzelement_rw_istref=check_fk_in_subsetid(subset_ids, row.fk_wastewater_networkelement_rw_current__REL), + abwassernetzelement_sw_geplantref=check_fk_in_subsetid(subset_ids, row.fk_wastewater_networkelement_ww_planned__REL), + abwassernetzelement_sw_istref=check_fk_in_subsetid(subset_ids, row.fk_wastewater_networkelement_ww_current__REL), befestigungsgrad_rw_geplant=row.seal_factor_rw_planned, befestigungsgrad_rw_ist=row.seal_factor_rw_current, befestigungsgrad_sw_geplant=row.seal_factor_ww_planned, @@ -2966,7 +2967,10 @@ def textpos_common(row, t_type, geojson_crs_def): logger.info("Exporting QGEP.measuring_point -> ABWASSER.messstelle, ABWASSER.metaattribute") query = qgep_session.query(QGEP.measuring_point) if filtered: - query1=query.join(QGEP.wastewater_structure, QGEP.wastewater_networkelement) + query1 = query.join( + QGEP.wastewater_structure, + QGEP.wastewater_networkelement + ) # needs to add QGEP.wastewater_structure as waste_water_treatment_plant is a subclass of organisation that has a relation to wastewater_structure and then wastewater_networkelement #variant1 for query2 # query2=query.join(QGEP.waste_water_treatment_plant, (QGEP.wastewater_structure, QGEP.waste_water_treatment_plant.obj_id == QGEP.wastewater_structure.fk_owner), (QGEP.wastewater_structure, QGEP.waste_water_treatment_plant.obj_id == QGEP.wastewater_structure.fk_provider),QGEP.wastewater_networkelement, @@ -2980,20 +2984,23 @@ def textpos_common(row, t_type, geojson_crs_def): # QGEP.wastewater_networkelement, # ) - query3=query.join(QGEP.water_course_segment, QGEP.river, QGEP.sector_water_body, QGEP.discharge_point, QGEP.wastewater_networkelement) - # query=union(query1, query2, query3) - query=query.union(query1, query3) - query = query.filter(QGEP.wastewater_networkelement.obj_id.in_(subset_ids) - ) - # QGEP.wastewater_networkelement, - # or does not work with this - currently do not support other connections - # or_( - # (QGEP.waste_water_treatment_plant, QGEP.wastewater_networkelement), - # (QGEP.wastewater_structure, QGEP.wastewater_networkelement), - # currently do not support other connections - # (QGEP.water_course_segment, QGEP.river, QGEP.sector_water_body, QGEP.discharge_point, QGEP.wastewater_networkelement), - # ) - + # query2 via waste_water_treatment_plant + query2 = query.join( + self.model_classes_tww_od.waste_water_treatment_plant, + self.model_classes_tww_od.wwtp_structure, + self.model_classes_tww_od.wastewater_networkelement, + ) + query3 = query.join( + QGEP.water_course_segment, + QGEP.river, + QGEP.sector_water_body, + QGEP.discharge_point, + QGEP.wastewater_networkelement) + query = query.union(query1, query2, query3) + # query = query.union(query1, query3) + query = query.filter( + QGEP.wastewater_networkelement.obj_id.in_(subset_ids) + ) for row in query: # AVAILABLE FIELDS IN QGEP.measuring_point From 9d58cf194500b9c172d1cb6fc82ff97bfd7a04da Mon Sep 17 00:00:00 2001 From: SJiB Date: Thu, 27 Jun 2024 21:21:34 +0200 Subject: [PATCH 052/111] adapted filter hydraulic_char_data --- qgepqwat2ili/qgepdss/export.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/qgepqwat2ili/qgepdss/export.py b/qgepqwat2ili/qgepdss/export.py index b64b1129..7dec2672 100644 --- a/qgepqwat2ili/qgepdss/export.py +++ b/qgepqwat2ili/qgepdss/export.py @@ -3382,7 +3382,12 @@ def textpos_common(row, t_type, geojson_crs_def): query = qgep_session.query(QGEP.hydraulic_char_data) # side fk_overflow_char not considered in filter query if filtered: - query = query.join(QGEP.wastewater_node).filter( + query = query.join(QGEP.wastewater_node) + or_( + QGEP.wastewater_node.obj_id + == QGEP.hydraulic_char_data.fk_wastewater_node, + ), + .filter( QGEP.wastewater_networkelement.obj_id.in_(subset_ids) ) for row in query: From b068658bbe283ea2b077b3a7530d2ea628edd203 Mon Sep 17 00:00:00 2001 From: SJiB Date: Fri, 28 Jun 2024 17:11:53 +0200 Subject: [PATCH 053/111] comment query3 - will not be needed in release 2020 anymore --- qgepqwat2ili/qgepdss/export.py | 1 + 1 file changed, 1 insertion(+) diff --git a/qgepqwat2ili/qgepdss/export.py b/qgepqwat2ili/qgepdss/export.py index 7dec2672..52790772 100644 --- a/qgepqwat2ili/qgepdss/export.py +++ b/qgepqwat2ili/qgepdss/export.py @@ -2990,6 +2990,7 @@ def textpos_common(row, t_type, geojson_crs_def): self.model_classes_tww_od.wwtp_structure, self.model_classes_tww_od.wastewater_networkelement, ) + # only until VSA-DSS Release 2015 query3 = query.join( QGEP.water_course_segment, QGEP.river, From 8c55b19c554a8425bf4dd005447cb042e7d36242 Mon Sep 17 00:00:00 2001 From: SJiB Date: Tue, 14 May 2024 17:44:54 +0200 Subject: [PATCH 054/111] qgepdss/export.py - rohrprofil_geometry add if filtered --- qgepqwat2ili/qgepdss/export.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/qgepqwat2ili/qgepdss/export.py b/qgepqwat2ili/qgepdss/export.py index 4061e0d2..6d5efe02 100644 --- a/qgepqwat2ili/qgepdss/export.py +++ b/qgepqwat2ili/qgepdss/export.py @@ -2086,6 +2086,10 @@ def textpos_common(row, t_type, geojson_crs_def): logger.info("Exporting QGEP.profile_geometry -> ABWASSER.rohrprofil_geometrie, ABWASSER.metaattribute") query = qgep_session.query(QGEP.profile_geometry) + if filtered: + query = query.join( + QGEP.reach, + ).filter(QGEP.wastewater_networkelement.obj_id.in_(subset_ids)) for row in query: # AVAILABLE FIELDS IN QGEP.profile_geometry From 9f102a82b05ece133e0e360973ef10ebdaea0f72 Mon Sep 17 00:00:00 2001 From: SJiB Date: Wed, 15 May 2024 22:15:19 +0200 Subject: [PATCH 055/111] Adapt if filtered QGEP.pipe_profile, QGEP.reach Add whole line of references to wastewater_networkelement --- qgepqwat2ili/qgepdss/export.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/qgepqwat2ili/qgepdss/export.py b/qgepqwat2ili/qgepdss/export.py index 6d5efe02..20114d2e 100644 --- a/qgepqwat2ili/qgepdss/export.py +++ b/qgepqwat2ili/qgepdss/export.py @@ -2088,7 +2088,7 @@ def textpos_common(row, t_type, geojson_crs_def): query = qgep_session.query(QGEP.profile_geometry) if filtered: query = query.join( - QGEP.reach, + QGEP.pipe_profile, QGEP.reach ).filter(QGEP.wastewater_networkelement.obj_id.in_(subset_ids)) for row in query: From 426065996162377806c303dd82934f8c52afb4fb Mon Sep 17 00:00:00 2001 From: SJiB Date: Thu, 16 May 2024 13:24:29 +0200 Subject: [PATCH 056/111] Add filter for Subclasses of Anschlussobjekt --- qgepqwat2ili/qgepdss/export.py | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/qgepqwat2ili/qgepdss/export.py b/qgepqwat2ili/qgepdss/export.py index 20114d2e..c46c6be5 100644 --- a/qgepqwat2ili/qgepdss/export.py +++ b/qgepqwat2ili/qgepdss/export.py @@ -2572,6 +2572,10 @@ def textpos_common(row, t_type, geojson_crs_def): logger.info("Exporting QGEP.building -> ABWASSER.gebaeude, ABWASSER.metaattribute") query = qgep_session.query(QGEP.building) + if filtered: + query = query.join(QGEP.wastewater_networkelement).filter( + QGEP.wastewater_networkelement.obj_id.in_(subset_ids) + ) for row in query: # AVAILABLE FIELDS IN QGEP.building @@ -2610,6 +2614,10 @@ def textpos_common(row, t_type, geojson_crs_def): logger.info("Exporting QGEP.reservoir -> ABWASSER.reservoir, ABWASSER.metaattribute") query = qgep_session.query(QGEP.reservoir) + if filtered: + query = query.join(QGEP.wastewater_networkelement).filter( + QGEP.wastewater_networkelement.obj_id.in_(subset_ids) + ) for row in query: # AVAILABLE FIELDS IN QGEP.reservoir @@ -2646,6 +2654,10 @@ def textpos_common(row, t_type, geojson_crs_def): logger.info("Exporting QGEP.individual_surface -> ABWASSER.einzelflaeche, ABWASSER.metaattribute") query = qgep_session.query(QGEP.individual_surface) + if filtered: + query = query.join(QGEP.wastewater_networkelement).filter( + QGEP.wastewater_networkelement.obj_id.in_(subset_ids) + ) for row in query: # AVAILABLE FIELDS IN QGEP.individual_surface @@ -2684,6 +2696,10 @@ def textpos_common(row, t_type, geojson_crs_def): logger.info("Exporting QGEP.fountain -> ABWASSER.brunnen, ABWASSER.metaattribute") query = qgep_session.query(QGEP.fountain) + if filtered: + query = query.join(QGEP.wastewater_networkelement).filter( + QGEP.wastewater_networkelement.obj_id.in_(subset_ids) + ) for row in query: # AVAILABLE FIELDS IN QGEP.fountain From 879799839a7389de60dc01cf4e17d8954643af0c Mon Sep 17 00:00:00 2001 From: SJiB Date: Thu, 16 May 2024 14:53:50 +0200 Subject: [PATCH 057/111] adjust filter criteria reach_point, take out reach_point_to statement --- qgepqwat2ili/qgepdss/export.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/qgepqwat2ili/qgepdss/export.py b/qgepqwat2ili/qgepdss/export.py index c46c6be5..eed3b887 100644 --- a/qgepqwat2ili/qgepdss/export.py +++ b/qgepqwat2ili/qgepdss/export.py @@ -1951,7 +1951,7 @@ def textpos_common(row, t_type, geojson_crs_def): QGEP.reach, or_( QGEP.reach_point.obj_id == QGEP.reach.fk_reach_point_from, - QGEP.reach_point.obj_id == QGEP.reach.fk_reach_point_to, + # QGEP.reach_point.obj_id == QGEP.reach.fk_reach_point_to, ), ).filter(QGEP.wastewater_networkelement.obj_id.in_(subset_ids)) for row in query: From 4ab67616e1fdc15b27b471ea8f01faa6ba3f9f41 Mon Sep 17 00:00:00 2001 From: SJiB Date: Thu, 16 May 2024 15:10:18 +0200 Subject: [PATCH 058/111] filter for hydr_geometry and hydr_geomrelation --- qgepqwat2ili/qgepdss/export.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/qgepqwat2ili/qgepdss/export.py b/qgepqwat2ili/qgepdss/export.py index eed3b887..33f034bf 100644 --- a/qgepqwat2ili/qgepdss/export.py +++ b/qgepqwat2ili/qgepdss/export.py @@ -1911,6 +1911,8 @@ def textpos_common(row, t_type, geojson_crs_def): logger.info("Exporting QGEP.hydr_geometry -> ABWASSER.hydr_geometrie, ABWASSER.metaattribute") query = qgep_session.query(QGEP.hydr_geometry) + if filtered: + query = query.join(QGEP.wastewater_node).filter(QGEP.wastewater_networkelement.obj_id.in_(subset_ids)) for row in query: # AVAILABLE FIELDS IN QGEP.hydr_geometry @@ -2122,6 +2124,8 @@ def textpos_common(row, t_type, geojson_crs_def): logger.info("Exporting QGEP.hydr_geom_relation -> ABWASSER.hydr_geomrelation, ABWASSER.metaattribute") query = qgep_session.query(QGEP.hydr_geom_relation) + if filtered: + query = query.join(QGEP.hydr_geometry, QGEP.wastewater_node).filter(QGEP.wastewater_networkelement.obj_id.in_(subset_ids)) for row in query: # AVAILABLE FIELDS IN QGEP.hydr_geom_relation From 4baefeaf2a717a048745d0d7495dbf50b1f99121 Mon Sep 17 00:00:00 2001 From: SJiB Date: Thu, 16 May 2024 15:15:34 +0200 Subject: [PATCH 059/111] filter for param_ca_general and param_ca_mouse1 --- qgepqwat2ili/qgepdss/export.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/qgepqwat2ili/qgepdss/export.py b/qgepqwat2ili/qgepdss/export.py index 33f034bf..97f8480c 100644 --- a/qgepqwat2ili/qgepdss/export.py +++ b/qgepqwat2ili/qgepdss/export.py @@ -3433,6 +3433,10 @@ def textpos_common(row, t_type, geojson_crs_def): logger.info("Exporting QGEP.param_ca_general -> ABWASSER.ezg_parameter_allg, ABWASSER.metaattribute") query = qgep_session.query(QGEP.param_ca_general) + if filtered: + query = query.join(QGEP.catchment_area).filter( + QGEP.wastewater_networkelement.obj_id.in_(subset_ids) + ) for row in query: # AVAILABLE FIELDS IN QGEP.param_ca_general @@ -3472,6 +3476,10 @@ def textpos_common(row, t_type, geojson_crs_def): logger.info("Exporting QGEP.param_ca_mouse1 -> ABWASSER.ezg_parameter_mouse1, ABWASSER.metaattribute") query = qgep_session.query(QGEP.param_ca_mouse1) + if filtered: + query = query.join(QGEP.catchment_area).filter( + QGEP.wastewater_networkelement.obj_id.in_(subset_ids) + ) for row in query: # AVAILABLE FIELDS IN QGEP.param_ca_mouse1 From 273214a175fae252147d303d5afbfe768c560e63 Mon Sep 17 00:00:00 2001 From: SJiB Date: Thu, 16 May 2024 15:22:28 +0200 Subject: [PATCH 060/111] filters for catchment areas - 4 different fk --- qgepqwat2ili/qgepdss/export.py | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/qgepqwat2ili/qgepdss/export.py b/qgepqwat2ili/qgepdss/export.py index 97f8480c..3a2b5cd3 100644 --- a/qgepqwat2ili/qgepdss/export.py +++ b/qgepqwat2ili/qgepdss/export.py @@ -2841,6 +2841,15 @@ def textpos_common(row, t_type, geojson_crs_def): logger.info("Exporting QGEP.catchment_area -> ABWASSER.einzugsgebiet, ABWASSER.metaattribute") query = qgep_session.query(QGEP.catchment_area) + if filtered: + query = query.join( + or_( + QGEP.wastewater_networkelement.obj_id == QGEP.catchment_area.fk_wastewater_networkelement_rw_planned, + QGEP.wastewater_networkelement.obj_id == QGEP.catchment_area.fk_wastewater_networkelement_rw_current, + QGEP.wastewater_networkelement.obj_id == QGEP.catchment_area.fk_wastewater_networkelement_ww_planned, + QGEP.wastewater_networkelement.obj_id == QGEP.catchment_area.fk_wastewater_networkelement_ww_current, + ), + ).filter(QGEP.wastewater_networkelement.obj_id.in_(subset_ids)) for row in query: # AVAILABLE FIELDS IN QGEP.catchment_area From 1c417b1d95222d66d2e5ca489f8a4c1e7ed9c781 Mon Sep 17 00:00:00 2001 From: SJiB Date: Mon, 3 Jun 2024 15:55:50 +0200 Subject: [PATCH 061/111] Add filter control_center --- qgepqwat2ili/qgepdss/export.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/qgepqwat2ili/qgepdss/export.py b/qgepqwat2ili/qgepdss/export.py index 3a2b5cd3..146b1d4f 100644 --- a/qgepqwat2ili/qgepdss/export.py +++ b/qgepqwat2ili/qgepdss/export.py @@ -1570,6 +1570,10 @@ def textpos_common(row, t_type, geojson_crs_def): logger.info("Exporting QGEP.control_center -> ABWASSER.steuerungszentrale, ABWASSER.metaattribute") query = qgep_session.query(QGEP.control_center) + if filtered: + query = query.join(QGEP.throttle_shut_off_unit, QGEP.wastewater_node).filter( + QGEP.wastewater_networkelement.obj_id.in_(subset_ids) + ) for row in query: # AVAILABLE FIELDS IN QGEP.control_center From 94840a821b9c15bf9a81dffc42d49f3f2948fe7b Mon Sep 17 00:00:00 2001 From: SJiB Date: Mon, 3 Jun 2024 16:00:55 +0200 Subject: [PATCH 062/111] Add filter mechanical_pretreatment --- qgepqwat2ili/qgepdss/export.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/qgepqwat2ili/qgepdss/export.py b/qgepqwat2ili/qgepdss/export.py index 146b1d4f..507cf841 100644 --- a/qgepqwat2ili/qgepdss/export.py +++ b/qgepqwat2ili/qgepdss/export.py @@ -2162,6 +2162,10 @@ def textpos_common(row, t_type, geojson_crs_def): logger.info("Exporting QGEP.mechanical_pretreatment -> ABWASSER.mechanischevorreinigung, ABWASSER.metaattribute") query = qgep_session.query(QGEP.mechanical_pretreatment) + if filtered: + query = query.join(QGEP.wastewater_structure, QGEP.wastewater_networkelement).filter( + QGEP.wastewater_networkelement.obj_id.in_(subset_ids) + ) for row in query: # AVAILABLE FIELDS IN QGEP.mechanical_pretreatment From 0fbb99cd67992d2e743541866d63955b2d4ec9d3 Mon Sep 17 00:00:00 2001 From: SJiB Date: Mon, 3 Jun 2024 16:02:04 +0200 Subject: [PATCH 063/111] Add filter retention_body --- qgepqwat2ili/qgepdss/export.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/qgepqwat2ili/qgepdss/export.py b/qgepqwat2ili/qgepdss/export.py index 507cf841..2fb44f7e 100644 --- a/qgepqwat2ili/qgepdss/export.py +++ b/qgepqwat2ili/qgepdss/export.py @@ -2199,6 +2199,10 @@ def textpos_common(row, t_type, geojson_crs_def): logger.info("Exporting QGEP.retention_body -> ABWASSER.retentionskoerper, ABWASSER.metaattribute") query = qgep_session.query(QGEP.retention_body) + if filtered: + query = query.join(QGEP.infiltration_installation, QGEP.wastewater_networkelement).filter( + QGEP.wastewater_networkelement.obj_id.in_(subset_ids) + ) for row in query: # AVAILABLE FIELDS IN QGEP.retention_body From 1d76fb99a6fb013fab5ef3a1552c8b638efdbc6d Mon Sep 17 00:00:00 2001 From: SJiB Date: Mon, 3 Jun 2024 16:08:17 +0200 Subject: [PATCH 064/111] add filter hazard_source --- qgepqwat2ili/qgepdss/export.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/qgepqwat2ili/qgepdss/export.py b/qgepqwat2ili/qgepdss/export.py index 2fb44f7e..beba4a00 100644 --- a/qgepqwat2ili/qgepdss/export.py +++ b/qgepqwat2ili/qgepdss/export.py @@ -2752,6 +2752,10 @@ def textpos_common(row, t_type, geojson_crs_def): logger.info("Exporting QGEP.hazard_source -> ABWASSER.gefahrenquelle, ABWASSER.metaattribute") query = qgep_session.query(QGEP.hazard_source) + if filtered: + query = query.join(QGEP.connection_object, QGEP.wastewater_networkelement).filter( + QGEP.wastewater_networkelement.obj_id.in_(subset_ids) + ) for row in query: # AVAILABLE FIELDS IN QGEP.hazard_source From 2e5d777965827e417bc6b388e5bc820bfce3cb25 Mon Sep 17 00:00:00 2001 From: SJiB Date: Mon, 3 Jun 2024 16:50:58 +0200 Subject: [PATCH 065/111] add filter accident --- qgepqwat2ili/qgepdss/export.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/qgepqwat2ili/qgepdss/export.py b/qgepqwat2ili/qgepdss/export.py index beba4a00..72455703 100644 --- a/qgepqwat2ili/qgepdss/export.py +++ b/qgepqwat2ili/qgepdss/export.py @@ -2789,6 +2789,10 @@ def textpos_common(row, t_type, geojson_crs_def): logger.info("Exporting QGEP.accident -> ABWASSER.unfall, ABWASSER.metaattribute") query = qgep_session.query(QGEP.accident) + if filtered: + query = query.join(QGEP.hazard_source, QGEP.connection_object, QGEP.wastewater_networkelement).filter( + QGEP.wastewater_networkelement.obj_id.in_(subset_ids) + ) for row in query: # AVAILABLE FIELDS IN QGEP.accident From 0c1df8db2dbec9ae19739ab5c6de97e98dd6b69e Mon Sep 17 00:00:00 2001 From: SJiB Date: Mon, 3 Jun 2024 16:51:23 +0200 Subject: [PATCH 066/111] add filter substance --- qgepqwat2ili/qgepdss/export.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/qgepqwat2ili/qgepdss/export.py b/qgepqwat2ili/qgepdss/export.py index 72455703..e7d882fe 100644 --- a/qgepqwat2ili/qgepdss/export.py +++ b/qgepqwat2ili/qgepdss/export.py @@ -2828,6 +2828,10 @@ def textpos_common(row, t_type, geojson_crs_def): logger.info("Exporting QGEP.substance -> ABWASSER.stoff, ABWASSER.metaattribute") query = qgep_session.query(QGEP.substance) + if filtered: + query = query.join(QGEP.hazard_source, QGEP.connection_object, QGEP.wastewater_networkelement).filter( + QGEP.wastewater_networkelement.obj_id.in_(subset_ids) + ) for row in query: # AVAILABLE FIELDS IN QGEP.substance From 4ed00f87f0444f9bcb8f3b083df443a11993e5e6 Mon Sep 17 00:00:00 2001 From: SJiB Date: Mon, 3 Jun 2024 17:15:00 +0200 Subject: [PATCH 067/111] add filter measuring_point to review if or_ statement is correct --- qgepqwat2ili/qgepdss/export.py | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/qgepqwat2ili/qgepdss/export.py b/qgepqwat2ili/qgepdss/export.py index e7d882fe..b7f45e1b 100644 --- a/qgepqwat2ili/qgepdss/export.py +++ b/qgepqwat2ili/qgepdss/export.py @@ -2939,6 +2939,17 @@ def textpos_common(row, t_type, geojson_crs_def): logger.info("Exporting QGEP.measuring_point -> ABWASSER.messstelle, ABWASSER.metaattribute") query = qgep_session.query(QGEP.measuring_point) + if filtered: + query = query.query.join( + or_( + (QGEP.waste_water_treatment_plant, QGEP.wastewater_networkelement), + (QGEP.wastewater_structure, QGEP.wastewater_networkelement), + (QGEP.water_course_segment, QGEP.river, QGEP.sector_water_body, QGEP.discharge_point, QGEP.wastewater_networkelement), + ) + ). + filter( + QGEP.wastewater_networkelement.obj_id.in_(subset_ids) + ) for row in query: # AVAILABLE FIELDS IN QGEP.measuring_point From a394545624a67ee089cba1313b356a3afe97fda1 Mon Sep 17 00:00:00 2001 From: SJiB Date: Mon, 3 Jun 2024 17:18:14 +0200 Subject: [PATCH 068/111] add filter measuring_device and measurement_series --- qgepqwat2ili/qgepdss/export.py | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/qgepqwat2ili/qgepdss/export.py b/qgepqwat2ili/qgepdss/export.py index b7f45e1b..aa86e096 100644 --- a/qgepqwat2ili/qgepdss/export.py +++ b/qgepqwat2ili/qgepdss/export.py @@ -2989,6 +2989,17 @@ def textpos_common(row, t_type, geojson_crs_def): logger.info("Exporting QGEP.measuring_device -> ABWASSER.messgeraet, ABWASSER.metaattribute") query = qgep_session.query(QGEP.measuring_device) + if filtered: + query = query.query.join( + or_( + (QGEP.measuring_point, QGEP.waste_water_treatment_plant, QGEP.wastewater_networkelement), + (QGEP.measuring_point, QGEP.wastewater_structure, QGEP.wastewater_networkelement), + (QGEP.measuring_point, QGEP.water_course_segment, QGEP.river, QGEP.sector_water_body, QGEP.discharge_point, QGEP.wastewater_networkelement), + ) + ). + filter( + QGEP.wastewater_networkelement.obj_id.in_(subset_ids) + ) for row in query: # AVAILABLE FIELDS IN QGEP.measuring_device @@ -3023,6 +3034,17 @@ def textpos_common(row, t_type, geojson_crs_def): logger.info("Exporting QGEP.measurement_series -> ABWASSER.messreihe, ABWASSER.metaattribute") query = qgep_session.query(QGEP.measurement_series) + if filtered: + query = query.query.join( + or_( + (QGEP.measuring_point, QGEP.waste_water_treatment_plant, QGEP.wastewater_networkelement), + (QGEP.measuring_point, QGEP.wastewater_structure, QGEP.wastewater_networkelement), + (QGEP.measuring_point, QGEP.water_course_segment, QGEP.river, QGEP.sector_water_body, QGEP.discharge_point, QGEP.wastewater_networkelement), + ) + ). + filter( + QGEP.wastewater_networkelement.obj_id.in_(subset_ids) + ) for row in query: # AVAILABLE FIELDS IN QGEP.measurement_series From 462e669b36e014e0b5c69115ac33a6f56a268f54 Mon Sep 17 00:00:00 2001 From: SJiB Date: Mon, 3 Jun 2024 17:22:32 +0200 Subject: [PATCH 069/111] add filter measurement_result --- qgepqwat2ili/qgepdss/export.py | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/qgepqwat2ili/qgepdss/export.py b/qgepqwat2ili/qgepdss/export.py index aa86e096..7f550707 100644 --- a/qgepqwat2ili/qgepdss/export.py +++ b/qgepqwat2ili/qgepdss/export.py @@ -3079,6 +3079,21 @@ def textpos_common(row, t_type, geojson_crs_def): logger.info("Exporting QGEP.measurement_result -> ABWASSER.messresultat, ABWASSER.metaattribute") query = qgep_session.query(QGEP.measurement_result) + if filtered: + query = query.query.join( + or_( + (QGEP.measurement_series, QGEP.measuring_point, QGEP.waste_water_treatment_plant, QGEP.wastewater_networkelement), + (QGEP.measurement_series, QGEP.measuring_point, QGEP.wastewater_structure, QGEP.wastewater_networkelement), + (QGEP.measurement_series, QGEP.measuring_point, QGEP.water_course_segment, QGEP.river, QGEP.sector_water_body, QGEP.discharge_point, QGEP.wastewater_networkelement), + + (QGEP.measuring_device, QGEP.measuring_point, QGEP.waste_water_treatment_plant, QGEP.wastewater_networkelement), + (QGEP.measuring_device, QGEP.measuring_point, QGEP.wastewater_structure, QGEP.wastewater_networkelement), + (QGEP.measuring_device, QGEP.measuring_point, QGEP.water_course_segment, QGEP.river, QGEP.sector_water_body, QGEP.discharge_point, QGEP.wastewater_networkelement), + ) + ). + filter( + QGEP.wastewater_networkelement.obj_id.in_(subset_ids) + ) for row in query: # AVAILABLE FIELDS IN QGEP.measurement_result From 8e8ea80ff3a1008bf25b5f0bf3f5764caa2801f4 Mon Sep 17 00:00:00 2001 From: SJiB Date: Mon, 3 Jun 2024 17:24:59 +0200 Subject: [PATCH 070/111] add filter throttle_shut_off_unit --- qgepqwat2ili/qgepdss/export.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/qgepqwat2ili/qgepdss/export.py b/qgepqwat2ili/qgepdss/export.py index 7f550707..e90fa74c 100644 --- a/qgepqwat2ili/qgepdss/export.py +++ b/qgepqwat2ili/qgepdss/export.py @@ -3130,6 +3130,11 @@ def textpos_common(row, t_type, geojson_crs_def): logger.info("Exporting QGEP.throttle_shut_off_unit -> ABWASSER.absperr_drosselorgan, ABWASSER.metaattribute") query = qgep_session.query(QGEP.throttle_shut_off_unit) + # to check if fk_control_center__REL has also to be considered + if filtered: + query = query.join(QGEP.wastewater_networkelement).filter( + QGEP.wastewater_networkelement.obj_id.in_(subset_ids) + ) for row in query: # AVAILABLE FIELDS IN QGEP.throttle_shut_off_unit From 297476e710f0ccbc9ef4c784f4768ccbdd0ffccc Mon Sep 17 00:00:00 2001 From: SJiB Date: Mon, 3 Jun 2024 17:30:09 +0200 Subject: [PATCH 071/111] add filter prank_weir --- qgepqwat2ili/qgepdss/export.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/qgepqwat2ili/qgepdss/export.py b/qgepqwat2ili/qgepdss/export.py index e90fa74c..25417973 100644 --- a/qgepqwat2ili/qgepdss/export.py +++ b/qgepqwat2ili/qgepdss/export.py @@ -3180,6 +3180,14 @@ def textpos_common(row, t_type, geojson_crs_def): logger.info("Exporting QGEP.prank_weir -> ABWASSER.streichwehr, ABWASSER.metaattribute") query = qgep_session.query(QGEP.prank_weir) + # to check if fk_overflow_char also has to be considered + if filtered: + query = query.join( + or_( + QGEP.wastewater_node.obj_id == QGEP.prank_weir.fk_wastewater_node, + QGEP.wastewater_node.obj_id == QGEP.prank_weir.fk_overflow_to, + ), + ).filter(QGEP.wastewater_networkelement.obj_id.in_(subset_ids)) for row in query: # AVAILABLE FIELDS IN QGEP.prank_weir From 0acb1371e655a3e0f8fa47fe002a5aea2e942d07 Mon Sep 17 00:00:00 2001 From: SJiB Date: Mon, 3 Jun 2024 17:30:45 +0200 Subject: [PATCH 072/111] add filter pump --- qgepqwat2ili/qgepdss/export.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/qgepqwat2ili/qgepdss/export.py b/qgepqwat2ili/qgepdss/export.py index 25417973..3b0fbf0b 100644 --- a/qgepqwat2ili/qgepdss/export.py +++ b/qgepqwat2ili/qgepdss/export.py @@ -3227,7 +3227,15 @@ def textpos_common(row, t_type, geojson_crs_def): logger.info("Exporting QGEP.pump -> ABWASSER.foerderaggregat, ABWASSER.metaattribute") query = qgep_session.query(QGEP.pump) - for row in query: + # to check if fk_overflow_char also has to be considered + if filtered: + query = query.join( + or_( + QGEP.wastewater_node.obj_id == QGEP.prank_weir.fk_wastewater_node, + QGEP.wastewater_node.obj_id == QGEP.prank_weir.fk_overflow_to, + ), + ).filter(QGEP.wastewater_networkelement.obj_id.in_(subset_ids)) + for row in query: # AVAILABLE FIELDS IN QGEP.pump # --- overflow --- From 25d4c5692427cd59f1d5208c30de47d748107b6c Mon Sep 17 00:00:00 2001 From: SJiB Date: Mon, 3 Jun 2024 17:35:21 +0200 Subject: [PATCH 073/111] add filter leapingweir --- qgepqwat2ili/qgepdss/export.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/qgepqwat2ili/qgepdss/export.py b/qgepqwat2ili/qgepdss/export.py index 3b0fbf0b..d8ff2666 100644 --- a/qgepqwat2ili/qgepdss/export.py +++ b/qgepqwat2ili/qgepdss/export.py @@ -3278,6 +3278,14 @@ def textpos_common(row, t_type, geojson_crs_def): logger.info("Exporting QGEP.leapingweir -> ABWASSER.leapingwehr, ABWASSER.metaattribute") query = qgep_session.query(QGEP.leapingweir) + # to check if fk_overflow_char also has to be considered + if filtered: + query = query.join( + or_( + QGEP.wastewater_node.obj_id == QGEP.prank_weir.fk_wastewater_node, + QGEP.wastewater_node.obj_id == QGEP.prank_weir.fk_overflow_to, + ), + ).filter(QGEP.wastewater_networkelement.obj_id.in_(subset_ids)) for row in query: # AVAILABLE FIELDS IN QGEP.leapingweir From 9635bbb7113a8a62ce6fe5ad675fb50c5e8b4717 Mon Sep 17 00:00:00 2001 From: SJiB Date: Mon, 3 Jun 2024 17:44:21 +0200 Subject: [PATCH 074/111] add filter hydraulic_char_data --- qgepqwat2ili/qgepdss/export.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/qgepqwat2ili/qgepdss/export.py b/qgepqwat2ili/qgepdss/export.py index d8ff2666..41043dee 100644 --- a/qgepqwat2ili/qgepdss/export.py +++ b/qgepqwat2ili/qgepdss/export.py @@ -3323,6 +3323,11 @@ def textpos_common(row, t_type, geojson_crs_def): logger.info("Exporting QGEP.hydraulic_char_data -> ABWASSER.hydr_kennwerte, ABWASSER.metaattribute") query = qgep_session.query(QGEP.hydraulic_char_data) + # side overflow_char not considered + if filtered: + query = query.join(QGEP.wastewater_node).filter( + QGEP.wastewater_networkelement.obj_id.in_(subset_ids) + ) for row in query: # AVAILABLE FIELDS IN QGEP.hydraulic_char_data From 8112726cac0894aac6b22221fb0e45abe53d4ee7 Mon Sep 17 00:00:00 2001 From: SJiB Date: Mon, 3 Jun 2024 17:47:33 +0200 Subject: [PATCH 075/111] comment on filter hydraulic_char_data and backflow_prevention --- qgepqwat2ili/qgepdss/export.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/qgepqwat2ili/qgepdss/export.py b/qgepqwat2ili/qgepdss/export.py index 41043dee..348790dd 100644 --- a/qgepqwat2ili/qgepdss/export.py +++ b/qgepqwat2ili/qgepdss/export.py @@ -3323,7 +3323,7 @@ def textpos_common(row, t_type, geojson_crs_def): logger.info("Exporting QGEP.hydraulic_char_data -> ABWASSER.hydr_kennwerte, ABWASSER.metaattribute") query = qgep_session.query(QGEP.hydraulic_char_data) - # side overflow_char not considered + # side fk_overflow_char not considered in filter query if filtered: query = query.join(QGEP.wastewater_node).filter( QGEP.wastewater_networkelement.obj_id.in_(subset_ids) @@ -3377,6 +3377,7 @@ def textpos_common(row, t_type, geojson_crs_def): logger.info("Exporting QGEP.backflow_prevention -> ABWASSER.rueckstausicherung, ABWASSER.metaattribute") query = qgep_session.query(QGEP.backflow_prevention) + # side fk_throttle_shut_off_unit and fk_overflow not considered in filter query - they are usually added only for log_cards and then the corresponding nodes exist anyway thru the direct relation. if filtered: query = query.join(QGEP.wastewater_structure, QGEP.wastewater_networkelement).filter( QGEP.wastewater_networkelement.obj_id.in_(subset_ids) From fc06f40afbad34751874782273c2c821664697a3 Mon Sep 17 00:00:00 2001 From: SJiB Date: Mon, 3 Jun 2024 17:48:23 +0200 Subject: [PATCH 076/111] comment on filter tank_cleaning --- qgepqwat2ili/qgepdss/export.py | 1 + 1 file changed, 1 insertion(+) diff --git a/qgepqwat2ili/qgepdss/export.py b/qgepqwat2ili/qgepdss/export.py index 348790dd..ddad29f8 100644 --- a/qgepqwat2ili/qgepdss/export.py +++ b/qgepqwat2ili/qgepdss/export.py @@ -3464,6 +3464,7 @@ def textpos_common(row, t_type, geojson_crs_def): logger.info("Exporting QGEP.tank_cleaning -> ABWASSER.beckenreinigung, ABWASSER.metaattribute") query = qgep_session.query(QGEP.tank_cleaning) + # side fk_throttle_shut_off_unit and fk_overflow not considered in filter query - they are usually added only for log_cards and then the corresponding nodes exist anyway thru the direct relation. if filtered: query = query.join(QGEP.wastewater_structure, QGEP.wastewater_networkelement).filter( QGEP.wastewater_networkelement.obj_id.in_(subset_ids) From 3de6c3f71ad7b207ec5b0d776d95ab813ebfaa76 Mon Sep 17 00:00:00 2001 From: SJiB Date: Mon, 3 Jun 2024 17:49:10 +0200 Subject: [PATCH 077/111] moved comment to tank_emptying --- qgepqwat2ili/qgepdss/export.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/qgepqwat2ili/qgepdss/export.py b/qgepqwat2ili/qgepdss/export.py index ddad29f8..c09f54a8 100644 --- a/qgepqwat2ili/qgepdss/export.py +++ b/qgepqwat2ili/qgepdss/export.py @@ -3464,7 +3464,6 @@ def textpos_common(row, t_type, geojson_crs_def): logger.info("Exporting QGEP.tank_cleaning -> ABWASSER.beckenreinigung, ABWASSER.metaattribute") query = qgep_session.query(QGEP.tank_cleaning) - # side fk_throttle_shut_off_unit and fk_overflow not considered in filter query - they are usually added only for log_cards and then the corresponding nodes exist anyway thru the direct relation. if filtered: query = query.join(QGEP.wastewater_structure, QGEP.wastewater_networkelement).filter( QGEP.wastewater_networkelement.obj_id.in_(subset_ids) @@ -3506,6 +3505,7 @@ def textpos_common(row, t_type, geojson_crs_def): logger.info("Exporting QGEP.tank_emptying -> ABWASSER.beckenentleerung, ABWASSER.metaattribute") query = qgep_session.query(QGEP.tank_emptying) + # side fk_throttle_shut_off_unit and fk_overflow not considered in filter query - they are usually added only for log_cards and then the corresponding nodes exist anyway thru the direct relation. if filtered: query = query.join(QGEP.wastewater_structure, QGEP.wastewater_networkelement).filter( QGEP.wastewater_networkelement.obj_id.in_(subset_ids) From 7c4a61b84f3fcbe4672d5ce3f4f84cd41a547aea Mon Sep 17 00:00:00 2001 From: SJiB Date: Mon, 3 Jun 2024 17:56:44 +0200 Subject: [PATCH 078/111] add filter re_maintenance_event_wastewater_structure --- qgepqwat2ili/qgepdss/export.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/qgepqwat2ili/qgepdss/export.py b/qgepqwat2ili/qgepdss/export.py index c09f54a8..d927d41d 100644 --- a/qgepqwat2ili/qgepdss/export.py +++ b/qgepqwat2ili/qgepdss/export.py @@ -3778,7 +3778,11 @@ def textpos_common(row, t_type, geojson_crs_def): # -- adapted 24.9.2022 to do adjust in MD code logger.info("Exporting QGEP.re_maintenance_event_wastewater_structure -> ABWASSER.erhaltungsereignis_abwasserbauwerkassoc") query = qgep_session.query(QGEP.re_maintenance_event_wastewater_structure) - for row in query: + if filtered: + query = query.join(QGEP.wastewater_structure, QGEP.wastewater_networkelement).filter( + QGEP.wastewater_networkelement.obj_id.in_(subset_ids) + ) + for row in query: # AVAILABLE FIELDS IN QGEP.maintenance_event_wastewater_structure From bad737c6f0d8f5012fe13ed91b0d6d88b644ceda Mon Sep 17 00:00:00 2001 From: SJiB Date: Mon, 3 Jun 2024 18:23:02 +0200 Subject: [PATCH 079/111] add filter maintenance_event --- qgepqwat2ili/qgepdss/export.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/qgepqwat2ili/qgepdss/export.py b/qgepqwat2ili/qgepdss/export.py index d927d41d..2bdda7d1 100644 --- a/qgepqwat2ili/qgepdss/export.py +++ b/qgepqwat2ili/qgepdss/export.py @@ -3638,7 +3638,11 @@ def textpos_common(row, t_type, geojson_crs_def): # neu 17.4.2022 class maintenance_event as class, is not superclass in VSA-DSS 2015 logger.info("Exporting QGEP.maintenance_event -> ABWASSER.maintenance_event, ABWASSER.metaattribute") query = qgep_session.query(QGEP.maintenance_event) - + # to check if join is correct like this n:m re_maintenance_event_wastewater_structure + if filtered: + query = query.join(QGEP.re_maintenance_event_wastewater_structure, QGEP.wastewater_structure, QGEP.wastewater_networkelement).filter( + QGEP.wastewater_networkelement.obj_id.in_(subset_ids) + ) for row in query: # AVAILABLE FIELDS IN QGEP.maintenance_event From 010604c756697b31f802132fb0fe3d3708d136ab Mon Sep 17 00:00:00 2001 From: SJiB Date: Mon, 3 Jun 2024 18:24:00 +0200 Subject: [PATCH 080/111] adjust intend --- qgepqwat2ili/qgepdss/export.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/qgepqwat2ili/qgepdss/export.py b/qgepqwat2ili/qgepdss/export.py index 2bdda7d1..15950e59 100644 --- a/qgepqwat2ili/qgepdss/export.py +++ b/qgepqwat2ili/qgepdss/export.py @@ -3786,7 +3786,7 @@ def textpos_common(row, t_type, geojson_crs_def): query = query.join(QGEP.wastewater_structure, QGEP.wastewater_networkelement).filter( QGEP.wastewater_networkelement.obj_id.in_(subset_ids) ) - for row in query: + for row in query: # AVAILABLE FIELDS IN QGEP.maintenance_event_wastewater_structure From 11502c60eff57bd244558a306edd64b2bd0da597 Mon Sep 17 00:00:00 2001 From: SJiB Date: Mon, 3 Jun 2024 19:14:46 +0200 Subject: [PATCH 081/111] correct syntax --- qgepqwat2ili/qgepdss/export.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/qgepqwat2ili/qgepdss/export.py b/qgepqwat2ili/qgepdss/export.py index 15950e59..d3ed10c2 100644 --- a/qgepqwat2ili/qgepdss/export.py +++ b/qgepqwat2ili/qgepdss/export.py @@ -2946,8 +2946,7 @@ def textpos_common(row, t_type, geojson_crs_def): (QGEP.wastewater_structure, QGEP.wastewater_networkelement), (QGEP.water_course_segment, QGEP.river, QGEP.sector_water_body, QGEP.discharge_point, QGEP.wastewater_networkelement), ) - ). - filter( + ).filter( QGEP.wastewater_networkelement.obj_id.in_(subset_ids) ) for row in query: From 917523934b2b84abc94bd60301ee9b3f0d7c122e Mon Sep 17 00:00:00 2001 From: SJiB Date: Mon, 3 Jun 2024 19:16:00 +0200 Subject: [PATCH 082/111] correct syntax --- qgepqwat2ili/qgepdss/export.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/qgepqwat2ili/qgepdss/export.py b/qgepqwat2ili/qgepdss/export.py index d3ed10c2..c331b575 100644 --- a/qgepqwat2ili/qgepdss/export.py +++ b/qgepqwat2ili/qgepdss/export.py @@ -2995,8 +2995,7 @@ def textpos_common(row, t_type, geojson_crs_def): (QGEP.measuring_point, QGEP.wastewater_structure, QGEP.wastewater_networkelement), (QGEP.measuring_point, QGEP.water_course_segment, QGEP.river, QGEP.sector_water_body, QGEP.discharge_point, QGEP.wastewater_networkelement), ) - ). - filter( + ).filter( QGEP.wastewater_networkelement.obj_id.in_(subset_ids) ) for row in query: From e1e1ea6c5c1feafc5cda16c1d748733ad52c1ce0 Mon Sep 17 00:00:00 2001 From: SJiB Date: Mon, 3 Jun 2024 19:17:24 +0200 Subject: [PATCH 083/111] correct syntax --- qgepqwat2ili/qgepdss/export.py | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/qgepqwat2ili/qgepdss/export.py b/qgepqwat2ili/qgepdss/export.py index c331b575..223703ec 100644 --- a/qgepqwat2ili/qgepdss/export.py +++ b/qgepqwat2ili/qgepdss/export.py @@ -3039,8 +3039,7 @@ def textpos_common(row, t_type, geojson_crs_def): (QGEP.measuring_point, QGEP.wastewater_structure, QGEP.wastewater_networkelement), (QGEP.measuring_point, QGEP.water_course_segment, QGEP.river, QGEP.sector_water_body, QGEP.discharge_point, QGEP.wastewater_networkelement), ) - ). - filter( + ).filter( QGEP.wastewater_networkelement.obj_id.in_(subset_ids) ) for row in query: @@ -3088,8 +3087,7 @@ def textpos_common(row, t_type, geojson_crs_def): (QGEP.measuring_device, QGEP.measuring_point, QGEP.wastewater_structure, QGEP.wastewater_networkelement), (QGEP.measuring_device, QGEP.measuring_point, QGEP.water_course_segment, QGEP.river, QGEP.sector_water_body, QGEP.discharge_point, QGEP.wastewater_networkelement), ) - ). - filter( + ).filter( QGEP.wastewater_networkelement.obj_id.in_(subset_ids) ) for row in query: From d3472eaa2d01960fba883e4e6b7bea2bc316e0d7 Mon Sep 17 00:00:00 2001 From: SJiB Date: Mon, 3 Jun 2024 19:20:52 +0200 Subject: [PATCH 084/111] correct intend --- qgepqwat2ili/qgepdss/export.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/qgepqwat2ili/qgepdss/export.py b/qgepqwat2ili/qgepdss/export.py index 223703ec..8036aa28 100644 --- a/qgepqwat2ili/qgepdss/export.py +++ b/qgepqwat2ili/qgepdss/export.py @@ -3231,7 +3231,7 @@ def textpos_common(row, t_type, geojson_crs_def): QGEP.wastewater_node.obj_id == QGEP.prank_weir.fk_overflow_to, ), ).filter(QGEP.wastewater_networkelement.obj_id.in_(subset_ids)) - for row in query: + for row in query: # AVAILABLE FIELDS IN QGEP.pump # --- overflow --- @@ -3245,7 +3245,7 @@ def textpos_common(row, t_type, geojson_crs_def): # --- _rel_ --- # to do extra funktion schreiben wo alle fk auf diese klasse erzeugt werden z.B. # accessibility__REL, bedding_encasement__REL, - + foerderaggregat = ABWASSER.foerderaggregat( # FIELDS TO MAP TO ABWASSER.foerderaggregat # --- baseclass --- From 5d2d8fc4bcd1616c01a84d7d6717b08a70f4c370 Mon Sep 17 00:00:00 2001 From: SJiB Date: Tue, 4 Jun 2024 17:51:54 +0200 Subject: [PATCH 085/111] correct join if also _or --- qgepqwat2ili/qgepdss/export.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/qgepqwat2ili/qgepdss/export.py b/qgepqwat2ili/qgepdss/export.py index 8036aa28..c387163d 100644 --- a/qgepqwat2ili/qgepdss/export.py +++ b/qgepqwat2ili/qgepdss/export.py @@ -2867,6 +2867,7 @@ def textpos_common(row, t_type, geojson_crs_def): query = qgep_session.query(QGEP.catchment_area) if filtered: query = query.join( + QGEP.wastewater_networkelement, or_( QGEP.wastewater_networkelement.obj_id == QGEP.catchment_area.fk_wastewater_networkelement_rw_planned, QGEP.wastewater_networkelement.obj_id == QGEP.catchment_area.fk_wastewater_networkelement_rw_current, @@ -3179,6 +3180,7 @@ def textpos_common(row, t_type, geojson_crs_def): # to check if fk_overflow_char also has to be considered if filtered: query = query.join( + QGEP.wastewater_node, or_( QGEP.wastewater_node.obj_id == QGEP.prank_weir.fk_wastewater_node, QGEP.wastewater_node.obj_id == QGEP.prank_weir.fk_overflow_to, @@ -3226,6 +3228,7 @@ def textpos_common(row, t_type, geojson_crs_def): # to check if fk_overflow_char also has to be considered if filtered: query = query.join( + QGEP.wastewater_node, or_( QGEP.wastewater_node.obj_id == QGEP.prank_weir.fk_wastewater_node, QGEP.wastewater_node.obj_id == QGEP.prank_weir.fk_overflow_to, @@ -3277,6 +3280,7 @@ def textpos_common(row, t_type, geojson_crs_def): # to check if fk_overflow_char also has to be considered if filtered: query = query.join( + QGEP.wastewater_node, or_( QGEP.wastewater_node.obj_id == QGEP.prank_weir.fk_wastewater_node, QGEP.wastewater_node.obj_id == QGEP.prank_weir.fk_overflow_to, From 8206d927fe1288ef478207609a66f1524179c4b4 Mon Sep 17 00:00:00 2001 From: SJiB Date: Tue, 4 Jun 2024 19:24:17 +0200 Subject: [PATCH 086/111] debugging if filtered statements --- qgepqwat2ili/qgepdss/export.py | 89 +++++++++++++++++++--------------- 1 file changed, 49 insertions(+), 40 deletions(-) diff --git a/qgepqwat2ili/qgepdss/export.py b/qgepqwat2ili/qgepdss/export.py index c387163d..1cc67f4f 100644 --- a/qgepqwat2ili/qgepdss/export.py +++ b/qgepqwat2ili/qgepdss/export.py @@ -1957,7 +1957,8 @@ def textpos_common(row, t_type, geojson_crs_def): QGEP.reach, or_( QGEP.reach_point.obj_id == QGEP.reach.fk_reach_point_from, - # QGEP.reach_point.obj_id == QGEP.reach.fk_reach_point_to, + # 4.6.2024 again added + QGEP.reach_point.obj_id == QGEP.reach.fk_reach_point_to, ), ).filter(QGEP.wastewater_networkelement.obj_id.in_(subset_ids)) for row in query: @@ -2941,15 +2942,17 @@ def textpos_common(row, t_type, geojson_crs_def): logger.info("Exporting QGEP.measuring_point -> ABWASSER.messstelle, ABWASSER.metaattribute") query = qgep_session.query(QGEP.measuring_point) if filtered: - query = query.query.join( - or_( - (QGEP.waste_water_treatment_plant, QGEP.wastewater_networkelement), - (QGEP.wastewater_structure, QGEP.wastewater_networkelement), - (QGEP.water_course_segment, QGEP.river, QGEP.sector_water_body, QGEP.discharge_point, QGEP.wastewater_networkelement), - ) - ).filter( - QGEP.wastewater_networkelement.obj_id.in_(subset_ids) - ) + query = query.join(QGEP.wastewater_structure, QGEP.wastewater_networkelement).filter(QGEP.wastewater_networkelement.obj_id.in_(subset_ids) + ) + # QGEP.wastewater_networkelement, + # or does not work with this - currently do not support other connections + # or_( + # (QGEP.waste_water_treatment_plant, QGEP.wastewater_networkelement), + # (QGEP.wastewater_structure, QGEP.wastewater_networkelement), + # currently do not support other connections + # (QGEP.water_course_segment, QGEP.river, QGEP.sector_water_body, QGEP.discharge_point, QGEP.wastewater_networkelement), + # ) + for row in query: # AVAILABLE FIELDS IN QGEP.measuring_point @@ -2990,15 +2993,16 @@ def textpos_common(row, t_type, geojson_crs_def): logger.info("Exporting QGEP.measuring_device -> ABWASSER.messgeraet, ABWASSER.metaattribute") query = qgep_session.query(QGEP.measuring_device) if filtered: - query = query.query.join( - or_( - (QGEP.measuring_point, QGEP.waste_water_treatment_plant, QGEP.wastewater_networkelement), - (QGEP.measuring_point, QGEP.wastewater_structure, QGEP.wastewater_networkelement), - (QGEP.measuring_point, QGEP.water_course_segment, QGEP.river, QGEP.sector_water_body, QGEP.discharge_point, QGEP.wastewater_networkelement), - ) - ).filter( - QGEP.wastewater_networkelement.obj_id.in_(subset_ids) + query = query.join(QGEP.measuring_point, QGEP.wastewater_structure, QGEP.wastewater_networkelement).filter(QGEP.wastewater_networkelement.obj_id.in_(subset_ids) ) + # or does not work with this - currently do not support + # QGEP.wastewater_networkelement, + # or_( + # (QGEP.measuring_point, QGEP.waste_water_treatment_plant, QGEP.wastewater_networkelement), + # (QGEP.measuring_point, QGEP.wastewater_structure, QGEP.wastewater_networkelement), + # (QGEP.measuring_point, QGEP.water_course_segment, QGEP.river, QGEP.sector_water_body, QGEP.discharge_point, QGEP.wastewater_networkelement), + # ) + for row in query: # AVAILABLE FIELDS IN QGEP.measuring_device @@ -3034,15 +3038,14 @@ def textpos_common(row, t_type, geojson_crs_def): logger.info("Exporting QGEP.measurement_series -> ABWASSER.messreihe, ABWASSER.metaattribute") query = qgep_session.query(QGEP.measurement_series) if filtered: - query = query.query.join( - or_( - (QGEP.measuring_point, QGEP.waste_water_treatment_plant, QGEP.wastewater_networkelement), - (QGEP.measuring_point, QGEP.wastewater_structure, QGEP.wastewater_networkelement), - (QGEP.measuring_point, QGEP.water_course_segment, QGEP.river, QGEP.sector_water_body, QGEP.discharge_point, QGEP.wastewater_networkelement), - ) - ).filter( - QGEP.wastewater_networkelement.obj_id.in_(subset_ids) - ) + query = query.join(QGEP.measuring_point, QGEP.wastewater_structure, QGEP.wastewater_networkelement).filter(QGEP.wastewater_networkelement.obj_id.in_(subset_ids) + ) + # QGEP.wastewater_networkelement, + # or_( + # (QGEP.measuring_point, QGEP.waste_water_treatment_plant, QGEP.wastewater_networkelement), + # (QGEP.measuring_point, QGEP.wastewater_structure, QGEP.wastewater_networkelement), + # (QGEP.measuring_point, QGEP.water_course_segment, QGEP.river, QGEP.sector_water_body, QGEP.discharge_point, QGEP.wastewater_networkelement), + # ) for row in query: # AVAILABLE FIELDS IN QGEP.measurement_series @@ -3078,19 +3081,19 @@ def textpos_common(row, t_type, geojson_crs_def): logger.info("Exporting QGEP.measurement_result -> ABWASSER.messresultat, ABWASSER.metaattribute") query = qgep_session.query(QGEP.measurement_result) if filtered: - query = query.query.join( - or_( - (QGEP.measurement_series, QGEP.measuring_point, QGEP.waste_water_treatment_plant, QGEP.wastewater_networkelement), - (QGEP.measurement_series, QGEP.measuring_point, QGEP.wastewater_structure, QGEP.wastewater_networkelement), - (QGEP.measurement_series, QGEP.measuring_point, QGEP.water_course_segment, QGEP.river, QGEP.sector_water_body, QGEP.discharge_point, QGEP.wastewater_networkelement), - - (QGEP.measuring_device, QGEP.measuring_point, QGEP.waste_water_treatment_plant, QGEP.wastewater_networkelement), - (QGEP.measuring_device, QGEP.measuring_point, QGEP.wastewater_structure, QGEP.wastewater_networkelement), - (QGEP.measuring_device, QGEP.measuring_point, QGEP.water_course_segment, QGEP.river, QGEP.sector_water_body, QGEP.discharge_point, QGEP.wastewater_networkelement), - ) - ).filter( + query = query.join(QGEP.measurement_series, QGEP.measuring_point, QGEP.wastewater_structure, QGEP.wastewater_networkelement).filter( QGEP.wastewater_networkelement.obj_id.in_(subset_ids) ) + # or_( + # (QGEP.measurement_series, QGEP.measuring_point, QGEP.waste_water_treatment_plant, QGEP.wastewater_networkelement), + # (QGEP.measurement_series, QGEP.measuring_point, QGEP.wastewater_structure, QGEP.wastewater_networkelement), + # (QGEP.measurement_series, QGEP.measuring_point, QGEP.water_course_segment, QGEP.river, QGEP.sector_water_body, QGEP.discharge_point, QGEP.wastewater_networkelement), + + # (QGEP.measuring_device, QGEP.measuring_point, QGEP.waste_water_treatment_plant, QGEP.wastewater_networkelement), + # (QGEP.measuring_device, QGEP.measuring_point, QGEP.wastewater_structure, QGEP.wastewater_networkelement), + # (QGEP.measuring_device, QGEP.measuring_point, QGEP.water_course_segment, QGEP.river, QGEP.sector_water_body, QGEP.discharge_point, QGEP.wastewater_networkelement), + # ) + for row in query: # AVAILABLE FIELDS IN QGEP.measurement_result @@ -3127,9 +3130,15 @@ def textpos_common(row, t_type, geojson_crs_def): logger.info("Exporting QGEP.throttle_shut_off_unit -> ABWASSER.absperr_drosselorgan, ABWASSER.metaattribute") query = qgep_session.query(QGEP.throttle_shut_off_unit) - # to check if fk_control_center__REL has also to be considered + # sqlalchemy.exc.InvalidRequestError: Don't know how to join to . Please use the .select_from() method to establish an explicit left side, as well as providing an explcit ON clause if not present already to help resolve the ambiguity. + # fk_control_center has also to be NOT considered if filtered: - query = query.join(QGEP.wastewater_networkelement).filter( + query = query.join( + QGEP.wastewater_node, + or_( + QGEP.wastewater_node.obj_id == QGEP.throttle_shut_off_unit.fk_wastewater_node, + ), + ).filter( QGEP.wastewater_networkelement.obj_id.in_(subset_ids) ) for row in query: From 65790d8c9d1c441aab5d8a1375cb1263cfe7a1fe Mon Sep 17 00:00:00 2001 From: SJiB Date: Wed, 5 Jun 2024 13:38:18 +0200 Subject: [PATCH 087/111] added query.union to measuring_point --- qgepqwat2ili/qgepdss/export.py | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/qgepqwat2ili/qgepdss/export.py b/qgepqwat2ili/qgepdss/export.py index 1cc67f4f..437cce88 100644 --- a/qgepqwat2ili/qgepdss/export.py +++ b/qgepqwat2ili/qgepdss/export.py @@ -2942,7 +2942,24 @@ def textpos_common(row, t_type, geojson_crs_def): logger.info("Exporting QGEP.measuring_point -> ABWASSER.messstelle, ABWASSER.metaattribute") query = qgep_session.query(QGEP.measuring_point) if filtered: - query = query.join(QGEP.wastewater_structure, QGEP.wastewater_networkelement).filter(QGEP.wastewater_networkelement.obj_id.in_(subset_ids) + query1=query.join(QGEP.wastewater_structure, QGEP.wastewater_networkelement) + # needs to add QGEP.wastewater_structure as waste_water_treatment_plant is a subclass of organisation that has a relation to wastewater_structure and then wastewater_networkelement + #variant1 for query2 + # query2=query.join(QGEP.waste_water_treatment_plant, (QGEP.wastewater_structure, QGEP.waste_water_treatment_plant.obj_id == QGEP.wastewater_structure.fk_owner), (QGEP.wastewater_structure, QGEP.waste_water_treatment_plant.obj_id == QGEP.wastewater_structure.fk_provider),QGEP.wastewater_networkelement, + # ) + #variant2 for query2 + # try with extra or_ + # or_( + # QGEP.waste_water_treatment_plant.obj_id == QGEP.wastewater_structure.fk_owner, + # QGEP.waste_water_treatment_plant.obj_id == QGEP.wastewater_structure.fk_provider, + # ), + # QGEP.wastewater_networkelement, + + # ) + query3=query.join(QGEP.water_course_segment, QGEP.river, QGEP.sector_water_body, QGEP.discharge_point, QGEP.wastewater_networkelement) + # query=union(query1, query2, query3) + query=query.union(query1, query3) + query = query.filter(QGEP.wastewater_networkelement.obj_id.in_(subset_ids) ) # QGEP.wastewater_networkelement, # or does not work with this - currently do not support other connections From 904943e1f9c676c30519e3898a2e7de71f8f6324 Mon Sep 17 00:00:00 2001 From: SJiB Date: Wed, 12 Jun 2024 15:34:27 +0200 Subject: [PATCH 088/111] cleanup qgep export --- qgepqwat2ili/qgep/export.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/qgepqwat2ili/qgep/export.py b/qgepqwat2ili/qgep/export.py index 6e8add4f..0f65ce5c 100644 --- a/qgepqwat2ili/qgep/export.py +++ b/qgepqwat2ili/qgep/export.py @@ -101,7 +101,7 @@ def modulo_angle(val): if val is None: return None - # 5.4.2023 add orientation + # add orientation val = val + float(labelorientation) val = val % 360.0 From 60c6588a22368f7163cbfa8e48e1fa92a91b0163 Mon Sep 17 00:00:00 2001 From: SJiB Date: Wed, 12 Jun 2024 15:42:53 +0200 Subject: [PATCH 089/111] cleanup qgepsia405 --- qgepqwat2ili/qgepsia405/export.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/qgepqwat2ili/qgepsia405/export.py b/qgepqwat2ili/qgepsia405/export.py index 64597daa..8b709b1b 100644 --- a/qgepqwat2ili/qgepsia405/export.py +++ b/qgepqwat2ili/qgepsia405/export.py @@ -101,7 +101,7 @@ def modulo_angle(val): if val is None: return None - # 5.4.2023 add orientation + # add orientation val = val + float(labelorientation) val = val % 360.0 @@ -118,10 +118,11 @@ def create_metaattributes(row): # FIELDS TO MAP TO ABWASSER.metaattribute # --- metaattribute --- - # 31.3.2023 obj_id instead of name + # datenherr=getattr(row.fk_dataowner__REL, "name", "unknown"), # TODO : is unknown ok ? # datenlieferant=getattr(row.fk_provider__REL, "name", "unknown"), # TODO : is unknown ok ? - + + # obj_id instead of name datenherr=getattr(row.fk_dataowner__REL, "obj_id", "unknown"), # TODO : is unknown ok ? datenlieferant=getattr(row.fk_provider__REL, "obj_id", "unknown"), # TODO : is unknown ok ? From c20ffd7894153caa173f2b0ea1c7fd9329646215 Mon Sep 17 00:00:00 2001 From: SJiB Date: Wed, 12 Jun 2024 15:56:07 +0200 Subject: [PATCH 090/111] cleanup gepdss export --- qgepqwat2ili/qgepdss/export.py | 52 +++++++++++++--------------------- 1 file changed, 20 insertions(+), 32 deletions(-) diff --git a/qgepqwat2ili/qgepdss/export.py b/qgepqwat2ili/qgepdss/export.py index 437cce88..410434c2 100644 --- a/qgepqwat2ili/qgepdss/export.py +++ b/qgepqwat2ili/qgepdss/export.py @@ -1,5 +1,3 @@ -# version von hand 13.3.2023 - import json from geoalchemy2.functions import ST_Force2D, ST_GeomFromGeoJSON @@ -12,9 +10,7 @@ from .model_abwasser import get_abwasser_model from .model_qgep import get_qgep_model -# 18.3.2023 adapted as in /qgep version -# def qgep_export(selection=None): -#def qgep_export(selection=None, labels_file=None): + def qgep_export(selection=None, labels_file=None, orientation=None): """ Export data from the QGEP model into the ili2pg model. @@ -106,7 +102,7 @@ def modulo_angle(val): if val is None: return None - # 5.4.2023 add orientation + # add orientation val = val + float(labelorientation) val = val % 360.0 @@ -124,11 +120,11 @@ def create_metaattributes(row): # FIELDS TO MAP TO ABWASSER.metaattribute # --- metaattribute --- - # 31.3.2023 obj_id instead of name + # datenherr=getattr(row.fk_dataowner__REL, "name", "unknown"), # TODO : is unknown ok ? # datenlieferant=getattr(row.fk_provider__REL, "name", "unknown"), # TODO : is unknown ok ? - + # obj_id instead of name datenherr=getattr(row.fk_dataowner__REL, "obj_id", "unknown"), # TODO : is unknown ok ? datenlieferant=getattr(row.fk_provider__REL, "obj_id", "unknown"), # TODO : is unknown ok ? @@ -159,7 +155,7 @@ def organisation_common(row): return { "bemerkung": truncate(emptystr_to_null(row.remark), 80), "bezeichnung": row.identifier, - # 5.9.2022 doppelt - erst in release 2020 bei organisation + # attribute organisation.gemeindenummer will be added with release 2020 # "gemeindenummer": row.municipality_number, # not supported in model qgep 2015 # "teil_vonref": get_tid(row.fk_part_of__REL), @@ -336,7 +332,8 @@ def textpos_common(row, t_type, geojson_crs_def): "textinhalt": row["properties"]["LabelText"], "bemerkung": None, } -# -- 25.9.2022 re_maintenance_event_wastewater_structure moved to end, as wastewater_structure and maintenance_event are not yet added + +# re_maintenance_event_wastewater_structure moved to end, as wastewater_structure and maintenance_event are not yet added logger.info("Exporting QGEP.mutation -> ABWASSER.mutation, ABWASSER.metaattribute") query = qgep_session.query(QGEP.mutation) @@ -364,8 +361,9 @@ def textpos_common(row, t_type, geojson_crs_def): aufnahmedatum=row.date_time, aufnehmer=row.recorded_by, bemerkung=truncate(emptystr_to_null(row.remark), 80), - # 21.7.2022 zuerst qgep datenmodell anpassen + # Model adapted with delta/delta_1.5.8_dss_upddate_attributes_class.sql #klasse=row.class, + klasse=row.classname, letzter_wert=row.last_value, mutationsdatum=row.date_mutation, objekt=null_to_emptystr(row.object), @@ -667,7 +665,7 @@ def textpos_common(row, t_type, geojson_crs_def): oberflaechengewaesserref=get_tid(row.fk_surface_water_body__REL), reflaenge=row.ref_length, verlauf=ST_Force2D(row.progression_geometry), - # 6.9.2022 to do md rausnehmen da auf gleiche klasse + # reference to own class not supported in qgep # vorherigersektorref=get_tid(row.fk_sector_previous__REL), ) abwasser_session.add(gewaessersektor) @@ -1957,7 +1955,6 @@ def textpos_common(row, t_type, geojson_crs_def): QGEP.reach, or_( QGEP.reach_point.obj_id == QGEP.reach.fk_reach_point_from, - # 4.6.2024 again added QGEP.reach_point.obj_id == QGEP.reach.fk_reach_point_to, ), ).filter(QGEP.wastewater_networkelement.obj_id.in_(subset_ids)) @@ -2923,7 +2920,7 @@ def textpos_common(row, t_type, geojson_crs_def): perimeter=ST_Force2D(row.perimeter_geometry), retention_geplant=get_vl(row.retention_planned__REL), retention_ist=get_vl(row.retention_current__REL), - # 6.9.2022 only in Release 2020 to do in code von MD abfangen + # sbw_*ref will be added with release 2020 # sbw_rw_geplantref=get_tid(row.fk_special_building_rw_planned__REL), # sbw_rw_istref=get_tid(row.fk_special_building_rw_current__REL), # sbw_sw_geplantref=get_tid(row.fk_special_building_ww_planned__REL), @@ -3382,7 +3379,7 @@ def textpos_common(row, t_type, geojson_crs_def): foerderstrommin=row.pump_flow_min, hauptwehrart=get_vl(row.main_weir_kind__REL), mehrbelastung=row.overcharge, - # 6.9.2022 erst in release 2020 md anpassen + # primaerrichtungref will be added with release 2020 #primaerrichtungref=get_tid(row.fk_primary_direction__REL), pumpenregime=get_vl(row.pump_characteristics__REL), qab=row.q_discharge, @@ -3661,7 +3658,7 @@ def textpos_common(row, t_type, geojson_crs_def): logger.info("done") abwasser_session.flush() -# neu 17.4.2022 class maintenance_event as class, is not superclass in VSA-DSS 2015 +# class maintenance_event as class, is not superclass in VSA-DSS 2015 logger.info("Exporting QGEP.maintenance_event -> ABWASSER.maintenance_event, ABWASSER.metaattribute") query = qgep_session.query(QGEP.maintenance_event) # to check if join is correct like this n:m re_maintenance_event_wastewater_structure @@ -3799,13 +3796,11 @@ def textpos_common(row, t_type, geojson_crs_def): # -- extra commit abwasser_session.commit() -# -- extra session2 +# -- extra session2 for re_maintenance_event_wastewater_structure abwasser_session2 = Session(utils.sqlalchemy.create_engine(), autocommit=False, autoflush=False) -# -- logger.info("Exporting QGEP.re_maintenance_event_wastewater_structure -> ABWASSER.erhaltungsereignis_abwasserbauwerk, ABWASSER.metaattribute") -# -- adapted 24.9.2022 to do adjust in MD code logger.info("Exporting QGEP.re_maintenance_event_wastewater_structure -> ABWASSER.erhaltungsereignis_abwasserbauwerkassoc") query = qgep_session.query(QGEP.re_maintenance_event_wastewater_structure) if filtered: @@ -3824,34 +3819,27 @@ def textpos_common(row, t_type, geojson_crs_def): # --- _rel_ --- # to do add relations fk_dataowner__REL, fk_provider__REL, profile_type__REL -# -- erhaltungsereignis_abwasserbauwerk = ABWASSER.erhaltungsereignis_abwasserbauwerk( -# -- adapted 24.9.2022 to do adjust in MD code + erhaltungsereignis_abwasserbauwerk = ABWASSER.erhaltungsereignis_abwasserbauwerkassoc( # FIELDS TO MAP TO ABWASSER.erhaltungsereignis_abwasserbauwerk # --- baseclass --- # --- sia405_baseclass --- -# -- **base_common(row, "erhaltungsereignis_abwasserbauwerk"), -# -- adapted 24.9.2022 to do adjust in MD code -# -- adapted2 24.9.2022 no base for erhaltungsereignis_abwasserbauwerkassoc -# -- **base_common(row, "erhaltungsereignis_abwasserbauwerkassoc"), + # --- erhaltungsereignis_abwasserbauwerk --- abwasserbauwerkref=get_tid(row.fk_wastewater_structure__REL), -# -- erhaltungsereignisref=get_tid(row.fk_maintenance_event__REL), -# -- adapted 24.9.2022 to do adjust in MD code erhaltungsereignis_abwasserbauwerkassocref=get_tid(row.fk_maintenance_event__REL), ) -# abwasser_session.add(erhaltungsereignis_abwasserbauwerk) + abwasser_session2.add(erhaltungsereignis_abwasserbauwerk) -# -- 24.9.2022 adapted to do MD code - no metaattributes -# -- create_metaattributes(row) + print(".", end="") logger.info("done") -# -- 25.9.22 abwasser_session.flush() + abwasser_session2.flush() -# -- 25.9.22 abwasser_session.commit() + abwasser_session2.commit() qgep_session.close() From a22ef11004464f4aa7695008351532ca107d832e Mon Sep 17 00:00:00 2001 From: SJiB Date: Wed, 12 Jun 2024 17:30:54 +0200 Subject: [PATCH 091/111] adding check_fk_in_subsetid --- qgepqwat2ili/qgepdss/export.py | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/qgepqwat2ili/qgepdss/export.py b/qgepqwat2ili/qgepdss/export.py index 410434c2..4232826f 100644 --- a/qgepqwat2ili/qgepdss/export.py +++ b/qgepqwat2ili/qgepdss/export.py @@ -114,7 +114,22 @@ def modulo_angle(val): return val + + def check_fk_in_subsetid (foreignkey2, subset): + """ + 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 ") + else: + logger.info(f"check_fk_in_subsetid - '{foreignkey2}' is not in subset - replaced with None instead!") + foreignkey2 = None + return foreignkey2 + + def create_metaattributes(row): metaattribute = ABWASSER.metaattribute( # FIELDS TO MAP TO ABWASSER.metaattribute @@ -1960,6 +1975,9 @@ 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 --- @@ -1977,7 +1995,8 @@ def textpos_common(row, t_type, geojson_crs_def): **base_common(row, "haltungspunkt"), # --- haltungspunkt --- - abwassernetzelementref=get_tid(row.fk_wastewater_networkelement__REL), + #abwassernetzelementref=get_tid(row.fk_wastewater_networkelement__REL), + abwassernetzelementref=get_tid(check_fk_in_subsetid((row.fk_wastewater_networkelement__REL), subset_ids)), auslaufform=get_vl(row.outlet_shape__REL), bemerkung=truncate(emptystr_to_null(row.remark), 80), bezeichnung=null_to_emptystr(row.identifier), From aa250faecde6be83470ae61994d20d1c34a8506f Mon Sep 17 00:00:00 2001 From: SJiB Date: Fri, 14 Jun 2024 23:07:38 +0200 Subject: [PATCH 092/111] 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 4232826f..d98b45bb 100644 --- a/qgepqwat2ili/qgepdss/export.py +++ b/qgepqwat2ili/qgepdss/export.py @@ -49,6 +49,7 @@ def get_tid(relation): """ if relation is None: return None + return tid_maker.tid_for_row(relation) def get_vl(relation): @@ -95,6 +96,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) @@ -112,23 +114,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( @@ -1975,9 +1978,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 --- @@ -1996,7 +1996,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), From 3b7cbf74fa79cfabea8f5414664e35972446863e Mon Sep 17 00:00:00 2001 From: SJiB Date: Fri, 14 Jun 2024 23:08:54 +0200 Subject: [PATCH 093/111] change description of check_fk_in_subsetid --- qgepqwat2ili/qgepdss/export.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/qgepqwat2ili/qgepdss/export.py b/qgepqwat2ili/qgepdss/export.py index d98b45bb..da04f93d 100644 --- a/qgepqwat2ili/qgepdss/export.py +++ b/qgepqwat2ili/qgepdss/export.py @@ -118,7 +118,7 @@ def modulo_angle(val): 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 + checks, whether foreignkey is in the subset_ids - if yes it return the tid of the foreignkey, if no it will return None """ logger.info(f"check_fk_in_subsetid - Subset ID's '{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 From 9e85940e9d0d3f65c4c91dec72faf96a8498dea1 Mon Sep 17 00:00:00 2001 From: SJiB Date: Fri, 14 Jun 2024 23:15:54 +0200 Subject: [PATCH 094/111] add check_fk_in_subsetid to qgep and qgepsia405 --- qgepqwat2ili/qgep/export.py | 24 ++++++++++++++++++++++-- qgepqwat2ili/qgepdss/export.py | 2 +- qgepqwat2ili/qgepsia405/export.py | 22 +++++++++++++++++++++- 3 files changed, 44 insertions(+), 4 deletions(-) diff --git a/qgepqwat2ili/qgep/export.py b/qgepqwat2ili/qgep/export.py index 0f65ce5c..d7616a10 100644 --- a/qgepqwat2ili/qgep/export.py +++ b/qgepqwat2ili/qgep/export.py @@ -10,8 +10,8 @@ from .model_abwasser import get_abwasser_model from .model_qgep import get_qgep_model +# to do add check_fk_in_subsetid to qgepdss and qgepsia405 -#def qgep_export(selection=None, labels_file=None): def qgep_export(selection=None, labels_file=None, orientation=None): """ Export data from the QGEP model into the ili2pg model. @@ -113,6 +113,23 @@ def modulo_angle(val): return val + def check_fk_in_subsetid (subset, relation): + """ + checks, whether foreignkey is in the subset_ids - if yes it return the tid of the foreignkey, if no it will return None + """ + logger.info(f"check_fk_in_subsetid - Subset ID's '{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 - '{fremdschluesselstr}' is not in subset - replaced with None instead!") + return None + def create_metaattributes(row): metaattribute = ABWASSER.metaattribute( # FIELDS TO MAP TO ABWASSER.metaattribute @@ -512,7 +529,10 @@ def textpos_common(row, t_type, geojson_crs_def): # --- sia405_baseclass --- **base_common(row, "haltungspunkt"), # --- haltungspunkt --- - abwassernetzelementref=get_tid(row.fk_wastewater_networkelement__REL), + + # changed call from get_tid to check_fk_in_subsetid so it does not wirte foreignkeys on elements that do not exist + #abwassernetzelementref=get_tid(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), diff --git a/qgepqwat2ili/qgepdss/export.py b/qgepqwat2ili/qgepdss/export.py index da04f93d..05004e15 100644 --- a/qgepqwat2ili/qgepdss/export.py +++ b/qgepqwat2ili/qgepdss/export.py @@ -1995,8 +1995,8 @@ def textpos_common(row, t_type, geojson_crs_def): **base_common(row, "haltungspunkt"), # --- haltungspunkt --- + # changed call from get_tid to check_fk_in_subsetid so it does not wirte foreignkeys on elements that do not exist #abwassernetzelementref=get_tid(row.fk_wastewater_networkelement__REL), - # 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), diff --git a/qgepqwat2ili/qgepsia405/export.py b/qgepqwat2ili/qgepsia405/export.py index 8b709b1b..b351c9bc 100644 --- a/qgepqwat2ili/qgepsia405/export.py +++ b/qgepqwat2ili/qgepsia405/export.py @@ -113,6 +113,23 @@ def modulo_angle(val): return val + def check_fk_in_subsetid (subset, relation): + """ + checks, whether foreignkey is in the subset_ids - if yes it return the tid of the foreignkey, if no it will return None + """ + logger.info(f"check_fk_in_subsetid - Subset ID's '{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 - '{fremdschluesselstr}' is not in subset - replaced with None instead!") + return None + def create_metaattributes(row): metaattribute = ABWASSER.metaattribute( # FIELDS TO MAP TO ABWASSER.metaattribute @@ -510,7 +527,10 @@ def textpos_common(row, t_type, geojson_crs_def): # --- sia405_baseclass --- **base_common(row, "haltungspunkt"), # --- haltungspunkt --- - abwassernetzelementref=get_tid(row.fk_wastewater_networkelement__REL), + + # changed call from get_tid to check_fk_in_subsetid so it does not wirte foreignkeys on elements that do not exist + #abwassernetzelementref=get_tid(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), From 88db2be6eeb48ed2070903105ce7c3e8e3302811 Mon Sep 17 00:00:00 2001 From: SJiB Date: Fri, 14 Jun 2024 23:23:40 +0200 Subject: [PATCH 095/111] add first check for None, --- qgepqwat2ili/qgep/export.py | 4 ++++ qgepqwat2ili/qgepdss/export.py | 4 ++++ qgepqwat2ili/qgepsia405/export.py | 4 ++++ 3 files changed, 12 insertions(+) diff --git a/qgepqwat2ili/qgep/export.py b/qgepqwat2ili/qgep/export.py index d7616a10..e7e92262 100644 --- a/qgepqwat2ili/qgep/export.py +++ b/qgepqwat2ili/qgep/export.py @@ -117,6 +117,10 @@ def check_fk_in_subsetid (subset, relation): """ checks, whether foreignkey is in the subset_ids - if yes it return the tid of the foreignkey, if no it will return None """ + # first check for None, as is get_tid + if relation is None: + return None + logger.info(f"check_fk_in_subsetid - Subset ID's '{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") diff --git a/qgepqwat2ili/qgepdss/export.py b/qgepqwat2ili/qgepdss/export.py index 05004e15..4069266a 100644 --- a/qgepqwat2ili/qgepdss/export.py +++ b/qgepqwat2ili/qgepdss/export.py @@ -120,6 +120,10 @@ def check_fk_in_subsetid (subset, relation): """ checks, whether foreignkey is in the subset_ids - if yes it return the tid of the foreignkey, if no it will return None """ + # first check for None, as is get_tid + if relation is None: + return None + logger.info(f"check_fk_in_subsetid - Subset ID's '{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") diff --git a/qgepqwat2ili/qgepsia405/export.py b/qgepqwat2ili/qgepsia405/export.py index b351c9bc..c4abe4ba 100644 --- a/qgepqwat2ili/qgepsia405/export.py +++ b/qgepqwat2ili/qgepsia405/export.py @@ -117,6 +117,10 @@ def check_fk_in_subsetid (subset, relation): """ checks, whether foreignkey is in the subset_ids - if yes it return the tid of the foreignkey, if no it will return None """ + # first check for None, as is get_tid + if relation is None: + return None + logger.info(f"check_fk_in_subsetid - Subset ID's '{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") From 9b66fd73ddd7b00ae6cb90a5b29b3746488dacca Mon Sep 17 00:00:00 2001 From: SJiB Date: Mon, 17 Jun 2024 11:19:55 +0200 Subject: [PATCH 096/111] catchment_area - changed from get_tid to check_fk_in_subsetid --- qgepqwat2ili/qgepdss/export.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/qgepqwat2ili/qgepdss/export.py b/qgepqwat2ili/qgepdss/export.py index 4069266a..d632777f 100644 --- a/qgepqwat2ili/qgepdss/export.py +++ b/qgepqwat2ili/qgepdss/export.py @@ -2922,10 +2922,10 @@ def textpos_common(row, t_type, geojson_crs_def): abflussbeiwert_rw_ist=row.discharge_coefficient_rw_current, abflussbeiwert_sw_geplant=row.discharge_coefficient_ww_planned, abflussbeiwert_sw_ist=row.discharge_coefficient_ww_current, - abwassernetzelement_rw_geplantref=get_tid(row.fk_wastewater_networkelement_rw_planned__REL), - abwassernetzelement_rw_istref=get_tid(row.fk_wastewater_networkelement_rw_current__REL), - abwassernetzelement_sw_geplantref=get_tid(row.fk_wastewater_networkelement_ww_planned__REL), - abwassernetzelement_sw_istref=get_tid(row.fk_wastewater_networkelement_ww_current__REL), + abwassernetzelement_rw_geplantref=check_fk_in_subsetid(row.fk_wastewater_networkelement_rw_planned__REL), + abwassernetzelement_rw_istref=check_fk_in_subsetid(row.fk_wastewater_networkelement_rw_current__REL), + abwassernetzelement_sw_geplantref=check_fk_in_subsetid(row.fk_wastewater_networkelement_ww_planned__REL), + abwassernetzelement_sw_istref=check_fk_in_subsetid(row.fk_wastewater_networkelement_ww_current__REL), befestigungsgrad_rw_geplant=row.seal_factor_rw_planned, befestigungsgrad_rw_ist=row.seal_factor_rw_current, befestigungsgrad_sw_geplant=row.seal_factor_ww_planned, From 3d5d28fc8886e3140a878f0393fe4e1c7d127c07 Mon Sep 17 00:00:00 2001 From: SJiB Date: Tue, 18 Jun 2024 17:27:26 +0200 Subject: [PATCH 097/111] debug add logger info --- qgepqwat2ili/qgepdss/export.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/qgepqwat2ili/qgepdss/export.py b/qgepqwat2ili/qgepdss/export.py index d632777f..da0fb86b 100644 --- a/qgepqwat2ili/qgepdss/export.py +++ b/qgepqwat2ili/qgepdss/export.py @@ -34,8 +34,15 @@ def qgep_export(selection=None, labels_file=None, orientation=None): # Filtering filtered = selection is not None + + # Logging for debugging + logger.info(f"print filtered '{filtered}'") + subset_ids = selection if selection is not None else [] + # Logging for debugging + logger.info(f"print subset_ids '{subset_ids}'") + # Orientation oriented = orientation is not None if oriented: From c271b12b131eb94a75bb163b649a52e8318cea17 Mon Sep 17 00:00:00 2001 From: SJiB Date: Tue, 18 Jun 2024 18:44:00 +0200 Subject: [PATCH 098/111] add extra logger.info to check the passed on selection --- qgepqwat2ili/gui/__init__.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/qgepqwat2ili/gui/__init__.py b/qgepqwat2ili/gui/__init__.py index 2bc2f723..97e7f949 100644 --- a/qgepqwat2ili/gui/__init__.py +++ b/qgepqwat2ili/gui/__init__.py @@ -599,6 +599,10 @@ def action_do_export(): #18.3.2023 # 22.3.2023 added try - seems not to work # try: + + # add logger info to check what selection is used + logger.info(f"Start Exporting with selection {str(export_dialog.selected_ids)}") + if emodel == "VSA_KEK_2019_LV95": logger.info("Start Exporting VSA_KEK_2019_LV95 - qgep_export") #qgep_export(selection=export_dialog.selected_ids, labels_file=labels_file_path) From d2676c3a4d18466e8339a4a2f3b21a2544992b5a Mon Sep 17 00:00:00 2001 From: SJiB Date: Wed, 19 Jun 2024 11:33:06 +0200 Subject: [PATCH 099/111] turn on flag_test to allow subclass test for wastewater_structures --- qgepqwat2ili/gui/__init__.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/qgepqwat2ili/gui/__init__.py b/qgepqwat2ili/gui/__init__.py index 97e7f949..d7ae73fe 100644 --- a/qgepqwat2ili/gui/__init__.py +++ b/qgepqwat2ili/gui/__init__.py @@ -440,7 +440,8 @@ def action_do_export(): return # 2. check wastewater_structure for all data models - flag_test = False + # flag_test - set to true if this test should be applied also + flag_test = True if flag_test: check_wastewater_structure = False check_wastewater_structure = check_wastewater_structure_subclass_data() From 2527a3974e84f4d37b9701b89dd24310a52d223c Mon Sep 17 00:00:00 2001 From: SJiB Date: Wed, 26 Jun 2024 22:24:42 +0200 Subject: [PATCH 100/111] corrections qgepdss export.py --- qgepqwat2ili/qgepdss/export.py | 45 ++++++++++++++++++++-------------- 1 file changed, 26 insertions(+), 19 deletions(-) diff --git a/qgepqwat2ili/qgepdss/export.py b/qgepqwat2ili/qgepdss/export.py index da0fb86b..022394c8 100644 --- a/qgepqwat2ili/qgepdss/export.py +++ b/qgepqwat2ili/qgepdss/export.py @@ -2929,10 +2929,11 @@ def textpos_common(row, t_type, geojson_crs_def): abflussbeiwert_rw_ist=row.discharge_coefficient_rw_current, abflussbeiwert_sw_geplant=row.discharge_coefficient_ww_planned, abflussbeiwert_sw_ist=row.discharge_coefficient_ww_current, - abwassernetzelement_rw_geplantref=check_fk_in_subsetid(row.fk_wastewater_networkelement_rw_planned__REL), - abwassernetzelement_rw_istref=check_fk_in_subsetid(row.fk_wastewater_networkelement_rw_current__REL), - abwassernetzelement_sw_geplantref=check_fk_in_subsetid(row.fk_wastewater_networkelement_ww_planned__REL), - abwassernetzelement_sw_istref=check_fk_in_subsetid(row.fk_wastewater_networkelement_ww_current__REL), + # changed call from get_tid to check_fk_in_subsetid so it does not write foreignkeys on elements that do not exist + abwassernetzelement_rw_geplantref=check_fk_in_subsetid(subset_ids, row.fk_wastewater_networkelement_rw_planned__REL), + abwassernetzelement_rw_istref=check_fk_in_subsetid(subset_ids, row.fk_wastewater_networkelement_rw_current__REL), + abwassernetzelement_sw_geplantref=check_fk_in_subsetid(subset_ids, row.fk_wastewater_networkelement_ww_planned__REL), + abwassernetzelement_sw_istref=check_fk_in_subsetid(subset_ids, row.fk_wastewater_networkelement_ww_current__REL), befestigungsgrad_rw_geplant=row.seal_factor_rw_planned, befestigungsgrad_rw_ist=row.seal_factor_rw_current, befestigungsgrad_sw_geplant=row.seal_factor_ww_planned, @@ -2970,7 +2971,10 @@ def textpos_common(row, t_type, geojson_crs_def): logger.info("Exporting QGEP.measuring_point -> ABWASSER.messstelle, ABWASSER.metaattribute") query = qgep_session.query(QGEP.measuring_point) if filtered: - query1=query.join(QGEP.wastewater_structure, QGEP.wastewater_networkelement) + query1 = query.join( + QGEP.wastewater_structure, + QGEP.wastewater_networkelement + ) # needs to add QGEP.wastewater_structure as waste_water_treatment_plant is a subclass of organisation that has a relation to wastewater_structure and then wastewater_networkelement #variant1 for query2 # query2=query.join(QGEP.waste_water_treatment_plant, (QGEP.wastewater_structure, QGEP.waste_water_treatment_plant.obj_id == QGEP.wastewater_structure.fk_owner), (QGEP.wastewater_structure, QGEP.waste_water_treatment_plant.obj_id == QGEP.wastewater_structure.fk_provider),QGEP.wastewater_networkelement, @@ -2984,20 +2988,23 @@ def textpos_common(row, t_type, geojson_crs_def): # QGEP.wastewater_networkelement, # ) - query3=query.join(QGEP.water_course_segment, QGEP.river, QGEP.sector_water_body, QGEP.discharge_point, QGEP.wastewater_networkelement) - # query=union(query1, query2, query3) - query=query.union(query1, query3) - query = query.filter(QGEP.wastewater_networkelement.obj_id.in_(subset_ids) - ) - # QGEP.wastewater_networkelement, - # or does not work with this - currently do not support other connections - # or_( - # (QGEP.waste_water_treatment_plant, QGEP.wastewater_networkelement), - # (QGEP.wastewater_structure, QGEP.wastewater_networkelement), - # currently do not support other connections - # (QGEP.water_course_segment, QGEP.river, QGEP.sector_water_body, QGEP.discharge_point, QGEP.wastewater_networkelement), - # ) - + # query2 via waste_water_treatment_plant + query2 = query.join( + self.model_classes_tww_od.waste_water_treatment_plant, + self.model_classes_tww_od.wwtp_structure, + self.model_classes_tww_od.wastewater_networkelement, + ) + query3 = query.join( + QGEP.water_course_segment, + QGEP.river, + QGEP.sector_water_body, + QGEP.discharge_point, + QGEP.wastewater_networkelement) + query = query.union(query1, query2, query3) + # query = query.union(query1, query3) + query = query.filter( + QGEP.wastewater_networkelement.obj_id.in_(subset_ids) + ) for row in query: # AVAILABLE FIELDS IN QGEP.measuring_point From 7c6d9bbe013012e496fd194e72494c11c84e89b7 Mon Sep 17 00:00:00 2001 From: SJiB Date: Thu, 27 Jun 2024 21:21:34 +0200 Subject: [PATCH 101/111] adapted filter hydraulic_char_data --- qgepqwat2ili/qgepdss/export.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/qgepqwat2ili/qgepdss/export.py b/qgepqwat2ili/qgepdss/export.py index 022394c8..7fa67666 100644 --- a/qgepqwat2ili/qgepdss/export.py +++ b/qgepqwat2ili/qgepdss/export.py @@ -3386,7 +3386,12 @@ def textpos_common(row, t_type, geojson_crs_def): query = qgep_session.query(QGEP.hydraulic_char_data) # side fk_overflow_char not considered in filter query if filtered: - query = query.join(QGEP.wastewater_node).filter( + query = query.join(QGEP.wastewater_node) + or_( + QGEP.wastewater_node.obj_id + == QGEP.hydraulic_char_data.fk_wastewater_node, + ), + .filter( QGEP.wastewater_networkelement.obj_id.in_(subset_ids) ) for row in query: From 789fd9535ca55454ef90c72a4fb2b272c2cb1e94 Mon Sep 17 00:00:00 2001 From: SJiB Date: Fri, 28 Jun 2024 17:11:53 +0200 Subject: [PATCH 102/111] comment query3 - will not be needed in release 2020 anymore --- qgepqwat2ili/qgepdss/export.py | 1 + 1 file changed, 1 insertion(+) diff --git a/qgepqwat2ili/qgepdss/export.py b/qgepqwat2ili/qgepdss/export.py index 7fa67666..76c97f46 100644 --- a/qgepqwat2ili/qgepdss/export.py +++ b/qgepqwat2ili/qgepdss/export.py @@ -2994,6 +2994,7 @@ def textpos_common(row, t_type, geojson_crs_def): self.model_classes_tww_od.wwtp_structure, self.model_classes_tww_od.wastewater_networkelement, ) + # only until VSA-DSS Release 2015 query3 = query.join( QGEP.water_course_segment, QGEP.river, From 1bedd554d54565a5186ad12def77b06ceb62250a Mon Sep 17 00:00:00 2001 From: SJiB Date: Wed, 17 Jul 2024 19:38:32 +0200 Subject: [PATCH 103/111] clean up --- qgepqwat2ili/qgep/export.py | 1 - qgepqwat2ili/qgepsia405/export.py | 1 - 2 files changed, 2 deletions(-) diff --git a/qgepqwat2ili/qgep/export.py b/qgepqwat2ili/qgep/export.py index e7e92262..dcc98481 100644 --- a/qgepqwat2ili/qgep/export.py +++ b/qgepqwat2ili/qgep/export.py @@ -10,7 +10,6 @@ from .model_abwasser import get_abwasser_model from .model_qgep import get_qgep_model -# to do add check_fk_in_subsetid to qgepdss and qgepsia405 def qgep_export(selection=None, labels_file=None, orientation=None): """ diff --git a/qgepqwat2ili/qgepsia405/export.py b/qgepqwat2ili/qgepsia405/export.py index c4abe4ba..3c4a894f 100644 --- a/qgepqwat2ili/qgepsia405/export.py +++ b/qgepqwat2ili/qgepsia405/export.py @@ -11,7 +11,6 @@ from .model_qgep import get_qgep_model -# def qgep_export(selection=None, labels_file=None): def qgep_export(selection=None, labels_file=None, orientation=None): """ Export data from the QGEP model into the ili2pg model. From cd3e1f61f1e9f1c11dd7bcb651dd0053e5aeeded Mon Sep 17 00:00:00 2001 From: SJiB Date: Wed, 17 Jul 2024 19:44:23 +0200 Subject: [PATCH 104/111] correct intends --- qgepqwat2ili/qgep/export.py | 4 +++- qgepqwat2ili/qgepdss/export.py | 12 ++++++------ 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/qgepqwat2ili/qgep/export.py b/qgepqwat2ili/qgep/export.py index dcc98481..ac5da502 100644 --- a/qgepqwat2ili/qgep/export.py +++ b/qgepqwat2ili/qgep/export.py @@ -512,7 +512,9 @@ def textpos_common(row, t_type, geojson_crs_def): QGEP.reach_point.obj_id == QGEP.reach.fk_reach_point_from, QGEP.reach_point.obj_id == QGEP.reach.fk_reach_point_to, ), - ).filter(QGEP.wastewater_networkelement.obj_id.in_(subset_ids)) + ).filter( + QGEP.wastewater_networkelement.obj_id.in_(subset_ids) + ) for row in query: # AVAILABLE FIELDS IN QGEP.reach_point diff --git a/qgepqwat2ili/qgepdss/export.py b/qgepqwat2ili/qgepdss/export.py index 76c97f46..87db0f44 100644 --- a/qgepqwat2ili/qgepdss/export.py +++ b/qgepqwat2ili/qgepdss/export.py @@ -3387,12 +3387,12 @@ def textpos_common(row, t_type, geojson_crs_def): query = qgep_session.query(QGEP.hydraulic_char_data) # side fk_overflow_char not considered in filter query if filtered: - query = query.join(QGEP.wastewater_node) - or_( - QGEP.wastewater_node.obj_id - == QGEP.hydraulic_char_data.fk_wastewater_node, - ), - .filter( + query = query.join( + QGEP.wastewater_node) + or_( + QGEP.wastewater_node.obj_id == QGEP.hydraulic_char_data.fk_wastewater_node, + ), + .filter( QGEP.wastewater_networkelement.obj_id.in_(subset_ids) ) for row in query: From 17e893f78d3835c79b9181c59eeed3a335c88f87 Mon Sep 17 00:00:00 2001 From: SJiB Date: Wed, 17 Jul 2024 19:49:54 +0200 Subject: [PATCH 105/111] correct , and ) --- qgepqwat2ili/qgepdss/export.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/qgepqwat2ili/qgepdss/export.py b/qgepqwat2ili/qgepdss/export.py index 87db0f44..c3dd5294 100644 --- a/qgepqwat2ili/qgepdss/export.py +++ b/qgepqwat2ili/qgepdss/export.py @@ -3388,11 +3388,11 @@ def textpos_common(row, t_type, geojson_crs_def): # side fk_overflow_char not considered in filter query if filtered: query = query.join( - QGEP.wastewater_node) + QGEP.wastewater_node, or_( QGEP.wastewater_node.obj_id == QGEP.hydraulic_char_data.fk_wastewater_node, ), - .filter( + ).filter( QGEP.wastewater_networkelement.obj_id.in_(subset_ids) ) for row in query: From 7580bdc87cc631f47a527a9954c402d1f589cba6 Mon Sep 17 00:00:00 2001 From: SJiB Date: Wed, 17 Jul 2024 20:01:32 +0200 Subject: [PATCH 106/111] add filter hq_relation --- qgepqwat2ili/qgepdss/export.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/qgepqwat2ili/qgepdss/export.py b/qgepqwat2ili/qgepdss/export.py index c3dd5294..3288a3cd 100644 --- a/qgepqwat2ili/qgepdss/export.py +++ b/qgepqwat2ili/qgepdss/export.py @@ -2297,6 +2297,14 @@ def textpos_common(row, t_type, geojson_crs_def): logger.info("Exporting QGEP.hq_relation -> ABWASSER.hq_relation, ABWASSER.metaattribute") query = qgep_session.query(QGEP.hq_relation) + if filtered: + # just check if overflow_char exists, but no filter + query = query.join( + QGEP.overflow_char, + ) + # add sql statement to logger + statement = query.statement + logger.info(f" selection query = {statement}") for row in query: # AVAILABLE FIELDS IN QGEP.hq_relation From d5342ced320a72ff3e031a9e77daf60df7a069bf Mon Sep 17 00:00:00 2001 From: SJiB Date: Wed, 17 Jul 2024 20:04:05 +0200 Subject: [PATCH 107/111] filter overlow_char --- qgepqwat2ili/qgepdss/export.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/qgepqwat2ili/qgepdss/export.py b/qgepqwat2ili/qgepdss/export.py index 3288a3cd..d9309469 100644 --- a/qgepqwat2ili/qgepdss/export.py +++ b/qgepqwat2ili/qgepdss/export.py @@ -2265,6 +2265,11 @@ def textpos_common(row, t_type, geojson_crs_def): logger.info("Exporting QGEP.overflow_char -> ABWASSER.ueberlaufcharakteristik, ABWASSER.metaattribute") query = qgep_session.query(QGEP.overflow_char) + # always export all overflow_char datasets + if filtered: + # add sql statement to logger + statement = query.statement + logger.info(f" always export all overflow_char datasets query = {statement}") for row in query: # AVAILABLE FIELDS IN QGEP.overflow_char From 831e9166446d9f38ebf425749920ae17a7b29a52 Mon Sep 17 00:00:00 2001 From: SJiB Date: Wed, 17 Jul 2024 20:07:30 +0200 Subject: [PATCH 108/111] checked filter hydraulic_char_data --- qgepqwat2ili/qgepdss/export.py | 1 + 1 file changed, 1 insertion(+) diff --git a/qgepqwat2ili/qgepdss/export.py b/qgepqwat2ili/qgepdss/export.py index d9309469..76d5f565 100644 --- a/qgepqwat2ili/qgepdss/export.py +++ b/qgepqwat2ili/qgepdss/export.py @@ -3404,6 +3404,7 @@ def textpos_common(row, t_type, geojson_crs_def): QGEP.wastewater_node, or_( QGEP.wastewater_node.obj_id == QGEP.hydraulic_char_data.fk_wastewater_node, + # fk_primary_direction only added with VSA-DSS 2020 ), ).filter( QGEP.wastewater_networkelement.obj_id.in_(subset_ids) From c9a9410dd1f713d436ca171857af396554b93537 Mon Sep 17 00:00:00 2001 From: SJiB Date: Wed, 17 Jul 2024 20:54:04 +0200 Subject: [PATCH 109/111] filter mutation --- qgepqwat2ili/qgepdss/export.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/qgepqwat2ili/qgepdss/export.py b/qgepqwat2ili/qgepdss/export.py index 76d5f565..234a7cb3 100644 --- a/qgepqwat2ili/qgepdss/export.py +++ b/qgepqwat2ili/qgepdss/export.py @@ -366,6 +366,9 @@ def textpos_common(row, t_type, geojson_crs_def): logger.info("Exporting QGEP.mutation -> ABWASSER.mutation, ABWASSER.metaattribute") query = qgep_session.query(QGEP.mutation) + # only export explicitly specified mutation objects if filtered + if filtered: + query = query.filter(QGEP.mutation.obj_id.in_(subset_ids)) for row in query: # AVAILABLE FIELDS IN QGEP.mutation From a33819a977dc96059a3a53880d8cc7618a263b18 Mon Sep 17 00:00:00 2001 From: SJiB Date: Wed, 17 Jul 2024 20:56:22 +0200 Subject: [PATCH 110/111] always export all aquifier --- qgepqwat2ili/qgepdss/export.py | 1 + 1 file changed, 1 insertion(+) diff --git a/qgepqwat2ili/qgepdss/export.py b/qgepqwat2ili/qgepdss/export.py index 234a7cb3..fdf315bd 100644 --- a/qgepqwat2ili/qgepdss/export.py +++ b/qgepqwat2ili/qgepdss/export.py @@ -409,6 +409,7 @@ def textpos_common(row, t_type, geojson_crs_def): logger.info("Exporting QGEP.aquifier -> ABWASSER.grundwasserleiter, ABWASSER.metaattribute") query = qgep_session.query(QGEP.aquifier) + # always export all aquifier for row in query: # AVAILABLE FIELDS IN QGEP.aquifier From 5d99389cbbbebd32da3d8ec9b58e2eafe52e8655 Mon Sep 17 00:00:00 2001 From: SJiB Date: Wed, 17 Jul 2024 22:30:56 +0200 Subject: [PATCH 111/111] adding comment if no filter is set --- qgepqwat2ili/qgepdss/export.py | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/qgepqwat2ili/qgepdss/export.py b/qgepqwat2ili/qgepdss/export.py index fdf315bd..b26be76f 100644 --- a/qgepqwat2ili/qgepdss/export.py +++ b/qgepqwat2ili/qgepdss/export.py @@ -444,6 +444,7 @@ def textpos_common(row, t_type, geojson_crs_def): logger.info("Exporting QGEP.river -> ABWASSER.fliessgewaesser, ABWASSER.metaattribute") query = qgep_session.query(QGEP.river) + # always export all river for row in query: # AVAILABLE FIELDS IN QGEP.river @@ -479,6 +480,7 @@ def textpos_common(row, t_type, geojson_crs_def): logger.info("Exporting QGEP.lake -> ABWASSER.see, ABWASSER.metaattribute") query = qgep_session.query(QGEP.lake) + # always export all lake for row in query: # AVAILABLE FIELDS IN QGEP.lake @@ -514,6 +516,7 @@ def textpos_common(row, t_type, geojson_crs_def): logger.info("Exporting QGEP.water_course_segment -> ABWASSER.gewaesserabschnitt, ABWASSER.metaattribute") query = qgep_session.query(QGEP.water_course_segment) + # always export all water_course_segment for row in query: # AVAILABLE FIELDS IN QGEP.water_course_segment @@ -563,6 +566,7 @@ def textpos_common(row, t_type, geojson_crs_def): logger.info("Exporting QGEP.water_catchment -> ABWASSER.wasserfassung, ABWASSER.metaattribute") query = qgep_session.query(QGEP.water_catchment) + # always export all water_catchment for row in query: # AVAILABLE FIELDS IN QGEP.water_catchment @@ -596,6 +600,7 @@ def textpos_common(row, t_type, geojson_crs_def): abwasser_session.flush() logger.info("Exporting QGEP.river_bank -> ABWASSER.ufer, ABWASSER.metaattribute") + # always export all river_bank query = qgep_session.query(QGEP.river_bank) for row in query: @@ -635,6 +640,7 @@ def textpos_common(row, t_type, geojson_crs_def): logger.info("Exporting QGEP.river_bed -> ABWASSER.gewaessersohle, ABWASSER.metaattribute") query = qgep_session.query(QGEP.river_bed) + # always export all river_bed for row in query: # AVAILABLE FIELDS IN QGEP.river_bed @@ -670,6 +676,7 @@ def textpos_common(row, t_type, geojson_crs_def): logger.info("Exporting QGEP.sector_water_body -> ABWASSER.gewaessersektor, ABWASSER.metaattribute") query = qgep_session.query(QGEP.sector_water_body) + # always export all sector_water_body for row in query: # AVAILABLE FIELDS IN QGEP.sector_water_body @@ -709,6 +716,7 @@ def textpos_common(row, t_type, geojson_crs_def): logger.info("Exporting QGEP.administrative_office -> ABWASSER.amt, ABWASSER.metaattribute") query = qgep_session.query(QGEP.administrative_office) + # always export all administrative_office for row in query: # AVAILABLE FIELDS IN QGEP.administrative_office @@ -743,6 +751,7 @@ def textpos_common(row, t_type, geojson_crs_def): logger.info("Exporting QGEP.cooperative -> ABWASSER.genossenschaft_korporation, ABWASSER.metaattribute") query = qgep_session.query(QGEP.cooperative) + # always export all cooperative for row in query: # AVAILABLE FIELDS IN QGEP.cooperative @@ -777,6 +786,7 @@ def textpos_common(row, t_type, geojson_crs_def): logger.info("Exporting QGEP.canton -> ABWASSER.kanton, ABWASSER.metaattribute") query = qgep_session.query(QGEP.canton) + # always export all canton for row in query: # AVAILABLE FIELDS IN QGEP.canton @@ -812,6 +822,7 @@ def textpos_common(row, t_type, geojson_crs_def): logger.info("Exporting QGEP.waste_water_association -> ABWASSER.abwasserverband, ABWASSER.metaattribute") query = qgep_session.query(QGEP.waste_water_association) + # always export all waste_water_association for row in query: # AVAILABLE FIELDS IN QGEP.waste_water_association @@ -846,6 +857,7 @@ def textpos_common(row, t_type, geojson_crs_def): logger.info("Exporting QGEP.municipality -> ABWASSER.gemeinde, ABWASSER.metaattribute") query = qgep_session.query(QGEP.municipality) + # always export all municipality for row in query: # AVAILABLE FIELDS IN QGEP.municipality @@ -886,6 +898,7 @@ def textpos_common(row, t_type, geojson_crs_def): logger.info("Exporting QGEP.waste_water_treatment_plant -> ABWASSER.abwasserreinigungsanlage, ABWASSER.metaattribute") query = qgep_session.query(QGEP.waste_water_treatment_plant) + # always export all waste_water_treatment_plant for row in query: # AVAILABLE FIELDS IN QGEP.waste_water_treatment_plant