From 7899dad7e8b09384c270315fe36e82a8891d35c3 Mon Sep 17 00:00:00 2001 From: Samweli Date: Tue, 7 Nov 2023 10:54:08 +0300 Subject: [PATCH 1/2] fix issue in styling weighted models --- src/cplus_plugin/gui/qgis_cplus_main.py | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/src/cplus_plugin/gui/qgis_cplus_main.py b/src/cplus_plugin/gui/qgis_cplus_main.py index 1c45c0cdd..ecbada083 100644 --- a/src/cplus_plugin/gui/qgis_cplus_main.py +++ b/src/cplus_plugin/gui/qgis_cplus_main.py @@ -92,8 +92,6 @@ SCENARIO_OUTPUT_FILE_NAME, SCENARIO_OUTPUT_LAYER_NAME, USER_DOCUMENTATION_SITE, - PILOT_AREA_SCENARIO_SYMBOLOGY, - IM_COLOUR_RAMPS, ) from ..definitions.constants import ( IM_GROUP_LAYER_NAME, @@ -233,6 +231,7 @@ def prepare_input(self): self.analysis_scenario_description = None self.analysis_extent = None self.analysis_implementation_models = None + self.analysis_weighted_ims = [] self.analysis_priority_layers_groups = [] def priority_groups_update(self, target_item, selected_items): @@ -2111,6 +2110,8 @@ def priority_layers_analysis_done( if output is not None and output.get("OUTPUT") is not None: model.path = output.get("OUTPUT") + self.analysis_weighted_ims.append(model) + if model_index == len(models) - 1: self.run_highest_position_analysis() @@ -2299,7 +2300,9 @@ def post_analysis(self, scenario_result): im_index = im_index + 1 - for weighted_im in list_weighted_ims: + for model in self.analysis_weighted_ims: + weighted_im = model.path + if not weighted_im.endswith(".tif"): continue @@ -2309,11 +2312,7 @@ def post_analysis(self, scenario_result): im_weighted_dir + weighted_im, weighted_im_name, QGIS_GDAL_PROVIDER ) - weighted_im_model = settings_manager.find_implementation_model_by_name( - weighted_im - ) - - renderer = self.style_model_layer(im_weighted_layer, weighted_im_model) + renderer = self.style_model_layer(im_weighted_layer, model) im_weighted_layer.setRenderer(renderer) im_weighted_layer.triggerRepaint() From c66fc418c70984d418510b3f95aa244369682811 Mon Sep 17 00:00:00 2001 From: Samweli Date: Tue, 7 Nov 2023 13:10:08 +0300 Subject: [PATCH 2/2] use analysis weighted ims in styles --- src/cplus_plugin/gui/qgis_cplus_main.py | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/src/cplus_plugin/gui/qgis_cplus_main.py b/src/cplus_plugin/gui/qgis_cplus_main.py index ecbada083..af3fb394f 100644 --- a/src/cplus_plugin/gui/qgis_cplus_main.py +++ b/src/cplus_plugin/gui/qgis_cplus_main.py @@ -2301,15 +2301,14 @@ def post_analysis(self, scenario_result): im_index = im_index + 1 for model in self.analysis_weighted_ims: - weighted_im = model.path + weighted_im_path = model.path + weighted_im_name = model.name - if not weighted_im.endswith(".tif"): + if not weighted_im_path.endswith(".tif"): continue - weighted_im_name = weighted_im[: len(weighted_im) - 9] - im_weighted_layer = QgsRasterLayer( - im_weighted_dir + weighted_im, weighted_im_name, QGIS_GDAL_PROVIDER + weighted_im_path, weighted_im_name, QGIS_GDAL_PROVIDER ) renderer = self.style_model_layer(im_weighted_layer, model)