-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
272 add available workflow steps for proxy processing (#297)
* add binarize to custom proxy processing workflows * add proximity to anomaly to custom proxy processing workflows * add proximity to features to custom proxy processing workflows * fix available workflow steps in custom proxy modification
- Loading branch information
Showing
12 changed files
with
1,863 additions
and
42 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
85 changes: 85 additions & 0 deletions
85
eis_qgis_plugin/eis_wizard/mineral_proxies/workflows/binarize.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
from typing import Literal, Optional | ||
|
||
from qgis.core import QgsMapLayerProxyModel | ||
from qgis.gui import ( | ||
QgsDoubleSpinBox, | ||
QgsFileWidget, | ||
QgsMapLayerComboBox, | ||
) | ||
from qgis.PyQt.QtWidgets import ( | ||
QComboBox, | ||
QGroupBox, | ||
QLabel, | ||
QStackedWidget, | ||
QWidget, | ||
) | ||
|
||
from eis_qgis_plugin.eis_wizard.mineral_proxies.proxy_processing import EISWizardProxyProcess | ||
from eis_qgis_plugin.qgis_plugin_tools.tools.resources import load_ui | ||
from eis_qgis_plugin.utils.misc_utils import get_output_path | ||
|
||
FORM_CLASS = load_ui("mineral_proxies/proxy_workflow_binarize.ui") | ||
|
||
|
||
|
||
class EISWizardProxyBinarize(EISWizardProxyProcess, FORM_CLASS): | ||
|
||
ALG_NAME = "eis:binarize" | ||
WORKFLOW_NAME = "Binarize" | ||
|
||
def __init__(self, | ||
proxy_manager: QWidget, | ||
mineral_system: str, | ||
category: str, | ||
proxy_name: str, | ||
mineral_system_component: str, | ||
process_type: Literal["single_step", "multi_step", "multi_step_final"] = "single_step", | ||
parent: Optional[QWidget] = None | ||
) -> None: | ||
super().__init__(parent) | ||
self.setupUi(self) | ||
|
||
self.mineral_system = mineral_system | ||
self.mineral_system_component = mineral_system_component | ||
self.process_type = process_type | ||
self.category = category | ||
self.proxy_name = proxy_name | ||
self.proxy_manager = proxy_manager | ||
|
||
# DECLARE TYPES | ||
self.raster_layer: QgsMapLayerComboBox | ||
|
||
self.method_box: QGroupBox | ||
self.binarizing_threshold_label: QLabel | ||
self.binarizing_threshold: QgsDoubleSpinBox | ||
|
||
self.output_raster_path: QgsFileWidget | ||
self.output_raster_settings: QComboBox | ||
self.output_raster_settings_pages: QStackedWidget | ||
|
||
self.initialize() | ||
|
||
|
||
def initialize(self): | ||
self.raster_layer.setFilters(QgsMapLayerProxyModel.RasterLayer) | ||
super().initialize(self.process_type) | ||
|
||
|
||
def on_output_raster_settings_changed(self, i): | ||
max_height = 50 if i == 0 else 230 | ||
self.output_raster_settings_pages.setMaximumHeight(max_height) | ||
self.output_raster_settings_pages.setCurrentIndex(i) | ||
|
||
|
||
def on_define_anomaly_output_raster_settings_changed(self, i): | ||
self.output_raster_settings_pages.setCurrentIndex(i) | ||
|
||
|
||
def run(self): | ||
params = { | ||
"input_raster": self.raster_layer.currentLayer(), | ||
"threshold": self.binarizing_threshold.value(), | ||
"output_raster": get_output_path(self.output_raster_path) | ||
} | ||
self.executor.configure(self.ALG_NAME, self.feedback) | ||
self.executor.run(params) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
116 changes: 116 additions & 0 deletions
116
eis_qgis_plugin/eis_wizard/mineral_proxies/workflows/proximity_to_anomaly.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,116 @@ | ||
from typing import Literal, Optional | ||
|
||
from qgis.core import QgsMapLayerProxyModel | ||
from qgis.gui import ( | ||
QgsDoubleSpinBox, | ||
QgsFileWidget, | ||
QgsMapLayerComboBox, | ||
) | ||
from qgis.PyQt.QtWidgets import ( | ||
QComboBox, | ||
QGroupBox, | ||
QLabel, | ||
QStackedWidget, | ||
QWidget, | ||
) | ||
|
||
from eis_qgis_plugin.eis_wizard.mineral_proxies.proxy_processing import EISWizardProxyProcess | ||
from eis_qgis_plugin.qgis_plugin_tools.tools.resources import load_ui | ||
from eis_qgis_plugin.utils.misc_utils import get_output_path | ||
|
||
FORM_CLASS = load_ui("mineral_proxies/proxy_workflow_proximity_to_anomaly.ui") | ||
|
||
|
||
|
||
class EISWizardProxyProximityToAnomaly(EISWizardProxyProcess, FORM_CLASS): | ||
|
||
ALG_NAME = "eis:proximity_to_anomaly" | ||
WORKFLOW_NAME = "Proximity to anomaly" | ||
|
||
def __init__(self, | ||
proxy_manager: QWidget, | ||
mineral_system: str, | ||
category: str, | ||
proxy_name: str, | ||
mineral_system_component: str, | ||
process_type: Literal["single_step", "multi_step", "multi_step_final"] = "single_step", | ||
parent: Optional[QWidget] = None | ||
) -> None: | ||
super().__init__(parent) | ||
self.setupUi(self) | ||
|
||
self.mineral_system = mineral_system | ||
self.mineral_system_component = mineral_system_component | ||
self.process_type = process_type | ||
self.category = category | ||
self.proxy_name = proxy_name | ||
self.proxy_manager = proxy_manager | ||
|
||
# DECLARE TYPES | ||
self.raster_layer: QgsMapLayerComboBox | ||
|
||
self.method_box: QGroupBox | ||
self.threshold_criteria: QComboBox | ||
self.threshold_1: QgsDoubleSpinBox | ||
self.threshold_label_1: QLabel | ||
self.threshold_2: QgsDoubleSpinBox | ||
self.threshold_label_2: QLabel | ||
self.max_distance: QgsDoubleSpinBox | ||
self.max_distance_value: QgsDoubleSpinBox | ||
self.anomaly_value: QgsDoubleSpinBox | ||
|
||
self.output_raster_path: QgsFileWidget | ||
self.output_raster_settings: QComboBox | ||
self.output_raster_settings_pages: QStackedWidget | ||
|
||
self.initialize() | ||
|
||
|
||
def initialize(self): | ||
self.raster_layer.setFilters(QgsMapLayerProxyModel.RasterLayer) | ||
self.threshold_criteria.currentTextChanged.connect(self.on_threshold_criteria_changed) | ||
self.on_threshold_criteria_changed("higher") | ||
|
||
super().initialize(self.process_type) | ||
|
||
|
||
def on_output_raster_settings_changed(self, i): | ||
max_height = 50 if i == 0 else 230 | ||
self.output_raster_settings_pages.setMaximumHeight(max_height) | ||
self.output_raster_settings_pages.setCurrentIndex(i) | ||
|
||
|
||
def on_define_anomaly_output_raster_settings_changed(self, i): | ||
self.output_raster_settings_pages.setCurrentIndex(i) | ||
|
||
|
||
def on_threshold_criteria_changed(self, text: str): | ||
text = text.lower() | ||
if text == "higher" or text == "lower": | ||
self.threshold_label_1.setText("Threshold value") | ||
self.threshold_label_2.hide() | ||
self.threshold_2.hide() | ||
else: | ||
self.threshold_label_1.setText("Threshold value lower") | ||
self.threshold_label_2.show() | ||
self.threshold_2.show() | ||
|
||
|
||
def run(self): | ||
threshold_criteria = self.threshold_criteria.currentIndex() | ||
anomaly_threshold_2 = self.threshold_2.value() | ||
if threshold_criteria == 0 or threshold_criteria == 1: | ||
anomaly_threshold_2 = None | ||
|
||
params = { | ||
"input_raster": self.raster_layer.currentLayer(), | ||
"threshold_criteria": self.threshold_criteria.currentIndex(), | ||
"first_threshold_criteria_value": self.threshold_1.value(), | ||
"second_threshold_criteria_value": anomaly_threshold_2, | ||
"max_distance": self.max_distance.value(), | ||
"max_distance_value": self.max_distance_value.value(), | ||
"anomaly_value": self.anomaly_value.value(), | ||
"output_raster": get_output_path(self.output_raster_path) | ||
} | ||
self.executor.configure(self.ALG_NAME, self.feedback) | ||
self.executor.run(params) |
90 changes: 90 additions & 0 deletions
90
eis_qgis_plugin/eis_wizard/mineral_proxies/workflows/proximity_to_features.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,90 @@ | ||
from typing import Literal, Optional | ||
|
||
from qgis.core import QgsMapLayerProxyModel | ||
from qgis.gui import ( | ||
QgsDoubleSpinBox, | ||
QgsFieldExpressionWidget, | ||
QgsFileWidget, | ||
QgsMapLayerComboBox, | ||
) | ||
from qgis.PyQt.QtWidgets import ( | ||
QComboBox, | ||
QStackedWidget, | ||
QWidget, | ||
) | ||
|
||
from eis_qgis_plugin.eis_wizard.mineral_proxies.proxy_processing import EISWizardProxyProcess | ||
from eis_qgis_plugin.qgis_plugin_tools.tools.resources import load_ui | ||
from eis_qgis_plugin.utils.misc_utils import get_output_path | ||
|
||
FORM_CLASS = load_ui("mineral_proxies/proxy_workflow_proximity_to_features.ui") | ||
|
||
class EISWizardProxyProximityToFeatures(EISWizardProxyProcess, FORM_CLASS): | ||
|
||
ALG_NAME = "eis:proximity_computation" | ||
WORKFLOW_NAME = "Proximity to features" | ||
|
||
def __init__( | ||
self, | ||
proxy_manager: QWidget, | ||
mineral_system: str, | ||
category: str, | ||
proxy_name: str, | ||
mineral_system_component: str, | ||
process_type: Literal["single_step", "multi_step", "multi_step_final"] = "single_step", | ||
parent: Optional[QWidget] = None | ||
) -> None: | ||
super().__init__(parent) | ||
self.setupUi(self) | ||
|
||
self.mineral_system = mineral_system | ||
self.mineral_system_component = mineral_system_component | ||
self.process_type = process_type | ||
self.category = category | ||
self.proxy_name = proxy_name | ||
self.proxy_manager = proxy_manager | ||
|
||
# DELCARE TYPES | ||
self.vector_layer: QgsMapLayerComboBox | ||
self.selection: QgsFieldExpressionWidget | ||
|
||
self.max_distance: QgsDoubleSpinBox | ||
self.max_distance_value: QgsDoubleSpinBox | ||
self.features_value: QgsDoubleSpinBox | ||
|
||
self.output_raster_path: QgsFileWidget | ||
self.output_raster_settings: QComboBox | ||
self.output_raster_settings_pages: QStackedWidget | ||
|
||
self.initialize() | ||
|
||
|
||
def initialize(self): | ||
self.vector_layer.setFilters(QgsMapLayerProxyModel.VectorLayer) | ||
self.vector_layer.layerChanged.connect(self.selection.setLayer) | ||
self.selection.setLayer(self.vector_layer.currentLayer()) | ||
|
||
super().initialize(self.process_type) | ||
|
||
|
||
def on_output_raster_settings_changed(self, i: int): | ||
max_height = 50 if i == 0 else 230 | ||
self.output_raster_settings_pages.setMaximumHeight(max_height) | ||
self.output_raster_settings_pages.setCurrentIndex(i) | ||
|
||
|
||
def run(self): | ||
output_raster_params = self.get_output_raster_params() | ||
if output_raster_params is None or self.executor.is_running: | ||
return | ||
|
||
params = { | ||
"input_vector": self.vector_layer.currentLayer(), # SELECTION NOT INCLUDED! (yet) | ||
**output_raster_params, | ||
"max_distance": self.max_distance.value(), | ||
"max_distance_value": self.max_distance_value.value(), | ||
"geometries_value": self.features_value.value(), | ||
"output_raster": get_output_path(self.output_raster_path) | ||
} | ||
self.executor.configure(self.ALG_NAME, self.feedback) | ||
self.executor.run(params) |
Oops, something went wrong.