|
33 | 33 | from processing.outputs.OutputVector import OutputVector
|
34 | 34 | from processing.tools import dataobjects, vector
|
35 | 35 |
|
| 36 | +wkbTypeGroups = { |
| 37 | + 'Point': (QGis.WKBPoint, QGis.WKBMultiPoint, QGis.WKBPoint25D, QGis.WKBMultiPoint25D,), |
| 38 | + 'LineString': (QGis.WKBLineString, QGis.WKBMultiLineString, QGis.WKBLineString25D, QGis.WKBMultiLineString25D,), |
| 39 | + 'Polygon': (QGis.WKBPolygon, QGis.WKBMultiPolygon, QGis.WKBPolygon25D, QGis.WKBMultiPolygon25D,), |
| 40 | +} |
| 41 | +for key, value in wkbTypeGroups.items(): |
| 42 | + for const in value: |
| 43 | + wkbTypeGroups[const] = key |
36 | 44 |
|
37 | 45 | class Intersection(GeoAlgorithm):
|
38 | 46 |
|
@@ -70,16 +78,17 @@ def processAlgorithm(self, progress):
|
70 | 78 | if geom.intersects(tmpGeom):
|
71 | 79 | atMapB = inFeatB.attributes()
|
72 | 80 | int_geom = QgsGeometry(geom.intersection(tmpGeom))
|
73 |
| - if int_geom.wkbType() == 7: |
| 81 | + if int_geom.wkbType() == QGis.WKBUnknown: |
74 | 82 | int_com = geom.combine(tmpGeom)
|
75 | 83 | int_sym = geom.symDifference(tmpGeom)
|
76 | 84 | int_geom = QgsGeometry(int_com.difference(int_sym))
|
77 |
| - outFeat.setGeometry(int_geom) |
78 |
| - attrs = [] |
79 |
| - attrs.extend(atMapA) |
80 |
| - attrs.extend(atMapB) |
81 |
| - outFeat.setAttributes(attrs) |
82 |
| - writer.addFeature(outFeat) |
| 85 | + if int_geom.wkbType() in wkbTypeGroups[wkbTypeGroups[int_geom.wkbType()]]: |
| 86 | + outFeat.setGeometry(int_geom) |
| 87 | + attrs = [] |
| 88 | + attrs.extend(atMapA) |
| 89 | + attrs.extend(atMapB) |
| 90 | + outFeat.setAttributes(attrs) |
| 91 | + writer.addFeature(outFeat) |
83 | 92 |
|
84 | 93 | del writer
|
85 | 94 |
|
|
0 commit comments