|
29 | 29 | from PyQt4.QtGui import *
|
30 | 30 | from qgis.core import *
|
31 | 31 | from processing.core.GeoAlgorithm import GeoAlgorithm
|
| 32 | +from processing.core.ProcessingLog import ProcessingLog |
32 | 33 | from processing.parameters.ParameterVector import ParameterVector
|
33 | 34 | from processing.outputs.OutputVector import OutputVector
|
34 | 35 | from processing.tools import dataobjects, vector
|
@@ -75,20 +76,28 @@ def processAlgorithm(self, progress):
|
75 | 76 | request = QgsFeatureRequest().setFilterFid(i)
|
76 | 77 | inFeatB = vlayerB.getFeatures(request).next()
|
77 | 78 | tmpGeom = QgsGeometry(inFeatB.geometry())
|
78 |
| - if geom.intersects(tmpGeom): |
79 |
| - atMapB = inFeatB.attributes() |
80 |
| - int_geom = QgsGeometry(geom.intersection(tmpGeom)) |
81 |
| - if int_geom.wkbType() == QGis.WKBUnknown: |
82 |
| - int_com = geom.combine(tmpGeom) |
83 |
| - int_sym = geom.symDifference(tmpGeom) |
84 |
| - int_geom = QgsGeometry(int_com.difference(int_sym)) |
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) |
| 79 | + try: |
| 80 | + if geom.intersects(tmpGeom): |
| 81 | + atMapB = inFeatB.attributes() |
| 82 | + int_geom = QgsGeometry(geom.intersection(tmpGeom)) |
| 83 | + if int_geom.wkbType() == QGis.WKBUnknown: |
| 84 | + int_com = geom.combine(tmpGeom) |
| 85 | + int_sym = geom.symDifference(tmpGeom) |
| 86 | + int_geom = QgsGeometry(int_com.difference(int_sym)) |
| 87 | + try: |
| 88 | + if int_geom.wkbType() in wkbTypeGroups[wkbTypeGroups[int_geom.wkbType()]]: |
| 89 | + outFeat.setGeometry(int_geom) |
| 90 | + attrs = [] |
| 91 | + attrs.extend(atMapA) |
| 92 | + attrs.extend(atMapB) |
| 93 | + outFeat.setAttributes(attrs) |
| 94 | + writer.addFeature(outFeat) |
| 95 | + except: |
| 96 | + ProcessingLog.addToLog(ProcessingLog.LOG_INFO, 'Feature geometry error: One or more output features ignored due to invalid geometry.') |
| 97 | + continue |
| 98 | + except: |
| 99 | + break |
| 100 | + |
92 | 101 |
|
93 | 102 | del writer
|
94 | 103 |
|
|
0 commit comments