22QString QgsSymmetricalDifferenceAlgorithm::name()
const
24 return QStringLiteral(
"symmetricaldifference" );
27QString QgsSymmetricalDifferenceAlgorithm::displayName()
const
29 return QObject::tr(
"Symmetrical difference" );
32QStringList QgsSymmetricalDifferenceAlgorithm::tags()
const
34 return QObject::tr(
"difference,symdiff,not overlap" ).split(
',' );
37QString QgsSymmetricalDifferenceAlgorithm::group()
const
39 return QObject::tr(
"Vector overlay" );
42QString QgsSymmetricalDifferenceAlgorithm::groupId()
const
44 return QStringLiteral(
"vectoroverlay" );
47QString 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();
59void 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() );
70 std::unique_ptr< QgsProcessingParameterNumber > gridSize = std::make_unique< QgsProcessingParameterNumber >( QStringLiteral(
"GRID_SIZE" ),
73 addParameter( gridSize.release() );
79 std::unique_ptr< QgsFeatureSource > sourceA( parameterAsSource( parameters, QStringLiteral(
"INPUT" ), context ) );
83 std::unique_ptr< QgsFeatureSource > sourceB( parameterAsSource( parameters, QStringLiteral(
"OVERLAY" ), context ) );
90 if ( geomTypeA != geomTypeB )
93 const QString overlayFieldsPrefix = parameterAsString( parameters, QStringLiteral(
"OVERLAY_FIELDS_PREFIX" ), context );
97 std::unique_ptr< QgsFeatureSink > sink( parameterAsSink( parameters, QStringLiteral(
"OUTPUT" ), context, dest, fields, geomTypeA, sourceA->sourceCrs(),
QgsFeatureSink::RegeneratePrimaryKey ) );
102 outputs.insert( QStringLiteral(
"OUTPUT" ), dest );
105 const long total = sourceA->featureCount() + sourceB->featureCount();
108 if ( parameters.value( QStringLiteral(
"GRID_SIZE" ) ).isValid() )
110 geometryParameters.
setGridSize( parameterAsDouble( parameters, QStringLiteral(
"GRID_SIZE" ), context ) );
113 QgsOverlayUtils::difference( *sourceA, *sourceB, *sink, context, feedback, count, total, QgsOverlayUtils::OutputAB, geometryParameters, QgsOverlayUtils::SanitizeFlag::DontPromotePointGeometryToMultiPoint );
117 QgsOverlayUtils::difference( *sourceB, *sourceA, *sink, context, feedback, count, total, QgsOverlayUtils::OutputBA, geometryParameters, QgsOverlayUtils::SanitizeFlag::DontPromotePointGeometryToMultiPoint );
@ 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.
Encapsulates parameters under which a geometry operation is performed.
void setGridSize(double size)
Sets the grid size which will be used to snap vertices of a geometry.
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.
virtual void pushWarning(const QString &warning)
Pushes a warning informational message from the 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.
@ Double
Double/float values.
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.
static QString displayString(Type type) SIP_HOLDGIL
Returns a non-translated display string type for a WKB type, e.g., the geometry name used in WKT geom...