Skip to content

Commit

Permalink
ftools api update (fixes #7130)
Browse files Browse the repository at this point in the history
  • Loading branch information
jef-n committed Feb 9, 2013
1 parent 80240d8 commit 92cbf8f
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 7 deletions.
9 changes: 7 additions & 2 deletions python/plugins/fTools/tools/doMeanCoords.py
Expand Up @@ -128,10 +128,15 @@ def compute(self, inName, outName, weightField="", times=1, uniqueField=""):
uniqueValues = [QVariant(1)]
single = True
if self.function == 2:
fieldList = { 0 : QgsField("STD_DIST", QVariant.Double), 1 : QgsField("UID", QVariant.String) }
fieldList = QgsFields()
fieldList.append( QgsField("STD_DIST", QVariant.Double) )
fieldList.append( QgsField("UID", QVariant.String) )
writer = QgsVectorFileWriter(self.shapefileName, self.encoding, fieldList, QGis.WKBPolygon, sRs)
else:
fieldList = { 0 : QgsField("MEAN_X", QVariant.Double), 1 : QgsField("MEAN_Y", QVariant.Double), 2 : QgsField("UID", QVariant.String) }
fieldList = QgsFields()
fieldList.append( QgsField("MEAN_X", QVariant.Double) )
fieldList.append( QgsField("MEAN_Y", QVariant.Double) )
fieldList.append( QgsField("UID", QVariant.String) )
writer = QgsVectorFileWriter(self.shapefileName, self.encoding, fieldList, QGis.WKBPoint, sRs)
outfeat = QgsFeature()
points = []
Expand Down
3 changes: 2 additions & 1 deletion python/plugins/fTools/tools/doRandPoints.py
Expand Up @@ -213,7 +213,8 @@ def randomize(self, inLayer, outPath, minimum, design, value):
else: points = self.loopThruPolygons(inLayer, value, design)
crs = self.iface.mapCanvas().mapRenderer().destinationCrs()
if not crs.isValid(): crs = None
fields = { 0 : QgsField("ID", QVariant.Int) }
fields = QgsFields()
fields.append( QgsField("ID", QVariant.Int) )
check = QFile(self.shapefileName)
if check.exists():
if not QgsVectorFileWriter.deleteShapeFile(self.shapefileName):
Expand Down
3 changes: 2 additions & 1 deletion python/plugins/fTools/tools/doRegPoints.py
Expand Up @@ -126,7 +126,8 @@ def regularize(self, bound, outPath, offset, value, gridType, inset, crs):
# Calculate grid spacing
pointSpacing = sqrt(area / value)
outFeat = QgsFeature()
fields = { 0 : QgsField("ID", QVariant.Int) }
fields = QgsFields()
fields.append( QgsField("ID", QVariant.Int) )
check = QFile(self.shapefileName)
if check.exists():
if not QgsVectorFileWriter.deleteShapeFile(self.shapefileName):
Expand Down
12 changes: 9 additions & 3 deletions python/plugins/fTools/tools/doVectorGrid.py
Expand Up @@ -163,16 +163,22 @@ def compute( self, bound, xOffset, yOffset, polygon ):
else:
crs = layer.crs()
if not crs.isValid(): crs = None

fields = QgsFields()
fields.append( QgsField("ID", QVariant.Int) )

if polygon:
fields = {0:QgsField("ID", QVariant.Int), 1:QgsField("XMIN", QVariant.Double), 2:QgsField("XMAX", QVariant.Double),
3:QgsField("YMIN", QVariant.Double), 4:QgsField("YMAX", QVariant.Double)}
fields.append( QgsField("XMIN", QVariant.Double) )
fields.append( QgsField("XMAX", QVariant.Double) )
fields.append( QgsField("YMIN", QVariant.Double) )
fields.append( QgsField("YMAX", QVariant.Double) )
check = QFile(self.shapefileName)
if check.exists():
if not QgsVectorFileWriter.deleteShapeFile(self.shapefileName):
return
writer = QgsVectorFileWriter(self.shapefileName, self.encoding, fields, QGis.WKBPolygon, crs)
else:
fields = {0:QgsField("ID", QVariant.Int), 1:QgsField("COORD", QVariant.Double)}
fields.append( QgsField("COORD", QVariant.Double) )
check = QFile(self.shapefileName)
if check.exists():
if not QgsVectorFileWriter.deleteShapeFile(self.shapefileName):
Expand Down

0 comments on commit 92cbf8f

Please sign in to comment.