Skip to content
Permalink
Browse files

fixed #6295

did some cleaning in GrassAlgorithm.py
  • Loading branch information
volaya committed Sep 22, 2012
1 parent 73fcb66 commit d80d3cf985b7795cee586da9c0f62ab02966c77c
Showing with 1 addition and 74 deletions.
  1. +0 −73 python/plugins/sextante/grass/GrassAlgorithm.py
  2. +1 −1 python/plugins/sextante/r/RAlgorithm.py
@@ -103,67 +103,9 @@ def defineCharacteristicsFromFile(self):
raise e
lines.close()

#=======================================================================
# self.xmin = SextanteConfig.getSetting(GrassUtils.GRASS_REGION_XMIN)
# self.xmax = SextanteConfig.getSetting(GrassUtils.GRASS_REGION_XMAX)
# self.ymin = SextanteConfig.getSetting(GrassUtils.GRASS_REGION_YMIN)
# self.ymax = SextanteConfig.getSetting(GrassUtils.GRASS_REGION_YMAX)
# extentString = str(self.xmin) + "," + str(self.xmax) + str(self.xmin) + "," + str(self.xmax)
# self.cellsize = SextanteConfig.getSetting(GrassUtils.GRASS_REGION_CELLSIZE)
#=======================================================================
self.addParameter(ParameterExtent(self.GRASS_REGION_EXTENT_PARAMETER, "GRASS region extent"))
self.addParameter(ParameterNumber(self.GRASS_REGION_CELLSIZE_PARAMETER, "GRASS region cellsize", 0, None, 1))

#===============================================================================
# def calculateRegion(self):
# auto = SextanteConfig.getSetting(GrassUtils.GRASS_AUTO_REGION)
# if auto:
# try:
# self.cellsize = SextanteConfig.getSetting(GrassUtils.GRASS_REGION_CELLSIZE)
# except Exception:
# self.cellsize = 0;
# first = True;
# for param in self.parameters:
# if param.value:
# if isinstance(param, (ParameterRaster, ParameterVector)):
# if isinstance(param.value, (QgsRasterLayer, QgsVectorLayer)):
# layer = param.value
# else:
# layer = QGisLayers.getObjectFromUri(param.value)
# self.addToRegion(layer, first)
# first = False
# elif isinstance(param, ParameterMultipleInput):
# layers = param.value.split(";")
# for layername in layers:
# layer = QGisLayers.getObjectFromUri(layername, first)
# self.addToRegion(layer, first)
# first = False
# if self.cellsize == 0:
# self.cellsize = 1
# else:
# self.xmin = SextanteConfig.getSetting(GrassUtils.GRASS_REGION_XMIN)
# self.xmax = SextanteConfig.getSetting(GrassUtils.GRASS_REGION_XMAX)
# self.ymin = SextanteConfig.getSetting(GrassUtils.GRASS_REGION_YMIN)
# self.ymax = SextanteConfig.getSetting(GrassUtils.GRASS_REGION_YMAX)
# self.cellsize = SextanteConfig.getSetting(GrassUtils.GRASS_REGION_CELLSIZE)
#
#
# def addToRegion(self, layer, first):
# if first:
# self.xmin = layer.extent().xMinimum()
# self.xmax = layer.extent().xMaximum()
# self.ymin = layer.extent().yMinimum()
# self.ymax = layer.extent().yMaximum()
# if isinstance(layer, QgsRasterLayer):
# self.cellsize = (layer.extent().xMaximum() - layer.extent().xMinimum())/layer.width()
# else:
# self.xmin = min(self.xmin, layer.extent().xMinimum())
# self.xmax = max(self.xmax, layer.extent().xMaximum())
# self.ymin = min(self.ymin, layer.extent().yMinimum())
# self.ymax = max(self.ymax, layer.extent().yMaximum())
# if isinstance(layer, QgsRasterLayer):
# self.cellsize = max(self.cellsize, (layer.extent().xMaximum() - layer.extent().xMinimum())/layer.width())
#===============================================================================

def processAlgorithm(self, progress):
if SextanteUtils.isWindows():
@@ -327,18 +269,3 @@ def getTempFilename(self):

def commandLineName(self):
return "grass:" + self.name[:self.name.find(" ")]

#===============================================================================
# def checkBeforeOpeningParametersDialog(self):
# for param in self.parameters:
# if isinstance(param, (ParameterRaster, ParameterVector)):
# return None
# if isinstance(param, ParameterMultipleInput):
# if not param.optional:
# return None
#
# if SextanteConfig.getSetting(GrassUtils.GRASS_AUTO_REGION):
# return "This algorithm cannot be run with the 'auto-region' setting\nPlease set a GRASS region before running it"
# else:
# return None
#===============================================================================
@@ -230,7 +230,7 @@ def getImportCommands(self):
# if rgdal is not available, try to install it
# just use US mirror
commands.append('options("repos"="http://cran.us.r-project.org")')
rLibDir = "%s/rlibs" % SextanteUtils.userFolder()
rLibDir = "%s/rlibs" % SextanteUtils.userFolder().replace("\\","/")
if not os.path.isdir(rLibDir): os.mkdir(rLibDir)
commands.append(
'tryCatch(find.package("rgdal"), error=function(e) install.packages("rgdal", lib="%s"))' % rLibDir)

0 comments on commit d80d3cf

Please sign in to comment.
You can’t perform that action at this time.