Skip to content

Commit

Permalink
Merge pull request #984 from BioEcoForests/master
Browse files Browse the repository at this point in the history
Use the layer type when adding a part to a featureless entry. Fix #8459
  • Loading branch information
mhugent committed Nov 5, 2013
2 parents e18dcbf + 872e500 commit e3e22be
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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 e3e22be

Please sign in to comment.