23using namespace Qt::StringLiterals;
28QString QgsDifferenceAlgorithm::name()
const
30 return u
"difference"_s;
33QString QgsDifferenceAlgorithm::displayName()
const
35 return QObject::tr(
"Difference" );
38QStringList QgsDifferenceAlgorithm::tags()
const
40 return QObject::tr(
"difference,erase,not overlap" ).split(
',' );
43QString QgsDifferenceAlgorithm::group()
const
45 return QObject::tr(
"Vector overlay" );
48QString QgsDifferenceAlgorithm::groupId()
const
50 return u
"vectoroverlay"_s;
53QString QgsDifferenceAlgorithm::shortHelpString()
const
56 "This algorithm extracts features from the Input layer that fall outside, or partially overlap, features in the Overlay layer. "
57 "Input layer features that partially overlap feature(s) in the Overlay layer are split along those features' boundary "
58 "and only the portions outside the Overlay layer features are retained."
62 "Attributes are not modified, although properties such as area or length of the features will "
63 "be modified by the difference operation. If such properties are stored as attributes, those attributes will have to "
64 "be manually updated."
68QString QgsDifferenceAlgorithm::shortDescription()
const
70 return QObject::tr(
"Extracts features from an input layer that fall outside, or partially overlap, features in an overlay layer." );
73bool QgsDifferenceAlgorithm::supportInPlaceEdit(
const QgsMapLayer *l )
const
75 const QgsVectorLayer *layer = qobject_cast<const QgsVectorLayer *>( l );
91 return new QgsDifferenceAlgorithm();
94void QgsDifferenceAlgorithm::initAlgorithm(
const QVariantMap & )
102 addParameter( gridSize.release() );
108 std::unique_ptr<QgsFeatureSource> sourceA( parameterAsSource( parameters, u
"INPUT"_s, context ) );
112 const std::unique_ptr<QgsFeatureSource> sourceB( parameterAsSource( parameters, u
"OVERLAY"_s, context ) );
119 std::unique_ptr<QgsFeatureSink> sink( parameterAsSink( parameters, u
"OUTPUT"_s, context, dest, sourceA->fields(), geomType, sourceA->sourceCrs() ) );
124 outputs.insert( u
"OUTPUT"_s, dest );
127 const long total = sourceA->featureCount();
130 if ( parameters.value( u
"GRID_SIZE"_s ).isValid() )
132 geometryParameters.
setGridSize( parameterAsDouble( parameters, u
"GRID_SIZE"_s, context ) );
135 QgsOverlayUtils::difference( *sourceA, *sourceB, *sink, context, feedback, count, total, QgsOverlayUtils::OutputA, geometryParameters, QgsOverlayUtils::SanitizeFlag::DontPromotePointGeometryToMultiPoint );
QFlags< ProcessingAlgorithmFlag > ProcessingAlgorithmFlags
Flags indicating how and when an algorithm operates and should be exposed to users.
WkbType
The WKB type describes the number of dimensions a geometry has.
@ SupportsInPlaceEdits
Algorithm supports in-place editing.
@ Advanced
Parameter is an advanced parameter which should be hidden from users by default.
@ Double
Double/float values.
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 Qgis::ProcessingAlgorithmFlags flags() const
Returns the flags indicating how and when the algorithm operates and should be exposed to users.
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.
A feature sink output for processing algorithms.
An input feature source (such as vector layers) parameter for processing algorithms.
Represents a vector layer which manages a vector based dataset.
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...