Skip to content

Commit

Permalink
Enable in-place buffer on polygons
Browse files Browse the repository at this point in the history
Fixes #20101 - "Buffer" is not listed as an edit in place algorithm for polygon layer
  • Loading branch information
elpaso committed Oct 18, 2018
1 parent 89058ba commit 51c3c2a
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 0 deletions.
18 changes: 18 additions & 0 deletions src/analysis/processing/qgsalgorithmbuffer.cpp
Expand Up @@ -16,6 +16,8 @@
***************************************************************************/

#include "qgsalgorithmbuffer.h"
#include "qgswkbtypes.h"
#include "qgsvectorlayer.h"

///@cond PRIVATE

Expand Down Expand Up @@ -165,4 +167,20 @@ QVariantMap QgsBufferAlgorithm::processAlgorithm( const QVariantMap &parameters,
return outputs;
}

QgsProcessingAlgorithm::Flags QgsBufferAlgorithm::flags() const
{
Flags f = QgsProcessingAlgorithm::flags();
f |= QgsProcessingAlgorithm::FlagSupportsInPlaceEdits;
return f;
}

bool QgsBufferAlgorithm::supportInPlaceEdit( const QgsMapLayer *layer ) const
{
const QgsVectorLayer *vlayer = qobject_cast< const QgsVectorLayer * >( layer );
if ( !vlayer )
return false;
QgsWkbTypes::GeometryType inPlaceGeometryType = vlayer->geometryType();
return inPlaceGeometryType == QgsWkbTypes::GeometryType::PolygonGeometry;
}

///@endcond
4 changes: 4 additions & 0 deletions src/analysis/processing/qgsalgorithmbuffer.h
Expand Up @@ -44,12 +44,16 @@ class QgsBufferAlgorithm : public QgsProcessingAlgorithm
QString groupId() const override;
QString shortHelpString() const override;
QgsBufferAlgorithm *createInstance() const override SIP_FACTORY;
bool supportInPlaceEdit( const QgsMapLayer *layer ) const override;
QgsProcessingAlgorithm::Flags flags() const override;


protected:

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


};

///@endcond PRIVATE
Expand Down

0 comments on commit 51c3c2a

Please sign in to comment.