18#ifndef QGSPROCESSINGCONTEXT_H
19#define QGSPROCESSINGCONTEXT_H
68 mFlags = other.mFlags;
69 mProject = other.mProject;
70 mTransformContext = other.mTransformContext;
71 mExpressionContext = other.mExpressionContext;
73 mInvalidGeometryCallback = other.mInvalidGeometryCallback;
74 mUseDefaultInvalidGeometryCallback = other.mUseDefaultInvalidGeometryCallback;
75 mInvalidGeometryCheck = other.mInvalidGeometryCheck;
76 mTransformErrorCallback = other.mTransformErrorCallback;
77 mDefaultEncoding = other.mDefaultEncoding;
78 mFeedback = other.mFeedback;
79 mPreferredVectorFormat = other.mPreferredVectorFormat;
80 mPreferredRasterFormat = other.mPreferredRasterFormat;
81 mEllipsoid = other.mEllipsoid;
82 mDistanceUnit = other.mDistanceUnit;
83 mAreaUnit = other.mAreaUnit;
84 mLogLevel = other.mLogLevel;
85 mTemporaryFolderOverride = other.mTemporaryFolderOverride;
86 mMaximumThreads = other.mMaximumThreads;
87 mModelResult = other.mModelResult;
123 mTransformContext = mProject->transformContext();
124 if ( mEllipsoid.isEmpty() )
125 mEllipsoid = mProject->ellipsoid();
127 mDistanceUnit = mProject->distanceUnits();
129 mAreaUnit = mProject->areaUnits();
180 void setEllipsoid( const QString &ellipsoid )
SIP_HOLDGIL;
350 return mLayersToLoadOnCompletion;
364 return mLayersToLoadOnCompletion.contains( layer );
374 void setLayersToLoadOnCompletion(
const QMap< QString, QgsProcessingContext::LayerDetails > &layers )
SIP_HOLDGIL;
401 return mLayersToLoadOnCompletion[ layer ];
428 void setInvalidGeometryCallback( SIP_PYCALLABLE / AllowNone / );
430 Py_BEGIN_ALLOW_THREADS
432 sipCpp->setInvalidGeometryCallback( [a0](
const QgsFeature &arg )
435 Py_XDECREF( sipCallMethod( NULL, a0,
"D", &arg, sipType_QgsFeature, NULL ) );
450 SIP_SKIP std::function< void(
const QgsFeature & ) > invalidGeometryCallback( QgsFeatureSource *source =
nullptr )
const;
457 SIP_SKIP std::function< void(
const QgsFeature & ) > defaultInvalidGeometryCallbackForCheck(
Qgis::InvalidGeometryCheck check, QgsFeatureSource *source =
nullptr )
const;
469 void setTransformErrorCallback( SIP_PYCALLABLE / AllowNone / );
471 Py_BEGIN_ALLOW_THREADS
473 sipCpp->setTransformErrorCallback( [a0](
const QgsFeature &arg )
476 Py_XDECREF( sipCallMethod( NULL, a0,
"D", &arg, sipType_QgsFeature, NULL ) );
536 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" );
537 tempLayerStore.moveToThread(
thread );
559 QgsMapLayer *getMapLayer(
const QString &identifier );
685 void setTemporaryFolder( const QString &folder )
SIP_HOLDGIL;
731 IncludeProjectPath = 1 << 0,
811 void clearModelResult();
816 QPointer< QgsProject > mProject;
830 bool mUseDefaultInvalidGeometryCallback =
true;
831 std::function< void(
const QgsFeature & ) > mInvalidGeometryCallback;
833 std::function< void(
const QgsFeature & ) > mTransformErrorCallback;
834 QString mDefaultEncoding;
835 QMap< QString, LayerDetails > mLayersToLoadOnCompletion;
837 QPointer< QgsProcessingFeedback > mFeedback;
839 QString mPreferredVectorFormat;
840 QString mPreferredRasterFormat;
844 QString mTemporaryFolderOverride;
845 int mMaximumThreads = QThread::idealThreadCount();
847 std::unique_ptr< QgsProcessingModelInitialRunConfig > mModelConfig;
Provides global constants and enumerations for use throughout the application.
DistanceUnit
Units of distance.
@ Unknown
Unknown distance unit.
@ Unknown
Unknown areal unit.
InvalidGeometryCheck
Methods for handling of features with invalid geometries.
@ NoCheck
No invalid geometry checking.
ProcessingLogLevel
Logging level for algorithms to use when pushing feedback messages.
@ DefaultLevel
Default logging level.
Contains information about the context in which a coordinate transform is executed.
Expression contexts are used to encapsulate the parameters around which a QgsExpression should be eva...
void setLoadedLayerStore(QgsMapLayerStore *store)
Sets the destination layer store for any layers loaded during expression evaluation.
The feature class encapsulates a single feature including its unique ID, geometry and a list of field...
A storage object for map layers, in which the layers are owned by the store and have their lifetime b...
Base class for all map layer types.
Details for layers to load into projects.
int layerSortKey
Optional sorting key for sorting output layers when loading them into a project.
QString groupName
Optional name for a layer tree group under which to place the layer when loading it into a project.
bool forceName
Set to true if LayerDetails::name should always be used as the loaded layer name, regardless of the u...
QgsProcessingLayerPostProcessorInterface * postProcessor() const
Layer post-processor.
QString name
Friendly name for layer, possibly for use when loading layer into project.
QgsProject * project
Destination project.
LayerDetails(const QString &name, QgsProject *project, const QString &outputName=QString(), QgsProcessingUtils::LayerHint layerTypeHint=QgsProcessingUtils::LayerHint::UnknownType)
Constructor for LayerDetails.
void setPostProcessor(QgsProcessingLayerPostProcessorInterface *processor)
Sets the layer post-processor.
QString outputName
Associated output name from algorithm which generated the layer.
QgsProcessingUtils::LayerHint layerTypeHint
Layer type hint.
void setOutputLayerName(QgsMapLayer *layer) const
Sets a layer name to match this output, respecting any local user settings which affect this name.
Contains information about the context in which a processing algorithm is executed.
QString defaultEncoding() const
Returns the default encoding to use for newly created files.
QThread * thread()
Returns the thread in which the context lives.
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...
QgsProcessingModelResult & modelResult()
Returns a reference to the model results, populated when the context is used to run a model algorithm...
QgsProcessingFeedback * feedback()
Returns the associated feedback object.
QString preferredRasterFormat() const
Returns the preferred raster format to use for raster outputs.
QgsProcessingContext::Flags flags() const
Returns any flags set in the context.
ProcessArgumentFlag
Flags controlling the results given by asQgisProcessArguments().
QFlags< ProcessArgumentFlag > ProcessArgumentFlags
std::unique_ptr< QgsProcessingModelInitialRunConfig > takeModelInitialRunConfig()
Takes the model initial run configuration from the context.
QgsExpressionContext & expressionContext()
Returns the expression context.
QgsCoordinateTransformContext transformContext() const
Returns the coordinate transform context.
const QgsExpressionContext & expressionContext() const
Returns the expression context.
QStringList asQgisProcessArguments(QgsProcessingContext::ProcessArgumentFlags flags=QgsProcessingContext::ProcessArgumentFlags()) const
Returns list of the equivalent qgis_process arguments representing the settings from the context.
QgsProcessingContext(const QgsProcessingContext &other)=delete
void setDefaultEncoding(const QString &encoding)
Sets the default encoding to use for newly created files.
void setFeedback(QgsProcessingFeedback *feedback)
Sets an associated feedback object.
void setFlags(QgsProcessingContext::Flags flags)
Sets flags for the context.
QgsProcessingModelResult modelResult() const
Returns the model results, populated when the context is used to run a model algorithm.
void setProject(QgsProject *project)
Sets the project in which the algorithm will be executed.
QgsProcessingModelInitialRunConfig * modelInitialRunConfig()
Returns a reference to the model initial run configuration, used to run a model algorithm.
QgsProject * project() const
Returns the project in which the algorithm is being executed.
QMap< QString, QgsProcessingContext::LayerDetails > layersToLoadOnCompletion() const
Returns a map of layers (by ID or datasource) to LayerDetails, to load into the canvas upon completio...
void pushToThread(QThread *thread)
Pushes the thread affinity for the context (including all layers contained in the temporaryLayerStore...
Flag
Flags that affect how processing algorithms are run.
@ Unused
Temporary unused entry.
Qgis::InvalidGeometryCheck invalidGeometryCheck() const
Returns the behavior used for checking invalid geometries in input layers.
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...
void setModelInitialRunConfig(std::unique_ptr< QgsProcessingModelInitialRunConfig > config)
Sets the model initial run configuration, used to run a model algorithm.
QgsMapLayerStore * temporaryLayerStore()
Returns a reference to the layer store used for storing temporary layers during algorithm execution.
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...
void setPreferredVectorFormat(const QString &format)
Sets the preferred vector format to use for vector outputs.
void setTransformContext(const QgsCoordinateTransformContext &context)
Sets the coordinate transform context.
QgsProcessingContext & operator=(const QgsProcessingContext &other)=delete
void setTransformErrorCallback(const std::function< void(const QgsFeature &) > &callback)
Sets a callback function to use when encountering a transform error when iterating features.
QString preferredVectorFormat() const
Returns the preferred vector format to use for vector outputs.
std::function< void(const QgsFeature &) > transformErrorCallback() const
Returns the callback function to use when encountering a transform error when iterating features.
void setPreferredRasterFormat(const QString &format)
Sets the preferred raster format to use for raster outputs.
Base class for providing feedback from a processing algorithm.
An interface for layer post-processing handlers for execution following a processing algorithm operat...
virtual ~QgsProcessingLayerPostProcessorInterface()=default
virtual void postProcessLayer(QgsMapLayer *layer, QgsProcessingContext &context, QgsProcessingFeedback *feedback)=0
Post-processes the specified layer, following successful execution of a processing algorithm.
Configuration settings which control how a Processing model is executed.
Encapsulates the results of running a Processing model.
LayerHint
Layer type hints.
@ UnknownType
Unknown layer type.
Encapsulates a QGIS project, including sets of map layers and their styles, layouts,...
#define SIP_ENUM_BASETYPE(type)
QgsTemporalRange< QDateTime > QgsDateTimeRange
QgsRange which stores a range of date times.