Skip to content

Commit 51c3c2a

Browse files
committedOct 18, 2018
Enable in-place buffer on polygons
Fixes #20101 - "Buffer" is not listed as an edit in place algorithm for polygon layer
1 parent 89058ba commit 51c3c2a

File tree

2 files changed

+22
-0
lines changed

2 files changed

+22
-0
lines changed
 

‎src/analysis/processing/qgsalgorithmbuffer.cpp

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@
1616
***************************************************************************/
1717

1818
#include "qgsalgorithmbuffer.h"
19+
#include "qgswkbtypes.h"
20+
#include "qgsvectorlayer.h"
1921

2022
///@cond PRIVATE
2123

@@ -165,4 +167,20 @@ QVariantMap QgsBufferAlgorithm::processAlgorithm( const QVariantMap &parameters,
165167
return outputs;
166168
}
167169

170+
QgsProcessingAlgorithm::Flags QgsBufferAlgorithm::flags() const
171+
{
172+
Flags f = QgsProcessingAlgorithm::flags();
173+
f |= QgsProcessingAlgorithm::FlagSupportsInPlaceEdits;
174+
return f;
175+
}
176+
177+
bool QgsBufferAlgorithm::supportInPlaceEdit( const QgsMapLayer *layer ) const
178+
{
179+
const QgsVectorLayer *vlayer = qobject_cast< const QgsVectorLayer * >( layer );
180+
if ( !vlayer )
181+
return false;
182+
QgsWkbTypes::GeometryType inPlaceGeometryType = vlayer->geometryType();
183+
return inPlaceGeometryType == QgsWkbTypes::GeometryType::PolygonGeometry;
184+
}
185+
168186
///@endcond

‎src/analysis/processing/qgsalgorithmbuffer.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,12 +44,16 @@ class QgsBufferAlgorithm : public QgsProcessingAlgorithm
4444
QString groupId() const override;
4545
QString shortHelpString() const override;
4646
QgsBufferAlgorithm *createInstance() const override SIP_FACTORY;
47+
bool supportInPlaceEdit( const QgsMapLayer *layer ) const override;
48+
QgsProcessingAlgorithm::Flags flags() const override;
49+
4750

4851
protected:
4952

5053
QVariantMap processAlgorithm( const QVariantMap &parameters,
5154
QgsProcessingContext &context, QgsProcessingFeedback *feedback ) override;
5255

56+
5357
};
5458

5559
///@endcond PRIVATE

0 commit comments

Comments
 (0)
Please sign in to comment.