Skip to content

Commit e46795a

Browse files
committed
[sextante] updated to new sip api
1 parent 75cbdf6 commit e46795a

Some content is hidden

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

56 files changed

+138
-195
lines changed

python/plugins/sextante/admintools/ImportIntoPostGIS.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -54,11 +54,11 @@ def processAlgorithm(self, progress):
5454
settings = QSettings()
5555
mySettings = "/PostgreSQL/connections/"+ connection
5656
try:
57-
database = settings.value(mySettings+"/database").toString()
58-
username = settings.value(mySettings+"/username").toString()
59-
host = settings.value(mySettings+"/host").toString()
60-
port = int(settings.value(mySettings+"/port").toString())
61-
password = settings.value(mySettings+"/password").toString()
57+
database = settings.value(mySettings+"/database")
58+
username = settings.value(mySettings+"/username")
59+
host = settings.value(mySettings+"/host")
60+
port = settings.value(mySettings+"/port", type = int)
61+
password = settings.value(mySettings+"/password")
6262
except Exception, e:
6363
raise GeoAlgorithmExecutionException("Wrong database connection name: " + connection)
6464

python/plugins/sextante/admintools/PostGISExecuteSQL.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -46,11 +46,11 @@ def processAlgorithm(self, progress):
4646
settings = QSettings()
4747
mySettings = "/PostgreSQL/connections/"+ connection
4848
try:
49-
database = settings.value(mySettings+"/database").toString()
50-
username = settings.value(mySettings+"/username").toString()
51-
host = settings.value(mySettings+"/host").toString()
52-
port = int(settings.value(mySettings+"/port").toString())
53-
password = settings.value(mySettings+"/password").toString()
49+
database = settings.value(mySettings+"/database")
50+
username = settings.value(mySettings+"/username")
51+
host = settings.value(mySettings+"/host")
52+
port = settings.value(mySettings+"/port", type = int)
53+
password = settings.value(mySettings+"/password")
5454
except Exception, e:
5555
raise GeoAlgorithmExecutionException("Wrong database connection name: " + connection)
5656
try:

python/plugins/sextante/algs/AddTableField.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ def processAlgorithm(self, progress):
8989
inGeom = inFeat.geometry()
9090
outFeat.setGeometry( inGeom )
9191
atMap = inFeat.attributes()
92-
atMap.append(QVariant())
92+
atMap.append(None)
9393
outFeat.setAttributes(atMap)
9494
writer.addFeature( outFeat )
9595
del writer

python/plugins/sextante/algs/AutoincrementalField.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ def processAlgorithm(self, progress):
5959
inGeom = inFeat.geometry()
6060
outFeat.setGeometry( inGeom )
6161
attrs = inFeat.attributes()
62-
attrs.append(QVariant(nElement))
62+
attrs.append(nElement)
6363
outFeat.setAttributes(attrs)
6464
writer.addFeature(outFeat)
6565
del writer

python/plugins/sextante/algs/EquivalentNumField.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,10 +63,10 @@ def processAlgorithm(self, progress):
6363
inGeom = feature.geometry()
6464
outFeat.setGeometry( inGeom )
6565
atMap = feature.attributes()
66-
clazz = atMap[fieldindex].toString()
66+
clazz = atMap[fieldindex]
6767
if clazz not in classes:
6868
classes[clazz] = len(classes.keys())
69-
atMap.append(QVariant(classes[clazz]))
69+
atMap.append(classes[clazz])
7070
outFeat.setAttributes(atMap)
7171
writer.addFeature( outFeat )
7272
del writer

python/plugins/sextante/algs/FieldPyculator.py

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ def processAlgorithm(self, progress):
142142
new_ns['__geom'] = geom
143143

144144
if need_attrs:
145-
pyattrs = [self.Qvar2py(a) for a in attrs]
145+
pyattrs = [a for a in attrs]
146146
new_ns['__attr'] = pyattrs
147147

148148
#clear old result
@@ -161,20 +161,12 @@ def processAlgorithm(self, progress):
161161
#write feature
162162
nElement += 1
163163
outFeat.setGeometry( feat.geometry() )
164-
attrs.append(QVariant(new_ns[self.RESULT_VAR_NAME]))
164+
attrs.append(new_ns[self.RESULT_VAR_NAME])
165165
outFeat.setAttributes(attrs)
166166
writer.addFeature(outFeat)
167167

168168
del writer
169169

170-
def Qvar2py(self,qv):
171-
if qv.type() == 2:
172-
return qv.toInt()[0]
173-
if qv.type() == 10:
174-
return unicode(qv.toString())
175-
if qv.type() == 6:
176-
return qv.toDouble()[0]
177-
return None
178170

179171
def checkParameterValuesBeforeExecuting(self):
180172
##TODO check that formula is correct and fields exist

python/plugins/sextante/algs/FieldsCalculator.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ def processAlgorithm(self, progress):
9191
expression = formula
9292
k = 0
9393
for attr in attrs:
94-
expression = expression.replace(unicode(fields[k].name()), unicode(attr.toString()))
94+
expression = expression.replace(unicode(fields[k].name()), unicode(attr))
9595
k += 1
9696
try:
9797
result = eval(expression)
@@ -102,7 +102,7 @@ def processAlgorithm(self, progress):
102102
inGeom = inFeat.geometry()
103103
outFeat.setGeometry(inGeom)
104104
attrs = inFeat.attributes()
105-
attrs.append(QVariant(result))
105+
attrs.append(result)
106106
outFeat.setAttributes(attrs)
107107
writer.addFeature(outFeat)
108108
del writer

python/plugins/sextante/algs/JoinAttributes.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -83,12 +83,12 @@ def processAlgorithm(self, progress):
8383
for inFeat in features:
8484
inGeom = inFeat.geometry()
8585
attrs = inFeat.attributes()
86-
joinValue1 = attrs[joinField1Index].toString()
86+
joinValue1 = attrs[joinField1Index]
8787
features2 = QGisLayers.features(layer2);
8888
for inFeat2 in features2:
8989
## Maybe it should cache this entries...
9090
attrs2 = inFeat2.attributes()
91-
joinValue2 = attrs2[joinField2Index].toString()
91+
joinValue2 = attrs2[joinField2Index]
9292
if joinValue1 == joinValue2:
9393
# create the new feature
9494
outFeat.setGeometry(inGeom)

python/plugins/sextante/algs/PointsLayerFromTable.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,8 +58,8 @@ def processAlgorithm(self, progress):
5858
progress.setPercentage((nElement*100)/nFeat)
5959
attrs = feature.attributes()
6060
try:
61-
x = float(attrs[xfieldindex].toString())
62-
y = float(attrs[yfieldindex].toString())
61+
x = float(attrs[xfieldindex])
62+
y = float(attrs[yfieldindex])
6363
except:
6464
continue
6565
pt = QgsPoint(x, y)

python/plugins/sextante/algs/Polygonize.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ def processAlgorithm(self, progress):
8080
for polygon in polygons:
8181
outFeat.setGeometry(QgsGeometry.fromWkt( polygon.wkt ))
8282
if self.getParameterValue(self.GEOMETRY):
83-
outFeat.setAttributes([None]*fieldsCount + [ QVariant(polygon.area), QVariant(polygon.length)])
83+
outFeat.setAttributes([None]*fieldsCount + [ polygon.area, polygon.length])
8484
writer.addFeature(outFeat)
8585
current += 1
8686
progress.setPercentage(50+int(current * total))

0 commit comments

Comments
 (0)