Skip to content

Commit 1d61bc0

Browse files
committed
refactor(com7): simplify input handling and adjust subprocess commands
- Replaced `QgsProcessingParameterMultipleLayers` with `QgsProcessingParameterFeatureSource` for single layer input in `runCom7RegionalSplitting_algorithm`. - Updated command options in subprocess calls to use explicit flags `--split-inputs` and `--run-computations`. - Removed unused code related to multiple layer handling. - Registered updated algorithms in `pb_tool.cfg`.
1 parent e25ffa7 commit 1d61bc0

3 files changed

Lines changed: 22 additions & 18 deletions

File tree

pb_tool.cfg

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,8 @@ python_files: __init__.py avaframeConnector.py avaframeConnector_provider.py
6161
runAna4ProbAna_algorithm.py
6262
runAna4ProbDirOnly_algorithm.py
6363
runAna5DFAPathGeneration_algorithm.py
64+
runCom7RegionalSplitting_algorithm.py
65+
runCom7RegionalComputation_algorithm.py
6466
runIn1RelInfo_algorithm.py
6567
avaframeConnector_commonFunc.py
6668

runCom7RegionalComputation_algorithm.py

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -100,15 +100,17 @@ def processAlgorithm(self, parameters, context, feedback):
100100
feedback.pushInfo("See console for progress")
101101

102102
# Generate command and run via subprocess.run
103-
command = ["python", "-m", "avaframe.runCom7Regional", str(targetDir)]
103+
command = [
104+
"python",
105+
"-m",
106+
"avaframe.runCom7Regional",
107+
str(targetDir),
108+
"--run-computations",
109+
]
104110
cF.runAndCheck(command, self, feedback)
105111

106112
feedback.pushInfo("Done, start loading the results")
107113

108-
rasterResults = cF.getAna4ProbAnaResults(targetDir)
109-
110-
context = cF.addLayersToContext(context, rasterResults, self.OUTPUT)
111-
112114
feedback.pushInfo("\n---------------------------------")
113115
feedback.pushInfo("Done, find results and logs here:")
114116
feedback.pushInfo(str(targetDir.resolve()))

runCom7RegionalSplitting_algorithm.py

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@
3232

3333
import pathlib
3434
from qgis import processing
35-
from pathlib import Path
3635

3736
from qgis.PyQt.QtCore import QCoreApplication
3837
from qgis.core import (
@@ -76,10 +75,10 @@ def initAlgorithm(self, config):
7675
)
7776

7877
self.addParameter(
79-
QgsProcessingParameterMultipleLayers(
78+
QgsProcessingParameterFeatureSource(
8079
self.REL,
81-
self.tr("Release layer(s)"),
82-
layerType=QgsProcessing.TypeVectorAnyGeometry,
80+
self.tr("Release layer"),
81+
types=[QgsProcessing.TypeVectorAnyGeometry],
8382
)
8483
)
8584

@@ -143,14 +142,10 @@ def processAlgorithm(self, parameters, context, feedback):
143142
raise QgsProcessingException(self.invalidSourceError(parameters, self.DEM))
144143

145144
# Release files
146-
allREL = self.parameterAsLayerList(parameters, self.REL, context)
147-
if allREL is None:
145+
sourceREL = self.parameterAsVectorLayer(parameters, self.REL, context)
146+
if sourceREL is None:
148147
raise QgsProcessingException(self.invalidSourceError(parameters, self.REL))
149148

150-
relDict = {}
151-
if allREL:
152-
relDict = {lyr.source(): lyr for lyr in allREL}
153-
154149
sourceRES = self.parameterAsVectorLayer(parameters, self.RES, context)
155150

156151
sourceENT = self.parameterAsVectorLayer(parameters, self.ENT, context)
@@ -167,7 +162,7 @@ def processAlgorithm(self, parameters, context, feedback):
167162
cF.copyDEM(sourceDEM, targetDir)
168163

169164
# copy all release shapefile parts
170-
cF.copyMultipleShp(relDict, targetDir / "Inputs" / "REL")
165+
cF.copyShp(sourceREL.source(), targetDir / "Inputs" / "REL")
171166

172167
# copy all resistance shapefile parts
173168
if sourceRES is not None:
@@ -180,14 +175,19 @@ def processAlgorithm(self, parameters, context, feedback):
180175
feedback.pushInfo("Start splitting the input")
181176

182177
# Generate command and run via subprocess.run
183-
command = ['python', '-m', 'avaframe.runCom7Regional', str(targetDir), '-ac', str("splitOnly")]
178+
command = [
179+
"python",
180+
"-m",
181+
"avaframe.runCom7Regional",
182+
str(targetDir),
183+
"--split-inputs",
184+
]
184185
cF.runAndCheck(command, self, feedback)
185186

186187
feedback.pushInfo("Done, please check target directory ")
187188

188189
return {}
189190

190-
191191
def name(self):
192192
"""
193193
Returns the algorithm name, used for identifying the algorithm. This

0 commit comments

Comments
 (0)