Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
[processing] set CRS for output grid (fix #12518)
  • Loading branch information
alexbruy committed Apr 10, 2015
1 parent 864443d commit 96d4003
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions python/plugins/processing/algs/qgis/Grid.py
Expand Up @@ -34,18 +34,15 @@
from processing.core.parameters import ParameterExtent
from processing.core.parameters import ParameterNumber
from processing.core.parameters import ParameterSelection
from processing.core.parameters import ParameterCrs
from processing.core.outputs import OutputVector


class Grid(GeoAlgorithm):
TYPE = 'TYPE'
EXTENT = 'EXTENT'
WIDTH = 'WIDTH'
HEIGHT = 'HEIGHT'
HSPACING = 'HSPACING'
VSPACING = 'VSPACING'
CENTERX = 'CENTERX'
CENTERY = 'CENTERY'
CRS = 'CRS'
OUTPUT = 'OUTPUT'

Expand All @@ -67,14 +64,16 @@ def defineCharacteristics(self):
self.tr('Horizontal spacing'), default=10.0))
self.addParameter(ParameterNumber(self.VSPACING,
self.tr('Vertical spacing'), default=10.0))
self.addParameter(ParameterCrs(self.CRS, 'Grid CRS'))

self.addOutput(OutputVector(self.OUTPUT, self.tr('Output')))
self.addOutput(OutputVector(self.OUTPUT, self.tr('Grid')))

def processAlgorithm(self, progress):
idx = self.getParameterValue(self.TYPE)
extent = self.getParameterValue(self.EXTENT).split(',')
hSpacing = self.getParameterValue(self.HSPACING)
vSpacing = self.getParameterValue(self.VSPACING)
crs = QgsCoordinateReferenceSystem(self.getParameterValue(self.CRS))

bbox = QgsRectangle(float(extent[0]), float(extent[2]),
float(extent[1]), float(extent[3]))
Expand All @@ -85,7 +84,6 @@ def processAlgorithm(self, progress):
centerY = bbox.center().y()
originX = centerX - width / 2.0
originY = centerY - height / 2.0
crs = QgsCoordinateReferenceSystem(self.getParameterValue(self.CRS))

if hSpacing <= 0 or vSpacing <= 0:
raise GeoAlgorithmExecutionException(
Expand Down

0 comments on commit 96d4003

Please sign in to comment.