From 0db0b6616eef310d337119baf2b05478d3010dd6 Mon Sep 17 00:00:00 2001 From: edgarfuste <34737125+edgarfuste@users.noreply.github.com> Date: Thu, 26 Sep 2024 16:44:55 +0200 Subject: [PATCH 01/10] fix(tool): send parameters on featuretype_change_button --- core/toolbars/edit/featuretype_change_button.py | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/core/toolbars/edit/featuretype_change_button.py b/core/toolbars/edit/featuretype_change_button.py index 61ca00492..449c1940d 100644 --- a/core/toolbars/edit/featuretype_change_button.py +++ b/core/toolbars/edit/featuretype_change_button.py @@ -304,6 +304,11 @@ def btn_accept_featuretype_change(**kwargs): feature_type_new = tools_qt.get_widget_value(dialog, "tab_none_feature_type_new") featurecat_id = tools_qt.get_widget_value(dialog, "tab_none_featurecat_id") + fluid_type = tools_qt.get_widget_value(dialog, "tab_none_fluid_type") + localtion_type = tools_qt.get_widget_value(dialog, "tab_none_location_type") + category_type = tools_qt.get_widget_value(dialog, "tab_none_category_type") + function_type = tools_qt.get_widget_value(dialog, "tab_none_function_type") + if feature_type_new != "null": if (featurecat_id != "null" and featurecat_id is not None and project_type == 'ws') or ( @@ -314,6 +319,11 @@ def btn_accept_featuretype_change(**kwargs): extras = f'"feature_id":"{this.feature_id}"' extras += f', "feature_type_new":"{feature_type_new}"' extras += f', "featurecat_id":"{featurecat_id}"' + extras += f', "fluid_type":"{fluid_type}"' + extras += f', "localtion_type":"{localtion_type}"' + extras += f', "category_type":"{category_type}"' + extras += f', "function_type":"{function_type}"' + body = tools_gw.create_body(feature=feature, extras=extras) # Execute SQL function and show result to the user From ba0de4b85d641fd44d3ca154b24feb0c08571fa9 Mon Sep 17 00:00:00 2001 From: edgarfuste <34737125+edgarfuste@users.noreply.github.com> Date: Thu, 26 Sep 2024 18:19:05 +0200 Subject: [PATCH 02/10] fix(feature): improve last commit --- core/toolbars/edit/featuretype_change_button.py | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/core/toolbars/edit/featuretype_change_button.py b/core/toolbars/edit/featuretype_change_button.py index 449c1940d..ee635f1cb 100644 --- a/core/toolbars/edit/featuretype_change_button.py +++ b/core/toolbars/edit/featuretype_change_button.py @@ -305,9 +305,17 @@ def btn_accept_featuretype_change(**kwargs): featurecat_id = tools_qt.get_widget_value(dialog, "tab_none_featurecat_id") fluid_type = tools_qt.get_widget_value(dialog, "tab_none_fluid_type") - localtion_type = tools_qt.get_widget_value(dialog, "tab_none_location_type") + if fluid_type is None: + fluid_type = 'null' + location_type = tools_qt.get_widget_value(dialog, "tab_none_location_type") + if location_type is None: + location_type = 'null' category_type = tools_qt.get_widget_value(dialog, "tab_none_category_type") + if category_type is None: + category_type = 'null' function_type = tools_qt.get_widget_value(dialog, "tab_none_function_type") + if function_type is None: + function_type = 'null' if feature_type_new != "null": @@ -320,7 +328,7 @@ def btn_accept_featuretype_change(**kwargs): extras += f', "feature_type_new":"{feature_type_new}"' extras += f', "featurecat_id":"{featurecat_id}"' extras += f', "fluid_type":"{fluid_type}"' - extras += f', "localtion_type":"{localtion_type}"' + extras += f', "location_type":"{location_type}"' extras += f', "category_type":"{category_type}"' extras += f', "function_type":"{function_type}"' From a09a6797e166d68f766645680fd1f2ed85304681 Mon Sep 17 00:00:00 2001 From: edgarfuste <34737125+edgarfuste@users.noreply.github.com> Date: Fri, 27 Sep 2024 10:51:12 +0200 Subject: [PATCH 03/10] fix(column reference): remove manage style from btn_add_layer on managers --- core/toolbars/epa/dscenario_manager_btn.py | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/core/toolbars/epa/dscenario_manager_btn.py b/core/toolbars/epa/dscenario_manager_btn.py index 22af9b80c..94cbb47a6 100644 --- a/core/toolbars/epa/dscenario_manager_btn.py +++ b/core/toolbars/epa/dscenario_manager_btn.py @@ -925,7 +925,7 @@ def _manage_add_layers(self, table_name, sub_group): # Get layers to add lyr_filter = f"{table_name}%" - sql = f"SELECT id, alias, style_id, addparam FROM sys_table WHERE id LIKE '{lyr_filter}' AND alias IS NOT NULL ORDER BY alias ASC" + sql = f"SELECT id, alias, addparam FROM sys_table WHERE id LIKE '{lyr_filter}' AND alias IS NOT NULL ORDER BY alias ASC" rows = tools_db.get_rows(sql) if rows: @@ -939,13 +939,10 @@ def _manage_add_layers(self, table_name, sub_group): main_menu.addAction(widgetAction) # LAYERS - for tablename, alias, style_id, addparam in rows: + for tablename, alias, addparam in rows: # Manage alias if not alias: alias = tablename.replace('v_edit_inp_dscenario_', '').replace('_', ' ').capitalize() - # Manage style_id - if not style_id: - style_id = "-1" # Manage pkey pk = "id" if addparam: @@ -968,7 +965,7 @@ def _manage_add_layers(self, table_name, sub_group): widget.setStyleSheet("margin: 5px 5px 5px 8px;") widgetAction.defaultWidget().stateChanged.connect( - partial(self._check_action_ischecked, tablename, the_geom, pk, style_id, alias.strip(), sub_group)) + partial(self._check_action_ischecked, tablename, the_geom, pk, -1, alias.strip(), sub_group)) main_menu.exec_(click_point) From dd36fb69d553033f37632382d07b76cbad779c76 Mon Sep 17 00:00:00 2001 From: edgarfuste <34737125+edgarfuste@users.noreply.github.com> Date: Fri, 27 Sep 2024 10:55:45 +0200 Subject: [PATCH 04/10] fix(column reference): remove manage style from btn_add_layer on netscenario_manager_btn --- core/toolbars/plan/netscenario_manager_btn.py | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/core/toolbars/plan/netscenario_manager_btn.py b/core/toolbars/plan/netscenario_manager_btn.py index d694d4d2a..ea060b7f2 100644 --- a/core/toolbars/plan/netscenario_manager_btn.py +++ b/core/toolbars/plan/netscenario_manager_btn.py @@ -735,7 +735,7 @@ def _manage_add_layers(self): # Get layers to add lyr_filter = "%plan_netscenario_%" - sql = f"SELECT id, alias, style_id, addparam FROM sys_table WHERE id LIKE '{lyr_filter}' AND alias IS NOT NULL" + sql = f"SELECT id, alias, addparam FROM sys_table WHERE id LIKE '{lyr_filter}' AND alias IS NOT NULL" rows = tools_db.get_rows(sql) if rows: # LOAD ALL @@ -748,13 +748,10 @@ def _manage_add_layers(self): main_menu.addAction(widgetAction) # LAYERS - for tablename, alias, style_id, addparam in rows: + for tablename, alias, addparam in rows: # Manage alias if not alias: alias = tablename.replace('plan_netscenario_', '').replace('_', ' ').capitalize() - # Manage style_id - if not style_id: - style_id = "-1" # Manage pkey pk = "id" if addparam: @@ -777,7 +774,7 @@ def _manage_add_layers(self): widget.setStyleSheet("margin: 5px 5px 5px 8px;") widgetAction.defaultWidget().stateChanged.connect( - partial(self._check_action_ischecked, tablename, the_geom, pk, style_id, alias.strip())) + partial(self._check_action_ischecked, tablename, the_geom, pk, -1, alias.strip())) main_menu.exec_(click_point) From 1cf4c8c0f40c7a7c54740406bc382982eb34f705 Mon Sep 17 00:00:00 2001 From: edgarfuste <34737125+edgarfuste@users.noreply.github.com> Date: Thu, 3 Oct 2024 13:58:15 +0200 Subject: [PATCH 05/10] Update metadata version --- metadata.txt | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/metadata.txt b/metadata.txt index 426094fe8..f6b14d0cf 100644 --- a/metadata.txt +++ b/metadata.txt @@ -4,15 +4,10 @@ qgisMinimumVersion=3.22 qgisMaximumVersion=3.38 description=Plugin to manage water networks (water supply, sewerage and urban drainage) using QGIS and PostGIS-PostgreSQL about=Disclaimer: This plugin is released using the open source GNU-GPL3 license. Although a reasonable effort has been made to assure that the results obtained are correct, some of the capabilities provided by Giswater are experimental, therefore the development team and the Giswater Association are not responsible and assume no liability whatsoever for any results or any use made of the results obtained from the program, nor for any damages or litigation that result from the use of these programs for any purpose. -version=3.6.013 +version=3.6.014 author=David Erill, Barbara Rzepka, Sergi Muñoz, Josep Lluís Sala, Edgar Fusté, Albert Bofill, Sergi Maspons, Elies Bertran, Abel García Juanes, Maria Guzmán, Jordi Blanch, Xavier Torret, Daniel Marín, Ferran Martínez -Changelog=Version 3.6.013 - - Configure 'Change feature type' form in config_form_fields and add 4 new widgets: Fluid, Location, Category & Function. - - Fix valves symbology. - - Add 'ignore' to mapzone config. - - Remove toolbars_shortcuts from user config files (it wasn't used). - - Add project variable 'gwCurrentStyle' +Changelog=Version 3.6.014 tags= giswater, water networks, sewerage, urban drainage, EPANET, SWMM From 73e044072fbf7f57af3b25bc5454e35f64043de2 Mon Sep 17 00:00:00 2001 From: smaspons Date: Thu, 3 Oct 2024 14:21:05 +0200 Subject: [PATCH 06/10] fix(workcat): zoom to result & draw polygon --- core/shared/workcat.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/core/shared/workcat.py b/core/shared/workcat.py index 3248f9c9f..dda65c1a9 100644 --- a/core/shared/workcat.py +++ b/core/shared/workcat.py @@ -183,6 +183,18 @@ def workcat_open_table_items(self, item): if workcat_id is None: return False + if 'sys_geometry' in item: + # Zoom to result + list_coord = re.search('\(\((.*)\)\)', str(item['sys_geometry'])) + if not list_coord: + msg = "Empty coordinate list" + tools_qgis.show_warning(msg) + return + points = tools_qgis.get_geometry_vertex(list_coord) + tools_qgis.draw_polygon(points, self.rubber_band) + max_x, max_y, min_x, min_y = tools_qgis.get_max_rectangle_from_coords(list_coord) + tools_qgis.zoom_to_rectangle(max_x, max_y, min_x, min_y) + self._update_selector_workcat(workcat_id) current_selectors = self._get_current_selectors() self._force_expl(workcat_id) From d199576b565016ffed32d2ded84f34587efa6c13 Mon Sep 17 00:00:00 2001 From: smaspons Date: Thu, 3 Oct 2024 14:35:04 +0200 Subject: [PATCH 07/10] fix(workcat): also zoom to result & draw polygon from workcat manager --- core/shared/workcat.py | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/core/shared/workcat.py b/core/shared/workcat.py index dda65c1a9..970ccd6d7 100644 --- a/core/shared/workcat.py +++ b/core/shared/workcat.py @@ -182,6 +182,37 @@ def workcat_open_table_items(self, item): display_name = item['display_name'] if workcat_id is None: return False + if 'sys_geometry' not in item: + sql = f""" + SELECT row_to_json(row) FROM (SELECT + CASE + WHEN st_geometrytype(st_concavehull(d.the_geom, 0.99::double precision)) = 'ST_Polygon'::text THEN st_astext(st_buffer(st_concavehull(d.the_geom, 0.99::double precision), 10::double precision)::geometry(Polygon, {lib_vars.project_epsg})) + ELSE st_astext(st_expand(st_buffer(d.the_geom, 10::double precision), 1::double precision)::geometry(Polygon, {lib_vars.project_epsg})) + END AS st_astext + + FROM (SELECT st_collect(a.the_geom) AS the_geom, a.workcat_id FROM ( SELECT node.workcat_id, node.the_geom FROM node WHERE node.state = 1 + UNION + SELECT arc.workcat_id, arc.the_geom FROM arc WHERE arc.state = 1 + UNION + SELECT connec.workcat_id, connec.the_geom FROM connec WHERE connec.state = 1 + UNION + SELECT element.workcat_id, element.the_geom FROM element WHERE element.state = 1 + UNION + SELECT node.workcat_id_end AS workcat_id,node.the_geom FROM node WHERE node.state = 0 + UNION + SELECT arc.workcat_id_end AS workcat_id, arc.the_geom FROM arc WHERE arc.state = 0 + UNION + SELECT connec.workcat_id_end AS workcat_id,connec.the_geom FROM connec WHERE connec.state = 0 + UNION + SELECT element.workcat_id_end AS workcat_id, element.the_geom FROM element WHERE element.state = 0) a GROUP BY a.workcat_id ) d + + JOIN cat_work AS b ON d.workcat_id = b.id WHERE d.workcat_id::text = '{workcat_id}' LIMIT 1 )row + """ + row = tools_db.get_row(sql) + try: + item['sys_geometry'] = row[0]['st_astext'] + except Exception: + pass if 'sys_geometry' in item: # Zoom to result From c3d1756794e0aee72cb63f2f8f6b45c13b700367 Mon Sep 17 00:00:00 2001 From: smaspons Date: Fri, 4 Oct 2024 09:47:34 +0200 Subject: [PATCH 08/10] fix(info): generic info -- don't crash if layer is not found (cherry picked from commit feafcf52ff921907c7df4b8be4eaee785eba7046) --- core/shared/info.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/core/shared/info.py b/core/shared/info.py index 407c5d662..dfd8b33ef 100644 --- a/core/shared/info.py +++ b/core/shared/info.py @@ -435,7 +435,8 @@ def _open_generic_form(self, complet_result): finally: action_edit.setEnabled(is_enabled) action_edit.triggered.connect(partial(self._manage_edition, self.dlg_generic, action_edit, fid, new_feature, generic=True)) - action_edit.setChecked(layer.isEditable() and can_edit) + if layer: + action_edit.setChecked(layer.isEditable() and can_edit) # Signals self.dlg_generic.btn_accept.clicked.connect(partial( From 13e90c7815bfe28eba7ac2ce95b53dfc157ac8ee Mon Sep 17 00:00:00 2001 From: smaspons Date: Mon, 7 Oct 2024 09:55:03 +0200 Subject: [PATCH 09/10] fix(nonvisual): missing class_obj parameter for GwNonVisualPrint dialog (cherry picked from commit 39b2a9911f3f7f11e35e7f34adf37b76830cc2b8) --- core/shared/nonvisual.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/shared/nonvisual.py b/core/shared/nonvisual.py index a009ebee2..f8ca1b0c9 100644 --- a/core/shared/nonvisual.py +++ b/core/shared/nonvisual.py @@ -371,7 +371,7 @@ def _delete_object(self, dialog): def _print_object(self): # Get dialog - self.dlg_print = GwNonVisualPrint() + self.dlg_print = GwNonVisualPrint(self) tools_gw.load_settings(self.dlg_print) # Set values From 92a9e0f24939b27f8ee9d1ef35cd778021f59608 Mon Sep 17 00:00:00 2001 From: smaspons Date: Mon, 7 Oct 2024 13:09:04 +0200 Subject: [PATCH 10/10] fix(toolbox): disable run button if no layers found (cherry picked from commit e908178341b4f1ec39949f94d5234074dfcf66cc) --- core/toolbars/utilities/toolbox_btn.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/core/toolbars/utilities/toolbox_btn.py b/core/toolbars/utilities/toolbox_btn.py index d7acde21b..a40732105 100644 --- a/core/toolbars/utilities/toolbox_btn.py +++ b/core/toolbars/utilities/toolbox_btn.py @@ -721,9 +721,11 @@ def _populate_layer_combo(self, feature_types): elem.append(layer_name) elem.append(feature_type) layers.append(elem) + tools_qt.set_widget_enabled(self.dlg_functions, 'btn_run', True) if not layers: elem = [f"There is no layer related to {feature_type}.", None, None] layers.append(elem) + tools_qt.set_widget_enabled(self.dlg_functions, 'btn_run', False) tools_qt.fill_combo_values(self.dlg_functions.cmb_layers, layers, sort_combo=False, index_to_show=0)