Skip to content
Permalink
Browse files

[in-place] Limit buffer to (multi)polygons

  • Loading branch information
elpaso committed Oct 19, 2018
1 parent adb930b commit 21e685b46f2773f232a38d224bf9b07bc1868f12
Showing with 8 additions and 6 deletions.
  1. +2 −2 src/analysis/processing/qgsalgorithmbuffer.cpp
  2. +6 −4 tests/src/python/test_qgsprocessinginplace.py
@@ -179,8 +179,8 @@ 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;
//Only Polygons
return vlayer->wkbType() == QgsWkbTypes::Type::Polygon || vlayer->wkbType() == QgsWkbTypes::Type::MultiPolygon;
}

///@endcond
@@ -134,7 +134,8 @@ def test_support_in_place_edit(self):
Z_ONLY = {t: t.find('Z') > 0 for t in _all_true().keys()}
M_ONLY = {t: t.rfind('M') > 0 for t in _all_true().keys()}
NOT_M = {t: t.rfind('M') < 1 and t != 'NoGeometry' for t in _all_true().keys()}
POLYGON_ONLY = {t: t in ('Polygon', 'MultiPolygon') for t in _all_true().keys()}
POLYGON_ONLY = {t: t.find('Polygon') for t in _all_true().keys()}
POLYGON_ONLY_NOT_M_NOT_Z = {t: t in ('Polygon', 'MultiPolygon') for t in _all_true().keys()}
MULTI_ONLY = {t: t.find('Multi') == 0 for t in _all_true().keys()}
SINGLE_ONLY = {t: t.find('Multi') == -1 for t in _all_true().keys()}
LINESTRING_AND_POLYGON_ONLY = {t: (t.find('LineString') >= 0 or t.find('Polygon') >= 0) for t in _all_true().keys()}
@@ -151,9 +152,9 @@ def test_support_in_place_edit(self):
self._support_inplace_edit_tester('native:explodelines', LINESTRING_ONLY)
self._support_inplace_edit_tester('native:extendlines', LINESTRING_ONLY)
self._support_inplace_edit_tester('native:fixgeometries', NOT_M)
self._support_inplace_edit_tester('native:minimumenclosingcircle', POLYGON_ONLY)
self._support_inplace_edit_tester('native:multiringconstantbuffer', POLYGON_ONLY)
self._support_inplace_edit_tester('native:orientedminimumboundingbox', POLYGON_ONLY)
self._support_inplace_edit_tester('native:minimumenclosingcircle', POLYGON_ONLY_NOT_M_NOT_Z)
self._support_inplace_edit_tester('native:multiringconstantbuffer', POLYGON_ONLY_NOT_M_NOT_Z)
self._support_inplace_edit_tester('native:orientedminimumboundingbox', POLYGON_ONLY_NOT_M_NOT_Z)
self._support_inplace_edit_tester('qgis:orthogonalize', LINESTRING_AND_POLYGON_ONLY)
self._support_inplace_edit_tester('native:removeduplicatevertices', GEOMETRY_ONLY)
self._support_inplace_edit_tester('native:rotatefeatures', GEOMETRY_ONLY)
@@ -174,6 +175,7 @@ def test_support_in_place_edit(self):
self._support_inplace_edit_tester('native:difference', GEOMETRY_ONLY)
self._support_inplace_edit_tester('native:dropgeometries', ALL)
self._support_inplace_edit_tester('native:splitwithlines', LINESTRING_AND_POLYGON_ONLY)
self._support_inplace_edit_tester('native:buffer', POLYGON_ONLY_NOT_M_NOT_Z)

def _make_compatible_tester(self, feature_wkt, layer_wkb_name, attrs=[1]):
layer = self._make_layer(layer_wkb_name)

0 comments on commit 21e685b

Please sign in to comment.
You can’t perform that action at this time.