22 QString QgsSymmetricalDifferenceAlgorithm::name()
const 24 return QStringLiteral(
"symmetricaldifference" );
27 QString QgsSymmetricalDifferenceAlgorithm::displayName()
const 29 return QObject::tr(
"Symmetrical difference" );
32 QString QgsSymmetricalDifferenceAlgorithm::group()
const 34 return QObject::tr(
"Vector overlay" );
37 QString QgsSymmetricalDifferenceAlgorithm::groupId()
const 39 return QStringLiteral(
"vectoroverlay" );
42 QString QgsSymmetricalDifferenceAlgorithm::shortHelpString()
const 44 return QObject::tr(
"This algorithm extracts the portions of features from both the Input and Overlay layers that do not overlap. " 45 "Overlapping areas between the two layers are removed. The attribute table of the Symmetrical Difference layer " 46 "contains original attributes from both the Input and Difference layers." );
51 return new QgsSymmetricalDifferenceAlgorithm();
54 void QgsSymmetricalDifferenceAlgorithm::initAlgorithm(
const QVariantMap & )
59 std::unique_ptr< QgsProcessingParameterString > prefix = qgis::make_unique< QgsProcessingParameterString >( QStringLiteral(
"OVERLAY_FIELDS_PREFIX" ), QObject::tr(
"Overlay fields prefix" ), QString(),
false, true );
61 addParameter( prefix.release() );
69 std::unique_ptr< QgsFeatureSource > sourceA( parameterAsSource( parameters, QStringLiteral(
"INPUT" ), context ) );
73 std::unique_ptr< QgsFeatureSource > sourceB( parameterAsSource( parameters, QStringLiteral(
"OVERLAY" ), context ) );
79 QString overlayFieldsPrefix = parameterAsString( parameters, QStringLiteral(
"OVERLAY_FIELDS_PREFIX" ), context );
83 std::unique_ptr< QgsFeatureSink > sink( parameterAsSink( parameters, QStringLiteral(
"OUTPUT" ), context, dest, fields, geomType, sourceA->sourceCrs(),
QgsFeatureSink::RegeneratePrimaryKey ) );
88 outputs.insert( QStringLiteral(
"OUTPUT" ), dest );
91 int total = sourceA->featureCount() + sourceB->featureCount();
93 QgsOverlayUtils::difference( *sourceA, *sourceB, *sink, context, feedback, count, total, QgsOverlayUtils::OutputAB );
95 QgsOverlayUtils::difference( *sourceB, *sourceA, *sink, context, feedback, count, total, QgsOverlayUtils::OutputBA );
static Type multiType(Type type)
Returns the multi type for a WKB type.
Base class for providing feedback from a processing algorithm.
Parameter is an advanced parameter which should be hidden from users by default.
Container of fields for a vector layer.
Abstract base class for processing algorithms.
A feature sink output for processing algorithms.
This flag indicates, that a primary key field cannot be guaranteed to be unique and the sink should i...
Type
The WKB type describes the number of dimensions a geometry has.
Custom exception class for processing related exceptions.
An input feature source (such as vector layers) parameter for processing algorithms.
static QgsFields combineFields(const QgsFields &fieldsA, const QgsFields &fieldsB, const QString &fieldsBPrefix=QString())
Combines two field lists, avoiding duplicate field names (in a case-insensitive manner).
Contains information about the context in which a processing algorithm is executed.