Skip to content
Browse files

[processing] Fix "Split with lines" algorithm can get stuck in

an endless loop if geos difference result is numerically unstable

Amend the test to determine whether a split occurred from an exact
topological test to instead test with a very small tolerance. This
avoids us flagging that a split has occurred when the actual results
have only varied by a insignificant amount due to precision of
the GEOS difference op.

This fixes a hang which can otherwise result where we keep splitting
the same pair of lines and think that a change is occurring every
  • Loading branch information
nyalldawson committed Oct 15, 2020
1 parent bf319fd commit 05645b320d8547f50a308843e961e343c383036d
Showing with 6 additions and 4 deletions.
  1. +6 −4 src/analysis/processing/qgsalgorithmsplitwithlines.cpp
@@ -209,12 +209,14 @@ QVariantMap QgsSplitWithLinesAlgorithm::processAlgorithm( const QVariantMap &par

// splitGeometry: If there are several intersections
// between geometry and splitLine, only the first one is considered.
if ( result == QgsGeometry::Success ) // split occurred
if ( result == QgsGeometry::Success )
if ( inGeom.isGeosEqual( before ) )
// sometimes the resultant geometry has changed from the input, but only because of numerical precision issues.
// and is effectively indistinguishable from the input. By testing the Hausdorff distance is less than this threshold
// we are checking that the maximum "change" between the result and the input is actually significant enough to be meaningful...
if ( inGeom.hausdorffDistance( before ) < 1e-12 )
// bug in splitGeometry: sometimes it returns 0 but
// the geometry is unchanged
// effectively no change!!
outGeoms.append( inGeom );

0 comments on commit 05645b3

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