Skip to content

Commit 9976c30

Browse files
committedJul 22, 2016
[processing] fix buffer tool
1 parent e8bac30 commit 9976c30

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed
 

‎python/plugins/processing/algs/qgis/Buffer.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,8 +57,11 @@ def buffering(progress, writer, distance, field, useField, layer, dissolve,
5757
value = distance
5858

5959
inGeom = QgsGeometry(inFeat.geometry())
60-
if inGeom.isGeosEmpty() or not inGeom.isGeosValid():
61-
ProcessingLog.addToLog(ProcessingLog.LOG_WARNING, 'Feature {} has empty or invalid geometry. Skipping...'.format(inFeat.id()))
60+
if inGeom.isGeosEmpty():
61+
ProcessingLog.addToLog(ProcessingLog.LOG_WARNING, 'Feature {} has empty geometry. Skipping...'.format(inFeat.id()))
62+
continue
63+
if not inGeom.isGeosValid():
64+
ProcessingLog.addToLog(ProcessingLog.LOG_WARNING, 'Feature {} has invalid geometry. Skipping...'.format(inFeat.id()))
6265
continue
6366
outGeom = inGeom.buffer(float(value), segments)
6467
if first:

11 commit comments

Comments
 (11)

m-kuhn commented on Jul 22, 2016

@m-kuhn
Member

What do you think about a parameter IGNORE_INVALID, off by default like here
143cfab?

This way, a user has to consciously accept that he wants invalid geometries to be ignored or preprocess his data.

alexbruy commented on Jul 23, 2016

@alexbruy
ContributorAuthor

Personally I think that we should maintain same behavior for all Processing algorithms, including 3rd party backends. If one want to check/fix/reproject/etc layer before actual analysis, Processing provides all necessary tools for this: scripts, models and hooks.

m-kuhn commented on Jul 23, 2016

@m-kuhn
Member

gioman commented on Jul 23, 2016

@gioman
Contributor

@alexbruy @alexbruy Hi Alex and Matthias. I also think that fixing tools must be left separate from actual geoprocessing tools. The real issue here are tools that return wrong almost silently (logs are not very useful for the vast majority of users) because of geometry errors. Unfortunately we still have even worst cases: qgis tools returning silently wrong results even when input layers are ok.

m-kuhn commented on Aug 3, 2016

@m-kuhn
Member

@alexbruy what do you think about the approach in 143cfab?

alexbruy commented on Aug 3, 2016

@alexbruy
ContributorAuthor

@m-kuhn I think it is ok. But on other hand we can use this approach only with native algs. GDAL, SAGA and other algs will lack this feature and confuse users.

@volaya what is your opinion?

m-kuhn commented on Aug 3, 2016

@m-kuhn
Member

@alexbruy is there a proper solution that works with 3rd party algs as well?

alexbruy commented on Aug 3, 2016

@alexbruy
ContributorAuthor

@m-kuhn AFAIK there is no proper solution for this. Only workaround: export layer in compatible format excluding invalid geometries if checkbox is checked. But this will increase analysis time considerably and this again can be done with models/scripts/pre-execution hook without altering algorihtms code

m-kuhn commented on Aug 3, 2016

@m-kuhn
Member

volaya commented on Aug 9, 2016

@volaya
Contributor

I think that the more atomized the alg collection is, the better. If one needs to have several operations performed (clean + process), then the modeler can be used to wrap them. Easier algorithms are more useful and better to maintain.

m-kuhn commented on Aug 9, 2016

@m-kuhn
Member

@volaya I think we all agree on that part.

The question is what to do by default with input data that produce erroneous output.

  • Write something to the log and continue (producing erroneous output).
  • Abort algorithm with an error (unless the user consciously opted in to ignore such errors).
Please sign in to comment.