Skip to content
Permalink
Browse files

Check validity of input geometries in intersection algorithm

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 dbbbf610cfcf3fa655118d73d27a197ac1b3b224
Showing with 7 additions and 3 deletions.
  1. +7 −3 python/plugins/processing/algs/qgis/Intersection.py
@@ -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))

0 comments on commit dbbbf61

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