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 );
225 QgsDateTimeRange currentTimeRange()
const;
233 void setCurrentTimeRange(
const QgsDateTimeRange ¤tTimeRange );
255 , outputName( outputName )
256 , layerTypeHint( layerTypeHint )
276 bool forceName =
false;
312 void setOutputLayerName(
QgsMapLayer *layer )
const;
333 return mLayersToLoadOnCompletion;
347 return mLayersToLoadOnCompletion.contains( layer );
357 void setLayersToLoadOnCompletion(
const QMap< QString, QgsProcessingContext::LayerDetails > &layers );
384 return mLayersToLoadOnCompletion[ layer ];
411 void setInvalidGeometryCallback( SIP_PYCALLABLE / AllowNone / );
413 Py_BEGIN_ALLOW_THREADS
415 sipCpp->setInvalidGeometryCallback( [a0](
const QgsFeature &arg )
418 Py_XDECREF( sipCallMethod( NULL, a0,
"D", &arg, sipType_QgsFeature, NULL ) );
433 SIP_SKIP std::function< void( const QgsFeature & ) > invalidGeometryCallback(
QgsFeatureSource *source =
nullptr )
const;
452 void setTransformErrorCallback( SIP_PYCALLABLE / AllowNone / );
454 Py_BEGIN_ALLOW_THREADS
456 sipCpp->setTransformErrorCallback( [a0](
const QgsFeature &arg )
459 Py_XDECREF( sipCallMethod( NULL, a0,
"D", &arg, sipType_QgsFeature, NULL ) );
508 QThread *
thread() {
return tempLayerStore.thread(); }
519 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" );
520 tempLayerStore.moveToThread( thread );
542 QgsMapLayer *getMapLayer(
const QString &identifier );
630 QgsProcessingContext::Flags mFlags = QgsProcessingContext::Flags();
631 QPointer< QgsProject > mProject;
638 QgsDateTimeRange mCurrentTimeRange;
645 bool mUseDefaultInvalidGeometryCallback =
true;
646 std::function< void( const QgsFeature & ) > mInvalidGeometryCallback;
648 std::function< void( const QgsFeature & ) > mTransformErrorCallback;
649 QString mDefaultEncoding;
650 QMap< QString, LayerDetails > mLayersToLoadOnCompletion;
652 QPointer< QgsProcessingFeedback > mFeedback;
654 QString mPreferredVectorFormat;
655 QString mPreferredRasterFormat;
681 virtual ~QgsProcessingLayerPostProcessorInterface() =
default;
702 #endif // QGSPROCESSINGPARAMETERS_H void setProject(QgsProject *project)
Sets the project in which the algorithm will be executed.
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...
Base class for all map layer types.
Base class for providing feedback from a processing algorithm.
QMap< QString, QgsProcessingContext::LayerDetails > layersToLoadOnCompletion() const
Returns a map of layers (by ID or datasource) to LayerDetails, to load into the canvas upon completio...
An interface for layer post-processing handlers for execution following a processing algorithm operat...
LayerHint
Layer type hints.
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.
LayerDetails(const QString &name, QgsProject *project, const QString &outputName=QString(), QgsProcessingUtils::LayerHint layerTypeHint=QgsProcessingUtils::LayerHint::UnknownType)
Constructor for LayerDetails.
QString preferredVectorFormat() const
Returns the preferred vector format to use for vector outputs.
QThread * thread()
Returns the thread in which the context lives.
void pushToThread(QThread *thread)
Pushes the thread affinity for the context (including all layers contained in the temporaryLayerStore...
The feature class encapsulates a single feature including its id, geometry and a list of field/values...
InvalidGeometryCheck
Handling of features with invalid geometries.
QgsProject * project() const
Returns the project in which the algorithm is being executed.
QString name
Friendly name for layer, possibly for use when loading layer into project.
std::function< void(const QgsFeature &) > transformErrorCallback() const
Returns the callback function to use when encountering a transform error when iterating features...
QgsProcessingFeedback * feedback()
Returns the associated feedback object.
void setTransformErrorCallback(const std::function< void(const QgsFeature &) > &callback)
Sets a callback function to use when encountering a transform error when iterating features...
QgsMapLayerStore * temporaryLayerStore()
Returns a reference to the layer store used for storing temporary layers during algorithm execution...
QgsProcessingContext::Flags flags() const
Returns any flags set in the context.
void copyThreadSafeSettings(const QgsProcessingContext &other)
Copies all settings which are safe for use across different threads from other to this context...
Expression contexts are used to encapsulate the parameters around which a QgsExpression should be eva...
QgsFeatureRequest::InvalidGeometryCheck invalidGeometryCheck() const
Returns the behavior used for checking invalid geometries in input layers.
void setExpressionContext(const QgsExpressionContext &context)
Sets the expression context.
const QgsExpressionContext & expressionContext() const
Returns the expression context.
void setDefaultEncoding(const QString &encoding)
Sets the default encoding to use for newly created files.
QgsCoordinateTransformContext transformContext() const
Returns the coordinate transform context.
Encapsulates a QGIS project, including sets of map layers and their styles, layouts, annotations, canvases, etc.
No invalid geometry checking.
void setFeedback(QgsProcessingFeedback *feedback)
Sets an associated feedback object.
QString outputName
Associated output name from algorithm which generated the layer.
Contains information about the context in which a coordinate transform is executed.
Details for layers to load into projects.
QgsExpressionContext & expressionContext()
Returns the expression context.
DistanceUnit
Units of distance.
QString preferredRasterFormat() const
Returns the preferred raster format to use for vector outputs.
QgsCoordinateTransformContext transformContext
QString defaultEncoding() const
Returns the default encoding to use for newly created files.
An interface for objects which provide features via a getFeatures method.
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...
void setTransformContext(const QgsCoordinateTransformContext &context)
Sets the coordinate transform context.
void setPreferredVectorFormat(const QString &format)
Sets the preferred vector format to use for vector outputs.
void setFlags(QgsProcessingContext::Flags flags)
Sets flags for the context.
A storage object for map layers, in which the layers are owned by the store and have their lifetime b...
Contains information about the context in which a processing algorithm is executed.
Flag
Flags that affect how processing algorithms are run.
void setPreferredRasterFormat(const QString &format)
Sets the preferred raster format to use for vector outputs.