Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Fix multicurve allowing insertion of non curve geometries
  • Loading branch information
nyalldawson committed Sep 26, 2017
1 parent 6505104 commit ed90bf4
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 0 deletions.
2 changes: 2 additions & 0 deletions python/core/geometry/qgsmulticurve.sip
Expand Up @@ -38,6 +38,8 @@ class QgsMultiCurve: QgsGeometryCollection

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

virtual bool insertGeometry( QgsAbstractGeometry *g /Transfer/, int index );


QgsMultiCurve *reversed() const /Factory/;
%Docstring
Expand Down
11 changes: 11 additions & 0 deletions src/core/geometry/qgsmulticurve.cpp
Expand Up @@ -142,6 +142,17 @@ bool QgsMultiCurve::addGeometry( QgsAbstractGeometry *g )
return QgsGeometryCollection::addGeometry( g );
}

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

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

QgsMultiCurve *QgsMultiCurve::reversed() const
{
QgsMultiCurve *reversedMultiCurve = new QgsMultiCurve();
Expand Down
1 change: 1 addition & 0 deletions src/core/geometry/qgsmulticurve.h
Expand Up @@ -38,6 +38,7 @@ class CORE_EXPORT QgsMultiCurve: public QgsGeometryCollection
QDomElement asGML3( QDomDocument &doc, int precision = 17, const QString &ns = "gml" ) const override;
QString asJSON( int precision = 17 ) const override;
bool addGeometry( QgsAbstractGeometry *g SIP_TRANSFER ) override;
bool insertGeometry( QgsAbstractGeometry *g SIP_TRANSFER, int index ) override;

/** Returns a copy of the multi curve, where each component curve has had its line direction reversed.
* \since QGIS 2.14
Expand Down

0 comments on commit ed90bf4

Please sign in to comment.