Skip to content
Permalink
Browse files

Fixed bug in the processing toolbox qgis:intersection tool, preventing

attempts at writing the wrong geometry type to a shapefile.
  • Loading branch information
snorfalorpagus committed Jan 14, 2014
1 parent a31ebb4 commit bb9c9893fd57b84bf038efbcc0e5a6f5945b8d99
Showing with 16 additions and 7 deletions.
  1. +16 −7 python/plugins/processing/algs/ftools/Intersection.py
@@ -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):

@@ -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

0 comments on commit bb9c989

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