Navigation Menu

Skip to content

Commit

Permalink
Use the layer type when adding a part to a featureless entry. Fix #8459
Browse files Browse the repository at this point in the history
  • Loading branch information
Laurent Defert committed Nov 4, 2013
1 parent c59cd92 commit 872e500
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 4 deletions.
12 changes: 10 additions & 2 deletions src/core/qgsgeometry.cpp
Expand Up @@ -2890,9 +2890,12 @@ int QgsGeometry::addRing( const QList<QgsPoint>& ring )
return 0;
}

int QgsGeometry::addPart( const QList<QgsPoint> &points )
int QgsGeometry::addPart( const QList<QgsPoint> &points, QGis::GeometryType geomType )
{
QGis::GeometryType geomType = type();
if ( geomType == QGis::UnknownGeometry )
{
geomType = type();
}

switch ( geomType )
{
Expand Down Expand Up @@ -2977,6 +2980,11 @@ int QgsGeometry::addPart( const QList<QgsPoint> &points )
return 2;
}

if ( type() == QGis::UnknownGeometry )
{
fromGeos( newPart );
return 0;
}
return addPart( newPart );
}

Expand Down
2 changes: 1 addition & 1 deletion src/core/qgsgeometry.h
Expand Up @@ -265,7 +265,7 @@ class CORE_EXPORT QgsGeometry
/**Adds a new island polygon to a multipolygon feature
@return 0 in case of success, 1 if not a multipolygon, 2 if ring is not a valid geometry, 3 if new polygon ring
not disjoint with existing polygons of the feature*/
int addPart( const QList<QgsPoint> &points );
int addPart( const QList<QgsPoint> &points, QGis::GeometryType geomType = QGis::UnknownGeometry );

/**Adds a new island polygon to a multipolygon feature
@return 0 in case of success, 1 if not a multipolygon, 2 if ring is not a valid geometry, 3 if new polygon ring
Expand Down
2 changes: 1 addition & 1 deletion src/core/qgsvectorlayereditutils.cpp
Expand Up @@ -130,7 +130,7 @@ int QgsVectorLayerEditUtils::addPart( const QList<QgsPoint> &points, QgsFeatureI
geometry = *f.geometry();
}

int errorCode = geometry.addPart( points );
int errorCode = geometry.addPart( points, L->geometryType() );
if ( errorCode == 0 )
{
L->editBuffer()->changeGeometry( featureId, &geometry );
Expand Down

0 comments on commit 872e500

Please sign in to comment.