24QString QgsDifferenceAlgorithm::name()
const
26 return QStringLiteral(
"difference" );
29QString QgsDifferenceAlgorithm::displayName()
const
31 return QObject::tr(
"Difference" );
34QStringList QgsDifferenceAlgorithm::tags()
const
36 return QObject::tr(
"difference,erase,not overlap" ).split(
',' );
39QString QgsDifferenceAlgorithm::group()
const
41 return QObject::tr(
"Vector overlay" );
44QString QgsDifferenceAlgorithm::groupId()
const
46 return QStringLiteral(
"vectoroverlay" );
49QString QgsDifferenceAlgorithm::shortHelpString()
const
51 return QObject::tr(
"This algorithm extracts features from the Input layer that fall outside, or partially overlap, features in the Overlay layer. "
52 "Input layer features that partially overlap feature(s) in the Overlay layer are split along those features' boundary "
53 "and only the portions outside the Overlay layer features are retained." )
54 + QStringLiteral(
"\n\n" )
55 + QObject::tr(
"Attributes are not modified, although properties such as area or length of the features will "
56 "be modified by the difference operation. If such properties are stored as attributes, those attributes will have to "
57 "be manually updated." );
60bool QgsDifferenceAlgorithm::supportInPlaceEdit(
const QgsMapLayer *l )
const
62 const QgsVectorLayer *layer = qobject_cast< const QgsVectorLayer * >( l );
69QgsProcessingAlgorithm::Flags QgsDifferenceAlgorithm::flags()
const
78 return new QgsDifferenceAlgorithm();
81void QgsDifferenceAlgorithm::initAlgorithm(
const QVariantMap & )
87 std::unique_ptr< QgsProcessingParameterNumber > gridSize = std::make_unique< QgsProcessingParameterNumber >( QStringLiteral(
"GRID_SIZE" ),
90 addParameter( gridSize.release() );
96 std::unique_ptr< QgsFeatureSource > sourceA( parameterAsSource( parameters, QStringLiteral(
"INPUT" ), context ) );
100 const std::unique_ptr< QgsFeatureSource > sourceB( parameterAsSource( parameters, QStringLiteral(
"OVERLAY" ), context ) );
107 std::unique_ptr< QgsFeatureSink > sink( parameterAsSink( parameters, QStringLiteral(
"OUTPUT" ), context, dest, sourceA->fields(), geomType, sourceA->sourceCrs() ) );
112 outputs.insert( QStringLiteral(
"OUTPUT" ), dest );
115 const long total = sourceA->featureCount();
118 if ( parameters.value( QStringLiteral(
"GRID_SIZE" ) ).isValid() )
120 geometryParameters.
setGridSize( parameterAsDouble( parameters, QStringLiteral(
"GRID_SIZE" ), context ) );
123 QgsOverlayUtils::difference( *sourceA, *sourceB, *sink, context, feedback, count, total, QgsOverlayUtils::OutputA, geometryParameters, QgsOverlayUtils::SanitizeFlag::DontPromotePointGeometryToMultiPoint );
WkbType
The WKB type describes the number of dimensions a geometry has.
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.
Base class for all map layer types.
Abstract base class for processing algorithms.
virtual Flags flags() const
Returns the flags indicating how and when the algorithm operates and should be exposed to users.
@ FlagSupportsInPlaceEdits
Algorithm supports in-place editing.
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.
@ Double
Double/float values.
Represents a vector layer which manages a vector based data sets.
bool isSpatial() const FINAL
Returns true if this is a geometry layer and false in case of NoGeometry (table only) or UnknownGeome...
static Qgis::WkbType promoteNonPointTypesToMulti(Qgis::WkbType type)
Promotes a WKB geometry type to its multi-type equivalent, with the exception of point geometry types...