22 QString QgsSymmetricalDifferenceAlgorithm::name()
const
24 return QStringLiteral(
"symmetricaldifference" );
27 QString QgsSymmetricalDifferenceAlgorithm::displayName()
const
29 return QObject::tr(
"Symmetrical difference" );
32 QStringList QgsSymmetricalDifferenceAlgorithm::tags()
const
34 return QObject::tr(
"difference,symdiff,not overlap" ).split(
',' );
37 QString QgsSymmetricalDifferenceAlgorithm::group()
const
39 return QObject::tr(
"Vector overlay" );
42 QString QgsSymmetricalDifferenceAlgorithm::groupId()
const
44 return QStringLiteral(
"vectoroverlay" );
47 QString QgsSymmetricalDifferenceAlgorithm::shortHelpString()
const
49 return QObject::tr(
"This algorithm extracts the portions of features from both the Input and Overlay layers that do not overlap. "
50 "Overlapping areas between the two layers are removed. The attribute table of the Symmetrical Difference layer "
51 "contains original attributes from both the Input and Difference layers." );
56 return new QgsSymmetricalDifferenceAlgorithm();
59 void QgsSymmetricalDifferenceAlgorithm::initAlgorithm(
const QVariantMap & )
64 std::unique_ptr< QgsProcessingParameterString > prefix = std::make_unique< QgsProcessingParameterString >( QStringLiteral(
"OVERLAY_FIELDS_PREFIX" ), QObject::tr(
"Overlay fields prefix" ), QString(),
false,
true );
66 addParameter( prefix.release() );
74 std::unique_ptr< QgsFeatureSource > sourceA( parameterAsSource( parameters, QStringLiteral(
"INPUT" ), context ) );
78 std::unique_ptr< QgsFeatureSource > sourceB( parameterAsSource( parameters, QStringLiteral(
"OVERLAY" ), context ) );
84 const QString overlayFieldsPrefix = parameterAsString( parameters, QStringLiteral(
"OVERLAY_FIELDS_PREFIX" ), context );
88 std::unique_ptr< QgsFeatureSink > sink( parameterAsSink( parameters, QStringLiteral(
"OUTPUT" ), context, dest, fields, geomType, sourceA->sourceCrs(),
QgsFeatureSink::RegeneratePrimaryKey ) );
93 outputs.insert( QStringLiteral(
"OUTPUT" ), dest );
96 const long total = sourceA->featureCount() + sourceB->featureCount();
98 QgsOverlayUtils::difference( *sourceA, *sourceB, *sink, context, feedback, count, total, QgsOverlayUtils::OutputAB );
102 QgsOverlayUtils::difference( *sourceB, *sourceA, *sink, context, feedback, count, total, QgsOverlayUtils::OutputBA );
@ RegeneratePrimaryKey
This flag indicates, that a primary key field cannot be guaranteed to be unique and the sink should i...
bool isCanceled() const SIP_HOLDGIL
Tells whether the operation has been canceled already.
Container of fields for a vector layer.
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.
@ FlagAdvanced
Parameter is an advanced parameter which should be hidden from users by default.
A feature sink output for processing algorithms.
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).
static Type promoteNonPointTypesToMulti(Type type) SIP_HOLDGIL
Promotes a WKB geometry type to its multi-type equivalent, with the exception of point geometry types...
Type
The WKB type describes the number of dimensions a geometry has.