Skip to content
Permalink
Browse files
ftools api update (fixes #7130)
  • Loading branch information
jef-n committed Feb 9, 2013
1 parent 80240d8 commit 92cbf8f506357ca804d20e8b09b2ae8f372ae3a4
@@ -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 = []
@@ -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):
@@ -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):
@@ -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):

0 comments on commit 92cbf8f

Please sign in to comment.