Skip to content
Permalink
Browse files

fixed #6571, #6619 and problem with missing arrows in modeler

added first draft of geoserver tools
nviz is back in grass tools
  • Loading branch information
volaya committed Nov 5, 2012
1 parent a4e4999 commit 983535fa58bd001fc9b624e9c44cae5dbfe6e9e5
Showing with 4,203 additions and 278 deletions.
  1. +3 −1 .gitignore
  2. +2 −0 python/plugins/sextante/core/Sextante.py
  3. +57 −0 python/plugins/sextante/database/DatabaseToolsAlgorithmProvider.py
  4. 0 python/plugins/sextante/database/__init__.py
  5. +6 −0 python/plugins/sextante/gdal/translate.py
  6. +2 −5 python/plugins/sextante/grass/GrassAlgorithmProvider.py
  7. +0 −1 python/plugins/sextante/gui/ParametersPanel.py
  8. BIN python/plugins/sextante/images/geoserver.png
  9. +3 −0 python/plugins/sextante/modeler/ModelerAlgorithm.py
  10. +9 −4 python/plugins/sextante/modeler/ModelerArrowItem.py
  11. +15 −0 python/plugins/sextante/modeler/ModelerParametersDialog.py
  12. +2 −2 python/plugins/sextante/modeler/ModelerScene.py
  13. +1 −3 python/plugins/sextante/modeler/ModelerUtils.py
  14. +75 −0 python/plugins/sextante/modeler/models/watersheds.model
  15. +2 −2 python/plugins/sextante/outputs/OutputFactory.py
  16. +15 −19 python/plugins/{sextanteexampleprovider/__init__.py → sextante/outputs/OutputString.py}
  17. +1 −1 python/plugins/sextante/pymorph/PymorphAlgorithmProvider.py
  18. +3 −1 python/plugins/sextante/r/EditRScriptDialog.py
  19. +2 −0 python/plugins/sextante/script/EditScriptDialog.py
  20. +61 −0 python/plugins/sextante/servertools/CreateMosaicDatastore.py
  21. +56 −0 python/plugins/sextante/servertools/CreateWorkspace.py
  22. +56 −0 python/plugins/sextante/servertools/DeleteDatastore.py
  23. +53 −0 python/plugins/sextante/servertools/DeleteWorkspace.py
  24. +52 −0 python/plugins/sextante/servertools/GeoServerToolsAlgorithm.py
  25. +63 −0 python/plugins/sextante/servertools/GeoServerToolsAlgorithmProvider.py
  26. +62 −0 python/plugins/sextante/servertools/ImportRasterIntoGeoServer.py
  27. +64 −0 python/plugins/sextante/servertools/ImportVectorIntoGeoServer.py
  28. 0 python/plugins/sextante/servertools/__init__.py
  29. 0 python/plugins/sextante/servertools/geoserver/__init__.py
  30. +504 −0 python/plugins/sextante/servertools/geoserver/catalog.py
  31. +132 −0 python/plugins/sextante/servertools/geoserver/layer.py
  32. +84 −0 python/plugins/sextante/servertools/geoserver/layergroup.py
  33. 0 python/plugins/sextante/servertools/geoserver/namespace.py
  34. +176 −0 python/plugins/sextante/servertools/geoserver/resource.py
  35. +117 −0 python/plugins/sextante/servertools/geoserver/store.py
  36. +46 −0 python/plugins/sextante/servertools/geoserver/style.py
  37. +218 −0 python/plugins/sextante/servertools/geoserver/support.py
  38. +5 −0 python/plugins/sextante/servertools/geoserver/util.py
  39. +33 −0 python/plugins/sextante/servertools/geoserver/workspace.py
  40. +1,675 −0 python/plugins/sextante/servertools/httplib2/__init__.py
  41. +110 −0 python/plugins/sextante/servertools/httplib2/iri2uri.py
  42. +438 −0 python/plugins/sextante/servertools/httplib2/socks.py
  43. +0 −104 python/plugins/sextanteexampleprovider/ExampleAlgorithm.py
  44. +0 −78 python/plugins/sextanteexampleprovider/ExampleAlgorithmProvider.py
  45. +0 −46 python/plugins/sextanteexampleprovider/SextanteExampleProviderPlugin.py
  46. +0 −11 python/plugins/sextanteexampleprovider/metadata.txt
