Skip to content
Permalink
Browse files

Merge branch 'master' of github.com:qgis/Quantum-GIS

  • Loading branch information
kyngchaos committed Apr 1, 2013
2 parents 3d15e67 + af7d6f8 commit 4f6c2d253cdb1cd7313a05ca4d0b5935a78cbd99
@@ -192,15 +192,16 @@ tar -C %OSGEO4W_ROOT% -cjf %PACKAGENAME%-common-%VERSION%-%PACKAGE%.tar.bz2 ^
"apps/%PACKAGENAME%/plugins/gdalprovider.dll" ^
"apps/%PACKAGENAME%/plugins/gpxprovider.dll" ^
"apps/%PACKAGENAME%/plugins/memoryprovider.dll" ^
"apps/%PACKAGENAME%/plugins/mssqlprovider.dll" ^
"apps/%PACKAGENAME%/plugins/ogrprovider.dll" ^
"apps/%PACKAGENAME%/plugins/osmprovider.dll" ^
"apps/%PACKAGENAME%/plugins/owsprovider.dll" ^
"apps/%PACKAGENAME%/plugins/postgresprovider.dll" ^
"apps/%PACKAGENAME%/plugins/qgissqlanyconnection.dll" ^
"apps/%PACKAGENAME%/plugins/spatialiteprovider.dll" ^
"apps/%PACKAGENAME%/plugins/sqlanywhereprovider.dll" ^
"apps/%PACKAGENAME%/plugins/qgissqlanyconnection.dll" ^
"apps/%PACKAGENAME%/plugins/wcsprovider.dll" ^
"apps/%PACKAGENAME%/plugins/wfsprovider.dll" ^
"apps/%PACKAGENAME%/plugins/wmsprovider.dll" ^
"apps/%PACKAGENAME%/plugins/mssqlprovider.dll" ^
"apps/%PACKAGENAME%/resources/qgis.db" ^
"apps/%PACKAGENAME%/resources/spatialite.db" ^
"apps/%PACKAGENAME%/resources/srs.db" ^
@@ -241,6 +242,7 @@ tar -C %OSGEO4W_ROOT% -cjf %PACKAGENAME%-%VERSION%-%PACKAGE%.tar.bz2 ^
"apps/%PACKAGENAME%/plugins/evis.dll" ^
"apps/%PACKAGENAME%/plugins/georefplugin.dll" ^
"apps/%PACKAGENAME%/plugins/gpsimporterplugin.dll" ^
"apps/%PACKAGENAME%/plugins/heatmapplugin.dll" ^
"apps/%PACKAGENAME%/plugins/interpolationplugin.dll" ^
"apps/%PACKAGENAME%/plugins/offlineeditingplugin.dll" ^
"apps/%PACKAGENAME%/plugins/oracleplugin.dll" ^
@@ -249,8 +251,8 @@ tar -C %OSGEO4W_ROOT% -cjf %PACKAGENAME%-%VERSION%-%PACKAGE%.tar.bz2 ^
"apps/%PACKAGENAME%/plugins/spatialqueryplugin.dll" ^
"apps/%PACKAGENAME%/plugins/spitplugin.dll" ^
"apps/%PACKAGENAME%/plugins/sqlanywhereplugin.dll" ^
"apps/%PACKAGENAME%/plugins/topolplugin.dll" ^
"apps/%PACKAGENAME%/plugins/zonalstatisticsplugin.dll" ^
"apps/%PACKAGENAME%/plugins/heatmapplugin.dll" ^
"apps/%PACKAGENAME%/qgis_help.exe" ^
"apps/qt4/plugins/sqldrivers/qsqlspatialite.dll" ^
"apps/%PACKAGENAME%/python/" ^
@@ -273,6 +275,7 @@ tar -C %OSGEO4W_ROOT% -cjf %PACKAGENAME%-grass-plugin-%VERSION%-%PACKAGE%.tar.bz
"apps/%PACKAGENAME%/plugins/grassrasterprovider.dll" ^
"apps/%PACKAGENAME%/plugins/grassplugin.dll" ^
"apps/%PACKAGENAME%/plugins/grassprovider.dll" ^
"apps/%PACKAGENAME%/plugins/libgrass_gis.%GRASS_VERSION%.dll" ^
>>%LOG% 2>&1
if errorlevel 1 goto error

@@ -314,3 +317,4 @@ if exist %PACKAGENAME%-oracle-provider-%VERSION%-%PACKAGE%.tar.bz2 del %PACKAGEN

:end
echo FINISHED: %DATE% %TIME% >>%LOG% 2>&1

@@ -84,6 +84,19 @@ def getName(self):

