Skip to content
Permalink
Browse files
[sextante] added autofilling on double-click in batch processing dialog
Other minor changes
  • Loading branch information
volaya committed Feb 24, 2013
1 parent e394fc1 commit 724506dc93526a233f892ec62787cbe4e58be136
@@ -41,7 +41,13 @@ def __init__(self):
AlgorithmProvider.__init__(self)
self.alglist = [ImportVectorIntoGeoServer(), ImportRasterIntoGeoServer(),
CreateWorkspace(), DeleteWorkspace(), DeleteDatastore(),
CreateStyleGeoServer(), ImportIntoPostGIS(), PostGISExecuteSQL()]#, TruncateSeedGWC()]
CreateStyleGeoServer()]

try:
self.alglist.append(ImportIntoPostGIS())
self.alglist.append(PostGISExecuteSQL())
except:
pass

def initializeSettings(self):
AlgorithmProvider.initializeSettings(self)
@@ -18,7 +18,6 @@
"""
from sextante.parameters.ParameterTable import ParameterTable
from sextante.parameters.ParameterTableField import ParameterTableField
from sextante.core.SextanteLog import SextanteLog

__author__ = 'Victor Olaya'
__date__ = 'August 2013'
@@ -270,14 +270,14 @@ def runAlgorithm(algOrName, onFinish, *args):
for param in alg.parameters:
if not param.hidden:
if not param.setValue(args[i]):
print ("Error: Wrong parameter value: " + args[i])
print ("Error: Wrong parameter value: " + unicode(args[i]))
return
i = i +1

for output in alg.outputs:
if not output.hidden:
if not output.setValue(args[i]):
print ("Error: Wrong output value: " + args[i])
print ("Error: Wrong output value: " + unicode(args[i]))
return
i = i +1

@@ -23,15 +23,17 @@
# This will get replaced with a git SHA1 when you do a git archive
__revision__ = '$Format:%H$'

import os
from qgis.core import *
from PyQt4 import QtGui
from sextante.core.GeoAlgorithm import GeoAlgorithm
from sextante.parameters.ParameterRaster import ParameterRaster
from sextante.outputs.OutputRaster import OutputRaster
import os
from qgis.core import *
from sextante.parameters.ParameterSelection import ParameterSelection
from sextante.parameters.ParameterCrs import ParameterCrs
from sextante.gdal.GdalUtils import GdalUtils
from sextante.parameters.ParameterNumber import ParameterNumber
from sextante.parameters.ParameterString import ParameterString

class warp(GeoAlgorithm):

@@ -41,6 +43,8 @@ class warp(GeoAlgorithm):
DEST_SRS = "DEST_SRS "
METHOD = "METHOD"
METHOD_OPTIONS = ["near", "bilinear", "cubic", "cubicspline", "lanczos"]
TR = "TR"
EXTRA = "EXTRA"

def getIcon(self):
filepath = os.path.dirname(__file__) + "/icons/warp.png"
@@ -52,7 +56,9 @@ def defineCharacteristics(self):
self.addParameter(ParameterRaster(warp.INPUT, "Input layer", False))
self.addParameter(ParameterCrs(warp.SOURCE_SRS, "Source SRS (EPSG Code)", "EPSG:4326"))
self.addParameter(ParameterCrs(warp.DEST_SRS, "Destination SRS (EPSG Code)", "EPSG:4326"))
self.addParameter(ParameterNumber(warp.TR, "Output file resolution in target georeferenced units (leave 0 for no change)", 0.0, None, 0.0))
self.addParameter(ParameterSelection(warp.METHOD, "Resampling method", warp.METHOD_OPTIONS))
self.addParameter(ParameterString(warp.EXTRA, "Additional creation parameters", " "))
self.addOutput(OutputRaster(warp.OUTPUT, "Output layer"))

def processAlgorithm(self, progress):
@@ -68,6 +74,10 @@ def processAlgorithm(self, progress):
commands.append("-of")
out = self.getOutputValue(warp.OUTPUT)
commands.append(GdalUtils.getFormatShortNameFromFilename(out))
if self.getParameterValue(warp.TR) != 0:
trStr = "-tr "+str(self.getParameterValue(warp.TR))+" "+str(self.getParameterValue(warp.TR))
commands.append(trStr)
commands.append(str(self.getParameterValue(warp.EXTRA)))
commands.append(self.getParameterValue(warp.INPUT))
commands.append(out)

@@ -86,6 +86,37 @@ def __init__(self, alg):
self.table.setSizePolicy(QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Expanding)
self.addRowButton.clicked.connect(self.addRow)
self.deleteRowButton.clicked.connect(self.deleteRow)
self.table.horizontalHeader().sectionDoubleClicked.connect(self.headerDoubleClicked)


def headerDoubleClicked(self, col):
widget = self.table.cellWidget(0, col)
if isinstance(widget, QtGui.QComboBox):
widgetValue = widget.currentIndex()
for row in range(1, self.table.rowCount()):
self.table.cellWidget(row, col).setCurrentIndex(widgetValue)

elif isinstance(widget, ExtentSelectionPanel):
widgetValue = widget.getValue()
for row in range(1, self.table.rowCount()):
if widgetValue != None:
self.table.cellWidget(row, col).text.setText(widgetValue)
else:
self.table.cellWidget(row, col).text.setText("")

elif isinstance(widget, CrsSelectionPanel):
widgetValue = widget.getValue()
for row in range(1, self.table.rowCount()):
self.table.cellWidget(row, col).epsg = widgetValue
self.table.cellWidget(row, col).setText()

elif isinstance(widget, QtGui.QLineEdit):
widgetValue = widget.text()
for row in range(1, self.table.rowCount()):
self.table.cellWidget(row, col).setText(widgetValue)
else:
pass


def setTableContent(self):
i = 0
@@ -267,7 +267,9 @@ def getImportCommands(self):
# just use US mirror
commands.append('options("repos"="http://cran.us.r-project.org")')
rLibDir = "%s/rlibs" % SextanteUtils.userFolder().replace("\\","/")
if not os.path.isdir(rLibDir): os.mkdir(rLibDir)
if not os.path.isdir(rLibDir):
os.mkdir(rLibDir)
commands.append('.libPaths("%s")' % rLibDir )
commands.append(
'tryCatch(find.package("rgdal"), error=function(e) install.packages("rgdal", lib="%s"))' % rLibDir)
commands.append("library(\"rgdal\")");

0 comments on commit 724506d

Please sign in to comment.