Skip to content
Permalink
Browse files

[processing] skip invalid geometries when buffering (fix #13763)

  • Loading branch information
alexbruy committed Jan 15, 2016
1 parent 0c02f18 commit 3bc3f52f0cf7aa587fa97818202ac6279db46843
Showing with 9 additions and 0 deletions.
  1. +9 −0 python/plugins/processing/algs/qgis/Buffer.py
@@ -26,6 +26,8 @@
__revision__ = '$Format:%H$'

from qgis.core import QgsFeature, QgsGeometry

from processing.core.ProcessingLog import ProcessingLog
from processing.tools import vector


@@ -55,6 +57,9 @@ def buffering(progress, writer, distance, field, useField, layer, dissolve,
value = distance

inGeom = QgsGeometry(inFeat.geometry())
if inGeom.isGeosEmpty() or not inGeom.isGeosValid():
ProcessingLog.addToLog('Feature {} has empty or invalid geometry. Skipping...'.format(inFeat.id()), ProcessingLog.LOG_WARNING)
continue
outGeom = inGeom.buffer(float(value), segments)
if first:
tempGeom = QgsGeometry(outGeom)
@@ -77,6 +82,10 @@ def buffering(progress, writer, distance, field, useField, layer, dissolve,
else:
value = distance
inGeom = QgsGeometry(inFeat.geometry())
if inGeom.isGeosEmpty() or not inGeom.isGeosValid():
ProcessingLog.addToLog('Feature {} has empty or invalid geometry. Skipping...'.format(inFeat.id()), ProcessingLog.LOG_WARNING)
continue

outGeom = inGeom.buffer(float(value), segments)
outFeat.setGeometry(outGeom)
outFeat.setAttributes(attrs)

3 comments on commit 3bc3f52

@m-kuhn

This comment has been minimized.

Copy link
Member

@m-kuhn m-kuhn replied Jan 15, 2016

Just for your info (I don't think it applies here), QgsVectorFileWriter can now also produce geometry collections

@alexbruy

This comment has been minimized.

Copy link
Contributor Author

@alexbruy alexbruy replied Jan 15, 2016

Thanks Matthias! But as I understand such geometries still valid from GEOS point of view and should be correctly handled

@m-kuhn

This comment has been minimized.

Copy link
Member

@m-kuhn m-kuhn replied Jan 15, 2016

Absolutely, I think here you check the input geometries, this only applies where output geometries are dismissed because of a format incompatible with the produced output file.

It's not yet implemented anywhere in processing, just wanted to make you aware of it ;)

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