def getIcon(self):
return QIcon(os.path.dirname(__file__) + "/../images/grass.png")

def getPostProcessingErrorMessage(self, wrongLayers):
html = AlgorithmProvider.getPostProcessingErrorMessage(self, wrongLayers)
msg = GrassUtils.checkGrassIsInstalled(True)
html += ("<p>This algorithm requires GRASS to be run. A test to check if GRASS is correctly installed "
"and configured in your system has been performed, with the following result:</p><ul><i>")
if msg is None:
html += "GRASS seems to be correctly installed and configured</li></ul>"
else:
html += msg + "</i></li></ul>"
html += '<p><a href= "http://docs.qgis.org/html/en/docs/user_manual/sextante/3rdParty.html">Click here</a> to know more about how to install and configure GRASS to be used with SEXTANTE</p>'

return html

def getSupportedOutputVectorLayerExtensions(self):
return ["shp"]
@@ -16,6 +16,8 @@
* *
***************************************************************************
"""
from sextante.tests.TestData import points
import traceback

__author__ = 'Victor Olaya'
__date__ = 'August 2012'
@@ -323,6 +325,34 @@ def getSessionLayers():
def addSessionLayers(exportedLayers):
GrassUtils.sessionLayers = dict(GrassUtils.sessionLayers.items() + exportedLayers.items())

@staticmethod
def checkGrassIsInstalled(ignoreRegistrySettings=False):
if SextanteUtils.isWindows():
path = GrassUtils.grassPath()
if path == "":
return "GRASS folder is not configured.\nPlease configure it before running SAGA algorithms."
cmdpath = os.path.join(path, "bin\r.out.exe")
if not os.path.exists(cmdpath):
return ("The specified GRASS folder does not contain a valid set of GRASS modules.\n"
+ "Please, go to the SEXTANTE settings dialog, and check that the GRASS\n"
+ "folder is correctly configured")

if not ignoreRegistrySettings:
GRASS_INSTALLED = "/SextanteQGIS/GrassInstalled"
settings = QSettings()
if settings.contains(GRASS_INSTALLED):
return

try:
from sextante.core.Sextante import runalg
result = runalg("grass:v.voronoi", points(),False,False,"270778.60198,270855.745301,4458921.97814,4458983.8488",-1,0.0001,None)
if not os.path.exists(result['output']):
return "It seems that GRASS is not correctly installed and configured in your system.\nPlease install it before running GRASS algorithms."
except:
s = traceback.format_exc()
return "Error while checking GRASS installation. GRASS might not be correctly configured.\n" + s;

settings.setValue(GRASS_INSTALLED, True)



@@ -151,13 +151,16 @@ def fillTree(self):

def addRecentAlgorithms(self, updating):
showRecent = SextanteConfig.getSetting(SextanteConfig.SHOW_RECENT_ALGORITHMS)
if showRecent:
first = self.algorithmTree.topLevelItem(0)
if updating:
self.algorithmTree.removeItemWidget(first, 0)
if showRecent:
recent = SextanteLog.getRecentAlgorithms()
if len(recent) != 0:
found = False
if updating:
recentItem = self.algorithmTree.topLevelItem(0)
treeWidget = recentItem.treeWidget()
treeWidget.takeTopLevelItem(treeWidget.indexOfTopLevelItem(recentItem))
#self.algorithmTree.removeItemWidget(first, 0)

recentItem = QTreeWidgetItem()
recentItem.setText(0, self.tr("Recently used algorithms"))
for algname in recent:
@@ -166,13 +169,12 @@ def addRecentAlgorithms(self, updating):
algItem = TreeAlgorithmItem(alg)
recentItem.addChild(algItem)
found = True
if found:
if found:
self.algorithmTree.insertTopLevelItem(0, recentItem)
recentItem.setExpanded(True)

self.algorithmTree.setWordWrap(True)


def fillTreeUsingCategories(self):
providersToExclude = ["model", "script"]
self.algorithmTree.clear()
@@ -59,7 +59,7 @@ def getCopy(self):
newone = ModelerAlgorithm()
newone.openModel(self.descriptionFile)
newone.provider = self.provider
newone.deactivated = self.deactivate
newone.deactivated = self.deactivated
return newone

def __init__(self):
@@ -0,0 +1,39 @@
NAME:Model with algorithms not in running order
GROUP:[Test algorithms]
PARAMETER:ParameterRaster|RASTERLAYER_RASTER|raster|False
120.0,60.0
VALUE:HARDCODEDPARAMVALUE_MINSLOPE_1===0.01
VALUE:HARDCODEDPARAMVALUE_Method_0===0
VALUE:HARDCODEDPARAMVALUE_STEP_0===1
VALUE:HARDCODEDPARAMVALUE_DOLINEAR _0===True
VALUE:HARDCODEDPARAMVALUE_LINEARTHRS_0===500.0
VALUE:HARDCODEDPARAMVALUE_CONVERGENCE_0===1.0
ALGORITHM:saga:catchmentareaparallel
154.0,415.0
None
1|RESULT
None
None
None
None
-1|HARDCODEDPARAMVALUE_STEP_0
-1|HARDCODEDPARAMVALUE_Method_0
-1|HARDCODEDPARAMVALUE_DOLINEAR _0
-1|HARDCODEDPARAMVALUE_LINEARTHRS_0
None
None
-1|HARDCODEDPARAMVALUE_CONVERGENCE_0
None
None
None
None
None
None
None
None
ALGORITHM:saga:fillsinksplanchondarboux2001
340.0,260.0
None
-1|RASTERLAYER_RASTER
-1|HARDCODEDPARAMVALUE_MINSLOPE_1
None
@@ -8,7 +8,6 @@ ParameterString|-mask|Mask expression|
ParameterString|-expr|Connected Component Expression|
ParameterNumber|-minsize|Minimum Object Size|None|None|2
ParameterString|-obia|OBIA Expression|
ParameterSelection|-elev|Elevation management|dem;average|1
ParameterFile|-elev.dem.path|DEM directory|
ParameterFile|-elev.dem.geoid|Geoid File||
ParameterNumber|-elev.average.value|Average Elevation|None|None|0.0
ParameterFile|-elev.dem|DEM directory|True
ParameterFile|-elev.geoid|Geoid File||True
ParameterNumber|-elev.default|Average Elevation|None|None|0.0
@@ -5,6 +5,6 @@ Learning
ParameterRaster|-in|Input Image|False
ParameterRaster|-mask|Input Mask|True
ParameterFile|-svm|SVM Model file||
ParameterFile|-imstat|Statistics file||
ParameterFile|-imstat|Statistics file|
OutputRaster|-out|Output Image
ParameterNumber|-ram|Available RAM (Mb)|None|None|128
@@ -7,9 +7,9 @@ ParameterMultipleInput|-io.vd|Vector Data List|-1|False
ParameterFile|-io.imstat|XML image statistics file|
OutputFile|-io.out|Output SVM model
*ParameterSelection|-elev|Elevation management|dem;average|1
*ParameterFile|-elev.dem.path|DEM directory|
*ParameterFile|-elev.dem.geoid|Geoid File|
*ParameterNumber|-elev.average.value|Average Elevation|None|None|0.0
*ParameterFile|-elev.dem|DEM directory|
*ParameterFile|-elev.geoid|Geoid File|
*ParameterNumber|-elev.default|Average Elevation|None|None|0.0
*ParameterNumber|-sample.mt|Maximum training sample size|None|None|-1
*ParameterNumber|-sample.mv|Maximum validation sample size|None|None|-1
*ParameterBoolean|-sample.edg|On edge pixel inclusion|
@@ -98,7 +98,7 @@ def getPostProcessingErrorMessage(self, wrongLayers):
html += ("<p>This algorithm requires SAGA to be run. A test to check if SAGA is correctly installed "
"and configured in your system has been performed, with the following result:</p><ul><i>")
if msg is None:
html += "Saga seems to be correctly installed and configured</li></ul>"
html += "SAGA seems to be correctly installed and configured</li></ul>"
else:
html += msg + "</i></li></ul>"
html += '<p><a href= "http://docs.qgis.org/html/en/docs/user_manual/sextante/3rdParty.html">Click here</a> to know more about how to install and configure SAGA to be used with SEXTANTE</p>'
@@ -142,4 +142,4 @@ def checkSagaIsInstalled(ignoreRegistrySettings=False):
s = traceback.format_exc()
return "Error while checking SAGA installation. SAGA might not be correctly configured.\n" + s;

settings.setValue("/SextanteQGIS/SagaInstalled", True)
settings.setValue(SAGA_INSTALLED, True)
@@ -32,7 +32,6 @@
from qgis.core import *
from PyQt4.QtCore import *
from PyQt4.QtGui import *
from sextante.core.QGisLayers import QGisLayers
from sextante.core.SextanteVectorWriter import SextanteVectorWriter

#Here we define the input and outputs
@@ -46,15 +45,15 @@

#input layers values are always a string with its location.
#That string can be converted into a QGIS object (a QgsVectorLayer in this case))
#using the Sextante.getObjectFromUri() method
vectorLayer = QGisLayers.getObjectFromUri(input)
#using the sextante.getobject() method
vectorLayer = sextante.getobject(input)

#And now we can process

#First we create the output layer.
#To do so, we create a SextanteVectorWriter, that we can later use to add features.
provider = vectorLayer.dataProvider()
writer = SextanteVectorWriter(output, None, provider.fields(), provider.geometryType(), vectorLayer.crs() )
writer = SextanteVectorWriter(output, None, provider.fields(), provider.geometryType(), vectorLayer.crs())

#Now we take the selected features and add them to the output layer
selection = vectorLayer.selectedFeatures()
@@ -0,0 +1,35 @@
##input=vector
##output=output vector
from sextante.core.SextanteVectorWriter import SextanteVectorWriter
from qgis.core import *
from PyQt4.QtCore import *

inputLayer = sextante.getobject(input)
features = sextante.getfeatures(inputLayer)
fields = inputLayer.pendingFields().toList()
outputLayer = SextanteVectorWriter(output, None, fields, QGis.WKBPoint, inputLayer.crs())
count = 0
mean = [0 for field in fields]
x = 0
y = 0
for ft in features:
c = ft.geometry().centroid().asPoint()
x += c.x()
y += c.y()
attrs = ft.attributes()
for f in range(len(fields)):
try:
mean[f] += float(attrs[f].toDouble()[0])
except:
pass
count += 1
if count != 0:
mean = [value / count for value in mean]
x /= count
y /= count
outFeat = QgsFeature()
meanPoint = QgsPoint(x, y)
outFeat.setGeometry(QgsGeometry.fromPoint(meanPoint))
outFeat.setAttributes([QVariant(v) for v in mean])
outputLayer.addFeature(outFeat)

@@ -108,6 +108,13 @@ def test_modelerfieldautoextent(self):
strhash=hash(str(dataset.ReadAsArray(0).tolist()))
self.assertEqual(strhash,2026100494)

def test_modelernotinorder(self):
outputs=sextante.runalg("modeler:notinorder",raster(),None)
output=outputs['CAREA_ALG0']
self.assertTrue(os.path.isfile(output))
dataset=gdal.Open(output, GA_ReadOnly)
strhash=hash(str(dataset.ReadAsArray(0).tolist()))
self.assertEqual(strhash,-1557050506)


def suite():
@@ -2,18 +2,37 @@
import unittest
from sextante.tests.TestData import points, points2, polygons, polygons2, lines, union,\
table, polygonsGeoJson
table, polygonsGeoJson, raster
from sextante.core.QGisLayers import QGisLayers
from sextante.core.SextanteUtils import SextanteUtils
from osgeo.gdalconst import GA_ReadOnly
import os
from osgeo import gdal

class SagaTest(unittest.TestCase):
'''tests for saga algorithms'''

def test_sagametricconversions(self):
outputs=sextante.runalg("saga:metricconversions",raster(),0,None)
output=outputs['CONV']
self.assertTrue(os.path.isfile(output))
dataset=gdal.Open(output, GA_ReadOnly)
strhash=hash(str(dataset.ReadAsArray(0).tolist()))
self.assertEqual(strhash,-2137931723)

def test_sagasortgrid(self):
outputs=sextante.runalg("saga:sortgrid",raster(),True,None)
output=outputs['OUTPUT']
self.assertTrue(os.path.isfile(output))
dataset=gdal.Open(output, GA_ReadOnly)
strhash=hash(str(dataset.ReadAsArray(0).tolist()))
self.assertEqual(strhash,1320073153)

'''the following tests are not meant to test the algorithms themselves,
but the algorithm provider, testing things such as the file conversion,
'''the following tests are not meant to test the algorithms themselves,
but the algorithm provider, testing things such as the file conversion,
the selection awareness of SAGA process, etc'''

def test_SagaVvectorAlgorithmWithSelection(self):
def test_SagaVectorAlgorithmWithSelection(self):
layer = sextante.getobject(polygons2());
feature = layer.getFeatures().next()
selected = [feature.id()]
@@ -63,7 +82,13 @@ def test_SagaVectorAlgorithWithUnsupportedInputAndOutputFormat(self):
self.assertEqual(expectedvalues, values)
wkt='POINT(270787.49991451 4458955.46775295)'
self.assertEqual(wkt, str(feature.geometry().exportToWkt()))

def test_SagaRasterAlgorithmWithUnsupportedOutputFormat(self):
outputs=sextante.runalg("saga:convergenceindex",raster(),0,0,None)
output=outputs['RESULT']
self.assertTrue(os.path.isfile(output))
dataset=gdal.Open(output, GA_ReadOnly)
strhash=hash(str(dataset.ReadAsArray(0).tolist()))
self.assertEqual(strhash,485390137)



0 comments on commit 4f6c2d2

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