6 changes: 3 additions & 3 deletions python/plugins/sextante/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
***************************************************************************
"""

from sextante.core.Sextante import runalg, alghelp, alglist, algoptions, load, loadFromAlg, extent, getObjectFromName, getObjectFromUri
from sextante.core.Sextante import runalg, runandload, alghelp, alglist, algoptions, load, loadFromAlg, extent, getObjectFromName, getObjectFromUri

__author__ = 'Victor Olaya'
__date__ = 'August 2012'
Expand All @@ -32,7 +32,7 @@ def description():
return "SEXTANTE Geoprocessing Platform for QGIS"

def version():
return "1.0.8"
return "1.0.9"

def icon():
return "images/toolbox.png"
Expand All @@ -41,7 +41,7 @@ def category():
return "Analysis"

def qgisMinimumVersion():
return "1.0"
return "1.8"

def classFactory(iface):
from sextante.SextantePlugin import SextantePlugin
Expand Down
6 changes: 3 additions & 3 deletions python/plugins/sextante/admintools/geoserver/store.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import sextante.admintools.geoserver.workspace as ws
from sextante.admintools.geoserver.resource import featuretype_from_index, coverage_from_index
from sextante.admintools.geoserver.support import ResourceInfo, xml_property, key_value_pairs, \
write_bool, write_dict, write_string, url
from sextante.admintools.geoserver.workspace import Workspace

def datastore_from_index(catalog, workspace, node):
name = node.find("name")
Expand All @@ -18,7 +18,7 @@ class DataStore(ResourceInfo):
def __init__(self, catalog, workspace, name):
super(DataStore, self).__init__()

assert isinstance(workspace, ws.Workspace)
assert isinstance(workspace, Workspace)
assert isinstance(name, basestring)
self.catalog = catalog
self.workspace = workspace
Expand Down Expand Up @@ -69,7 +69,7 @@ class CoverageStore(ResourceInfo):
def __init__(self, catalog, workspace, name):
super(CoverageStore, self).__init__()

assert isinstance(workspace, ws.Workspace)
assert isinstance(workspace, Workspace)
assert isinstance(name, basestring)

self.catalog = catalog
Expand Down
16 changes: 8 additions & 8 deletions python/plugins/sextante/algs/AddTableField.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,13 +73,13 @@ def processAlgorithm(self, progress):
nFeat = vprovider.featureCount()
nElement = 0
while vprovider.nextFeature(inFeat):
progress.setPercentage(int((100 * nElement)/nFeat))
nElement += 1
inGeom = inFeat.geometry()
outFeat.setGeometry( inGeom )
atMap = inFeat.attributeMap()
outFeat.setAttributeMap( atMap )
outFeat.addAttribute( len(vprovider.fields()), QVariant() )
writer.addFeature( outFeat )
progress.setPercentage(int((100 * nElement)/nFeat))
nElement += 1
inGeom = inFeat.geometry()
outFeat.setGeometry( inGeom )
atMap = inFeat.attributeMap()
outFeat.setAttributeMap( atMap )
outFeat.addAttribute( len(vprovider.fields()), QVariant() )
writer.addFeature( outFeat )
del writer

11 changes: 3 additions & 8 deletions python/plugins/sextante/algs/FieldPyculator.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,6 @@ def processAlgorithm(self, progress):
code = self.getParameterValue(self.FORMULA)
globalExpression = self.getParameterValue(self.GLOBAL)
useSelected = self.getParameterValue(self.USE_SELECTED)
settings = QSettings()
systemEncoding = settings.value( "/UI/encoding", "System" ).toString()
output = self.getOutputFromName(self.OUTPUT_LAYER)
layer = QGisLayers.getObjectFromUri(self.getParameterValue(self.INPUT_LAYER))
vprovider = layer.dataProvider()
Expand All @@ -77,9 +75,7 @@ def processAlgorithm(self, progress):
fields = vprovider.fields()
fields[len(fields)] = QgsField(fieldname, QVariant.Double)
writer = output.getVectorWriter(fields, vprovider.geometryType(), vprovider.crs() )
outFeat = QgsFeature()
nFeatures = vprovider.featureCount()
nElement = 0
outFeat = QgsFeature()
new_ns = {}

#run global code
Expand Down Expand Up @@ -115,13 +111,12 @@ def processAlgorithm(self, progress):
"Field code block can't be executed! %s \n %s"
(unicode(sys.exc_info()[0].__name__), unicode(sys.exc_info()[1])))


QtGui.QMessageBox.critical(None, "", str(vprovider))
#run

nElement = 1
features = layer.selectedFeatures()
nFeatures = len(features)
if not useSelected or nFeatures == 0:
nFeatures = vprovider.featureCount()
feat = QgsFeature()
if need_attrs:
attr_ind = vprovider.attributeIndexes()
Expand Down
4 changes: 4 additions & 0 deletions python/plugins/sextante/core/Sextante.py
Original file line number Diff line number Diff line change
Expand Up @@ -376,6 +376,10 @@ def alghelp(name):
def runalg(algOrName, *args):
alg = Sextante.runAlgorithm(algOrName, None, *args)
return alg.getOutputValuesAsDictionary()

def runandload(name, *args):
Sextante.runAlgorithm(name, SextantePostprocessing.handleAlgorithmResults, *args)


def extent(layers):
first = True
Expand Down
5 changes: 4 additions & 1 deletion python/plugins/sextante/core/SextanteVectorWriter.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ def __init__(self, fileName, encoding, fields, geometryType, crs, options=None):

uri = self.TYPE_MAP[geometryType]
if crs.isValid():
uri += "?crs=" + crs.authid()
uri += "?crs=" + crs.authid()
self.memLayer = QgsVectorLayer(uri, self.fileName, "memory")
self.writer = self.memLayer.dataProvider()
self.writer.addAttributes(fields.values())
Expand All @@ -69,6 +69,9 @@ def __init__(self, fileName, encoding, fields, geometryType, crs, options=None):
OGRCodes[extension] = value

extension = self.fileName[self.fileName.rfind(".") + 1:]
if extension not in OGRCodes:
extension = "shp"
self.filename = self.filename + "shp"
self.writer = QgsVectorFileWriter(self.fileName, encoding, fields, geometryType, crs, OGRCodes[extension])

def addFeature(self, feature):
Expand Down
10 changes: 5 additions & 5 deletions python/plugins/sextante/gui/BatchProcessingDialog.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,6 @@
* *
***************************************************************************
"""
from sextante.gui.CrsSelectionPanel import CrsSelectionPanel
from sextante.outputs.OutputNumber import OutputNumber
from sextante.outputs.OutputString import OutputString
from sextante.core.SextanteUtils import SextanteUtils

