Skip to content

Commit

Permalink
update Vector Grid to vector API changes (fix #7322)
Browse files Browse the repository at this point in the history
  • Loading branch information
alexbruy committed Mar 14, 2013
1 parent 413b4ce commit 8ad1e2a
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions python/plugins/fTools/tools/doVectorGrid.py
Expand Up @@ -42,7 +42,6 @@ def __init__(self, iface):
self.setupUi(self)
QObject.connect(self.toolOut, SIGNAL("clicked()"), self.outFile)
QObject.connect(self.spnX, SIGNAL("valueChanged(double)"), self.offset)
#QObject.connect(self.inShape, SIGNAL("currentIndexChanged(QString)"), self.updateInput)
QObject.connect(self.btnUpdate, SIGNAL("clicked()"), self.updateLayer)
QObject.connect(self.btnCanvas, SIGNAL("clicked()"), self.updateCanvas)
QObject.connect(self.chkAlign, SIGNAL("toggled(bool)"), self.chkAlignToggled)
Expand Down Expand Up @@ -166,25 +165,30 @@ def compute( self, bound, xOffset, yOffset, polygon ):

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

if polygon:
fields.append( QgsField("XMIN", QVariant.Double) )
fields.append( QgsField("XMAX", QVariant.Double) )
fields.append( QgsField("YMIN", QVariant.Double) )
fields.append( QgsField("YMAX", QVariant.Double) )
fieldCount = 5
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.append( QgsField("COORD", QVariant.Double) )
fieldCount = 2
check = QFile(self.shapefileName)
if check.exists():
if not QgsVectorFileWriter.deleteShapeFile(self.shapefileName):
return
writer = QgsVectorFileWriter(self.shapefileName, self.encoding, fields, QGis.WKBLineString, crs)
outFeat = QgsFeature()
outFeat.initAttributes(fieldCount)
outFeat.setFields(fields)
outGeom = QgsGeometry()
idVar = 0
self.progressBar.setValue( 0 )
Expand Down Expand Up @@ -258,7 +262,6 @@ def compute( self, bound, xOffset, yOffset, polygon ):
prog = int( count / count_max * 100 )

self.progressBar.setValue( 100 )
#self.progressBar.setRange( 0, 100 )
del writer

def outFile(self):
Expand Down Expand Up @@ -302,4 +305,3 @@ def getClosestPixel(self, startVal, targetVal, step, isMin ):
foundVal = tmpVal
tmpVal += step
return foundVal

0 comments on commit 8ad1e2a

Please sign in to comment.