34 changes: 15 additions & 19 deletions python/plugins/sextante/algs/ftools/Intersection.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,25 +68,21 @@ def processAlgorithm(self, progress):
request = QgsFeatureRequest().setFilterFid(i)
inFeatB = vlayerB.getFeatures(request).next()
tmpGeom = QgsGeometry(inFeatB.geometry())
try:
if geom.intersects( tmpGeom ):
atMapB = inFeatB.attributes()
int_geom = QgsGeometry( geom.intersection( tmpGeom ) )
if int_geom.wkbType() == 7:
int_com = geom.combine( tmpGeom )
int_sym = geom.symDifference( tmpGeom )
int_geom = QgsGeometry( int_com.difference( int_sym ) )
try:
outFeat.setGeometry( int_geom )
attrs = []
attrs.extend(atMapA)
attrs.extend(atMapB)
outFeat.setAttributes(attrs)
writer.addFeature( outFeat )
except:
raise GeoAlgorithmExecutionException("Feature exception while computing intersection")
except:
raise GeoAlgorithmExecutionException("Geometry exception while computing intersection")
if geom.intersects( tmpGeom ):
print "hola"
atMapB = inFeatB.attributes()
int_geom = QgsGeometry( geom.intersection( tmpGeom ) )
if int_geom.wkbType() == 7:
int_com = geom.combine( tmpGeom )
int_sym = geom.symDifference( tmpGeom )
int_geom = QgsGeometry( int_com.difference( int_sym ) )
outFeat.setGeometry( int_geom )
attrs = []
attrs.extend(atMapA)
attrs.extend(atMapB)
outFeat.setAttributes(attrs)
writer.addFeature( outFeat )



del writer
Expand Down
2 changes: 0 additions & 2 deletions python/plugins/sextante/algs/ftools/ReprojectLayer.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,7 @@
__revision__ = '$Format:%H$'

from PyQt4.QtCore import *

from qgis.core import *

from sextante.core.GeoAlgorithm import GeoAlgorithm
from sextante.core.QGisLayers import QGisLayers
from sextante.parameters.ParameterVector import ParameterVector
Expand Down
10 changes: 9 additions & 1 deletion python/plugins/sextante/core/GeoAlgorithm.py
Original file line number Diff line number Diff line change
Expand Up @@ -262,7 +262,7 @@ def resolveTemporaryOutputs(self):
SextanteUtils.setTempOutput(out, self)

def setOutputCRS(self):
layers = QGisLayers.getAllLayers()
layers = QGisLayers.getAllLayers()
for param in self.parameters:
if isinstance(param, (ParameterRaster, ParameterVector, ParameterMultipleInput)):
if param.value:
Expand All @@ -272,6 +272,14 @@ def setOutputCRS(self):
if layer.source() == inputlayer:
self.crs = layer.crs()
return
if (isinstance(param, ParameterRaster) or
(isinstance(param, ParameterMultipleInput) and param.datatype == ParameterMultipleInput.TYPE_RASTER)):
p = QgsProviderRegistry.instance().provider('gdal', inputlayer)
else:
p = QgsProviderRegistry.instance().provider('ogr', inputlayer)
if p is not None:
self.crs = p.crs()
return
qgis = QGisLayers.iface
self.crs = qgis.mapCanvas().mapRenderer().destinationCrs()

Expand Down
7 changes: 4 additions & 3 deletions python/plugins/sextante/gdal/translate.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@

import os
from PyQt4 import QtGui
from qgis.core import *
from sextante.core.GeoAlgorithm import GeoAlgorithm
from sextante.parameters.ParameterString import ParameterString
from sextante.parameters.ParameterRaster import ParameterRaster
Expand Down Expand Up @@ -75,7 +76,7 @@ def processAlgorithm(self, progress):
noData = str(self.getParameterValue(translate.NO_DATA))
expand = str(self.getParameterFromName(translate.EXPAND).options[self.getParameterValue(translate.EXPAND)])
projwin = str(self.getParameterValue(translate.PROJWIN))
srs = self.getParameterValue(translate.SRS)
crsId = self.getParameterValue(translate.SRS)
sds = self.getParameterValue(translate.SDS)
extra = str(self.getParameterValue(translate.EXTRA))

