Skip to content

Commit

Permalink
Merge pull request #1076 from snorfalorpagus/processing_intersection_fix
Browse files Browse the repository at this point in the history
[processing] fix QGIS Intersection tool
  • Loading branch information
alexbruy committed Mar 25, 2014
2 parents af9da1d + bb9c989 commit 285fa01
Showing 1 changed file with 16 additions and 7 deletions.
23 changes: 16 additions & 7 deletions python/plugins/processing/algs/ftools/Intersection.py
Expand Up @@ -33,6 +33,14 @@
from processing.outputs.OutputVector import OutputVector
from processing.tools import dataobjects, vector

wkbTypeGroups = {
'Point': (QGis.WKBPoint, QGis.WKBMultiPoint, QGis.WKBPoint25D, QGis.WKBMultiPoint25D,),
'LineString': (QGis.WKBLineString, QGis.WKBMultiLineString, QGis.WKBLineString25D, QGis.WKBMultiLineString25D,),
'Polygon': (QGis.WKBPolygon, QGis.WKBMultiPolygon, QGis.WKBPolygon25D, QGis.WKBMultiPolygon25D,),
}
for key, value in wkbTypeGroups.items():
for const in value:
wkbTypeGroups[const] = key

class Intersection(GeoAlgorithm):

Expand Down Expand Up @@ -70,16 +78,17 @@ def processAlgorithm(self, progress):
if geom.intersects(tmpGeom):
atMapB = inFeatB.attributes()
int_geom = QgsGeometry(geom.intersection(tmpGeom))
if int_geom.wkbType() == 7:
if int_geom.wkbType() == QGis.WKBUnknown:
int_com = geom.combine(tmpGeom)
int_sym = geom.symDifference(tmpGeom)
int_geom = QgsGeometry(int_com.difference(int_sym))
outFeat.setGeometry(int_geom)
attrs = []
attrs.extend(atMapA)
attrs.extend(atMapB)
outFeat.setAttributes(attrs)
writer.addFeature(outFeat)
if int_geom.wkbType() in wkbTypeGroups[wkbTypeGroups[int_geom.wkbType()]]:
outFeat.setGeometry(int_geom)
attrs = []
attrs.extend(atMapA)
attrs.extend(atMapB)
outFeat.setAttributes(attrs)
writer.addFeature(outFeat)

del writer

Expand Down

0 comments on commit 285fa01

Please sign in to comment.