Skip to content

Commit

Permalink
[in-place] Limit buffer to (multi)polygons
Browse files Browse the repository at this point in the history
  • Loading branch information
elpaso committed Oct 19, 2018
1 parent adb930b commit 21e685b
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
4 changes: 2 additions & 2 deletions src/analysis/processing/qgsalgorithmbuffer.cpp
Expand Up @@ -179,8 +179,8 @@ bool QgsBufferAlgorithm::supportInPlaceEdit( const QgsMapLayer *layer ) const
const QgsVectorLayer *vlayer = qobject_cast< const QgsVectorLayer * >( layer ); const QgsVectorLayer *vlayer = qobject_cast< const QgsVectorLayer * >( layer );
if ( !vlayer ) if ( !vlayer )
return false; return false;
QgsWkbTypes::GeometryType inPlaceGeometryType = vlayer->geometryType(); //Only Polygons
return inPlaceGeometryType == QgsWkbTypes::GeometryType::PolygonGeometry; return vlayer->wkbType() == QgsWkbTypes::Type::Polygon || vlayer->wkbType() == QgsWkbTypes::Type::MultiPolygon;
} }


///@endcond ///@endcond
10 changes: 6 additions & 4 deletions tests/src/python/test_qgsprocessinginplace.py
Expand Up @@ -134,7 +134,8 @@ def test_support_in_place_edit(self):
Z_ONLY = {t: t.find('Z') > 0 for t in _all_true().keys()} 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()} 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()} 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()} 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()} 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()} LINESTRING_AND_POLYGON_ONLY = {t: (t.find('LineString') >= 0 or t.find('Polygon') >= 0) for t in _all_true().keys()}
Expand All @@ -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:explodelines', LINESTRING_ONLY)
self._support_inplace_edit_tester('native:extendlines', 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:fixgeometries', NOT_M)
self._support_inplace_edit_tester('native:minimumenclosingcircle', POLYGON_ONLY) self._support_inplace_edit_tester('native:minimumenclosingcircle', POLYGON_ONLY_NOT_M_NOT_Z)
self._support_inplace_edit_tester('native:multiringconstantbuffer', POLYGON_ONLY) self._support_inplace_edit_tester('native:multiringconstantbuffer', POLYGON_ONLY_NOT_M_NOT_Z)
self._support_inplace_edit_tester('native:orientedminimumboundingbox', POLYGON_ONLY) 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('qgis:orthogonalize', LINESTRING_AND_POLYGON_ONLY)
self._support_inplace_edit_tester('native:removeduplicatevertices', GEOMETRY_ONLY) self._support_inplace_edit_tester('native:removeduplicatevertices', GEOMETRY_ONLY)
self._support_inplace_edit_tester('native:rotatefeatures', GEOMETRY_ONLY) self._support_inplace_edit_tester('native:rotatefeatures', GEOMETRY_ONLY)
Expand All @@ -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:difference', GEOMETRY_ONLY)
self._support_inplace_edit_tester('native:dropgeometries', ALL) 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: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]): def _make_compatible_tester(self, feature_wkt, layer_wkb_name, attrs=[1]):
layer = self._make_layer(layer_wkb_name) layer = self._make_layer(layer_wkb_name)
Expand Down

0 comments on commit 21e685b

Please sign in to comment.