Skip to content

Commit

Permalink
Check validity of input geometries in intersection algorithm
Browse files Browse the repository at this point in the history
Fail if invalid geometries are found.
And some easy performance wins. Just because.

Fix #11986
  • Loading branch information
m-kuhn committed Oct 20, 2016
1 parent f0f093b commit dbbbf61
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions python/plugins/processing/algs/qgis/Intersection.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,12 +85,16 @@ def processAlgorithm(self, progress):
for current, inFeatA in enumerate(selectionA):
progress.setPercentage(int(current * total))
geom = QgsGeometry(inFeatA.geometry())
if not geom.isGeosValid():
raise GeoAlgorithmExecutionException(
self.tr('Input layer A contains invalid geometries. Unable to complete intersection algorithm.'))
atMapA = inFeatA.attributes()
intersects = index.intersects(geom.boundingBox())
for i in intersects:
request = QgsFeatureRequest().setFilterFid(i)
inFeatB = vlayerB.getFeatures(request).next()
for inFeatB in vlayerB.getFeatures(QgsFeatureRequest().setFilterFids(intersects)):
tmpGeom = QgsGeometry(inFeatB.geometry())
if not tmpGeom.isGeosValid():
raise GeoAlgorithmExecutionException(
self.tr('Input layer B contains invalid geometries. Unable to complete intersection algorithm.'))
if geom.intersects(tmpGeom):
atMapB = inFeatB.attributes()
int_geom = QgsGeometry(geom.intersection(tmpGeom))
Expand Down

0 comments on commit dbbbf61

Please sign in to comment.