@@ -102,9 +102,18 @@ class CORE_EXPORT QgsProcessingContext
102
102
103
103
/* *
104
104
* Sets the \a project in which the algorithm will be executed.
105
+ *
106
+ * This also automatically sets the transformContext() to match
107
+ * the project's transform context.
108
+ *
105
109
* \see project()
106
110
*/
107
- void setProject ( QgsProject *project ) { mProject = project; }
111
+ void setProject ( QgsProject *project )
112
+ {
113
+ mProject = project;
114
+ if ( mProject )
115
+ mTransformContext = mProject ->transformContext ();
116
+ }
108
117
109
118
/* *
110
119
* Returns the expression context.
@@ -121,6 +130,22 @@ class CORE_EXPORT QgsProcessingContext
121
130
*/
122
131
void setExpressionContext ( const QgsExpressionContext &context ) { mExpressionContext = context; }
123
132
133
+ /* *
134
+ * Returns the coordinate transform context.
135
+ * \see setTransformContext()
136
+ */
137
+ QgsCoordinateTransformContext transformContext () const { return mTransformContext ; }
138
+
139
+ /* *
140
+ * Sets the coordinate transform \a context.
141
+ *
142
+ * Note that setting a project for the context will automatically set the coordinate transform
143
+ * context.
144
+ *
145
+ * \see transformContext()
146
+ */
147
+ void setTransformContext ( const QgsCoordinateTransformContext &context ) { mTransformContext = context; }
148
+
124
149
/* *
125
150
* Returns a reference to the layer store used for storing temporary layers during
126
151
* algorithm execution.
@@ -375,6 +400,7 @@ class CORE_EXPORT QgsProcessingContext
375
400
376
401
QgsProcessingContext::Flags mFlags = nullptr ;
377
402
QPointer< QgsProject > mProject ;
403
+ QgsCoordinateTransformContext mTransformContext ;
378
404
// ! Temporary project owned by the context, used for storing temporarily loaded map layers
379
405
QgsMapLayerStore tempLayerStore;
380
406
QgsExpressionContext mExpressionContext ;
0 commit comments