Skip to content

Commit

Permalink
create vector grid in layer CRS (fix #5204)
Browse files Browse the repository at this point in the history
  • Loading branch information
alexbruy committed May 22, 2012
1 parent 860f370 commit c367a35
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions python/plugins/fTools/tools/doVectorGrid.py
Expand Up @@ -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),
Expand All @@ -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
Expand Down Expand Up @@ -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.