From 594fafe73b80d91d94b962c2e51aea0b0168a08a Mon Sep 17 00:00:00 2001 From: Marco Hugentobler Date: Tue, 24 Nov 2015 15:42:33 +0100 Subject: [PATCH] Fix ftools geometry collection handling --- .../plugins/fTools/tools/doGeoprocessing.py | 22 +++++++++---------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/python/plugins/fTools/tools/doGeoprocessing.py b/python/plugins/fTools/tools/doGeoprocessing.py index 073b5cd01ff..ed4e3d89c84 100644 --- a/python/plugins/fTools/tools/doGeoprocessing.py +++ b/python/plugins/fTools/tools/doGeoprocessing.py @@ -32,7 +32,7 @@ from PyQt4.QtCore import SIGNAL, QObject, Qt, QFile, QThread, QVariant from PyQt4.QtGui import QDialog, QDoubleValidator, QDialogButtonBox, QMessageBox -from qgis.core import QGis, QgsVectorFileWriter, QgsFeature, QgsGeometry, QgsFields, QgsField, QgsFeatureRequest, QgsPoint, QgsDistanceArea +from qgis.core import QGis, QgsVectorFileWriter, QgsFeature, QgsGeometry, QgsFields, QgsField, QgsFeatureRequest, QgsPoint, QgsDistanceArea, QgsMessageLog, QgsWKBTypes from ui_frmGeoprocessing import Ui_Dialog import ftools_utils @@ -966,7 +966,7 @@ class geoprocessingThread(QThread): if geom.intersects(tmpGeom): atMapB = inFeatB.attributes() int_geom = QgsGeometry(geom.intersection(tmpGeom)) - if int_geom.wkbType() == 0: + if int_geom.wkbType() == 0 or QgsWKBTypes.flatType( int_geom.geometry().wkbType() ) == QgsWKBTypes.GeometryCollection: int_com = geom.combine(tmpGeom) int_sym = geom.symDifference(tmpGeom) int_geom = QgsGeometry(int_com.difference(int_sym)) @@ -1001,7 +1001,7 @@ class geoprocessingThread(QThread): if geom.intersects(tmpGeom): atMapB = inFeatB.attributes() int_geom = QgsGeometry(geom.intersection(tmpGeom)) - if int_geom.wkbType() == 0: + if int_geom.wkbType() == 0 or QgsWKBTypes.flatType( int_geom.geometry().wkbType() ) == QgsWKBTypes.GeometryCollection: int_com = geom.combine(tmpGeom) int_sym = geom.symDifference(tmpGeom) int_geom = QgsGeometry(int_com.difference(int_sym)) @@ -1040,7 +1040,7 @@ class geoprocessingThread(QThread): if geom.intersects(tmpGeom): atMapB = inFeatB.attributes() int_geom = QgsGeometry(geom.intersection(tmpGeom)) - if int_geom.wkbType() == 0: + if int_geom.wkbType() == 0 or QgsWKBTypes.flatType( int_geom.geometry().wkbType() ) == QgsWKBTypes.GeometryCollection: int_com = geom.combine(tmpGeom) int_sym = geom.symDifference(tmpGeom) int_geom = QgsGeometry(int_com.difference(int_sym)) @@ -1072,7 +1072,7 @@ class geoprocessingThread(QThread): if geom.intersects(tmpGeom): atMapB = inFeatB.attributes() int_geom = QgsGeometry(geom.intersection(tmpGeom)) - if int_geom.wkbType() == 0: + if ( int_geom.wkbType() == 0 or QgsWKBTypes.flatType( int_geom.geometry().wkbType() ) == QgsWKBTypes.GeometryCollection ): int_com = geom.combine(tmpGeom) int_sym = geom.symDifference(tmpGeom) int_geom = QgsGeometry(int_com.difference(int_sym)) @@ -1161,7 +1161,7 @@ class geoprocessingThread(QThread): else: int_geom = QgsGeometry(int_geom) - if int_geom.wkbType() == 0: + if int_geom.wkbType() == 0 or QgsWKBTypes.flatType( int_geom.geometry().wkbType() ) == QgsWKBTypes.GeometryCollection: # intersection produced different geometry types temp_list = int_geom.asGeometryCollection() for i in temp_list: @@ -1197,7 +1197,7 @@ class geoprocessingThread(QThread): intB = QgsGeometry.unaryUnion(lstIntersectingB) diff_geom = diff_geom.difference(intB) - if diff_geom.wkbType() == 0: + if diff_geom.wkbType() == 0 or QgsWKBTypes.flatType( int_geom.geometry().wkbType() ) == QgsWKBTypes.GeometryCollection: temp_list = diff_geom.asGeometryCollection() for i in temp_list: if i.type() == geom.type(): @@ -1415,7 +1415,7 @@ class geoprocessingThread(QThread): try: cur_geom = QgsGeometry(outFeat.geometry()) new_geom = QgsGeometry(geom.intersection(cur_geom)) - if new_geom.wkbType() == 0: + if new_geom.wkbType() == 0 or QgsWKBTypes.flatType( int_geom.geometry().wkbType() ) == QgsWKBTypes.GeometryCollection: int_com = QgsGeometry(geom.combine(cur_geom)) int_sym = QgsGeometry(geom.symDifference(cur_geom)) new_geom = QgsGeometry(int_com.difference(int_sym)) @@ -1459,7 +1459,7 @@ class geoprocessingThread(QThread): try: cur_geom = QgsGeometry(outFeat.geometry()) new_geom = QgsGeometry(geom.intersection(cur_geom)) - if new_geom.wkbType() == 0: + if new_geom.wkbType() == 0 or QgsWKBTypes.flatType( int_geom.geometry().wkbType() ) == QgsWKBTypes.GeometryCollection: int_com = QgsGeometry(geom.combine(cur_geom)) int_sym = QgsGeometry(geom.symDifference(cur_geom)) new_geom = QgsGeometry(int_com.difference(int_sym)) @@ -1511,7 +1511,7 @@ class geoprocessingThread(QThread): try: cur_geom = QgsGeometry(outFeat.geometry()) new_geom = QgsGeometry(geom.intersection(cur_geom)) - if new_geom.wkbType() == 0: + if new_geom.wkbType() == 0 or QgsWKBTypes.flatType( int_geom.geometry().wkbType() ) == QgsWKBTypes.GeometryCollection: int_com = QgsGeometry(geom.combine(cur_geom)) int_sym = QgsGeometry(geom.symDifference(cur_geom)) new_geom = QgsGeometry(int_com.difference(int_sym)) @@ -1557,7 +1557,7 @@ class geoprocessingThread(QThread): try: cur_geom = QgsGeometry(outFeat.geometry()) new_geom = QgsGeometry(geom.intersection(cur_geom)) - if new_geom.wkbType() == 0: + if new_geom.wkbType() == 0 or QgsWKBTypes.flatType( int_geom.geometry().wkbType() ) == QgsWKBTypes.GeometryCollection: int_com = QgsGeometry(geom.combine(cur_geom)) int_sym = QgsGeometry(geom.symDifference(cur_geom)) new_geom = QgsGeometry(int_com.difference(int_sym))