@@ -45,4 +45,6 @@ qgis-test.ctest
i18n/*.qm
.project
.pydevproject
.idea
.idea
/python/plugins/sextante/resources_rc.py
/python/plugins/sextante/about/ui_aboutdialogbase.py
@@ -16,6 +16,7 @@
* *
***************************************************************************
"""
from sextante.servertools.GeoServerToolsAlgorithmProvider import GeoServerToolsAlgorithmProvider


__author__ = 'Victor Olaya'
@@ -130,6 +131,7 @@ def initialize():
Sextante.addProvider(GrassAlgorithmProvider())
Sextante.addProvider(ScriptAlgorithmProvider())
Sextante.addProvider(TauDEMAlgorithmProvider())
Sextante.addProvider(GeoServerToolsAlgorithmProvider())
Sextante.modeler.initializeSettings();
#and initialize
SextanteLog.startLogging()
@@ -0,0 +1,57 @@
# -*- coding: utf-8 -*-

"""
***************************************************************************
DatabaseToolProvider.py
---------------------
Date : October 2012
Copyright : (C) 2012 by Victor Olaya
Email : volayaf at gmail dot com
***************************************************************************
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
***************************************************************************
"""

__author__ = 'Victor Olaya'
__date__ = 'October 2012'
__copyright__ = '(C) 2012, Victor Olaya'
# This will get replaced with a git SHA1 when you do a git archive
__revision__ = '$Format:%H$'

from sextante.core.AlgorithmProvider import AlgorithmProvider
from PyQt4 import QtGui
import os

class DatabaseToolsAlgorithmProvider(AlgorithmProvider):

def __init__(self):
AlgorithmProvider.__init__(self)
self.alglist = []#PostGISSQL(), ImportIntoPostGIS(), CreateTable()]

def initializeSettings(self):
AlgorithmProvider.initializeSettings(self)


def unload(self):
AlgorithmProvider.unload(self)


def getName(self):
return "database"

def getDescription(self):
return "Database tools"

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

def _loadAlgorithms(self):
self.algs = self.alglist

def supportsNonFileBasedOutput(self):
return True
No changes.
@@ -16,6 +16,7 @@
* *
***************************************************************************
"""
from sextante.parameters.ParameterString import ParameterString

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

INPUT = "INPUT"
OUTPUT = "OUTPUT"
EXTRA = "EXTRA"

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

def processAlgorithm(self, progress):
commands = ["gdal_translate"]
commands.append("-of")
out = self.getOutputValue(translate.OUTPUT)
extra = self.getOutputValue(translate.EXTRA)
commands.append(GdalUtils.getFormatShortNameFromFilename(out))
commands.append(extra)
commands.append(self.getParameterValue(translate.INPUT))
commands.append(out)


GdalUtils.runGdal(commands, progress)
@@ -16,6 +16,7 @@
* *
***************************************************************************
"""
from sextante.grass.nviz import nviz

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

def __init__(self):
AlgorithmProvider.__init__(self)
#=======================================================================
# self.actions.append(DefineGrassRegionAction())
# self.actions.append(DefineGrassRegionFromLayerAction())
#=======================================================================
self.createAlgsList() #preloading algorithms to speed up

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

def _loadAlgorithms(self):
self.algs = self.preloadedAlgs
@@ -54,7 +54,6 @@
from sextante.outputs.OutputRaster import OutputRaster
from sextante.outputs.OutputTable import OutputTable
from sextante.outputs.OutputVector import OutputVector
from sextante.outputs.OutputNumber import OutputNumber
from sextante.parameters.ParameterString import ParameterString

class ParametersPanel(QtGui.QWidget):
Binary file not shown.
@@ -16,6 +16,7 @@
* *
***************************************************************************
"""
from sextante.outputs.OutputString import OutputString

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


def getAsPythonCode(self):
@@ -64,10 +64,14 @@ def endItem(self):
return self.myEndItem

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

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

painter.drawLine(line)
painter.drawPolygon(self.arrowHead)

@@ -17,6 +17,7 @@
***************************************************************************
"""
from sextante.parameters.ParameterCrs import ParameterCrs
from sextante.outputs.OutputString import OutputString

__author__ = 'Victor Olaya'
__date__ = 'August 2012'
@@ -317,6 +318,20 @@ def getStrings(self):
for param in params:
if isinstance(param, ParameterString):
strings.append(AlgorithmAndParameter(AlgorithmAndParameter.PARENT_MODEL_ALGORITHM, param.name, "", param.description))

if self.algIndex is None:
dependent = []
else:
dependent = self.model.getDependentAlgorithms(self.algIndex)
dependent.append(self.algIndex)

i=0
for alg in self.model.algs:
if i not in dependent:
for out in alg.outputs:
if isinstance(out, OutputString):
strings.append(AlgorithmAndParameter(i, out.name, alg.name, out.description))
i+=1
return strings

def getTableFields(self):
@@ -37,6 +37,7 @@ def __init__(self, parent=None):
super(ModelerScene, self).__init__(parent)
self.paramItems = []
self.algItems = []
self.setItemIndexMethod(QtGui.QGraphicsScene.NoIndex);

def getParameterPositions(self):
pos = []
@@ -116,8 +117,7 @@ def paintModel(self, model):
for sourceItem in sourceItems:
arrow = ModelerArrowItem(sourceItem, self.algItems[iAlg])
self.addItem(arrow)
iAlg+=1

iAlg+=1

def mousePressEvent(self, mouseEvent):
if (mouseEvent.button() != QtCore.Qt.LeftButton):
@@ -24,7 +24,6 @@
__revision__ = '$Format:%H$'

import os
from sextante.core.SextanteUtils import SextanteUtils
from sextante.core.SextanteUtils import mkdir
from sextante.core.SextanteConfig import SextanteConfig

@@ -37,8 +36,7 @@ class ModelerUtils:
def modelsFolder():
folder = SextanteConfig.getSetting(ModelerUtils.MODELS_FOLDER)
if folder == None:
#folder = os.path.join(os.path.dirname(__file__), "models")
folder = SextanteUtils.userFolder() + os.sep + "models"

This comment has been minimized.

Copy link
@slarosa

slarosa Nov 5, 2012

Member

Hi Victor, you should revert this line in order to avoid permission error at least in unix system !

This comment has been minimized.

Copy link
@volaya

volaya Nov 5, 2012

Author Contributor

shouldn't the user have permission to use that folder? it is the folder where the plugin is installed, in the .qgis folder. That's where qgis can install new plugins...

This comment has been minimized.

Copy link
@slarosa

slarosa Nov 6, 2012

Member

Now that sextante is in core os.path.dirname(file) returns this error:

Traceback (most recent call last):
  File "/usr/local/share/qgis/python/qgis/utils.py", line 188, in startPlugin
    plugins[packageName] = package.classFactory(iface)
  File "/usr/local/share/qgis/python/plugins/sextante/__init__.py", line 46, in classFactory
    return SextantePlugin(iface)
  File "/usr/local/share/qgis/python/plugins/sextante/SextantePlugin.py", line 56, in __init__
    Sextante.initialize()
  File "/usr/local/share/qgis/python/plugins/sextante/core/Sextante.py", line 135, in initialize
    Sextante.modeler.initializeSettings();
  File "/usr/local/share/qgis/python/plugins/sextante/modeler/ModelerAlgorithmProvider.py", line 49, in initializeSettings
    SextanteConfig.addSetting(Setting(self.getDescription(), ModelerUtils.MODELS_FOLDER, "Models folder", ModelerUtils.modelsFolder()))
  File "/usr/local/share/qgis/python/plugins/sextante/modeler/ModelerUtils.py", line 41, in modelsFolder
    mkdir(folder)
  File "/usr/local/share/qgis/python/plugins/sextante/core/SextanteUtils.py", line 87, in mkdir
    os.mkdir(newdir)
OSError: [Errno 13] Permesso negato: '/usr/local/share/qgis/python/plugins/sextante/modeler/models'
folder = os.path.join(os.path.dirname(__file__), "models")
mkdir(folder)

return folder
@@ -0,0 +1,75 @@
NAME:Watersheds from DEM
GROUP:[Sample models]
PARAMETER:ParameterRaster|RASTERLAYER_DEM|DEM|False
458.0,50.0
PARAMETER:ParameterNumber|NUMBER_INITIATIONTHRESHOLD|Initiation Threshold|None|None|10000000.0
257.0,403.0
VALUE:HARDCODEDPARAMVALUE_INIT_VALUE_1===10000000
VALUE:HARDCODEDPARAMVALUE_SPLIT_3===0
VALUE:HARDCODEDPARAMVALUE_Method_0===0
VALUE:HARDCODEDPARAMVALUE_INIT_METHOD_1===2
VALUE:HARDCODEDPARAMVALUE_CALC_METHOD_4===0
VALUE:HARDCODEDPARAMVALUE_CLASS_ID_3===0
VALUE:HARDCODEDPARAMVALUE_STEP_0===1
VALUE:HARDCODEDPARAMVALUE_MINLEN_1===10
VALUE:HARDCODEDPARAMVALUE_DOLINEAR _0===True
VALUE:HARDCODEDPARAMVALUE_MINSIZE_2===0
VALUE:HARDCODEDPARAMVALUE_CLASS_ALL_3===1
VALUE:HARDCODEDPARAMVALUE_LINEARTHRS_0===500.0
VALUE:HARDCODEDPARAMVALUE_CONVERGENCE_0===1.0
VALUE:HARDCODEDPARAMVALUE_DIV_CELLS_1===10
ALGORITHM:saga:catchmentarea(parallel)
260.0,172.0
-1|RASTERLAYER_DEM
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:channelnetwork
447.0,291.0
-1|RASTERLAYER_DEM
None
0|CAREA
-1|HARDCODEDPARAMVALUE_INIT_METHOD_1
-1|NUMBER_INITIATIONTHRESHOLD
None
-1|HARDCODEDPARAMVALUE_DIV_CELLS_1
None
-1|HARDCODEDPARAMVALUE_MINLEN_1
None
None
None
ALGORITHM:saga:watershedbasins
730.0,182.0
-1|RASTERLAYER_DEM
1|CHNLNTWRK
None
-1|HARDCODEDPARAMVALUE_MINSIZE_2
None
ALGORITHM:saga:vectorisinggridclasses
864.0,330.0
2|BASINS
-1|HARDCODEDPARAMVALUE_CLASS_ALL_3
-1|HARDCODEDPARAMVALUE_CLASS_ID_3
-1|HARDCODEDPARAMVALUE_SPLIT_3
None
ALGORITHM:ftools:export/addgeometrycolumns
655.0,442.0
3|POLYGONS
-1|HARDCODEDPARAMVALUE_CALC_METHOD_4
Watersheds
@@ -16,7 +16,6 @@
* *
***************************************************************************
"""

__author__ = 'Victor Olaya'
__date__ = 'August 2012'
__copyright__ = '(C) 2012, Victor Olaya'
@@ -29,12 +28,13 @@
from sextante.outputs.OutputVector import OutputVector
from sextante.outputs.OutputNumber import OutputNumber
from sextante.outputs.OutputFile import OutputFile
from sextante.outputs.OutputString import OutputString

class OutputFactory():

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

7 comments on commit 983535f

@slarosa

This comment has been minimized.

Copy link
Member

@slarosa slarosa replied Nov 5, 2012

Hi Victor,
Sextante seems broken to this revision !
Can you take a look at it, please ?

@volaya

This comment has been minimized.

Copy link
Contributor Author

@volaya volaya replied Nov 5, 2012

@volaya

This comment has been minimized.

Copy link
Contributor Author

@volaya volaya replied Nov 5, 2012

@dakcarto

This comment has been minimized.

Copy link
Member

@dakcarto dakcarto replied Nov 5, 2012

Hi Victor,

Don't know if it is related to this commit, but now getting the following on Sextante load, at launch of QGIS:

Couldn't load plugin sextante due an error when calling its classFactory() method

Traceback (most recent call last):
  File "/Users/larrys/QGIS/github.com/build/output/python/qgis/utils.py", line 188, in startPlugin
    plugins[packageName] = package.classFactory(iface)
  File "/Users/larrys/QGIS/github.com/build/output/python/plugins/sextante/__init__.py", line 45, in classFactory
    from sextante.SextantePlugin import SextantePlugin
  File "/Users/larrys/QGIS/github.com/build/output/python/qgis/utils.py", line 384, in _import
    mod = _builtin_import(name, globals, locals, fromlist, level)
  File "/Users/larrys/QGIS/github.com/build/output/python/plugins/sextante/SextantePlugin.py", line 34, in 
    from sextante.core.Sextante import Sextante
  File "/Users/larrys/QGIS/github.com/build/output/python/qgis/utils.py", line 384, in _import
    mod = _builtin_import(name, globals, locals, fromlist, level)
  File "/Users/larrys/QGIS/github.com/build/output/python/plugins/sextante/core/Sextante.py", line 19, in 
    from sextante.servertools.GeoServerToolsAlgorithmProvider import GeoServerToolsAlgorithmProvider
  File "/Users/larrys/QGIS/github.com/build/output/python/qgis/utils.py", line 384, in _import
    mod = _builtin_import(name, globals, locals, fromlist, level)
ImportError: No module named servertools.GeoServerToolsAlgorithmProvider
@slarosa

This comment has been minimized.

Copy link
Member

@slarosa slarosa replied Nov 5, 2012

Doesn't work here !

Traceback (most recent call last):
File "/usr/local/share/qgis/python/qgis/utils.py", line 188, in startPlugin
plugins[packageName] = package.classFactory(iface)
File "/usr/local/share/qgis/python/plugins/sextante/init.py", line 45, in classFactory
from sextante.SextantePlugin import SextantePlugin
File "/usr/local/share/qgis/python/qgis/utils.py", line 384, in _import
mod = _builtin_import(name, globals, locals, fromlist, level)
File "/usr/local/share/qgis/python/plugins/sextante/SextantePlugin.py", line 34, in
from sextante.core.Sextante import Sextante
File "/usr/local/share/qgis/python/qgis/utils.py", line 384, in _import
mod = _builtin_import(name, globals, locals, fromlist, level)
File "/usr/local/share/qgis/python/plugins/sextante/core/Sextante.py", line 19, in
from sextante.servertools.GeoServerToolsAlgorithmProvider import GeoServerToolsAlgorithmProvider
File "/usr/local/share/qgis/python/qgis/utils.py", line 384, in _import
mod = _builtin_import(name, globals, locals, fromlist, level)
ImportError: No module named servertools.GeoServerToolsAlgorithmProvider

@volaya

This comment has been minimized.

Copy link
Contributor Author

@volaya volaya replied Nov 5, 2012

Ok, I think I fixed it. I forgot to add the folder to the cmakelists file, so it was not being built. Since I work with a 1.8 install and not with the git version, I could not see the problem (I have my own ant task to do the deploying). Now it should copy the new folder as well and everything should be fine :-)

Sorry for this

@slarosa

This comment has been minimized.

Copy link
Member

@slarosa slarosa replied Nov 6, 2012

...and to get it to work ;-) , add CMakeLists.txt in dir servertools:

FILE(GLOB PY_FILES *.py)

ADD_SUBDIRECTORY(geoserver)
ADD_SUBDIRECTORY(httplib2)

PLUGIN_INSTALL(sextante servertools ${PY_FILES})

in geoserver dir:

FILE(GLOB PY_FILES *.py)

PLUGIN_INSTALL(sextante servertools/geoserver ${PY_FILES})

and finally httplib2 dir:

FILE(GLOB PY_FILES *.py)

PLUGIN_INSTALL(sextante servertools/httplib2 ${PY_FILES})

this should solve the problem !

Thanks !

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