diff --git a/python/core/auto_generated/processing/qgsprocessingutils.sip.in b/python/core/auto_generated/processing/qgsprocessingutils.sip.in index c72ac8b1eeb..e4b9853d823 100644 --- a/python/core/auto_generated/processing/qgsprocessingutils.sip.in +++ b/python/core/auto_generated/processing/qgsprocessingutils.sip.in @@ -177,11 +177,11 @@ temporary layer store. %End - static QgsRectangle combineLayerExtents( const QList &layers, const QgsCoordinateReferenceSystem &crs, const QgsCoordinateTransformContext &transformContext ); + static QgsRectangle combineLayerExtents( const QList &layers, const QgsCoordinateReferenceSystem &crs, QgsProcessingContext &context ); %Docstring Combines the extent of several map ``layers``. If specified, the target ``crs`` will be used to transform the layer's extent to the desired output reference system -using the specified ``transformContext``. +using the specified ``context``. .. versionadded:: 3.10 %End diff --git a/python/plugins/processing/algs/grass7/Grass7Algorithm.py b/python/plugins/processing/algs/grass7/Grass7Algorithm.py index 8b1660b2546..c3793952950 100644 --- a/python/plugins/processing/algs/grass7/Grass7Algorithm.py +++ b/python/plugins/processing/algs/grass7/Grass7Algorithm.py @@ -489,9 +489,9 @@ class Grass7Algorithm(QgsProcessingAlgorithm): elif layer.type() == QgsMapLayerType.VectorLayer: self.loadVectorLayer(layerName, layer, external=None, feedback=feedback) - self.postInputs() + self.postInputs(context) - def postInputs(self): + def postInputs(self, context): """ After layer imports, we need to update some internal parameters """ @@ -500,7 +500,7 @@ class Grass7Algorithm(QgsProcessingAlgorithm): # Build GRASS region if self.region.isEmpty(): - self.region = QgsProcessingUtils.combineLayerExtents(self.inputLayers) + self.region = QgsProcessingUtils.combineLayerExtents(self.inputLayers, context) command = 'g.region n={} s={} e={} w={}'.format( self.region.yMaximum(), self.region.yMinimum(), self.region.xMaximum(), self.region.xMinimum() diff --git a/python/plugins/processing/algs/grass7/ext/r_blend_combine.py b/python/plugins/processing/algs/grass7/ext/r_blend_combine.py index 3755ccf68a5..4b154b156ca 100644 --- a/python/plugins/processing/algs/grass7/ext/r_blend_combine.py +++ b/python/plugins/processing/algs/grass7/ext/r_blend_combine.py @@ -33,7 +33,7 @@ def processInputs(alg, parameters, context, feedback): # Use v.in.ogr for name in ['first', 'second']: alg.loadRasterLayerFromParameter(name, parameters, context, False, None) - alg.postInputs() + alg.postInputs(context) def processOutputs(alg, parameters, context, feedback): diff --git a/python/plugins/processing/algs/grass7/ext/r_blend_rgb.py b/python/plugins/processing/algs/grass7/ext/r_blend_rgb.py index 770965c2bf7..644e10361ca 100644 --- a/python/plugins/processing/algs/grass7/ext/r_blend_rgb.py +++ b/python/plugins/processing/algs/grass7/ext/r_blend_rgb.py @@ -37,7 +37,7 @@ def processInputs(alg, parameters, context, feedback): # Use v.in.ogr for name in ['first', 'second']: alg.loadRasterLayerFromParameter(name, parameters, context, False, None) - alg.postInputs() + alg.postInputs(context) def processCommand(alg, parameters, context, feedback): diff --git a/python/plugins/processing/algs/grass7/ext/r_category.py b/python/plugins/processing/algs/grass7/ext/r_category.py index 14372cc71e5..bad9a28fe8d 100644 --- a/python/plugins/processing/algs/grass7/ext/r_category.py +++ b/python/plugins/processing/algs/grass7/ext/r_category.py @@ -52,7 +52,7 @@ def processInputs(alg, parameters, context, feedback): parameters, context, False, None) alg.loadRasterLayerFromParameter('map', parameters, context) - alg.postInputs() + alg.postInputs(context) def processCommand(alg, parameters, context, feedback): diff --git a/python/plugins/processing/algs/grass7/ext/r_colors.py b/python/plugins/processing/algs/grass7/ext/r_colors.py index 008f1865417..b5aadd8d3bd 100644 --- a/python/plugins/processing/algs/grass7/ext/r_colors.py +++ b/python/plugins/processing/algs/grass7/ext/r_colors.py @@ -54,7 +54,7 @@ def processInputs(alg, parameters, context, feedback): if raster: alg.loadRasterLayerFromParameter('raster', parameters, context, False, None) - alg.postInputs() + alg.postInputs(context) def processCommand(alg, parameters, context, feedback): diff --git a/python/plugins/processing/algs/grass7/ext/r_colors_stddev.py b/python/plugins/processing/algs/grass7/ext/r_colors_stddev.py index e5bcc5bab7d..66c1c76bb89 100644 --- a/python/plugins/processing/algs/grass7/ext/r_colors_stddev.py +++ b/python/plugins/processing/algs/grass7/ext/r_colors_stddev.py @@ -35,7 +35,7 @@ def processInputs(alg, parameters, context, feedback): # We need to import all the bands and color tables of the input raster alg.loadRasterLayerFromParameter('map', parameters, context, False, None) - alg.postInputs() + alg.postInputs(context) def processCommand(alg, parameters, context, feedback): diff --git a/python/plugins/processing/algs/grass7/ext/r_null.py b/python/plugins/processing/algs/grass7/ext/r_null.py index 162b23bb46e..989cfab9b44 100644 --- a/python/plugins/processing/algs/grass7/ext/r_null.py +++ b/python/plugins/processing/algs/grass7/ext/r_null.py @@ -42,7 +42,7 @@ def processInputs(alg, parameters, context, feedback): # We need to import without r.external alg.loadRasterLayerFromParameter('map', parameters, context, False) - alg.postInputs() + alg.postInputs(context) def processCommand(alg, parameters, context, feedback): diff --git a/python/plugins/processing/algs/grass7/ext/r_rgb.py b/python/plugins/processing/algs/grass7/ext/r_rgb.py index 2ae41e860b8..cddd4c5594b 100644 --- a/python/plugins/processing/algs/grass7/ext/r_rgb.py +++ b/python/plugins/processing/algs/grass7/ext/r_rgb.py @@ -32,7 +32,7 @@ def processInputs(alg, parameters, context, feedback): # We need to import all the bands and color tables of the input raster alg.loadRasterLayerFromParameter('input', parameters, context, False, None) - alg.postInputs() + alg.postInputs(context) def processCommand(alg, parameters, context, feedback): diff --git a/python/plugins/processing/algs/grass7/ext/v_sample.py b/python/plugins/processing/algs/grass7/ext/v_sample.py index 62db74edbcb..330180beecc 100644 --- a/python/plugins/processing/algs/grass7/ext/v_sample.py +++ b/python/plugins/processing/algs/grass7/ext/v_sample.py @@ -34,4 +34,4 @@ def processInputs(alg, parameters, context, feedback): # and we can use r.external for the raster alg.loadVectorLayerFromParameter('input', parameters, context, feedback, False) alg.loadRasterLayerFromParameter('raster', parameters, context, True) - alg.postInputs() + alg.postInputs(context) diff --git a/python/plugins/processing/algs/grass7/ext/v_to_3d.py b/python/plugins/processing/algs/grass7/ext/v_to_3d.py index 88265aa5290..72bb7bc89fa 100644 --- a/python/plugins/processing/algs/grass7/ext/v_to_3d.py +++ b/python/plugins/processing/algs/grass7/ext/v_to_3d.py @@ -42,4 +42,4 @@ def processInputs(alg, parameters, context, feedback): # We need to import the vector layer with v.in.ogr alg.loadVectorLayerFromParameter('input', parameters, context, feedback, False) - alg.postInputs() + alg.postInputs(context) diff --git a/python/plugins/processing/algs/qgis/RasterCalculator.py b/python/plugins/processing/algs/qgis/RasterCalculator.py index 9210edc0fe2..03ab80e03cd 100644 --- a/python/plugins/processing/algs/qgis/RasterCalculator.py +++ b/python/plugins/processing/algs/qgis/RasterCalculator.py @@ -127,7 +127,7 @@ class RasterCalculator(QgisAlgorithm): bbox = transform.transformBoundingBox(bbox) if bbox.isNull() and layers: - bbox = QgsProcessingUtils.combineLayerExtents(layers, crs) + bbox = QgsProcessingUtils.combineLayerExtents(layers, crs, context) cellsize = self.parameterAsDouble(parameters, self.CELLSIZE, context) if cellsize == 0 and not layers: diff --git a/src/core/processing/qgsprocessingutils.cpp b/src/core/processing/qgsprocessingutils.cpp index 6feea171aaa..441578260ef 100644 --- a/src/core/processing/qgsprocessingutils.cpp +++ b/src/core/processing/qgsprocessingutils.cpp @@ -627,7 +627,7 @@ void QgsProcessingUtils::createFeatureSinkPython( QgsFeatureSink **sink, QString } -QgsRectangle QgsProcessingUtils::combineLayerExtents( const QList &layers, const QgsCoordinateReferenceSystem &crs, const QgsCoordinateTransformContext &transformContext ) +QgsRectangle QgsProcessingUtils::combineLayerExtents( const QList &layers, const QgsCoordinateReferenceSystem &crs, QgsProcessingContext &context ) { QgsRectangle extent; for ( const QgsMapLayer *layer : layers ) @@ -638,7 +638,7 @@ QgsRectangle QgsProcessingUtils::combineLayerExtents( const QList if ( crs.isValid() ) { //transform layer extent to target CRS - QgsCoordinateTransform ct( layer->crs(), crs, transformContext ); + QgsCoordinateTransform ct( layer->crs(), crs, context.transformContext() ); try { QgsRectangle reprojExtent = ct.transformBoundingBox( layer->extent() ); @@ -662,7 +662,8 @@ QgsRectangle QgsProcessingUtils::combineLayerExtents( const QList // Deprecated QgsRectangle QgsProcessingUtils::combineLayerExtents( const QList &layers, const QgsCoordinateReferenceSystem &crs ) { - return QgsProcessingUtils::combineLayerExtents( layers, crs, QgsCoordinateTransformContext( ) ); + QgsProcessingContext context; + return QgsProcessingUtils::combineLayerExtents( layers, crs, context ); } QVariant QgsProcessingUtils::generateIteratingDestination( const QVariant &input, const QVariant &id, QgsProcessingContext &context ) diff --git a/src/core/processing/qgsprocessingutils.h b/src/core/processing/qgsprocessingutils.h index 63dbb759466..784350b1684 100644 --- a/src/core/processing/qgsprocessingutils.h +++ b/src/core/processing/qgsprocessingutils.h @@ -217,10 +217,10 @@ class CORE_EXPORT QgsProcessingUtils /** * Combines the extent of several map \a layers. If specified, the target \a crs * will be used to transform the layer's extent to the desired output reference system - * using the specified \a transformContext. + * using the specified \a context. * \since QGIS 3.10 */ - static QgsRectangle combineLayerExtents( const QList &layers, const QgsCoordinateReferenceSystem &crs, const QgsCoordinateTransformContext &transformContext ); + static QgsRectangle combineLayerExtents( const QList &layers, const QgsCoordinateReferenceSystem &crs, QgsProcessingContext &context ); /** * Combines the extent of several map \a layers. If specified, the target \a crs diff --git a/tests/src/analysis/testqgsprocessing.cpp b/tests/src/analysis/testqgsprocessing.cpp index 721addac3cf..39551482ef6 100644 --- a/tests/src/analysis/testqgsprocessing.cpp +++ b/tests/src/analysis/testqgsprocessing.cpp @@ -6236,7 +6236,8 @@ void TestQgsProcessing::checkParamValues() void TestQgsProcessing::combineLayerExtent() { - QgsRectangle ext = QgsProcessingUtils::combineLayerExtents( QList< QgsMapLayer *>() ); + QgsProcessingContext context; + QgsRectangle ext = QgsProcessingUtils::combineLayerExtents( QList< QgsMapLayer *>(), context ); QVERIFY( ext.isNull() ); QString testDataDir = QStringLiteral( TEST_DATA_DIR ) + '/'; //defined in CmakeLists.txt @@ -6248,20 +6249,20 @@ void TestQgsProcessing::combineLayerExtent() QFileInfo fi2( raster2 ); std::unique_ptr< QgsRasterLayer > r2( new QgsRasterLayer( fi2.filePath(), "R2" ) ); - ext = QgsProcessingUtils::combineLayerExtents( QList< QgsMapLayer *>() << r1.get() ); + ext = QgsProcessingUtils::combineLayerExtents( QList< QgsMapLayer *>() << r1.get(), context ); QGSCOMPARENEAR( ext.xMinimum(), 1535375.000000, 10 ); QGSCOMPARENEAR( ext.xMaximum(), 1535475, 10 ); QGSCOMPARENEAR( ext.yMinimum(), 5083255, 10 ); QGSCOMPARENEAR( ext.yMaximum(), 5083355, 10 ); - ext = QgsProcessingUtils::combineLayerExtents( QList< QgsMapLayer *>() << r1.get() << r2.get() ); + ext = QgsProcessingUtils::combineLayerExtents( QList< QgsMapLayer *>() << r1.get() << r2.get(), context ); QGSCOMPARENEAR( ext.xMinimum(), 781662, 10 ); QGSCOMPARENEAR( ext.xMaximum(), 1535475, 10 ); QGSCOMPARENEAR( ext.yMinimum(), 3339523, 10 ); QGSCOMPARENEAR( ext.yMaximum(), 5083355, 10 ); // with reprojection - ext = QgsProcessingUtils::combineLayerExtents( QList< QgsMapLayer *>() << r1.get() << r2.get(), QgsCoordinateReferenceSystem::fromEpsgId( 3785 ) ); + ext = QgsProcessingUtils::combineLayerExtents( QList< QgsMapLayer *>() << r1.get() << r2.get(), QgsCoordinateReferenceSystem::fromEpsgId( 3785 ), context ); QGSCOMPARENEAR( ext.xMinimum(), 1995320, 10 ); QGSCOMPARENEAR( ext.xMaximum(), 2008833, 10 ); QGSCOMPARENEAR( ext.yMinimum(), 3523084, 10 );