Skip to content

Commit

Permalink
Fix grass alg combineLayerExtents
Browse files Browse the repository at this point in the history
  • Loading branch information
elpaso authored and nyalldawson committed Apr 17, 2019
1 parent bdd7a1c commit 0d7841a
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion python/plugins/processing/algs/grass7/Grass7Algorithm.py
Expand Up @@ -37,6 +37,7 @@
QgsRasterLayer,
QgsApplication,
QgsMapLayerType,
QgsCoordinateReferenceSystem,
QgsProcessingUtils,
QgsProcessing,
QgsMessageLog,
Expand Down Expand Up @@ -127,6 +128,9 @@ def __init__(self, descriptionfile):
self.minArea = None
self.alignToResolution = None

# destination Crs for combineLayerExtents, will be set from layer or mapSettings
self.destination_crs = QgsCoordinateReferenceSystem()

# Load parameters from a description file
self.defineCharacteristicsFromFile()
self.numExportedLayers = 0
Expand Down Expand Up @@ -500,7 +504,7 @@ def postInputs(self, context):

# Build GRASS region
if self.region.isEmpty():
self.region = QgsProcessingUtils.combineLayerExtents(self.inputLayers, context)
self.region = QgsProcessingUtils.combineLayerExtents(self.inputLayers, self.destination_crs, context)
command = 'g.region n={} s={} e={} w={}'.format(
self.region.yMaximum(), self.region.yMinimum(),
self.region.xMaximum(), self.region.xMinimum()
Expand Down Expand Up @@ -1001,6 +1005,7 @@ def setSessionProjectionFromProject(self):
We creates a PROJ4 definition which is transmitted to Grass
"""
if not Grass7Utils.projectionSet and iface:
self.destination_crs = iface.mapCanvas().mapSettings().destinationCrs()
proj4 = iface.mapCanvas().mapSettings().destinationCrs().toProj4()
command = 'g.proj -c proj4="{}"'.format(proj4)
self.commands.append(command)
Expand All @@ -1013,6 +1018,7 @@ def setSessionProjectionFromLayer(self, layer):
"""
if not Grass7Utils.projectionSet:
proj4 = str(layer.crs().toProj4())
self.destination_crs = layer.crs()
command = 'g.proj -c proj4="{}"'.format(proj4)
self.commands.append(command)
Grass7Utils.projectionSet = True
Expand Down

0 comments on commit 0d7841a

Please sign in to comment.