Skip to content

Commit 983535f

Browse files
committed
fixed #6571, #6619 and problem with missing arrows in modeler
added first draft of geoserver tools nviz is back in grass tools
1 parent a4e4999 commit 983535f

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

46 files changed

+4203
-278
lines changed

.gitignore

+3-1
Original file line numberDiff line numberDiff line change
@@ -45,4 +45,6 @@ qgis-test.ctest
4545
i18n/*.qm
4646
.project
4747
.pydevproject
48-
.idea
48+
.idea
49+
/python/plugins/sextante/resources_rc.py
50+
/python/plugins/sextante/about/ui_aboutdialogbase.py

python/plugins/sextante/core/Sextante.py

+2
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
* *
1717
***************************************************************************
1818
"""
19+
from sextante.servertools.GeoServerToolsAlgorithmProvider import GeoServerToolsAlgorithmProvider
1920

2021

2122
__author__ = 'Victor Olaya'
@@ -130,6 +131,7 @@ def initialize():
130131
Sextante.addProvider(GrassAlgorithmProvider())
131132
Sextante.addProvider(ScriptAlgorithmProvider())
132133
Sextante.addProvider(TauDEMAlgorithmProvider())
134+
Sextante.addProvider(GeoServerToolsAlgorithmProvider())
133135
Sextante.modeler.initializeSettings();
134136
#and initialize
135137
SextanteLog.startLogging()
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
# -*- coding: utf-8 -*-
2+
3+
"""
4+
***************************************************************************
5+
DatabaseToolProvider.py
6+
---------------------
7+
Date : October 2012
8+
Copyright : (C) 2012 by Victor Olaya
9+
Email : volayaf at gmail dot com
10+
***************************************************************************
11+
* *
12+
* This program is free software; you can redistribute it and/or modify *
13+
* it under the terms of the GNU General Public License as published by *
14+
* the Free Software Foundation; either version 2 of the License, or *
15+
* (at your option) any later version. *
16+
* *
17+
***************************************************************************
18+
"""
19+
20+
__author__ = 'Victor Olaya'
21+
__date__ = 'October 2012'
22+
__copyright__ = '(C) 2012, Victor Olaya'
23+
# This will get replaced with a git SHA1 when you do a git archive
24+
__revision__ = '$Format:%H$'
25+
26+
from sextante.core.AlgorithmProvider import AlgorithmProvider
27+
from PyQt4 import QtGui
28+
import os
29+
30+
class DatabaseToolsAlgorithmProvider(AlgorithmProvider):
31+
32+
def __init__(self):
33+
AlgorithmProvider.__init__(self)
34+
self.alglist = []#PostGISSQL(), ImportIntoPostGIS(), CreateTable()]
35+
36+
def initializeSettings(self):
37+
AlgorithmProvider.initializeSettings(self)
38+
39+
40+
def unload(self):
41+
AlgorithmProvider.unload(self)
42+
43+
44+
def getName(self):
45+
return "database"
46+
47+
def getDescription(self):
48+
return "Database tools"
49+
50+
def getIcon(self):
51+
return QtGui.QIcon(os.path.dirname(__file__) + "/../images/postgis.png")
52+
53+
def _loadAlgorithms(self):
54+
self.algs = self.alglist
55+
56+
def supportsNonFileBasedOutput(self):
57+
return True

python/plugins/sextante/database/__init__.py

Whitespace-only changes.

python/plugins/sextante/gdal/translate.py

+6
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
* *
1717
***************************************************************************
1818
"""
19+
from sextante.parameters.ParameterString import ParameterString
1920

2021
__author__ = 'Victor Olaya'
2122
__date__ = 'August 2012'
@@ -34,6 +35,7 @@ class translate(GeoAlgorithm):
3435

3536
INPUT = "INPUT"
3637
OUTPUT = "OUTPUT"
38+
EXTRA = "EXTRA"
3739

3840
def getIcon(self):
3941
filepath = os.path.dirname(__file__) + "/icons/translate.png"
@@ -43,14 +45,18 @@ def defineCharacteristics(self):
4345
self.name = "translate"
4446
self.group = "Conversion"
4547
self.addParameter(ParameterRaster(translate.INPUT, "Input layer", False))
48+
self.addParameter(ParameterString(translate.EXTRA, "Additional creation parameters"))
4649
self.addOutput(OutputRaster(translate.OUTPUT, "Output layer"))
4750

4851
def processAlgorithm(self, progress):
4952
commands = ["gdal_translate"]
5053
commands.append("-of")
5154
out = self.getOutputValue(translate.OUTPUT)
55+
extra = self.getOutputValue(translate.EXTRA)
5256
commands.append(GdalUtils.getFormatShortNameFromFilename(out))
57+
commands.append(extra)
5358
commands.append(self.getParameterValue(translate.INPUT))
5459
commands.append(out)
60+
5561

5662
GdalUtils.runGdal(commands, progress)

python/plugins/sextante/grass/GrassAlgorithmProvider.py

+2-5
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
* *
1717
***************************************************************************
1818
"""
19+
from sextante.grass.nviz import nviz
1920

2021
__author__ = 'Victor Olaya'
2122
__date__ = 'August 2012'
@@ -37,10 +38,6 @@ class GrassAlgorithmProvider(AlgorithmProvider):
3738

3839
def __init__(self):
3940
AlgorithmProvider.__init__(self)
40-
#=======================================================================
41-
# self.actions.append(DefineGrassRegionAction())
42-
# self.actions.append(DefineGrassRegionFromLayerAction())
43-
#=======================================================================
4441
self.createAlgsList() #preloading algorithms to speed up
4542

4643
def initializeSettings(self):
@@ -76,7 +73,7 @@ def createAlgsList(self):
7673
SextanteLog.addToLog(SextanteLog.LOG_ERROR, "Could not open GRASS algorithm: " + descriptionFile)
7774
except Exception,e:
7875
SextanteLog.addToLog(SextanteLog.LOG_ERROR, "Could not open GRASS algorithm: " + descriptionFile)
79-
#self.preloadedAlgs.append(nviz())
76+
self.preloadedAlgs.append(nviz())
8077

8178
def _loadAlgorithms(self):
8279
self.algs = self.preloadedAlgs

python/plugins/sextante/gui/ParametersPanel.py

-1
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,6 @@
5454
from sextante.outputs.OutputRaster import OutputRaster
5555
from sextante.outputs.OutputTable import OutputTable
5656
from sextante.outputs.OutputVector import OutputVector
57-
from sextante.outputs.OutputNumber import OutputNumber
5857
from sextante.parameters.ParameterString import ParameterString
5958

6059
class ParametersPanel(QtGui.QWidget):
744 Bytes
Loading

python/plugins/sextante/modeler/ModelerAlgorithm.py

+3
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
* *
1717
***************************************************************************
1818
"""
19+
from sextante.outputs.OutputString import OutputString
1920

2021
__author__ = 'Victor Olaya'
2122
__date__ = 'August 2012'
@@ -436,6 +437,8 @@ def getOutputType(self, i, outname):
436437
return "output html"
437438
elif isinstance(out, OutputNumber):
438439
return "output number"
440+
elif isinstance(out, OutputString):
441+
return "output string"
439442

440443

441444
def getAsPythonCode(self):

python/plugins/sextante/modeler/ModelerArrowItem.py

+9-4
Original file line numberDiff line numberDiff line change
@@ -64,10 +64,14 @@ def endItem(self):
6464
return self.myEndItem
6565

6666
def boundingRect(self):
67-
extra = (self.pen().width() + 20) / 2.0
68-
p1 = self.line().p1()
69-
p2 = self.line().p2()
70-
return QtCore.QRectF(p1, QtCore.QSizeF(p2.x() - p1.x(), p2.y() - p1.y())).normalized().adjusted(-extra, -extra, extra, extra)
67+
#this is a quick fix to avoid arrows not being drawn
68+
return QtCore.QRectF(0, 0, 4000,4000)
69+
#=======================================================================
70+
# extra = (self.pen().width() + 20) / 2.0
71+
# p1 = self.line().p1()
72+
# p2 = self.line().p2()
73+
# return QtCore.QRectF(p1, QtCore.QSizeF(p2.x() - p1.x(), p2.y() - p1.y())).normalized().adjusted(-extra, -extra, extra, extra)
74+
#=======================================================================
7175

7276
def shape(self):
7377
path = super(ModelerArrowItem, self).shape()
@@ -123,3 +127,4 @@ def paint(self, painter, option, widget=None):
123127

124128
painter.drawLine(line)
125129
painter.drawPolygon(self.arrowHead)
130+

python/plugins/sextante/modeler/ModelerParametersDialog.py

+15
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
***************************************************************************
1818
"""
1919
from sextante.parameters.ParameterCrs import ParameterCrs
20+
from sextante.outputs.OutputString import OutputString
2021

2122
__author__ = 'Victor Olaya'
2223
__date__ = 'August 2012'
@@ -317,6 +318,20 @@ def getStrings(self):
317318
for param in params:
318319
if isinstance(param, ParameterString):
319320
strings.append(AlgorithmAndParameter(AlgorithmAndParameter.PARENT_MODEL_ALGORITHM, param.name, "", param.description))
321+
322+
if self.algIndex is None:
323+
dependent = []
324+
else:
325+
dependent = self.model.getDependentAlgorithms(self.algIndex)
326+
dependent.append(self.algIndex)
327+
328+
i=0
329+
for alg in self.model.algs:
330+
if i not in dependent:
331+
for out in alg.outputs:
332+
if isinstance(out, OutputString):
333+
strings.append(AlgorithmAndParameter(i, out.name, alg.name, out.description))
334+
i+=1
320335
return strings
321336

322337
def getTableFields(self):

python/plugins/sextante/modeler/ModelerScene.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ def __init__(self, parent=None):
3737
super(ModelerScene, self).__init__(parent)
3838
self.paramItems = []
3939
self.algItems = []
40+
self.setItemIndexMethod(QtGui.QGraphicsScene.NoIndex);
4041

4142
def getParameterPositions(self):
4243
pos = []
@@ -116,8 +117,7 @@ def paintModel(self, model):
116117
for sourceItem in sourceItems:
117118
arrow = ModelerArrowItem(sourceItem, self.algItems[iAlg])
118119
self.addItem(arrow)
119-
iAlg+=1
120-
120+
iAlg+=1
121121

122122
def mousePressEvent(self, mouseEvent):
123123
if (mouseEvent.button() != QtCore.Qt.LeftButton):

python/plugins/sextante/modeler/ModelerUtils.py

+1-3
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@
2424
__revision__ = '$Format:%H$'
2525

2626
import os
27-
from sextante.core.SextanteUtils import SextanteUtils
2827
from sextante.core.SextanteUtils import mkdir
2928
from sextante.core.SextanteConfig import SextanteConfig
3029

@@ -37,8 +36,7 @@ class ModelerUtils:
3736
def modelsFolder():
3837
folder = SextanteConfig.getSetting(ModelerUtils.MODELS_FOLDER)
3938
if folder == None:
40-
#folder = os.path.join(os.path.dirname(__file__), "models")
41-
folder = SextanteUtils.userFolder() + os.sep + "models"
39+
folder = os.path.join(os.path.dirname(__file__), "models")
4240
mkdir(folder)
4341

4442
return folder
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
NAME:Watersheds from DEM
2+
GROUP:[Sample models]
3+
PARAMETER:ParameterRaster|RASTERLAYER_DEM|DEM|False
4+
458.0,50.0
5+
PARAMETER:ParameterNumber|NUMBER_INITIATIONTHRESHOLD|Initiation Threshold|None|None|10000000.0
6+
257.0,403.0
7+
VALUE:HARDCODEDPARAMVALUE_INIT_VALUE_1===10000000
8+
VALUE:HARDCODEDPARAMVALUE_SPLIT_3===0
9+
VALUE:HARDCODEDPARAMVALUE_Method_0===0
10+
VALUE:HARDCODEDPARAMVALUE_INIT_METHOD_1===2
11+
VALUE:HARDCODEDPARAMVALUE_CALC_METHOD_4===0
12+
VALUE:HARDCODEDPARAMVALUE_CLASS_ID_3===0
13+
VALUE:HARDCODEDPARAMVALUE_STEP_0===1
14+
VALUE:HARDCODEDPARAMVALUE_MINLEN_1===10
15+
VALUE:HARDCODEDPARAMVALUE_DOLINEAR _0===True
16+
VALUE:HARDCODEDPARAMVALUE_MINSIZE_2===0
17+
VALUE:HARDCODEDPARAMVALUE_CLASS_ALL_3===1
18+
VALUE:HARDCODEDPARAMVALUE_LINEARTHRS_0===500.0
19+
VALUE:HARDCODEDPARAMVALUE_CONVERGENCE_0===1.0
20+
VALUE:HARDCODEDPARAMVALUE_DIV_CELLS_1===10
21+
ALGORITHM:saga:catchmentarea(parallel)
22+
260.0,172.0
23+
-1|RASTERLAYER_DEM
24+
None
25+
None
26+
None
27+
None
28+
-1|HARDCODEDPARAMVALUE_STEP_0
29+
-1|HARDCODEDPARAMVALUE_Method_0
30+
-1|HARDCODEDPARAMVALUE_DOLINEAR _0
31+
-1|HARDCODEDPARAMVALUE_LINEARTHRS_0
32+
None
33+
None
34+
-1|HARDCODEDPARAMVALUE_CONVERGENCE_0
35+
None
36+
None
37+
None
38+
None
39+
None
40+
None
41+
None
42+
None
43+
ALGORITHM:saga:channelnetwork
44+
447.0,291.0
45+
-1|RASTERLAYER_DEM
46+
None
47+
0|CAREA
48+
-1|HARDCODEDPARAMVALUE_INIT_METHOD_1
49+
-1|NUMBER_INITIATIONTHRESHOLD
50+
None
51+
-1|HARDCODEDPARAMVALUE_DIV_CELLS_1
52+
None
53+
-1|HARDCODEDPARAMVALUE_MINLEN_1
54+
None
55+
None
56+
None
57+
ALGORITHM:saga:watershedbasins
58+
730.0,182.0
59+
-1|RASTERLAYER_DEM
60+
1|CHNLNTWRK
61+
None
62+
-1|HARDCODEDPARAMVALUE_MINSIZE_2
63+
None
64+
ALGORITHM:saga:vectorisinggridclasses
65+
864.0,330.0
66+
2|BASINS
67+
-1|HARDCODEDPARAMVALUE_CLASS_ALL_3
68+
-1|HARDCODEDPARAMVALUE_CLASS_ID_3
69+
-1|HARDCODEDPARAMVALUE_SPLIT_3
70+
None
71+
ALGORITHM:ftools:export/addgeometrycolumns
72+
655.0,442.0
73+
3|POLYGONS
74+
-1|HARDCODEDPARAMVALUE_CALC_METHOD_4
75+
Watersheds

python/plugins/sextante/outputs/OutputFactory.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616
* *
1717
***************************************************************************
1818
"""
19-
2019
__author__ = 'Victor Olaya'
2120
__date__ = 'August 2012'
2221
__copyright__ = '(C) 2012, Victor Olaya'
@@ -29,12 +28,13 @@
2928
from sextante.outputs.OutputVector import OutputVector
3029
from sextante.outputs.OutputNumber import OutputNumber
3130
from sextante.outputs.OutputFile import OutputFile
31+
from sextante.outputs.OutputString import OutputString
3232

3333
class OutputFactory():
3434

3535
@staticmethod
3636
def getFromString(s):
37-
classes = [OutputRaster, OutputVector, OutputTable, OutputHTML, OutputNumber, OutputFile]
37+
classes = [OutputRaster, OutputVector, OutputTable, OutputHTML, OutputNumber, OutputFile, OutputString]
3838
for clazz in classes:
3939
if s.startswith(clazz().outputTypeName()):
4040
tokens = s[len(clazz().outputTypeName())+1:].split("|")

0 commit comments

Comments
 (0)