Skip to content
Permalink
Browse files

Use the layer type when adding a part to a featureless entry. Fix #8459

  • Loading branch information
Laurent Defert
Laurent Defert committed Nov 4, 2013
1 parent c59cd92 commit 872e500679109faff99ed3b697f3ffe58c59df75
Showing with 12 additions and 4 deletions.
  1. +10 −2 src/core/qgsgeometry.cpp
  2. +1 −1 src/core/qgsgeometry.h
  3. +1 −1 src/core/qgsvectorlayereditutils.cpp
@@ -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 )
{
@@ -2977,6 +2980,11 @@ int QgsGeometry::addPart( const QList<QgsPoint> &points )
return 2;
}

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

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

0 comments on commit 872e500

Please sign in to comment.
You can’t perform that action at this time.