23 for (
auto it = mLayersToLoadOnCompletion.constBegin(); it != mLayersToLoadOnCompletion.constEnd(); ++it )
25 delete it.value().postProcessor();
31 for (
auto it = mLayersToLoadOnCompletion.constBegin(); it != mLayersToLoadOnCompletion.constEnd(); ++it )
33 if ( !layers.contains( it.key() ) || layers.value( it.key() ).postProcessor() != it.value().postProcessor() )
34 delete it.value().postProcessor();
36 mLayersToLoadOnCompletion = layers;
41 if ( mLayersToLoadOnCompletion.contains( layer ) && mLayersToLoadOnCompletion.value( layer ).postProcessor() != details.
postProcessor() )
42 delete mLayersToLoadOnCompletion.value( layer ).postProcessor();
44 mLayersToLoadOnCompletion.insert( layer, details );
49 mInvalidGeometryCheck = check;
51 switch ( mInvalidGeometryCheck )
55 auto callback = [](
const QgsFeature & feature )
57 throw QgsProcessingException( QObject::tr(
"Feature (%1) has invalid geometry. Please fix the geometry or change the Processing setting to the \"Ignore invalid input features\" option." ).arg( feature.id() ) );
59 mInvalidGeometryCallback = callback;
65 auto callback = [ = ](
const QgsFeature & feature )
68 mFeedback->reportError( QObject::tr(
"Feature (%1) has invalid geometry and has been skipped. Please fix the geometry or change the Processing setting to the \"Ignore invalid input features\" option." ).arg( feature.id() ) );
70 mInvalidGeometryCallback = callback;
82 context.mLayersToLoadOnCompletion.clear();
100 return mPostProcessor;
105 if ( mPostProcessor && mPostProcessor != processor )
106 delete mPostProcessor;
108 mPostProcessor = processor;
Base class for all map layer types.
void setLayersToLoadOnCompletion(const QMap< QString, QgsProcessingContext::LayerDetails > &layers)
Sets the map of layers (by ID or datasource) to LayerDetails, to load into the canvas upon completion...
An interface for layer post-processing handlers for execution following a processing algorithm operat...
void setPostProcessor(QgsProcessingLayerPostProcessorInterface *processor)
Sets the layer post-processor.
QgsMapLayer * takeResultLayer(const QString &id)
Takes the result map layer with matching id from the context and transfers ownership of it back to th...
Skip any features with invalid geometry. This requires a slow geometry validity check for every featu...
QgsMapLayer * takeMapLayer(QgsMapLayer *layer)
Takes a layer from the store.
The feature class encapsulates a single feature including its id, geometry and a list of field/values...
InvalidGeometryCheck
Handling of features with invalid geometries.
QgsProcessingLayerPostProcessorInterface * postProcessor() const
Layer post-processor.
QgsMapLayerStore * temporaryLayerStore()
Returns a reference to the layer store used for storing temporary layers during algorithm execution...
void takeResultsFrom(QgsProcessingContext &context)
Takes the results from another context and merges them with the results currently stored in this cont...
Custom exception class for processing related exceptions.
QgsMapLayer * getMapLayer(const QString &identifier)
Returns a map layer from the context with a matching identifier.
void setInvalidGeometryCheck(QgsFeatureRequest::InvalidGeometryCheck check)
Sets the behavior used for checking invalid geometries in input layers.
Details for layers to load into projects.
void addLayerToLoadOnCompletion(const QString &layer, const QgsProcessingContext::LayerDetails &details)
Adds a layer to load (by ID or datasource) into the canvas upon completion of the algorithm or model...
void transferLayersFromStore(QgsMapLayerStore *other)
Transfers all the map layers contained within another map layer store and adds them to this store...
static QgsMapLayer * mapLayerFromString(const QString &string, QgsProcessingContext &context, bool allowLoadingNewLayers=true, LayerHint typeHint=UnknownType)
Interprets a string as a map layer within the supplied context.
QgsMapLayer * mapLayer(const QString &id) const
Retrieve a pointer to a layer by layer id.
Contains information about the context in which a processing algorithm is executed.
Close iterator on encountering any features with invalid geometry. This requires a slow geometry vali...