Skip to content
Permalink
Browse files

Fix multipolygon allowing insertion of non polygon geometries

  • Loading branch information
nyalldawson committed Sep 26, 2017
1 parent 6c328d5 commit 9518c90a8b00c651f4f9a81171ed6c20eae5336f
@@ -26,23 +26,18 @@ class QgsMultiPolygonV2: QgsMultiSurface

virtual QgsMultiPolygonV2 *clone() const /Factory/;


virtual bool fromWkt( const QString &wkt );


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

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

virtual QString asJSON( int precision = 17 ) const;


virtual bool addGeometry( QgsAbstractGeometry *g /Transfer/ );

%Docstring
Adds a geometry and takes ownership. Returns true in case of success
:rtype: bool
%End
virtual bool insertGeometry( QgsAbstractGeometry *g /Transfer/, int index );


virtual QgsMultiSurface *toCurveType() const /Factory/;

@@ -148,6 +148,17 @@ bool QgsMultiPolygonV2::addGeometry( QgsAbstractGeometry *g )
return QgsGeometryCollection::addGeometry( g );
}

bool QgsMultiPolygonV2::insertGeometry( QgsAbstractGeometry *g, int index )
{
if ( !g || !qgsgeometry_cast< QgsPolygonV2 * >( g ) )
{
delete g;
return false;
}

return QgsMultiSurface::insertGeometry( g, index );
}

QgsMultiSurface *QgsMultiPolygonV2::toCurveType() const
{
QgsMultiSurface *multiSurface = new QgsMultiSurface();
@@ -32,18 +32,12 @@ class CORE_EXPORT QgsMultiPolygonV2: public QgsMultiSurface
QString geometryType() const override;
void clear() override;
QgsMultiPolygonV2 *clone() const override SIP_FACTORY;

bool fromWkt( const QString &wkt ) override;

// inherited: int wkbSize() const;
// inherited: unsigned char* asWkb( int& binarySize ) const;
// inherited: QString asWkt( int precision = 17 ) const;
QDomElement asGML2( QDomDocument &doc, int precision = 17, const QString &ns = "gml" ) const override;
QDomElement asGML3( QDomDocument &doc, int precision = 17, const QString &ns = "gml" ) const override;
QString asJSON( int precision = 17 ) const override;

//! Adds a geometry and takes ownership. Returns true in case of success
bool addGeometry( QgsAbstractGeometry *g SIP_TRANSFER ) override;
bool insertGeometry( QgsAbstractGeometry *g SIP_TRANSFER, int index ) override;

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

0 comments on commit 9518c90

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