Skip to content

Commit 0d7841a

Browse files
elpasonyalldawson
authored andcommittedApr 17, 2019
Fix grass alg combineLayerExtents
1 parent bdd7a1c commit 0d7841a

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed
 

‎python/plugins/processing/algs/grass7/Grass7Algorithm.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@
3737
QgsRasterLayer,
3838
QgsApplication,
3939
QgsMapLayerType,
40+
QgsCoordinateReferenceSystem,
4041
QgsProcessingUtils,
4142
QgsProcessing,
4243
QgsMessageLog,
@@ -127,6 +128,9 @@ def __init__(self, descriptionfile):
127128
self.minArea = None
128129
self.alignToResolution = None
129130

131+
# destination Crs for combineLayerExtents, will be set from layer or mapSettings
132+
self.destination_crs = QgsCoordinateReferenceSystem()
133+
130134
# Load parameters from a description file
131135
self.defineCharacteristicsFromFile()
132136
self.numExportedLayers = 0
@@ -500,7 +504,7 @@ def postInputs(self, context):
500504

501505
# Build GRASS region
502506
if self.region.isEmpty():
503-
self.region = QgsProcessingUtils.combineLayerExtents(self.inputLayers, context)
507+
self.region = QgsProcessingUtils.combineLayerExtents(self.inputLayers, self.destination_crs, context)
504508
command = 'g.region n={} s={} e={} w={}'.format(
505509
self.region.yMaximum(), self.region.yMinimum(),
506510
self.region.xMaximum(), self.region.xMinimum()
@@ -1001,6 +1005,7 @@ def setSessionProjectionFromProject(self):
10011005
We creates a PROJ4 definition which is transmitted to Grass
10021006
"""
10031007
if not Grass7Utils.projectionSet and iface:
1008+
self.destination_crs = iface.mapCanvas().mapSettings().destinationCrs()
10041009
proj4 = iface.mapCanvas().mapSettings().destinationCrs().toProj4()
10051010
command = 'g.proj -c proj4="{}"'.format(proj4)
10061011
self.commands.append(command)
@@ -1013,6 +1018,7 @@ def setSessionProjectionFromLayer(self, layer):
10131018
"""
10141019
if not Grass7Utils.projectionSet:
10151020
proj4 = str(layer.crs().toProj4())
1021+
self.destination_crs = layer.crs()
10161022
command = 'g.proj -c proj4="{}"'.format(proj4)
10171023
self.commands.append(command)
10181024
Grass7Utils.projectionSet = True

0 commit comments

Comments
 (0)
Please sign in to comment.