24 QString QgsDifferenceAlgorithm::name()
const
26 return QStringLiteral(
"difference" );
29 QString QgsDifferenceAlgorithm::displayName()
const
31 return QObject::tr(
"Difference" );
34 QStringList QgsDifferenceAlgorithm::tags()
const
36 return QObject::tr(
"difference,erase,not overlap" ).split(
',' );
39 QString QgsDifferenceAlgorithm::group()
const
41 return QObject::tr(
"Vector overlay" );
44 QString QgsDifferenceAlgorithm::groupId()
const
46 return QStringLiteral(
"vectoroverlay" );
49 QString 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." );
60 bool QgsDifferenceAlgorithm::supportInPlaceEdit(
const QgsMapLayer *l )
const
62 const QgsVectorLayer *layer = qobject_cast< const QgsVectorLayer * >( l );
69 QgsProcessingAlgorithm::Flags QgsDifferenceAlgorithm::flags()
const
78 return new QgsDifferenceAlgorithm();
81 void QgsDifferenceAlgorithm::initAlgorithm(
const QVariantMap & )
91 std::unique_ptr< QgsFeatureSource > sourceA( parameterAsSource( parameters, QStringLiteral(
"INPUT" ), context ) );
95 const std::unique_ptr< QgsFeatureSource > sourceB( parameterAsSource( parameters, QStringLiteral(
"OVERLAY" ), context ) );
102 std::unique_ptr< QgsFeatureSink > sink( parameterAsSink( parameters, QStringLiteral(
"OUTPUT" ), context, dest, sourceA->fields(), geomType, sourceA->sourceCrs() ) );
107 outputs.insert( QStringLiteral(
"OUTPUT" ), dest );
110 const long total = sourceA->featureCount();
111 QgsOverlayUtils::difference( *sourceA, *sourceB, *sink, context, feedback, count, total, QgsOverlayUtils::OutputA );