Fix for merge of adjacent multipolygons, ticket #2188

git-svn-id: http://svn.osgeo.org/qgis/trunk@12327 c8812cc2-4d05-0410-92ff-de0c093fc19c
This commit is contained in:
mhugent 2009-12-03 16:26:57 +00:00
parent 032c2cd05d
commit 25264aa14e
3 changed files with 19 additions and 5 deletions

View File

@ -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

View File

@ -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;

View File

@ -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
@ -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