Skip to content

Commit 9518c90

Browse files
committedSep 26, 2017
Fix multipolygon allowing insertion of non polygon geometries
1 parent 6c328d5 commit 9518c90

File tree

3 files changed

+14
-14
lines changed

3 files changed

+14
-14
lines changed
 

‎python/core/geometry/qgsmultipolygon.sip

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -26,23 +26,18 @@ class QgsMultiPolygonV2: QgsMultiSurface
2626

2727
virtual QgsMultiPolygonV2 *clone() const /Factory/;
2828

29-
3029
virtual bool fromWkt( const QString &wkt );
3130

32-
3331
virtual QDomElement asGML2( QDomDocument &doc, int precision = 17, const QString &ns = "gml" ) const;
3432

3533
virtual QDomElement asGML3( QDomDocument &doc, int precision = 17, const QString &ns = "gml" ) const;
3634

3735
virtual QString asJSON( int precision = 17 ) const;
3836

39-
4037
virtual bool addGeometry( QgsAbstractGeometry *g /Transfer/ );
4138

42-
%Docstring
43-
Adds a geometry and takes ownership. Returns true in case of success
44-
:rtype: bool
45-
%End
39+
virtual bool insertGeometry( QgsAbstractGeometry *g /Transfer/, int index );
40+
4641

4742
virtual QgsMultiSurface *toCurveType() const /Factory/;
4843

‎src/core/geometry/qgsmultipolygon.cpp

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,17 @@ bool QgsMultiPolygonV2::addGeometry( QgsAbstractGeometry *g )
148148
return QgsGeometryCollection::addGeometry( g );
149149
}
150150

151+
bool QgsMultiPolygonV2::insertGeometry( QgsAbstractGeometry *g, int index )
152+
{
153+
if ( !g || !qgsgeometry_cast< QgsPolygonV2 * >( g ) )
154+
{
155+
delete g;
156+
return false;
157+
}
158+
159+
return QgsMultiSurface::insertGeometry( g, index );
160+
}
161+
151162
QgsMultiSurface *QgsMultiPolygonV2::toCurveType() const
152163
{
153164
QgsMultiSurface *multiSurface = new QgsMultiSurface();

‎src/core/geometry/qgsmultipolygon.h

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -32,18 +32,12 @@ class CORE_EXPORT QgsMultiPolygonV2: public QgsMultiSurface
3232
QString geometryType() const override;
3333
void clear() override;
3434
QgsMultiPolygonV2 *clone() const override SIP_FACTORY;
35-
3635
bool fromWkt( const QString &wkt ) override;
37-
38-
// inherited: int wkbSize() const;
39-
// inherited: unsigned char* asWkb( int& binarySize ) const;
40-
// inherited: QString asWkt( int precision = 17 ) const;
4136
QDomElement asGML2( QDomDocument &doc, int precision = 17, const QString &ns = "gml" ) const override;
4237
QDomElement asGML3( QDomDocument &doc, int precision = 17, const QString &ns = "gml" ) const override;
4338
QString asJSON( int precision = 17 ) const override;
44-
45-
//! Adds a geometry and takes ownership. Returns true in case of success
4639
bool addGeometry( QgsAbstractGeometry *g SIP_TRANSFER ) override;
40+
bool insertGeometry( QgsAbstractGeometry *g SIP_TRANSFER, int index ) override;
4741

4842
/** Returns the geometry converted to the more generic curve type QgsMultiSurface
4943
\returns the converted geometry. Caller takes ownership*/

0 commit comments

Comments
 (0)
Please sign in to comment.