Skip to content
Permalink
Browse files
fixed bug when running unsaved models
added gridmetrics to FUSION

git-svn-id: http://sextante.googlecode.com/svn/trunk/soft/bindings/qgis-plugin@172 881b9c09-3ef8-f3c2-ec3d-21d735c97f4d
  • Loading branch information
volayaf committed May 8, 2012
1 parent c80371a commit cd2f975ae9dc5fdda599fca4fee40f5922d40b5b
@@ -11,14 +11,15 @@
from sextante.fusion.ClipData import ClipData
from sextante.fusion.Cover import Cover
from sextante.fusion.FilterData import FilterData
from sextante.fusion.GridMetrics import GridMetrics


class FusionAlgorithmProvider(AlgorithmProvider):

def __init__(self):
AlgorithmProvider.__init__(self)
self.actions.append(OpenViewerAction())
self.algsList = [CloudMetrics(), CanopyMaxima(), CanopyModel(), ClipData(), Cover(), FilterData()]
self.algsList = [CloudMetrics(), CanopyMaxima(), CanopyModel(), ClipData(), Cover(), FilterData(), GridMetrics()]

def initializeSettings(self):
AlgorithmProvider.initializeSettings(self)
@@ -0,0 +1,41 @@
import os
from sextante.parameters.ParameterFile import ParameterFile
from sextante.outputs.OutputTable import OutputTable
from sextante.fusion.FusionUtils import FusionUtils
from sextante.fusion.FusionAlgorithm import FusionAlgorithm
from sextante.parameters.ParameterNumber import ParameterNumber

class GridMetrics(FusionAlgorithm):

INPUT = "INPUT"
OUTPUT = "OUTPUT"
GROUND = "GROUND"
HEIGHT = "HEIGHT"
CELLSIZE = "CELLSIZE"

def defineCharacteristics(self):
self.name = "Grid Metrics"
self.group = "Points"
self.addParameter(ParameterFile(self.INPUT, "Input las layer"))
self.addParameter(ParameterFile(self.GROUND, "Input ground DTM layer"))
self.addParameter(ParameterNumber(self.HEIGHT, "Height break"))
self.addParameter(ParameterNumber(self.CELLSIZE, "Cellsize"))
self.addOutput(OutputTable(self.OUTPUT, "Output table with grid metrics"))
self.addAdvancedModifiers()

def processAlgorithm(self, progress):
commands = [os.path.join(FusionUtils.FusionPath(), "GridMetrics.exe")]
commands.append("/verbose")
self.addAdvancedModifiersToCommand(commands)
commands.append(self.getParameterValue(self.GROUND))
commands.append(str(self.getParameterValue(self.HEIGHT)))
commands.append(str(self.getParameterValue(self.CELLSIZE)))
commands.append(self.getOutputValue(self.OUTPUT))
files = self.getParameterValue(self.INPUT).split(";")
if len(files) == 1:
commands.append(self.getParameterValue(self.INPUT))
else:
FusionUtils.createFileList(files)
commands.append(FusionUtils.tempFileListFilepath())

FusionUtils.runFusion(commands, progress)
@@ -5,6 +5,7 @@
from sextante.core.QGisLayers import QGisLayers
from sextante.core.SextanteUtils import SextanteUtils
from sextante.gui.SextantePostprocessing import SextantePostprocessing
import traceback

class AlgorithmExecutor:

@@ -19,6 +20,9 @@ def runalg(alg, progress):
except GeoAlgorithmExecutionException, e :
QMessageBox.critical(None, "Error", e.msg)
return False
except Exception:
QMessageBox.critical(None, "Error", traceback.format_exc())
return False

@staticmethod
def runalgIterating(alg,paramToIter,progress):
@@ -183,13 +183,15 @@ def runModel(self):
fout.write(text)
fout.close()
self.alg.provider = Providers.providers["model"]
alg = self.alg.getCopy()#copy.deepcopy(self.alg)
alg = self.alg.getCopy()
dlg = ParametersDialog(alg)
dlg.exec_()
self.alg.descriptionFile = None
alg.descriptionFile = None
else:
alg = self.alg.getCopy()#copy.deepcopy(self.alg)
dlg = ParametersDialog(alg)
dlg.exec_()
alg = self.alg.getCopy()
dlg = ParametersDialog(alg)
dlg.exec_()

def saveModel(self):
if str(self.textGroup.text()).strip() == "" or str(self.textName.text()).strip() == "":
@@ -205,7 +207,7 @@ def saveModel(self):
if filename:
if not filename.endswith(".model"):
filename += ".model"
self.alg.descriptionFile = filename
self.alg.descriptionFile = filename
if filename:
text = self.alg.serialize()
fout = open(filename, "w")
@@ -46,7 +46,9 @@ def saveAlgorithm(self):
filename = self.alg.descriptionFile
else:
filename = QtGui.QFileDialog.getSaveFileName(self, "Save Script", RUtils.RScriptsFolder(), "R-SEXTANTE scripts (*.rsx)")

if filename:
self.alg.descriptionFile = filename
text = self.text.toPlainText()
fout = open(filename, "w")
fout.write(text)
@@ -59,6 +59,7 @@ def saveAlgorithm(self):
filename = QtGui.QFileDialog.getSaveFileName(self, "Save Script", ScriptUtils.scriptsFolder(), "Python scripts (*.py)")

if filename:
self.alg.descriptionFile = filename
text = self.text.toPlainText()
fout = open(filename, "w")
fout.write(text)

0 comments on commit cd2f975

Please sign in to comment.