Skip to content

Commit 21e685b

Browse files
committedOct 19, 2018
[in-place] Limit buffer to (multi)polygons
1 parent adb930b commit 21e685b

File tree

2 files changed

+8
-6
lines changed

2 files changed

+8
-6
lines changed
 

‎src/analysis/processing/qgsalgorithmbuffer.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -179,8 +179,8 @@ bool QgsBufferAlgorithm::supportInPlaceEdit( const QgsMapLayer *layer ) const
179179
const QgsVectorLayer *vlayer = qobject_cast< const QgsVectorLayer * >( layer );
180180
if ( !vlayer )
181181
return false;
182-
QgsWkbTypes::GeometryType inPlaceGeometryType = vlayer->geometryType();
183-
return inPlaceGeometryType == QgsWkbTypes::GeometryType::PolygonGeometry;
182+
//Only Polygons
183+
return vlayer->wkbType() == QgsWkbTypes::Type::Polygon || vlayer->wkbType() == QgsWkbTypes::Type::MultiPolygon;
184184
}
185185

186186
///@endcond

‎tests/src/python/test_qgsprocessinginplace.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,8 @@ def test_support_in_place_edit(self):
134134
Z_ONLY = {t: t.find('Z') > 0 for t in _all_true().keys()}
135135
M_ONLY = {t: t.rfind('M') > 0 for t in _all_true().keys()}
136136
NOT_M = {t: t.rfind('M') < 1 and t != 'NoGeometry' for t in _all_true().keys()}
137-
POLYGON_ONLY = {t: t in ('Polygon', 'MultiPolygon') for t in _all_true().keys()}
137+
POLYGON_ONLY = {t: t.find('Polygon') for t in _all_true().keys()}
138+
POLYGON_ONLY_NOT_M_NOT_Z = {t: t in ('Polygon', 'MultiPolygon') for t in _all_true().keys()}
138139
MULTI_ONLY = {t: t.find('Multi') == 0 for t in _all_true().keys()}
139140
SINGLE_ONLY = {t: t.find('Multi') == -1 for t in _all_true().keys()}
140141
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):
151152
self._support_inplace_edit_tester('native:explodelines', LINESTRING_ONLY)
152153
self._support_inplace_edit_tester('native:extendlines', LINESTRING_ONLY)
153154
self._support_inplace_edit_tester('native:fixgeometries', NOT_M)
154-
self._support_inplace_edit_tester('native:minimumenclosingcircle', POLYGON_ONLY)
155-
self._support_inplace_edit_tester('native:multiringconstantbuffer', POLYGON_ONLY)
156-
self._support_inplace_edit_tester('native:orientedminimumboundingbox', POLYGON_ONLY)
155+
self._support_inplace_edit_tester('native:minimumenclosingcircle', POLYGON_ONLY_NOT_M_NOT_Z)
156+
self._support_inplace_edit_tester('native:multiringconstantbuffer', POLYGON_ONLY_NOT_M_NOT_Z)
157+
self._support_inplace_edit_tester('native:orientedminimumboundingbox', POLYGON_ONLY_NOT_M_NOT_Z)
157158
self._support_inplace_edit_tester('qgis:orthogonalize', LINESTRING_AND_POLYGON_ONLY)
158159
self._support_inplace_edit_tester('native:removeduplicatevertices', GEOMETRY_ONLY)
159160
self._support_inplace_edit_tester('native:rotatefeatures', GEOMETRY_ONLY)
@@ -174,6 +175,7 @@ def test_support_in_place_edit(self):
174175
self._support_inplace_edit_tester('native:difference', GEOMETRY_ONLY)
175176
self._support_inplace_edit_tester('native:dropgeometries', ALL)
176177
self._support_inplace_edit_tester('native:splitwithlines', LINESTRING_AND_POLYGON_ONLY)
178+
self._support_inplace_edit_tester('native:buffer', POLYGON_ONLY_NOT_M_NOT_Z)
177179

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

0 commit comments

Comments
 (0)
Please sign in to comment.