Skip to content

Commit 594fafe

Browse files
committed
Fix ftools geometry collection handling
1 parent 2543af5 commit 594fafe

File tree

1 file changed

+11
-11
lines changed

1 file changed

+11
-11
lines changed

python/plugins/fTools/tools/doGeoprocessing.py

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232

3333
from PyQt4.QtCore import SIGNAL, QObject, Qt, QFile, QThread, QVariant
3434
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
3636

3737
from ui_frmGeoprocessing import Ui_Dialog
3838
import ftools_utils
@@ -966,7 +966,7 @@ def intersect(self):
966966
if geom.intersects(tmpGeom):
967967
atMapB = inFeatB.attributes()
968968
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:
970970
int_com = geom.combine(tmpGeom)
971971
int_sym = geom.symDifference(tmpGeom)
972972
int_geom = QgsGeometry(int_com.difference(int_sym))
@@ -1001,7 +1001,7 @@ def intersect(self):
10011001
if geom.intersects(tmpGeom):
10021002
atMapB = inFeatB.attributes()
10031003
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:
10051005
int_com = geom.combine(tmpGeom)
10061006
int_sym = geom.symDifference(tmpGeom)
10071007
int_geom = QgsGeometry(int_com.difference(int_sym))
@@ -1040,7 +1040,7 @@ def intersect(self):
10401040
if geom.intersects(tmpGeom):
10411041
atMapB = inFeatB.attributes()
10421042
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:
10441044
int_com = geom.combine(tmpGeom)
10451045
int_sym = geom.symDifference(tmpGeom)
10461046
int_geom = QgsGeometry(int_com.difference(int_sym))
@@ -1072,7 +1072,7 @@ def intersect(self):
10721072
if geom.intersects(tmpGeom):
10731073
atMapB = inFeatB.attributes()
10741074
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 ):
10761076
int_com = geom.combine(tmpGeom)
10771077
int_sym = geom.symDifference(tmpGeom)
10781078
int_geom = QgsGeometry(int_com.difference(int_sym))
@@ -1161,7 +1161,7 @@ def union(self):
11611161
else:
11621162
int_geom = QgsGeometry(int_geom)
11631163

1164-
if int_geom.wkbType() == 0:
1164+
if int_geom.wkbType() == 0 or QgsWKBTypes.flatType( int_geom.geometry().wkbType() ) == QgsWKBTypes.GeometryCollection:
11651165
# intersection produced different geometry types
11661166
temp_list = int_geom.asGeometryCollection()
11671167
for i in temp_list:
@@ -1197,7 +1197,7 @@ def union(self):
11971197
intB = QgsGeometry.unaryUnion(lstIntersectingB)
11981198
diff_geom = diff_geom.difference(intB)
11991199

1200-
if diff_geom.wkbType() == 0:
1200+
if diff_geom.wkbType() == 0 or QgsWKBTypes.flatType( int_geom.geometry().wkbType() ) == QgsWKBTypes.GeometryCollection:
12011201
temp_list = diff_geom.asGeometryCollection()
12021202
for i in temp_list:
12031203
if i.type() == geom.type():
@@ -1415,7 +1415,7 @@ def clip(self):
14151415
try:
14161416
cur_geom = QgsGeometry(outFeat.geometry())
14171417
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:
14191419
int_com = QgsGeometry(geom.combine(cur_geom))
14201420
int_sym = QgsGeometry(geom.symDifference(cur_geom))
14211421
new_geom = QgsGeometry(int_com.difference(int_sym))
@@ -1459,7 +1459,7 @@ def clip(self):
14591459
try:
14601460
cur_geom = QgsGeometry(outFeat.geometry())
14611461
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:
14631463
int_com = QgsGeometry(geom.combine(cur_geom))
14641464
int_sym = QgsGeometry(geom.symDifference(cur_geom))
14651465
new_geom = QgsGeometry(int_com.difference(int_sym))
@@ -1511,7 +1511,7 @@ def clip(self):
15111511
try:
15121512
cur_geom = QgsGeometry(outFeat.geometry())
15131513
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:
15151515
int_com = QgsGeometry(geom.combine(cur_geom))
15161516
int_sym = QgsGeometry(geom.symDifference(cur_geom))
15171517
new_geom = QgsGeometry(int_com.difference(int_sym))
@@ -1557,7 +1557,7 @@ def clip(self):
15571557
try:
15581558
cur_geom = QgsGeometry(outFeat.geometry())
15591559
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:
15611561
int_com = QgsGeometry(geom.combine(cur_geom))
15621562
int_sym = QgsGeometry(geom.symDifference(cur_geom))
15631563
new_geom = QgsGeometry(int_com.difference(int_sym))

0 commit comments

Comments
 (0)