Skip to content

Commit 25264aa

Browse files
author
mhugent
committed
Fix for merge of adjacent multipolygons, ticket #2188
git-svn-id: http://svn.osgeo.org/qgis/trunk@12327 c8812cc2-4d05-0410-92ff-de0c093fc19c
1 parent 032c2cd commit 25264aa

File tree

3 files changed

+19
-5
lines changed

3 files changed

+19
-5
lines changed

python/core/qgsgeometry.sip

+5
Original file line numberDiff line numberDiff line change
@@ -309,5 +309,10 @@ not disjoint with existing polygons of the feature*/
309309
@note added in version 1.2 */
310310
bool deletePart( int partNum );
311311

312+
/**Converts single type geometry into multitype geometry
313+
e.g. a polygon into a multipolygon geometry with one polygon
314+
@return true in case of success and false else*/
315+
bool convertToMultiType();
316+
312317
}; // class QgsGeometry
313318

src/app/qgisapp.cpp

+9
Original file line numberDiff line numberDiff line change
@@ -4229,6 +4229,15 @@ QgsGeometry* QgisApp::unionGeometries( const QgsVectorLayer* vl, QgsFeatureList&
42294229
}
42304230
}
42314231

4232+
//convert unionGeom to a multipart geometry in case it is necessary to match the layer type
4233+
QGis::WkbType t = vl->wkbType();
4234+
bool layerIsMultiType = ( t == QGis::WKBMultiPoint || t == QGis::WKBMultiPoint25D || t == QGis::WKBMultiLineString \
4235+
|| t == QGis::WKBMultiLineString25D || t == QGis::WKBMultiPolygon || t == QGis::WKBMultiPoint25D );
4236+
if ( layerIsMultiType && !unionGeom->isMultipart() )
4237+
{
4238+
unionGeom->convertToMultiType();
4239+
}
4240+
42324241
QApplication::restoreOverrideCursor();
42334242
progress.setValue( featureList.size() );
42344243
return unionGeom;

src/core/qgsgeometry.h

+5-5
Original file line numberDiff line numberDiff line change
@@ -348,6 +348,11 @@ class CORE_EXPORT QgsGeometry
348348
@note added in version 1.2 */
349349
bool deletePart( int partNum );
350350

351+
/**Converts single type geometry into multitype geometry
352+
e.g. a polygon into a multipolygon geometry with one polygon
353+
@return true in case of success and false else*/
354+
bool convertToMultiType();
355+
351356

352357
private:
353358
// Private variables
@@ -410,11 +415,6 @@ class CORE_EXPORT QgsGeometry
410415
const GEOSCoordSequence* old_sequence,
411416
GEOSCoordSequence** new_sequence );
412417

413-
/**Converts single type geometry into multitype geometry
414-
e.g. a polygon into a multipolygon geometry with one polygon
415-
@return true in case of success and false else*/
416-
bool convertToMultiType();
417-
418418
/**Translates a single vertex by dx and dy.
419419
@param ptr pointer to the wkb fragment containing the vertex
420420
@param wkbPosition position in wkb array. Is increased automatically by the function

0 commit comments

Comments
 (0)