Skip to content

Commit

Permalink
[sextante] changed how saga installation test is performed (now it us…
Browse files Browse the repository at this point in the history
…es the test data)
  • Loading branch information
volaya committed Mar 27, 2013
1 parent 72037dc commit 0dd7602
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 21 deletions.
5 changes: 2 additions & 3 deletions python/plugins/sextante/saga/SagaAlgorithm.py
Original file line number Diff line number Diff line change
Expand Up @@ -348,9 +348,8 @@ def exportRasterLayer(self, layer):
return "libio_gdal 0 -GRIDS \"" + destFilename + "\" -FILES \"" + layer + "\""


def checkBeforeOpeningParametersDialog(self):
pass
#return SagaUtils.checkSagaIsInstalled()
def checkBeforeOpeningParametersDialog(self):
return SagaUtils.checkSagaIsInstalled()


def checkParameterValuesBeforeExecuting(self):
Expand Down
39 changes: 21 additions & 18 deletions python/plugins/sextante/saga/SagaUtils.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
* *
***************************************************************************
"""
from sextante.tests.TestData import points

__author__ = 'Victor Olaya'
__date__ = 'August 2012'
Expand Down Expand Up @@ -132,25 +133,27 @@ def checkSagaIsInstalled(cls):
return

try:
qgis = QGisLayers.iface
crs = qgis.mapCanvas().mapRenderer().destinationCrs()
fields = []
fields.append(QgsField("NUM_FIELD", QVariant.Int))
filename = SextanteUtils.getTempFilename("shp")
writer = SextanteVectorWriter(filename, None, fields, QGis.WKBPoint, crs)
for x in range(5):
for y in range(5):
attrs = []
attrs.append(QVariant(x))
outFeat = QgsFeature()
pt = QgsPoint(x, y)
outFeat.setGeometry(QgsGeometry.fromPoint(pt))
outFeat.setAttributes(attrs)
writer.addFeature(outFeat)
del writer.writer
del writer
#===================================================================
# qgis = QGisLayers.iface
# crs = qgis.mapCanvas().mapRenderer().destinationCrs()
# fields = []
# fields.append(QgsField("NUM_FIELD", QVariant.Int))
# filename = SextanteUtils.getTempFilename("shp")
# writer = SextanteVectorWriter(filename, None, fields, QGis.WKBPoint, crs)
# for x in range(5):
# for y in range(5):
# attrs = []
# attrs.append(QVariant(x))
# outFeat = QgsFeature()
# pt = QgsPoint(x, y)
# outFeat.setGeometry(QgsGeometry.fromPoint(pt))
# outFeat.setAttributes(attrs)
# writer.addFeature(outFeat)
# del writer.writer
# del writer
#===================================================================
from sextante.core.Sextante import runalg
result = runalg("saga:thiessenpolygons", filename, None)
result = runalg("saga:thiessenpolygons", points(), None)
if not os.path.exists(result['POLYGONS']):
return "It seems that SAGA is not correctly installed in your system.\nPlease install it before running SAGA algorithms."
except:
Expand Down

0 comments on commit 0dd7602

Please sign in to comment.