Skip to content

Commit c367a35

Browse files
committedMay 22, 2012
create vector grid in layer CRS (fix #5204)
1 parent 860f370 commit c367a35

File tree

1 file changed

+4
-6
lines changed

1 file changed

+4
-6
lines changed
 

‎python/plugins/fTools/tools/doVectorGrid.py

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,7 @@ def accept(self):
153153
self.buttonOk.setEnabled( True )
154154

155155
def compute( self, bound, xOffset, yOffset, polygon ):
156-
crs = self.iface.mapCanvas().mapRenderer().destinationSrs()
156+
crs = ftools_utils.getMapLayerByName(unicode(self.inShape.currentText())).crs()
157157
if not crs.isValid(): crs = None
158158
if polygon:
159159
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 ):
163163
if not QgsVectorFileWriter.deleteShapeFile(self.shapefileName):
164164
return
165165
writer = QgsVectorFileWriter(self.shapefileName, self.encoding, fields, QGis.WKBPolygon, crs)
166-
#writer = QgsVectorFileWriter(outPath, "CP1250", fields, QGis.WKBPolygon, None)
167166
else:
168167
fields = {0:QgsField("ID", QVariant.Int), 1:QgsField("COORD", QVariant.Double)}
169168
check = QFile(self.shapefileName)
170169
if check.exists():
171170
if not QgsVectorFileWriter.deleteShapeFile(self.shapefileName):
172171
return
173172
writer = QgsVectorFileWriter(self.shapefileName, self.encoding, fields, QGis.WKBLineString, crs)
174-
#writer = QgsVectorFileWriter(unicode(outPath), "CP1250", fields, QGis.WKBLineString, None)
175173
outFeat = QgsFeature()
176174
outGeom = QgsGeometry()
177175
idVar = 0
@@ -279,16 +277,16 @@ def getClosestPixel(self, startVal, targetVal, step, isMin ):
279277
while foundVal is None:
280278
if tmpVal <= targetVal:
281279
if backOneStep:
282-
tmpVal -= step
280+
tmpVal -= step
283281
foundVal = tmpVal
284282
tmpVal += step
285283
else:
286284
backOneStep = isMin
287285
while foundVal is None:
288286
if tmpVal >= targetVal:
289287
if backOneStep:
290-
tmpVal -= step
288+
tmpVal -= step
291289
foundVal = tmpVal
292290
tmpVal += step
293-
return foundVal
291+
return foundVal
294292

0 commit comments

Comments
 (0)
Please sign in to comment.