Skip to content
Permalink
Browse files

create vector grid in layer CRS (fix #5204)

  • Loading branch information
alexbruy committed May 22, 2012
1 parent 860f370 commit c367a35ce9ae468660d2b25de9c04ec3613102bb
Showing with 4 additions and 6 deletions.
  1. +4 −6 python/plugins/fTools/tools/doVectorGrid.py
@@ -153,7 +153,7 @@ def accept(self):
self.buttonOk.setEnabled( True )

def compute( self, bound, xOffset, yOffset, polygon ):
crs = self.iface.mapCanvas().mapRenderer().destinationSrs()
crs = ftools_utils.getMapLayerByName(unicode(self.inShape.currentText())).crs()
if not crs.isValid(): crs = None
if polygon:
fields = {0:QgsField("ID", QVariant.Int), 1:QgsField("XMIN", QVariant.Double), 2:QgsField("XMAX", QVariant.Double),
@@ -163,15 +163,13 @@ def compute( self, bound, xOffset, yOffset, polygon ):
if not QgsVectorFileWriter.deleteShapeFile(self.shapefileName):
return
writer = QgsVectorFileWriter(self.shapefileName, self.encoding, fields, QGis.WKBPolygon, crs)
#writer = QgsVectorFileWriter(outPath, "CP1250", fields, QGis.WKBPolygon, None)
else:
fields = {0:QgsField("ID", QVariant.Int), 1:QgsField("COORD", QVariant.Double)}
check = QFile(self.shapefileName)
if check.exists():
if not QgsVectorFileWriter.deleteShapeFile(self.shapefileName):
return
writer = QgsVectorFileWriter(self.shapefileName, self.encoding, fields, QGis.WKBLineString, crs)
#writer = QgsVectorFileWriter(unicode(outPath), "CP1250", fields, QGis.WKBLineString, None)
outFeat = QgsFeature()
outGeom = QgsGeometry()
idVar = 0
@@ -279,16 +277,16 @@ def getClosestPixel(self, startVal, targetVal, step, isMin ):
while foundVal is None:
if tmpVal <= targetVal:
if backOneStep:
tmpVal -= step
tmpVal -= step
foundVal = tmpVal
tmpVal += step
else:
backOneStep = isMin
while foundVal is None:
if tmpVal >= targetVal:
if backOneStep:
tmpVal -= step
tmpVal -= step
foundVal = tmpVal
tmpVal += step
return foundVal
return foundVal

0 comments on commit c367a35

Please sign in to comment.
You can’t perform that action at this time.