__author__ = 'Victor Olaya'
__date__ = 'August 2012'
__copyright__ = '(C) 2012, Victor Olaya'
Expand All @@ -35,6 +30,10 @@
from sextante.parameters.ParameterVector import ParameterVector
from sextante.gui.BatchInputSelectionPanel import BatchInputSelectionPanel
from sextante.gui.AlgorithmExecutionDialog import AlgorithmExecutionDialog
from sextante.gui.CrsSelectionPanel import CrsSelectionPanel
from sextante.outputs.OutputNumber import OutputNumber
from sextante.outputs.OutputString import OutputString
from sextante.core.SextanteUtils import SextanteUtils

from sextante.parameters.ParameterExtent import ParameterExtent
from sextante.parameters.ParameterNumber import ParameterNumber
Expand All @@ -58,6 +57,7 @@
class BatchProcessingDialog(AlgorithmExecutionDialog):
def __init__(self, alg):
self.algs = None
self.showAdvanced = False
self.table = QtGui.QTableWidget(None)
AlgorithmExecutionDialog.__init__(self, alg, self.table)
self.setWindowModality(1)
Expand Down
2 changes: 1 addition & 1 deletion python/plugins/sextante/gui/HistoryDialog.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ def executeAlgorithm(self):
item = self.tree.currentItem()
if isinstance(item, TreeLogEntryItem):
if item.isAlg:
script = "from sextante.core.Sextante import Sextante\n"
script = "import sextante\n"
script+=item.entry.text.replace("runalg(","runandload(")
exec(script)

Expand Down
5 changes: 3 additions & 2 deletions python/plugins/sextante/gui/OutputSelectionPanel.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,9 +90,10 @@ def saveToFile(self):
fileDialog.setConfirmOverwrite(True)
if fileDialog.exec_() == QDialog.Accepted:
filename = fileDialog.selectedFiles().first()
encoding = fileDialog.encoding()
encoding = fileDialog.encoding()
self.output.encoding = encoding
self.text.setText(str(filename))
filename= unicode(filename);
self.text.setText(filename)
settings.setValue("/SextanteQGIS/LastOutputPath", os.path.dirname(str(filename)))
settings.setValue("/SextanteQGIS/encoding", encoding)

