26QString QgsMultiDifferenceAlgorithm::name()
 const 
   28  return QStringLiteral( 
"multidifference" );
 
   31QString QgsMultiDifferenceAlgorithm::displayName()
 const 
   33  return QObject::tr( 
"Difference (multiple)" );
 
   36QStringList QgsMultiDifferenceAlgorithm::tags()
 const 
   38  return QObject::tr( 
"difference,erase,not overlap" ).split( 
',' );
 
   41QString QgsMultiDifferenceAlgorithm::group()
 const 
   43  return QObject::tr( 
"Vector overlay" );
 
   46QString QgsMultiDifferenceAlgorithm::groupId()
 const 
   48  return QStringLiteral( 
"vectoroverlay" );
 
   51QString QgsMultiDifferenceAlgorithm::shortHelpString()
 const 
   53  return QObject::tr( 
"This algorithm extracts features from the Input layer that fall completely outside or only partially overlap the features from any of the Overlay layer(s). " 
   54                      "For each overlay layer the difference is calculated between the result of all previous difference operations and this overlay layer. " 
   55                      "Input layer features that partially overlap feature(s) in the Overlay layers are split along those features' boundary " 
   56                      "and only the portions outside the Overlay layer features are retained." )
 
   57         + QStringLiteral( 
"\n\n" )
 
   58         + QObject::tr( 
"Attributes are not modified, although properties such as area or length of the features will " 
   59                        "be modified by the difference operation. If such properties are stored as attributes, those attributes will have to " 
   60                        "be manually updated." );
 
   63QString QgsMultiDifferenceAlgorithm::shortDescription()
 const 
   65  return QObject::tr( 
"Extracts features from a layer that fall completely outside or only partially overlap the features from other layer(s)." );
 
   70  return new QgsMultiDifferenceAlgorithm();
 
   73void QgsMultiDifferenceAlgorithm::initAlgorithm( 
const QVariantMap & )
 
   83  std::unique_ptr<QgsFeatureSource> sourceA( parameterAsSource( parameters, QStringLiteral( 
"INPUT" ), context ) );
 
   87  const QList<QgsMapLayer *> layers = parameterAsLayerList( parameters, QStringLiteral( 
"OVERLAYS" ), context );
 
   90  long totalLayerCount = 0;
 
  107  std::unique_ptr<QgsFeatureSink> sink;
 
  111  if ( totalLayerCount == 1 )
 
  114    sink.reset( parameterAsSink( parameters, QStringLiteral( 
"OUTPUT" ), context, dest, sourceA->fields(), geometryType, 
crs ) );
 
  118    outputs.insert( QStringLiteral( 
"OUTPUT" ), dest );
 
  120    QgsVectorLayer *overlayLayer = qobject_cast<QgsVectorLayer *>( layers.at( 0 ) );
 
  122    const long total = sourceA->featureCount();
 
  123    QgsOverlayUtils::difference( *sourceA, *overlayLayer, *sink, context, feedback, count, total, QgsOverlayUtils::OutputA );
 
  137      multiStepFeedback.setCurrentStep( i );
 
  142      QgsVectorLayer *overlayLayer = qobject_cast<QgsVectorLayer *>( layer );
 
  149        QString 
id = QStringLiteral( 
"memory:" );
 
  151        QgsOverlayUtils::difference( *sourceA, *overlayLayer, *sink, context, &multiStepFeedback, count, sourceA->featureCount(), QgsOverlayUtils::OutputA );
 
  155      else if ( i == totalLayerCount - 1 )
 
  158        std::unique_ptr<QgsFeatureSink> sink( parameterAsSink( parameters, QStringLiteral( 
"OUTPUT" ), context, dest, differenceLayer->
fields(), geometryType, 
crs ) );
 
  162        outputs.insert( QStringLiteral( 
"OUTPUT" ), dest );
 
  164        QgsOverlayUtils::difference( *differenceLayer, *overlayLayer, *sink, context, &multiStepFeedback, count, differenceLayer->
featureCount(), QgsOverlayUtils::OutputA );
 
  168        QString 
id = QStringLiteral( 
"memory:" );
 
  170        QgsOverlayUtils::difference( *differenceLayer, *overlayLayer, *sink, context, &multiStepFeedback, count, differenceLayer->
featureCount(), QgsOverlayUtils::OutputA );
 
@ VectorAnyGeometry
Any vector layer with geometry.
 
WkbType
The WKB type describes the number of dimensions a geometry has.
 
Represents a coordinate reference system (CRS).
 
bool isCanceled() const
Tells whether the operation has been canceled already.
 
Base class for all map layer types.
 
Abstract base class for processing algorithms.
 
Contains information about the context in which a processing algorithm is executed.
 
Custom exception class for processing related exceptions.
 
Base class for providing feedback from a processing algorithm.
 
Processing feedback object for multi-step operations.
 
A feature sink output for processing algorithms.
 
An input feature source (such as vector layers) parameter for processing algorithms.
 
A parameter for processing algorithms which accepts multiple map layers.
 
static QgsFeatureSink * createFeatureSink(QString &destination, QgsProcessingContext &context, const QgsFields &fields, Qgis::WkbType geometryType, const QgsCoordinateReferenceSystem &crs, const QVariantMap &createOptions=QVariantMap(), const QStringList &datasourceOptions=QStringList(), const QStringList &layerOptions=QStringList(), QgsFeatureSink::SinkFlags sinkFlags=QgsFeatureSink::SinkFlags(), QgsRemappingSinkDefinition *remappingDefinition=nullptr)
Creates a feature sink ready for adding features.
 
static QgsMapLayer * mapLayerFromString(const QString &string, QgsProcessingContext &context, bool allowLoadingNewLayers=true, QgsProcessingUtils::LayerHint typeHint=QgsProcessingUtils::LayerHint::UnknownType, QgsProcessing::LayerOptionsFlags flags=QgsProcessing::LayerOptionsFlags())
Interprets a string as a map layer within the supplied context.
 
Represents a vector layer which manages a vector based dataset.
 
long long featureCount(const QString &legendKey) const
Number of features rendered with specified legend key.
 
static Qgis::WkbType multiType(Qgis::WkbType type)
Returns the multi type for a WKB type.
 
const QgsCoordinateReferenceSystem & crs