Expand All @@ -101,9 +102,9 @@ def processAlgorithm(self, progress):
arguments.append(regionCoords[3])
arguments.append(regionCoords[1])
arguments.append(regionCoords[2])
if srs is not None:
if crsId is not None:
arguments.append("-a_srs")
arguments.append(str(srs))
arguments.append(str(crsId))
self.crs = QgsCoordinateReferenceSystem(crsId)
if sds:
arguments.append("-sds")
Expand Down
27 changes: 9 additions & 18 deletions python/plugins/sextante/saga/SagaAlgorithm.py
Original file line number Diff line number Diff line change
Expand Up @@ -234,11 +234,9 @@ def processAlgorithm(self, progress):
raise GeoAlgorithmExecutionException("Unsupported file format")

#2: set parameters and outputs
if SextanteUtils.isWindows() or SextanteUtils.isMac():
command = self.undecoratedGroup + " \"" + self.cmdname + "\""
else:
command = "lib" + self.undecoratedGroup + " \"" + self.cmdname + "\""


command = self.undecoratedGroup + " \"" + self.cmdname + "\""

if self.hardcodedStrings:
for s in self.hardcodedStrings:
command += " " + s
Expand Down Expand Up @@ -300,11 +298,9 @@ def processAlgorithm(self, progress):
for out in self.outputs:
if isinstance(out, OutputRaster):
filename = out.getCompatibleFileName(self)
filename2 = SextanteUtils.tempFolder() + os.sep + os.path.basename(filename) + ".sgrd"
if SextanteUtils.isWindows() or SextanteUtils.isMac():
commands.append("io_gdal 1 -GRIDS \"" + filename2 + "\" -FORMAT 4 -TYPE 0 -FILE \"" + filename + "\"");
else:
commands.append("libio_gdal 1 -GRIDS \"" + filename2 + "\" -FORMAT 4 -TYPE 0 -FILE \"" + filename + "\"");
filename2 = SextanteUtils.tempFolder() + os.sep + os.path.basename(filename) + ".sgrd"
commands.append("io_gdal 1 -GRIDS \"" + filename2 + "\" -FORMAT 4 -TYPE 0 -FILE \"" + filename + "\"");


#4 Run SAGA
SagaUtils.createSagaBatchJobFileFromSagaCommands(commands)
Expand Down Expand Up @@ -336,14 +332,9 @@ def resampleRasterLayer(self,layer):
inputFilename = layer
destFilename = SextanteUtils.getTempFilename("sgrd")
self.exportedLayers[layer]= destFilename
if SextanteUtils.isWindows() or SextanteUtils.isMac():
s = "grid_tools \"Resampling\" -INPUT \"" + inputFilename + "\" -TARGET 0 -SCALE_UP_METHOD 4 -SCALE_DOWN_METHOD 4 -USER_XMIN " +\
str(self.xmin) + " -USER_XMAX " + str(self.xmax) + " -USER_YMIN " + str(self.ymin) + " -USER_YMAX " + str(self.ymax) +\
" -USER_SIZE " + str(self.cellsize) + " -USER_GRID \"" + destFilename + "\""
else:
s = "libgrid_tools \"Resampling\" -INPUT \"" + inputFilename + "\" -TARGET 0 -SCALE_UP_METHOD 4 -SCALE_DOWN_METHOD 4 -USER_XMIN " +\
str(self.xmin) + " -USER_XMAX " + str(self.xmax) + " -USER_YMIN " + str(self.ymin) + " -USER_YMAX " + str(self.ymax) +\
" -USER_SIZE " + str(self.cellsize) + " -USER_GRID \"" + destFilename + "\""
s = "grid_tools \"Resampling\" -INPUT \"" + inputFilename + "\" -TARGET 0 -SCALE_UP_METHOD 4 -SCALE_DOWN_METHOD 4 -USER_XMIN " +\
str(self.xmin) + " -USER_XMAX " + str(self.xmax) + " -USER_YMIN " + str(self.ymin) + " -USER_YMAX " + str(self.ymax) +\
" -USER_SIZE " + str(self.cellsize) + " -USER_GRID \"" + destFilename + "\""
return s


Expand Down