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 Overlay layers." );
 
   54QString QgsSymmetricalDifferenceAlgorithm::shortDescription()
 const 
   56  return QObject::tr( 
"Extracts the portions of features from two layers that do not overlap." );
 
   66  return new QgsSymmetricalDifferenceAlgorithm();
 
   69void QgsSymmetricalDifferenceAlgorithm::initAlgorithm( 
const QVariantMap & )
 
   74  auto prefix = std::make_unique<QgsProcessingParameterString>( QStringLiteral( 
"OVERLAY_FIELDS_PREFIX" ), QObject::tr( 
"Overlay fields prefix" ), QString(), 
false, 
true );
 
   76  addParameter( prefix.release() );
 
   82  addParameter( gridSize.release() );
 
   88  std::unique_ptr<QgsFeatureSource> sourceA( parameterAsSource( parameters, QStringLiteral( 
"INPUT" ), context ) );
 
   92  std::unique_ptr<QgsFeatureSource> sourceB( parameterAsSource( parameters, QStringLiteral( 
"OVERLAY" ), context ) );
 
   99  if ( geomTypeA != geomTypeB )
 
  102  const QString overlayFieldsPrefix = parameterAsString( parameters, QStringLiteral( 
"OVERLAY_FIELDS_PREFIX" ), context );
 
  106  std::unique_ptr<QgsFeatureSink> sink( parameterAsSink( parameters, QStringLiteral( 
"OUTPUT" ), context, dest, fields, geomTypeA, sourceA->sourceCrs(), 
QgsFeatureSink::RegeneratePrimaryKey ) );
 
  111  outputs.insert( QStringLiteral( 
"OUTPUT" ), dest );
 
  114  const long total = sourceA->featureCount() + sourceB->featureCount();
 
  117  if ( parameters.value( QStringLiteral( 
"GRID_SIZE" ) ).isValid() )
 
  119    geometryParameters.
setGridSize( parameterAsDouble( parameters, QStringLiteral( 
"GRID_SIZE" ), context ) );
 
  122  QgsOverlayUtils::difference( *sourceA, *sourceB, *sink, context, feedback, count, total, QgsOverlayUtils::OutputAB, geometryParameters, QgsOverlayUtils::SanitizeFlag::DontPromotePointGeometryToMultiPoint );
 
  126  QgsOverlayUtils::difference( *sourceB, *sourceA, *sink, context, feedback, count, total, QgsOverlayUtils::OutputBA, geometryParameters, QgsOverlayUtils::SanitizeFlag::DontPromotePointGeometryToMultiPoint );
 
@ RegeneratesPrimaryKey
Algorithm always drops any existing primary keys or FID values and regenerates them in outputs.
 
QFlags< ProcessingAlgorithmDocumentationFlag > ProcessingAlgorithmDocumentationFlags
Flags describing algorithm behavior for documentation purposes.
 
WkbType
The WKB type describes the number of dimensions a geometry has.
 
@ Advanced
Parameter is an advanced parameter which should be hidden from users by default.
 
@ Double
Double/float values.
 
@ RegeneratePrimaryKey
This flag indicates, that a primary key field cannot be guaranteed to be unique and the sink should i...
 
bool isCanceled() const
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.
 
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 Q_INVOKABLE QString displayString(Qgis::WkbType type)
Returns a non-translated display string type for a WKB type, e.g., the geometry name used in WKT geom...
 
static Qgis::WkbType promoteNonPointTypesToMulti(Qgis::WkbType type)
Promotes a WKB geometry type to its multi-type equivalent, with the exception of point geometry types...