44
44
45
45
pluginPath = os .path .split (os .path .split (os .path .dirname (__file__ ))[0 ])[0 ]
46
46
47
- wkbTypeGroups = {
48
- 'Point' : (QgsWkbTypes .Point , QgsWkbTypes .MultiPoint , QgsWkbTypes .Point25D , QgsWkbTypes .MultiPoint25D ,),
49
- 'LineString' : (QgsWkbTypes .LineString , QgsWkbTypes .MultiLineString , QgsWkbTypes .LineString25D , QgsWkbTypes .MultiLineString25D ,),
50
- 'Polygon' : (QgsWkbTypes .Polygon , QgsWkbTypes .MultiPolygon , QgsWkbTypes .Polygon25D , QgsWkbTypes .MultiPolygon25D ,),
51
- }
52
- for key , value in list (wkbTypeGroups .items ()):
53
- for const in value :
54
- wkbTypeGroups [const ] = key
55
-
56
47
57
48
class Union (QgisAlgorithm ):
58
49
@@ -113,6 +104,7 @@ def processAlgorithm(self, parameters, context, feedback):
113
104
intersects = indexB .intersects (geom .boundingBox ())
114
105
if len (intersects ) < 1 :
115
106
try :
107
+ geom .convertToMultiType ()
116
108
outFeat .setGeometry (geom )
117
109
outFeat .setAttributes (atMapA )
118
110
sink .addFeature (outFeat , QgsFeatureSink .FastInsert )
@@ -149,6 +141,7 @@ def processAlgorithm(self, parameters, context, feedback):
149
141
if i .type () == geom .type ():
150
142
int_geom = QgsGeometry (i )
151
143
try :
144
+ int_geom .convertToMultiType ()
152
145
outFeat .setGeometry (int_geom )
153
146
outFeat .setAttributes (atMapA + atMapB )
154
147
sink .addFeature (outFeat , QgsFeatureSink .FastInsert )
@@ -159,8 +152,9 @@ def processAlgorithm(self, parameters, context, feedback):
159
152
# in geometries of different types
160
153
# produced by the intersection
161
154
# fix #3549
162
- if int_geom .wkbType () in wkbTypeGroups [ wkbTypeGroups [ int_geom . wkbType ()]] :
155
+ if QgsWkbTypes . geometryType ( int_geom .wkbType ()) == QgsWkbTypes . geometryType ( geomType ) :
163
156
try :
157
+ int_geom .convertToMultiType ()
164
158
outFeat .setGeometry (int_geom )
165
159
outFeat .setAttributes (atMapA + atMapB )
166
160
sink .addFeature (outFeat , QgsFeatureSink .FastInsert )
@@ -180,6 +174,7 @@ def processAlgorithm(self, parameters, context, feedback):
180
174
if i .type () == geom .type ():
181
175
diff_geom = QgsGeometry (i )
182
176
try :
177
+ diff_geom .convertToMultiType ()
183
178
outFeat .setGeometry (diff_geom )
184
179
outFeat .setAttributes (atMapA )
185
180
sink .addFeature (outFeat , QgsFeatureSink .FastInsert )
@@ -205,6 +200,7 @@ def processAlgorithm(self, parameters, context, feedback):
205
200
206
201
if len (intersects ) < 1 :
207
202
try :
203
+ geom .convertToMultiType ()
208
204
outFeat .setGeometry (geom )
209
205
outFeat .setAttributes (atMap )
210
206
sink .addFeature (outFeat , QgsFeatureSink .FastInsert )
@@ -229,6 +225,7 @@ def processAlgorithm(self, parameters, context, feedback):
229
225
try :
230
226
# Ihis only happens if the bounding box
231
227
# intersects, but the geometry doesn't
228
+ diff_geom .convertToMultiType ()
232
229
outFeat .setGeometry (diff_geom )
233
230
outFeat .setAttributes (atMap )
234
231
sink .addFeature (outFeat , QgsFeatureSink .FastInsert )
@@ -237,6 +234,7 @@ def processAlgorithm(self, parameters, context, feedback):
237
234
238
235
if add :
239
236
try :
237
+ diff_geom .convertToMultiType ()
240
238
outFeat .setGeometry (diff_geom )
241
239
outFeat .setAttributes (atMap )
242
240
sink .addFeature (outFeat , QgsFeatureSink .FastInsert )
0 commit comments