Expand Down
4 changes: 2 additions & 2 deletions python/plugins/sextante/metadata.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
name=SEXTANTE
description=SEXTANTE Geoprocessing Platform for QGIS
category=Analysis
version=1.0.8
qgisMinimumVersion=1.0
version=1.0.9
qgisMinimumVersion=1.8

author=Victor Olaya
email=volayaf@gmail.com
Expand Down
6 changes: 3 additions & 3 deletions python/plugins/sextante/mmqgisx/mmqgisx_library.py
Original file line number Diff line number Diff line change
Expand Up @@ -1598,7 +1598,7 @@ def mmqgisx_grid(qgis, savename, hspacing, vspacing, width, height, originx, ori
if (hspacing <= 0) or (vspacing <= 0):
return "Invalid grid spacing: " + unicode(hspacing) + " / " + unicode(vspacing)

if (width <= hspacing) or (width < vspacing):
if (width < hspacing) or (height < vspacing):
return "Invalid width / height: " + unicode(width) + " / " + unicode(height)

fields = {
Expand Down Expand Up @@ -1681,9 +1681,9 @@ def mmqgisx_grid(qgis, savename, hspacing, vspacing, width, height, originx, ori
feature.addAttribute(1, QVariant(y + (vspacing / 2.0)))
outfile.addFeature(feature)
linecount = linecount + 1
y = y + hspacing;
y = y + vspacing;

x = x + vspacing
x = x + hspacing

elif gridtype == "Diamond (polygon)":
x = originx
Expand Down
6 changes: 6 additions & 0 deletions python/plugins/sextante/parameters/ParameterFile.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,12 @@ def serialize(self):
return self.__module__.split(".")[-1] + "|" + self.name + "|" + self.description +\
"|" + str(self.isFolder)

def setValue(self, obj):
self.value = str(obj)
if self.value.strip() == "":
return False
return True

def deserialize(self, s):
tokens = s.split("|")
return ParameterFile(tokens[0], tokens[1], tokens[2] == str(True))
Expand Down
8 changes: 0 additions & 8 deletions python/plugins/sextante/saga/description/SplitShapesLayer.txt

This file was deleted.

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,7 @@

#Iterate over input layer to count unique values in each class
while provider.nextFeature(inFeat):
#Printing a number to the console to indicate progress
print int((50 * nElement)/nFeat)
progress.setPercentage(int((100 * nElement)/nFeat))
nElement += 1
atMap = inFeat.attributeMap()
clazz = atMap[class_field_index].toString()
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
#Definition of inputs and outputs
#==================================
##[Example scripts]=group
##input=vector
##class_field=field input
##output=output file

#Algorithm body
#==================================
from sextante.core.QGisLayers import QGisLayers
from qgis.core import *
from PyQt4.QtCore import *
from sextante.core.SextanteVectorWriter import SextanteVectorWriter

# "input" contains the location of the selected layer.
# We get the actual object,
layer = QGisLayers.getObjectFromUri(input)
provider = layer.dataProvider()
allAttrs = provider.attributeIndexes()
provider.select( allAttrs )
fields = provider.fields()
writers = {}

# Fields are defined by their names, but QGIS needs the index for the attributes map
class_field_index = provider.fieldNameIndex(class_field)

inFeat = QgsFeature()
outFeat = QgsFeature()
inGeom = QgsGeometry()
nFeat = provider.featureCount()
nElement = 0
writers = {}

while provider.nextFeature(inFeat):
progress.setPercentage(int((100 * nElement)/nFeat))
nElement += 1
atMap = inFeat.attributeMap()
clazz = atMap[class_field_index].toString()
if clazz not in writers:
outputFile = output + "_" + str(len(writers)) + ".shp"
writers[clazz] = SextanteVectorWriter(outputFile, None, fields, provider.geometryType(), provider.crs() )
inGeom = inFeat.geometry()
outFeat.setGeometry(inGeom)
outFeat.setAttributeMap(atMap)
writers[clazz].addFeature(outFeat)



for writer in writers.values():
del writer