Skip to content

Commit

Permalink
changed resampling extent behaviour in SAGA
Browse files Browse the repository at this point in the history
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 fa6a4e5
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 6 deletions.
2 changes: 1 addition & 1 deletion src/sextante/gui/SextanteToolbox.py
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down
23 changes: 18 additions & 5 deletions src/sextante/saga/SagaAlgorithm.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand All @@ -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)
Expand All @@ -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):
Expand Down

0 comments on commit fa6a4e5

Please sign in to comment.