Skip to content

Commit

Permalink
Merge branch 'master' of github.com:qgis/Quantum-GIS
Browse files Browse the repository at this point in the history
  • Loading branch information
kyngchaos committed Apr 1, 2013
2 parents 3d15e67 + af7d6f8 commit 4f6c2d2
Show file tree
Hide file tree
Showing 15 changed files with 182 additions and 29 deletions.
12 changes: 8 additions & 4 deletions ms-windows/osgeo4w/package.cmd
Original file line number Diff line number Diff line change
Expand Up @@ -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" ^
Expand Down Expand Up @@ -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" ^
Expand All @@ -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/" ^
Expand All @@ -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

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

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

13 changes: 13 additions & 0 deletions python/plugins/sextante/grass/GrassAlgorithmProvider.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"]
Expand Down
30 changes: 30 additions & 0 deletions python/plugins/sextante/grass/GrassUtils.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@
* *
***************************************************************************
"""
from sextante.tests.TestData import points
import traceback

__author__ = 'Victor Olaya'
__date__ = 'August 2012'
Expand Down Expand Up @@ -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)



Expand Down
14 changes: 8 additions & 6 deletions python/plugins/sextante/gui/SextanteToolbox.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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()
Expand Down
2 changes: 1 addition & 1 deletion python/plugins/sextante/modeler/ModelerAlgorithm.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
39 changes: 39 additions & 0 deletions python/plugins/sextante/modeler/models/notinorder.model
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
Expand Up @@ -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
Original file line number Diff line number Diff line change
Expand Up @@ -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
Original file line number Diff line number Diff line change
Expand Up @@ -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|
Expand Down
2 changes: 1 addition & 1 deletion python/plugins/sextante/saga/SagaAlgorithmProvider.py
Original file line number Diff line number Diff line change
Expand Up @@ -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>'
Expand Down
2 changes: 1 addition & 1 deletion python/plugins/sextante/saga/SagaUtils.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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()
Expand Down
35 changes: 35 additions & 0 deletions python/plugins/sextante/script/scripts/Summarize.py
Original file line number Diff line number Diff line change
@@ -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)

7 changes: 7 additions & 0 deletions python/plugins/sextante/tests/ModelerAlgorithmTest.py
Original file line number Diff line number Diff line change
Expand Up @@ -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():
Expand Down
33 changes: 29 additions & 4 deletions python/plugins/sextante/tests/SagaTest.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()]
Expand Down Expand Up @@ -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)



Expand Down

0 comments on commit 4f6c2d2

Please sign in to comment.