Skip to content

Commit

Permalink
Fix for merge of adjacent multipolygons, ticket #2188
Browse files Browse the repository at this point in the history
git-svn-id: http://svn.osgeo.org/qgis/trunk@12327 c8812cc2-4d05-0410-92ff-de0c093fc19c
  • Loading branch information
mhugent committed Dec 3, 2009
1 parent 032c2cd commit 25264aa
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 5 deletions.
5 changes: 5 additions & 0 deletions python/core/qgsgeometry.sip
Expand Up @@ -309,5 +309,10 @@ not disjoint with existing polygons of the feature*/
@note added in version 1.2 */
bool deletePart( int partNum );

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

}; // class QgsGeometry

9 changes: 9 additions & 0 deletions src/app/qgisapp.cpp
Expand Up @@ -4229,6 +4229,15 @@ QgsGeometry* QgisApp::unionGeometries( const QgsVectorLayer* vl, QgsFeatureList&
}
}

//convert unionGeom to a multipart geometry in case it is necessary to match the layer type
QGis::WkbType t = vl->wkbType();
bool layerIsMultiType = ( t == QGis::WKBMultiPoint || t == QGis::WKBMultiPoint25D || t == QGis::WKBMultiLineString \
|| t == QGis::WKBMultiLineString25D || t == QGis::WKBMultiPolygon || t == QGis::WKBMultiPoint25D );
if ( layerIsMultiType && !unionGeom->isMultipart() )
{
unionGeom->convertToMultiType();
}

QApplication::restoreOverrideCursor();
progress.setValue( featureList.size() );
return unionGeom;
Expand Down
10 changes: 5 additions & 5 deletions src/core/qgsgeometry.h
Expand Up @@ -348,6 +348,11 @@ class CORE_EXPORT QgsGeometry
@note added in version 1.2 */
bool deletePart( int partNum );

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


private:
// Private variables
Expand Down Expand Up @@ -410,11 +415,6 @@ class CORE_EXPORT QgsGeometry
const GEOSCoordSequence* old_sequence,
GEOSCoordSequence** new_sequence );

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

/**Translates a single vertex by dx and dy.
@param ptr pointer to the wkb fragment containing the vertex
@param wkbPosition position in wkb array. Is increased automatically by the function
Expand Down

0 comments on commit 25264aa

Please sign in to comment.