Skip to content

Commit 92cbf8f

Browse files
committedFeb 9, 2013
ftools api update (fixes #7130)
1 parent 80240d8 commit 92cbf8f

File tree

4 files changed

+20
-7
lines changed

4 files changed

+20
-7
lines changed
 

‎python/plugins/fTools/tools/doMeanCoords.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -128,10 +128,15 @@ def compute(self, inName, outName, weightField="", times=1, uniqueField=""):
128128
uniqueValues = [QVariant(1)]
129129
single = True
130130
if self.function == 2:
131-
fieldList = { 0 : QgsField("STD_DIST", QVariant.Double), 1 : QgsField("UID", QVariant.String) }
131+
fieldList = QgsFields()
132+
fieldList.append( QgsField("STD_DIST", QVariant.Double) )
133+
fieldList.append( QgsField("UID", QVariant.String) )
132134
writer = QgsVectorFileWriter(self.shapefileName, self.encoding, fieldList, QGis.WKBPolygon, sRs)
133135
else:
134-
fieldList = { 0 : QgsField("MEAN_X", QVariant.Double), 1 : QgsField("MEAN_Y", QVariant.Double), 2 : QgsField("UID", QVariant.String) }
136+
fieldList = QgsFields()
137+
fieldList.append( QgsField("MEAN_X", QVariant.Double) )
138+
fieldList.append( QgsField("MEAN_Y", QVariant.Double) )
139+
fieldList.append( QgsField("UID", QVariant.String) )
135140
writer = QgsVectorFileWriter(self.shapefileName, self.encoding, fieldList, QGis.WKBPoint, sRs)
136141
outfeat = QgsFeature()
137142
points = []

‎python/plugins/fTools/tools/doRandPoints.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -213,7 +213,8 @@ def randomize(self, inLayer, outPath, minimum, design, value):
213213
else: points = self.loopThruPolygons(inLayer, value, design)
214214
crs = self.iface.mapCanvas().mapRenderer().destinationCrs()
215215
if not crs.isValid(): crs = None
216-
fields = { 0 : QgsField("ID", QVariant.Int) }
216+
fields = QgsFields()
217+
fields.append( QgsField("ID", QVariant.Int) )
217218
check = QFile(self.shapefileName)
218219
if check.exists():
219220
if not QgsVectorFileWriter.deleteShapeFile(self.shapefileName):

‎python/plugins/fTools/tools/doRegPoints.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,8 @@ def regularize(self, bound, outPath, offset, value, gridType, inset, crs):
126126
# Calculate grid spacing
127127
pointSpacing = sqrt(area / value)
128128
outFeat = QgsFeature()
129-
fields = { 0 : QgsField("ID", QVariant.Int) }
129+
fields = QgsFields()
130+
fields.append( QgsField("ID", QVariant.Int) )
130131
check = QFile(self.shapefileName)
131132
if check.exists():
132133
if not QgsVectorFileWriter.deleteShapeFile(self.shapefileName):

‎python/plugins/fTools/tools/doVectorGrid.py

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -163,16 +163,22 @@ def compute( self, bound, xOffset, yOffset, polygon ):
163163
else:
164164
crs = layer.crs()
165165
if not crs.isValid(): crs = None
166+
167+
fields = QgsFields()
168+
fields.append( QgsField("ID", QVariant.Int) )
169+
166170
if polygon:
167-
fields = {0:QgsField("ID", QVariant.Int), 1:QgsField("XMIN", QVariant.Double), 2:QgsField("XMAX", QVariant.Double),
168-
3:QgsField("YMIN", QVariant.Double), 4:QgsField("YMAX", QVariant.Double)}
171+
fields.append( QgsField("XMIN", QVariant.Double) )
172+
fields.append( QgsField("XMAX", QVariant.Double) )
173+
fields.append( QgsField("YMIN", QVariant.Double) )
174+
fields.append( QgsField("YMAX", QVariant.Double) )
169175
check = QFile(self.shapefileName)
170176
if check.exists():
171177
if not QgsVectorFileWriter.deleteShapeFile(self.shapefileName):
172178
return
173179
writer = QgsVectorFileWriter(self.shapefileName, self.encoding, fields, QGis.WKBPolygon, crs)
174180
else:
175-
fields = {0:QgsField("ID", QVariant.Int), 1:QgsField("COORD", QVariant.Double)}
181+
fields.append( QgsField("COORD", QVariant.Double) )
176182
check = QFile(self.shapefileName)
177183
if check.exists():
178184
if not QgsVectorFileWriter.deleteShapeFile(self.shapefileName):

0 commit comments

Comments
 (0)
Please sign in to comment.