Skip to content

Commit

Permalink
apply changes from review
Browse files Browse the repository at this point in the history
  • Loading branch information
leon-wagner committed Nov 21, 2024
1 parent b60e460 commit c766b3a
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 32 deletions.
8 changes: 4 additions & 4 deletions avaframeConnector_commonFunc.py
Original file line number Diff line number Diff line change
Expand Up @@ -141,11 +141,11 @@ def getAlphaBetaResults(targetDir, useSmallAva=False):
abResultsLayer = QgsVectorLayer(str(abResultsFile), "AlphaBeta (com2)", "ogr")
return abResultsLayer
else:
return "None"
return 'None'

def getDFAPathResults(targetDir):
'''Get results from path generation
'''Get results from path generation
Parameters
-----------
targetDir: pathlib path
Expand All @@ -156,7 +156,7 @@ def getDFAPathResults(targetDir):
'''
from qgis.core import (QgsVectorLayer)
avaDir = pathlib.Path(str(targetDir))
pathDir = avaDir / 'Outputs' / 'DFAPath'
pathDir = avaDir / 'Outputs' / 'ana5Utils' / 'DFAPath'
allDFAPathLayers = []

# Collect all path shapefiles
Expand Down
4 changes: 2 additions & 2 deletions avaframeConnector_provider.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,13 +89,13 @@ def find_python():
from .avaframeConnector_algorithm import AvaFrameConnectorAlgorithm
from .layerRename_algorithm import layerRenameAlgorithm
from .getVersion_algorithm import getVersionAlgorithm
from .runComputeDFAPath_algorithm import runComputeDFAPathAlgorithm
from .runCom1DFA_algorithm import runCom1DFAAlgorithm
from .runCom2AB_algorithm import runCom2ABAlgorithm
from .runCom5SnowSlide_algorithm import runCom5SnowSlideAlgorithm
from .runCom6RockAvalanche_algorithm import runCom6RockAvalancheAlgorithm
from .runAna4ProbAna_algorithm import runAna4ProbAnaAlgorithm
from .runAna4ProbDirOnly_algorithm import runAna4ProbDirOnlyAlgorithm
from .runAna5DFAPathGeneration_algorithm import runAna5DFAPathGenerationAlgorithm
from .runIn1RelInfo_algorithm import runIn1RelInfoAlgorithm
from .update_algorithm import updateAlgorithm

Expand Down Expand Up @@ -124,13 +124,13 @@ def loadAlgorithms(self):
"""
self.addAlgorithm(AvaFrameConnectorAlgorithm())
self.addAlgorithm(layerRenameAlgorithm())
self.addAlgorithm(runComputeDFAPathAlgorithm())
self.addAlgorithm(runCom1DFAAlgorithm())
self.addAlgorithm(runCom2ABAlgorithm())
self.addAlgorithm(runCom5SnowSlideAlgorithm())
self.addAlgorithm(runCom6RockAvalancheAlgorithm())
self.addAlgorithm(runAna4ProbAnaAlgorithm())
self.addAlgorithm(runAna4ProbDirOnlyAlgorithm())
self.addAlgorithm(runAna5DFAPathGenerationAlgorithm())
self.addAlgorithm(getVersionAlgorithm())
self.addAlgorithm(updateAlgorithm())
self.addAlgorithm(runIn1RelInfoAlgorithm())
Expand Down
6 changes: 3 additions & 3 deletions pb_tool.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -53,13 +53,13 @@ python_files: __init__.py avaframeConnector.py avaframeConnector_provider.py
layerRename_algorithm.py
getVersion_algorithm.py
update_algorithm.py
runComputeDFAPath_algorithm.py
runCom1DFA_algorithm.py
runCom2AB_algorithm.py
runAna4ProbAna_algorithm.py
runAna4ProbDirOnly_algorithm.py
runCom5SnowSlide_algorithm.py
runCom6RockAvalanche_algorithm.py
runAna4ProbAna_algorithm.py
runAna4ProbDirOnly_algorithm.py
runAna5DFAPathGeneration_algorithm.py
runIn1RelInfo_algorithm.py
avaframeConnector_commonFunc.py

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
)


class runComputeDFAPathAlgorithm(QgsProcessingAlgorithm):
class runAna5DFAPathGenerationAlgorithm(QgsProcessingAlgorithm):
"""
This is the AvaFrame Connection, i.e. the part running with QGis. For this
connector to work, more installation is needed. See instructions at docs.avaframe.org
Expand Down Expand Up @@ -110,7 +110,6 @@ def processAlgorithm(self, parameters, context, feedback):

feedback.pushInfo('AvaFrame Version: ' + gv.getVersion())

# targetADDTONAME = self.parameterAsString(parameters, self.ADDTONAME, context)
targetADDTONAME = ''

sourceDEM = self.parameterAsRasterLayer(parameters, self.DEM, context)
Expand Down Expand Up @@ -146,13 +145,13 @@ def processAlgorithm(self, parameters, context, feedback):
feedback.pushInfo('See console for progress')

# Prepare command for subprocess call
command = ['python', '-m', 'avaframe.runComputeDFAPath', str(targetDir)]
command = ['python', '-m', 'avaframe.runAna5DFAPathGeneration', str(targetDir)]

# Add --runDFA argument if RUNDFA boolean is True
if sourceRUNDFA:
command.append('--runDFA')

subprocess.call(command)
cF.runAndCheck(command, self, feedback)
feedback.pushInfo('Done, start loading the results')

# Move input, log and output folders to finalTargetDir
Expand All @@ -164,28 +163,12 @@ def processAlgorithm(self, parameters, context, feedback):
except:
raise QgsProcessingException(self.tr('Something went wrong with path generation, please check log files'))

context = cF.addLayersToContext(context, pathResults, self.OUTPUT)

# If runDFA, try to get eventual peakfiles from com1DFA to return to QGIS
# if sourceRUNDFA:
# try:
# rasterResults = cF.getLatestPeak(finalTargetDir)
# except:
# raise QgsProcessingException(self.tr('Something went wrong with com1DFA, please check log files'))
#
# allRasterLayers = cF.addStyleToCom1DFAResults(rasterResults)

# context = cF.addLayersToContext(context, allRasterLayers, self.OUTPPR)
# else:
# allRasterLayers = 0

feedback.pushInfo('\n---------------------------------')
feedback.pushInfo('Done, find results and logs here:')
feedback.pushInfo(str(targetDir.resolve()))
feedback.pushInfo('---------------------------------\n')

return {self.OUTPUT: pathResults}
# return {self.OUTPUT: pathResults, self.OUTPPR: allRasterLayers}

def name(self):
"""
Expand Down Expand Up @@ -233,11 +216,10 @@ def shortHelpString(self) -> str:
Homepage: https://avaframe.org\n\
Praxisleitfaden: https://avaframe.org/reports\n')

return self.tr(hstring)
# Praxisleitfaden: https://info.bml.gv.at/dam/jcr:edebd872-2a86-4edf-ac5e-635ef11e35fe/Praxisleitfaden%20LawSim%20WLV%202022%20Gr%C3%BCn.pdf\n'
return self.tr(hstring)

def helpUrl(self):
return "https://docs.avaframe.org/en/latest/connector.html"

def createInstance(self):
return runComputeDFAPathAlgorithm()
return runAna5DFAPathGenerationAlgorithm()

0 comments on commit c766b3a

Please sign in to comment.