Skip to content
Permalink
Browse files

Fix multi line string allowing insertion of non line geometries

  • Loading branch information
nyalldawson committed Sep 25, 2017
1 parent 6d95ba0 commit f5004ed7ef0d62ca6da05ef3b0bcfa0379bc2ade
@@ -20,29 +20,25 @@ class QgsMultiLineString: QgsMultiCurve
%End
public:
QgsMultiLineString();

virtual QString geometryType() const;

virtual QgsMultiLineString *clone() const /Factory/;


virtual void clear();

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 QgsMultiCurve *toCurveType() const /Factory/;

@@ -20,37 +20,29 @@ class QgsMultiPointV2: QgsGeometryCollection
%End
public:
QgsMultiPointV2();

virtual QString geometryType() const;

virtual QgsMultiPointV2 *clone() const /Factory/;

virtual QgsMultiPointV2 *toCurveType() const /Factory/;


virtual bool fromWkt( const QString &wkt );

virtual void clear();


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 int nCoordinates() 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 QgsAbstractGeometry *boundary() const /Factory/;


@@ -125,6 +125,14 @@ bool QgsMultiLineString::addGeometry( QgsAbstractGeometry *g )
return QgsGeometryCollection::addGeometry( g );
}

bool QgsMultiLineString::insertGeometry( QgsAbstractGeometry *g, int index )
{
if ( !g || QgsWkbTypes::flatType( g->wkbType() ) != QgsWkbTypes::LineString )
return false;

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

QgsMultiCurve *QgsMultiLineString::toCurveType() const
{
QgsMultiCurve *multiCurve = new QgsMultiCurve();
@@ -29,18 +29,16 @@ class CORE_EXPORT QgsMultiLineString: public QgsMultiCurve
{
public:
QgsMultiLineString();

QString geometryType() const override;
QgsMultiLineString *clone() const override SIP_FACTORY;

void clear() override;
bool fromWkt( const QString &wkt ) override;

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 QgsMultiCurve
\returns the converted geometry. Caller takes ownership*/
@@ -29,26 +29,18 @@ class CORE_EXPORT QgsMultiPointV2: public QgsGeometryCollection
{
public:
QgsMultiPointV2();

QString geometryType() const override;
QgsMultiPointV2 *clone() const override SIP_FACTORY;
QgsMultiPointV2 *toCurveType() const override SIP_FACTORY;

bool fromWkt( const QString &wkt ) override;
void clear() 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;

int nCoordinates() 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;

QgsAbstractGeometry *boundary() const override SIP_FACTORY;

#ifndef SIP_RUN

0 comments on commit f5004ed

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