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

This commit is contained in:
Laurent Defert 2013-11-04 12:13:53 +01:00
parent c59cd92c12
commit 872e500679
3 changed files with 12 additions and 4 deletions

View File

@ -2890,9 +2890,12 @@ int QgsGeometry::addRing( const QList<QgsPoint>& ring )
return 0; 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 ) switch ( geomType )
{ {
@ -2977,6 +2980,11 @@ int QgsGeometry::addPart( const QList<QgsPoint> &points )
return 2; return 2;
} }
if ( type() == QGis::UnknownGeometry )
{
fromGeos( newPart );
return 0;
}
return addPart( newPart ); return addPart( newPart );
} }

View File

@ -265,7 +265,7 @@ class CORE_EXPORT QgsGeometry
/**Adds a new island polygon to a multipolygon feature /**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 @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*/ 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 /**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 @return 0 in case of success, 1 if not a multipolygon, 2 if ring is not a valid geometry, 3 if new polygon ring

View File

@ -130,7 +130,7 @@ int QgsVectorLayerEditUtils::addPart( const QList<QgsPoint> &points, QgsFeatureI
geometry = *f.geometry(); geometry = *f.geometry();
} }
int errorCode = geometry.addPart( points ); int errorCode = geometry.addPart( points, L->geometryType() );
if ( errorCode == 0 ) if ( errorCode == 0 )
{ {
L->editBuffer()->changeGeometry( featureId, &geometry ); L->editBuffer()->changeGeometry( featureId, &geometry );