Skip to content
Permalink
Browse files
changed resampling extent behaviour in SAGA
git-svn-id: http://sextante.googlecode.com/svn/trunk/soft/bindings/qgis-plugin@167 881b9c09-3ef8-f3c2-ec3d-21d735c97f4d
  • Loading branch information
volayaf@gmail.com committed May 6, 2012
1 parent dc86682 commit fa6a4e56582d0cb772f99f58eb856acbb49f654a
Showing with 19 additions and 6 deletions.
  1. +1 −1 src/sextante/gui/SextanteToolbox.py
  2. +18 −5 src/sextante/saga/SagaAlgorithm.py
@@ -123,7 +123,7 @@ def executeAlgorithm(self):

def fillTree(self):
self.algorithmTree.clear()
text = str(self.searchBox.text())
text = unicode(self.searchBox.text())
for providerName in Sextante.algs.keys():
groups = {}
provider = Sextante.algs[providerName]
@@ -83,9 +83,12 @@ def defineCharacteristicsFromFile(self):


def calculateResamplingExtent(self):
'''this method calculates the resampling extent, but it might set self.resample
to false if, with the current layers, there is no need to resample'''
auto = SextanteConfig.getSetting(SagaUtils.SAGA_AUTO_RESAMPLING)
if auto:
first = True;
self.inputExtentsCount = 0
for param in self.parameters:
if param.value:
if isinstance(param, ParameterRaster):
@@ -102,6 +105,8 @@ def calculateResamplingExtent(self):
layer = QGisLayers.getObjectFromUri(layername)
self.addToResamplingExtent(layer, first)
first = False
if self.inputExtentsCount < 2:
self.resample = false
else:
self.xmin = SextanteConfig.getSetting(SagaUtils.SAGA_RESAMPLING_REGION_XMIN)
self.xmax = SextanteConfig.getSetting(SagaUtils.SAGA_RESAMPLING_REGION_XMAX)
@@ -112,17 +117,25 @@ def calculateResamplingExtent(self):

def addToResamplingExtent(self, layer, first):
if first:
self.inputExtentsCount = 1
self.xmin = layer.extent().xMinimum()
self.xmax = layer.extent().xMaximum()
self.ymin = layer.extent().yMinimum()
self.ymax = layer.extent().yMaximum()
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())
self.cellsize = max(self.cellsize, (layer.extent().xMaximum() - layer.extent().xMinimum())/layer.width())
cellsize = (layer.extent().xMaximum() - layer.extent().xMinimum())/layer.width()
if self.xmin != layer.extent().xMinimum() or
self.xmax != layer.extent().xMaximum() or
self.ymin != layer.extent().yMinimum() or
self.ymax != layer.extent().yMaximum() or
self.cellsize != cellsize:
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())
self.cellsize = max(self.cellsize, cellsize)
self.inputExtentsCount += 1


def processAlgorithm(self, progress):

0 comments on commit fa6a4e5

Please sign in to comment.