|
32 | 32 |
|
33 | 33 | from PyQt4.QtCore import SIGNAL, QObject, Qt, QFile, QThread, QVariant |
34 | 34 | from PyQt4.QtGui import QDialog, QDoubleValidator, QDialogButtonBox, QMessageBox |
35 | | -from qgis.core import QGis, QgsVectorFileWriter, QgsFeature, QgsGeometry, QgsFields, QgsField, QgsFeatureRequest, QgsPoint, QgsDistanceArea |
| 35 | +from qgis.core import QGis, QgsVectorFileWriter, QgsFeature, QgsGeometry, QgsFields, QgsField, QgsFeatureRequest, QgsPoint, QgsDistanceArea, QgsMessageLog, QgsWKBTypes |
36 | 36 |
|
37 | 37 | from ui_frmGeoprocessing import Ui_Dialog |
38 | 38 | import ftools_utils |
@@ -966,7 +966,7 @@ def intersect(self): |
966 | 966 | if geom.intersects(tmpGeom): |
967 | 967 | atMapB = inFeatB.attributes() |
968 | 968 | int_geom = QgsGeometry(geom.intersection(tmpGeom)) |
969 | | - if int_geom.wkbType() == 0: |
| 969 | + if int_geom.wkbType() == 0 or QgsWKBTypes.flatType( int_geom.geometry().wkbType() ) == QgsWKBTypes.GeometryCollection: |
970 | 970 | int_com = geom.combine(tmpGeom) |
971 | 971 | int_sym = geom.symDifference(tmpGeom) |
972 | 972 | int_geom = QgsGeometry(int_com.difference(int_sym)) |
@@ -1001,7 +1001,7 @@ def intersect(self): |
1001 | 1001 | if geom.intersects(tmpGeom): |
1002 | 1002 | atMapB = inFeatB.attributes() |
1003 | 1003 | int_geom = QgsGeometry(geom.intersection(tmpGeom)) |
1004 | | - if int_geom.wkbType() == 0: |
| 1004 | + if int_geom.wkbType() == 0 or QgsWKBTypes.flatType( int_geom.geometry().wkbType() ) == QgsWKBTypes.GeometryCollection: |
1005 | 1005 | int_com = geom.combine(tmpGeom) |
1006 | 1006 | int_sym = geom.symDifference(tmpGeom) |
1007 | 1007 | int_geom = QgsGeometry(int_com.difference(int_sym)) |
@@ -1040,7 +1040,7 @@ def intersect(self): |
1040 | 1040 | if geom.intersects(tmpGeom): |
1041 | 1041 | atMapB = inFeatB.attributes() |
1042 | 1042 | int_geom = QgsGeometry(geom.intersection(tmpGeom)) |
1043 | | - if int_geom.wkbType() == 0: |
| 1043 | + if int_geom.wkbType() == 0 or QgsWKBTypes.flatType( int_geom.geometry().wkbType() ) == QgsWKBTypes.GeometryCollection: |
1044 | 1044 | int_com = geom.combine(tmpGeom) |
1045 | 1045 | int_sym = geom.symDifference(tmpGeom) |
1046 | 1046 | int_geom = QgsGeometry(int_com.difference(int_sym)) |
@@ -1072,7 +1072,7 @@ def intersect(self): |
1072 | 1072 | if geom.intersects(tmpGeom): |
1073 | 1073 | atMapB = inFeatB.attributes() |
1074 | 1074 | int_geom = QgsGeometry(geom.intersection(tmpGeom)) |
1075 | | - if int_geom.wkbType() == 0: |
| 1075 | + if ( int_geom.wkbType() == 0 or QgsWKBTypes.flatType( int_geom.geometry().wkbType() ) == QgsWKBTypes.GeometryCollection ): |
1076 | 1076 | int_com = geom.combine(tmpGeom) |
1077 | 1077 | int_sym = geom.symDifference(tmpGeom) |
1078 | 1078 | int_geom = QgsGeometry(int_com.difference(int_sym)) |
@@ -1161,7 +1161,7 @@ def union(self): |
1161 | 1161 | else: |
1162 | 1162 | int_geom = QgsGeometry(int_geom) |
1163 | 1163 |
|
1164 | | - if int_geom.wkbType() == 0: |
| 1164 | + if int_geom.wkbType() == 0 or QgsWKBTypes.flatType( int_geom.geometry().wkbType() ) == QgsWKBTypes.GeometryCollection: |
1165 | 1165 | # intersection produced different geometry types |
1166 | 1166 | temp_list = int_geom.asGeometryCollection() |
1167 | 1167 | for i in temp_list: |
@@ -1197,7 +1197,7 @@ def union(self): |
1197 | 1197 | intB = QgsGeometry.unaryUnion(lstIntersectingB) |
1198 | 1198 | diff_geom = diff_geom.difference(intB) |
1199 | 1199 |
|
1200 | | - if diff_geom.wkbType() == 0: |
| 1200 | + if diff_geom.wkbType() == 0 or QgsWKBTypes.flatType( int_geom.geometry().wkbType() ) == QgsWKBTypes.GeometryCollection: |
1201 | 1201 | temp_list = diff_geom.asGeometryCollection() |
1202 | 1202 | for i in temp_list: |
1203 | 1203 | if i.type() == geom.type(): |
@@ -1415,7 +1415,7 @@ def clip(self): |
1415 | 1415 | try: |
1416 | 1416 | cur_geom = QgsGeometry(outFeat.geometry()) |
1417 | 1417 | new_geom = QgsGeometry(geom.intersection(cur_geom)) |
1418 | | - if new_geom.wkbType() == 0: |
| 1418 | + if new_geom.wkbType() == 0 or QgsWKBTypes.flatType( int_geom.geometry().wkbType() ) == QgsWKBTypes.GeometryCollection: |
1419 | 1419 | int_com = QgsGeometry(geom.combine(cur_geom)) |
1420 | 1420 | int_sym = QgsGeometry(geom.symDifference(cur_geom)) |
1421 | 1421 | new_geom = QgsGeometry(int_com.difference(int_sym)) |
@@ -1459,7 +1459,7 @@ def clip(self): |
1459 | 1459 | try: |
1460 | 1460 | cur_geom = QgsGeometry(outFeat.geometry()) |
1461 | 1461 | new_geom = QgsGeometry(geom.intersection(cur_geom)) |
1462 | | - if new_geom.wkbType() == 0: |
| 1462 | + if new_geom.wkbType() == 0 or QgsWKBTypes.flatType( int_geom.geometry().wkbType() ) == QgsWKBTypes.GeometryCollection: |
1463 | 1463 | int_com = QgsGeometry(geom.combine(cur_geom)) |
1464 | 1464 | int_sym = QgsGeometry(geom.symDifference(cur_geom)) |
1465 | 1465 | new_geom = QgsGeometry(int_com.difference(int_sym)) |
@@ -1511,7 +1511,7 @@ def clip(self): |
1511 | 1511 | try: |
1512 | 1512 | cur_geom = QgsGeometry(outFeat.geometry()) |
1513 | 1513 | new_geom = QgsGeometry(geom.intersection(cur_geom)) |
1514 | | - if new_geom.wkbType() == 0: |
| 1514 | + if new_geom.wkbType() == 0 or QgsWKBTypes.flatType( int_geom.geometry().wkbType() ) == QgsWKBTypes.GeometryCollection: |
1515 | 1515 | int_com = QgsGeometry(geom.combine(cur_geom)) |
1516 | 1516 | int_sym = QgsGeometry(geom.symDifference(cur_geom)) |
1517 | 1517 | new_geom = QgsGeometry(int_com.difference(int_sym)) |
@@ -1557,7 +1557,7 @@ def clip(self): |
1557 | 1557 | try: |
1558 | 1558 | cur_geom = QgsGeometry(outFeat.geometry()) |
1559 | 1559 | new_geom = QgsGeometry(geom.intersection(cur_geom)) |
1560 | | - if new_geom.wkbType() == 0: |
| 1560 | + if new_geom.wkbType() == 0 or QgsWKBTypes.flatType( int_geom.geometry().wkbType() ) == QgsWKBTypes.GeometryCollection: |
1561 | 1561 | int_com = QgsGeometry(geom.combine(cur_geom)) |
1562 | 1562 | int_sym = QgsGeometry(geom.symDifference(cur_geom)) |
1563 | 1563 | new_geom = QgsGeometry(int_com.difference(int_sym)) |
|
0 commit comments