QGIS API Documentation
3.16.0-Hannover (43b64b13f3)
|
Go to the documentation of this file.
18 #ifndef QGSPROCESSINGCONTEXT_H
19 #define QGSPROCESSINGCONTEXT_H
21 #include "qgis_core.h"
52 Q_DECLARE_FLAGS( Flags, Flag )
72 mFlags = other.mFlags;
73 mProject = other.mProject;
74 mTransformContext = other.mTransformContext;
75 mExpressionContext = other.mExpressionContext;
76 mInvalidGeometryCallback = other.mInvalidGeometryCallback;
77 mUseDefaultInvalidGeometryCallback = other.mUseDefaultInvalidGeometryCallback;
78 mInvalidGeometryCheck = other.mInvalidGeometryCheck;
79 mTransformErrorCallback = other.mTransformErrorCallback;
80 mDefaultEncoding = other.mDefaultEncoding;
81 mFeedback = other.mFeedback;
82 mPreferredVectorFormat = other.mPreferredVectorFormat;
83 mPreferredRasterFormat = other.mPreferredRasterFormat;
84 mEllipsoid = other.mEllipsoid;
85 mDistanceUnit = other.mDistanceUnit;
86 mAreaUnit = other.mAreaUnit;
93 QgsProcessingContext::Flags
flags()
const {
return mFlags; }
99 void setFlags( QgsProcessingContext::Flags flags ) { mFlags = flags; }
121 if ( mEllipsoid.isEmpty() )
122 mEllipsoid = mProject->ellipsoid();
124 mDistanceUnit = mProject->distanceUnits();
126 mAreaUnit = mProject->areaUnits();
167 QString ellipsoid()
const;
177 void setEllipsoid(
const QString &ellipsoid );
239 , outputName( outputName )
240 , layerTypeHint( layerTypeHint )
260 bool forceName =
false;
296 void setOutputLayerName(
QgsMapLayer *layer )
const;
317 return mLayersToLoadOnCompletion;
331 return mLayersToLoadOnCompletion.contains( layer );
341 void setLayersToLoadOnCompletion(
const QMap< QString, QgsProcessingContext::LayerDetails > &layers );
368 return mLayersToLoadOnCompletion[ layer ];
395 void setInvalidGeometryCallback( SIP_PYCALLABLE / AllowNone / );
397 Py_BEGIN_ALLOW_THREADS
399 sipCpp->setInvalidGeometryCallback( [a0](
const QgsFeature &arg )
402 Py_XDECREF( sipCallMethod( NULL, a0,
"D", &arg, sipType_QgsFeature, NULL ) );
436 void setTransformErrorCallback( SIP_PYCALLABLE / AllowNone / );
438 Py_BEGIN_ALLOW_THREADS
440 sipCpp->setTransformErrorCallback( [a0](
const QgsFeature &arg )
443 Py_XDECREF( sipCallMethod( NULL, a0,
"D", &arg, sipType_QgsFeature, NULL ) );
492 QThread *
thread() {
return tempLayerStore.thread(); }
503 Q_ASSERT_X( QThread::currentThread() ==
QgsProcessingContext::thread(),
"QgsProcessingContext::pushToThread",
"Cannot push context to another thread unless the current thread matches the existing context thread affinity" );
504 tempLayerStore.moveToThread( thread );
526 QgsMapLayer *getMapLayer(
const QString &identifier );
614 QgsProcessingContext::Flags mFlags = QgsProcessingContext::Flags();
615 QPointer< QgsProject > mProject;
627 bool mUseDefaultInvalidGeometryCallback =
true;
628 std::function< void(
const QgsFeature & ) > mInvalidGeometryCallback;
630 std::function< void(
const QgsFeature & ) > mTransformErrorCallback;
631 QString mDefaultEncoding;
632 QMap< QString, LayerDetails > mLayersToLoadOnCompletion;
634 QPointer< QgsProcessingFeedback > mFeedback;
636 QString mPreferredVectorFormat;
637 QString mPreferredRasterFormat;
684 #endif // QGSPROCESSINGPARAMETERS_H
Expression contexts are used to encapsulate the parameters around which a QgsExpression should be eva...
QgsProcessingContext(const QgsProcessingContext &other)=delete
QgsProcessingContext cannot be copied.
QMap< QString, QgsProcessingContext::LayerDetails > layersToLoadOnCompletion() const
Returns a map of layers (by ID or datasource) to LayerDetails, to load into the canvas upon completio...
Contains information about the context in which a coordinate transform is executed.
LayerDetails()=default
Default constructor.
bool willLoadLayerOnCompletion(const QString &layer) const
Returns true if the given layer (by ID or datasource) will be loaded into the current project upon co...
QgsProject * project() const
Returns the project in which the algorithm is being executed.
QString preferredVectorFormat() const
Returns the preferred vector format to use for vector outputs.
@ DistanceUnknownUnit
Unknown distance unit.
Base class for providing feedback from a processing algorithm.
QgsCoordinateTransformContext transformContext
An interface for objects which provide features via a getFeatures method.
QThread * thread()
Returns the thread in which the context lives.
LayerHint
Layer type hints.
InvalidGeometryCheck
Handling of features with invalid geometries.
DistanceUnit
Units of distance.
virtual ~QgsProcessingLayerPostProcessorInterface()=default
Encapsulates a QGIS project, including sets of map layers and their styles, layouts,...
void setTransformErrorCallback(const std::function< void(const QgsFeature &) > &callback)
Sets a callback function to use when encountering a transform error when iterating features.
A storage object for map layers, in which the layers are owned by the store and have their lifetime b...
void pushToThread(QThread *thread)
Pushes the thread affinity for the context (including all layers contained in the temporaryLayerStore...
LayerDetails(const QString &name, QgsProject *project, const QString &outputName=QString(), QgsProcessingUtils::LayerHint layerTypeHint=QgsProcessingUtils::LayerHint::UnknownType)
Constructor for LayerDetails.
QgsFeatureRequest::InvalidGeometryCheck invalidGeometryCheck() const
Returns the behavior used for checking invalid geometries in input layers.
Contains information about the context in which a processing algorithm is executed.
std::function< void(const QgsFeature &) > transformErrorCallback() const
Returns the callback function to use when encountering a transform error when iterating features.
QString defaultEncoding() const
Returns the default encoding to use for newly created files.
void setDefaultEncoding(const QString &encoding)
Sets the default encoding to use for newly created files.
QString name
Friendly name for layer, possibly for use when loading layer into project.
void copyThreadSafeSettings(const QgsProcessingContext &other)
Copies all settings which are safe for use across different threads from other to this context.
void setInvalidGeometryCallback(const std::function< void(const QgsFeature &) > &callback)
Sets a callback function to use when encountering an invalid geometry and invalidGeometryCheck() is s...
Q_DECLARE_OPERATORS_FOR_FLAGS(QgsField::ConfigurationFlags) CORE_EXPORT QDataStream &operator<<(QDataStream &out
Writes the field to stream out. QGIS version compatibility is not guaranteed.
QString preferredRasterFormat() const
Returns the preferred raster format to use for vector outputs.
void setExpressionContext(const QgsExpressionContext &context)
Sets the expression context.
QgsCoordinateTransformContext transformContext() const
Returns the coordinate transform context.
An interface for layer post-processing handlers for execution following a processing algorithm operat...
void setTransformContext(const QgsCoordinateTransformContext &context)
Sets the coordinate transform context.
Flag
Flags that affect how processing algorithms are run.
Details for layers to load into projects.
const QgsExpressionContext & expressionContext() const
Returns the expression context.
QgsMapLayerStore * temporaryLayerStore()
Returns a reference to the layer store used for storing temporary layers during algorithm execution.
QgsProcessingFeedback * feedback()
Returns the associated feedback object.
void setFeedback(QgsProcessingFeedback *feedback)
Sets an associated feedback object.
QString outputName
Associated output name from algorithm which generated the layer.
QgsProcessingContext & operator=(const QgsProcessingContext &other)=delete
QgsProcessingContext cannot be copied.
Base class for all map layer types.
QgsProcessingContext::LayerDetails & layerToLoadOnCompletionDetails(const QString &layer)
Returns a reference to the details for a given layer which is loaded on completion of the algorithm o...
QgsExpressionContext & expressionContext()
Returns the expression context.
virtual void postProcessLayer(QgsMapLayer *layer, QgsProcessingContext &context, QgsProcessingFeedback *feedback)=0
Post-processes the specified layer, following successful execution of a processing algorithm.
QgsProcessingContext::Flags flags() const
Returns any flags set in the context.
@ GeometryNoCheck
No invalid geometry checking.
void setPreferredVectorFormat(const QString &format)
Sets the preferred vector format to use for vector outputs.
The feature class encapsulates a single feature including its id, geometry and a list of field/values...
void setProject(QgsProject *project)
Sets the project in which the algorithm will be executed.
void setPreferredRasterFormat(const QString &format)
Sets the preferred raster format to use for vector outputs.
void setFlags(QgsProcessingContext::Flags flags)
Sets flags for the context.
@ AreaUnknownUnit
Unknown areal unit.
@ UnknownType
Unknown layer type.