Skip to content

Commit

Permalink
FCV Threshold should have its default applied as per the spreadsheet
Browse files Browse the repository at this point in the history
Fixes #666
Fixes #676
  • Loading branch information
timlinux committed Dec 4, 2024
1 parent 501cf37 commit 347ca8c
Show file tree
Hide file tree
Showing 12 changed files with 116 additions and 115 deletions.
21 changes: 12 additions & 9 deletions geest/core/generate_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,10 @@ def load_spreadsheet(self):
"Indicator",
"Default Indicator Factor Weighting",
"ID",
"Naming convention for outputs",
"Factor Description",
"Default Index Score",
"Index Score",
"Use Default Index Score",
"Use Index Score",
"Default Multi Buffer Distances",
"Use Multi Buffer Point",
"Default Single Buffer Distance",
Expand Down Expand Up @@ -141,21 +141,24 @@ def parse_to_json(self):
# These are all parsed from the spreadsheet
"indicator": row["Indicator"] if not pd.isna(row["Indicator"]) else "",
"id": row["ID"] if not pd.isna(row["ID"]) else "",
"output_filename": (
row["Naming convention for outputs"]
if not pd.isna(row["Naming convention for outputs"])
else ""
),
"description": "",
"default_factor_weighting": default_factor_weighting,
# Initialise the weighting to the default value
"factor_weighting": default_factor_weighting,
"default_index_score": (
row["Default Index Score"]
if not pd.isna(row["Default Index Score"])
else ""
"index_score": (
row["Index Score"] if not pd.isna(row["Index Score"]) else ""
),
"index_score": (
row["Index Score"] if not pd.isna(row["Index Score"]) else ""
),
"use_default_index_score": (
row["Use Default Index Score"]
if not pd.isna(row["Use Default Index Score"])
"use_index_score": (
row["Use Index Score"]
if not pd.isna(row["Use Index Score"])
else ""
),
"default_multi_buffer_distances": (
Expand Down
6 changes: 3 additions & 3 deletions geest/core/json_tree_item.py
Original file line number Diff line number Diff line change
Expand Up @@ -347,21 +347,21 @@ def getStatus(self):
# Test for algs requiring vector inputs
self.isIndicator()
and analysis_mode
not in ["use_default_index_score", "use_environmental_hazards"]
not in ["use_index_score", "use_environmental_hazards"]
and not data.get(qgis_layer_source_key, False)
and not data.get(qgis_layer_shapefile_key, False)
):
return "Not configured (optional)"
if (
# Test for algs requiring raster inputs
self.isIndicator()
and analysis_mode not in ["use_default_index_score"]
and analysis_mode not in ["use_index_score"]
and analysis_mode in ["use_environmental_hazards"]
and not data.get(qgis_layer_source_key, False)
and not data.get(qgis_layer_raster_key, False)
):
# log_message(f"Indicator {data.get('id')} is missing a raster input")
# log_message(f"analysis_mode in use_default_index_score, use_environmental_hazards: {analysis_mode in ['use_default_index_score', 'use_environmental_hazards']}")
# log_message(f"analysis_mode in use_index_score, use_environmental_hazards: {analysis_mode in ['use_index_score', 'use_environmental_hazards']}")
# log_message(f"qgis_layer_source_key: {qgis_layer_source_key}: {data.get(qgis_layer_source_key, False)}")
# log_message(f"qgis_layer_raster_key: {qgis_layer_raster_key}: {data.get(qgis_layer_raster_key, False)}")
return "Not configured (optional)"
Expand Down
2 changes: 1 addition & 1 deletion geest/core/workflow_factory.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ def create_workflow(

analysis_mode = attributes.get("analysis_mode", "")

if analysis_mode == "use_default_index_score":
if analysis_mode == "use_index_score":
return DefaultIndexScoreWorkflow(item, cell_size_m, feedback, context)
elif analysis_mode == "Do Not Use":
return DontUseWorkflow(item, cell_size_m, feedback, context)
Expand Down
2 changes: 1 addition & 1 deletion geest/core/workflows/__init__.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from .dont_use_workflow import DontUseWorkflow
from .default_index_score_workflow import DefaultIndexScoreWorkflow
from .index_score_workflow import DefaultIndexScoreWorkflow
from .factor_aggregation_workflow import FactorAggregationWorkflow
from .dimension_aggregation_workflow import DimensionAggregationWorkflow
from .analysis_aggregation_workflow import AnalysisAggregationWorkflow
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

class DefaultIndexScoreWorkflow(WorkflowBase):
"""
Concrete implementation of a 'use_default_index_score' workflow.
Concrete implementation of a 'use_index_score' workflow.
"""

def __init__(
Expand All @@ -39,11 +39,9 @@ def __init__(
super().__init__(
item, cell_size_m, feedback, context
) # ⭐️ Item is a reference - whatever you change in this item will directly update the tree
self.index_score = float(
(self.attributes.get("default_index_score", 0) / 100) * 5
)
self.index_score = float((self.attributes.get("index_score", 0) / 100) * 5)
self.features_layer = True # Normally we would set this to a QgsVectorLayer but in this workflow it is not needed
self.workflow_name = "default_index_score"
self.workflow_name = "index_score"

def _process_features_for_area(
self,
Expand Down
2 changes: 1 addition & 1 deletion geest/gui/configuration_widget_factory.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ def create_widget(
return DontUseConfigurationWidget(
analysis_mode="Do Not Use", attributes=attributes
)
if key == "use_default_index_score" and value == 1:
if key == "use_index_score" and value == 1:
return IndexScoreConfigurationWidget(
analysis_mode=key, attributes=attributes
)
Expand Down
2 changes: 1 addition & 1 deletion geest/gui/datasource_widget_factory.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ def create_widget(
cleaned_key = widget_key[4:]
if widget_key == "indicator_required" and value == 0:
return None
if widget_key == "use_default_index_score" and value == 1:
if widget_key == "use_index_score" and value == 1:
return FixedValueDataSourceWidget(
widget_key=widget_key, attributes=attributes
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ def _add_raster_layer_widgets(self) -> None:
self.spin_box = QDoubleSpinBox()
self.spin_box.setRange(0, 100)
self.spin_box.setSingleStep(1)
self.spin_box.setValue(self.attributes.get(f"default_index_score", 0))
self.spin_box.setValue(self.attributes.get(f"index_score", 0))
self.layout.addWidget(self.spin_box)

def update_attributes(self):
Expand All @@ -60,4 +60,4 @@ def update_attributes(self):
"""
# Collect data for the raster layerfactorlayer_data_weighting
value = self.spin_box.value()
self.attributes["default_index_score"] = value
self.attributes["index_score"] = value
4 changes: 2 additions & 2 deletions geest/resources/README-DEVELOPERS.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@ graph TB
D --> D2[id: string]
D --> D3[description: string]
D --> D4[default_factor_weighting: number]
D --> D5[default_index_score: integer]
D --> D5[index_score: integer]
D --> D6[index_score: integer]
D --> D7[use_default_index_score: integer]
D --> D7[use_index_score: integer]
D --> D8[default_multi_buffer_distances: string]
D --> D9[use_multi_buffer_point: integer]
D --> D10[default_single_buffer_distance: integer]
Expand Down
Binary file modified geest/resources/geest2.ods
Binary file not shown.
Loading

0 comments on commit 347ca8c

Please sign in to comment.