26 QString QgsMultiDifferenceAlgorithm::name()
const
28 return QStringLiteral(
"multidifference" );
31 QString QgsMultiDifferenceAlgorithm::displayName()
const
33 return QObject::tr(
"Difference (multiple)" );
36 QStringList QgsMultiDifferenceAlgorithm::tags()
const
38 return QObject::tr(
"difference,erase,not overlap" ).split(
',' );
41 QString QgsMultiDifferenceAlgorithm::group()
const
43 return QObject::tr(
"Vector overlay" );
46 QString QgsMultiDifferenceAlgorithm::groupId()
const
48 return QStringLiteral(
"vectoroverlay" );
51 QString QgsMultiDifferenceAlgorithm::shortHelpString()
const
53 return QObject::tr(
"This algorithm extracts features from the Input layer that fall completely outside or only partially overlap the features from any of the Overlay layer(s). "
54 "For each overlay layer the difference is calculated between the result of all previous difference operations and this overlay layer. "
55 "Input layer features that partially overlap feature(s) in the Overlay layers are split along those features' boundary "
56 "and only the portions outside the Overlay layer features are retained." )
57 + QStringLiteral(
"\n\n" )
58 + QObject::tr(
"Attributes are not modified, although properties such as area or length of the features will "
59 "be modified by the difference operation. If such properties are stored as attributes, those attributes will have to "
60 "be manually updated." );
65 return new QgsMultiDifferenceAlgorithm();
68 void QgsMultiDifferenceAlgorithm::initAlgorithm(
const QVariantMap & )
78 std::unique_ptr< QgsFeatureSource > sourceA( parameterAsSource( parameters, QStringLiteral(
"INPUT" ), context ) );
82 const QList< QgsMapLayer * > layers = parameterAsLayerList( parameters, QStringLiteral(
"OVERLAYS" ), context );
85 long totalLayerCount = 0;
102 std::unique_ptr< QgsFeatureSink > sink;
106 if ( totalLayerCount == 1 )
109 sink.reset( parameterAsSink( parameters, QStringLiteral(
"OUTPUT" ), context, dest, sourceA->fields(), geometryType,
crs ) );
113 outputs.insert( QStringLiteral(
"OUTPUT" ), dest );
115 QgsVectorLayer *overlayLayer = qobject_cast< QgsVectorLayer * >( layers.at( 0 ) );
117 const long total = sourceA->featureCount();
118 QgsOverlayUtils::difference( *sourceA, *overlayLayer, *sink, context, feedback, count, total, QgsOverlayUtils::OutputA );
131 multiStepFeedback.setCurrentStep( i );
136 QgsVectorLayer *overlayLayer = qobject_cast< QgsVectorLayer * >( layer );
143 QString
id = QStringLiteral(
"memory:" );
145 QgsOverlayUtils::difference( *sourceA, *overlayLayer, *sink, context, &multiStepFeedback, count, sourceA->featureCount(), QgsOverlayUtils::OutputA );
149 else if ( i == totalLayerCount - 1 )
152 std::unique_ptr< QgsFeatureSink > sink( parameterAsSink( parameters, QStringLiteral(
"OUTPUT" ), context, dest, differenceLayer->
fields(), geometryType,
crs ) );
156 outputs.insert( QStringLiteral(
"OUTPUT" ), dest );
158 QgsOverlayUtils::difference( *differenceLayer, *overlayLayer, *sink, context, &multiStepFeedback, count, differenceLayer->
featureCount(), QgsOverlayUtils::OutputA );
162 QString
id = QStringLiteral(
"memory:" );
164 QgsOverlayUtils::difference( *differenceLayer, *overlayLayer, *sink, context, &multiStepFeedback, count, differenceLayer->
featureCount(), QgsOverlayUtils::OutputA );