Skip to content
Permalink
Browse files

Implement segmentize method in QgsGeometryCollection2 instead of subc…

…lasses
  • Loading branch information
mhugent committed Jun 9, 2015
1 parent 06b4725 commit 3b5df98332ded19e8d44ff5bce8c5304513b0f20
@@ -476,3 +476,20 @@ bool QgsGeometryCollectionV2::hasCurvedSegments() const
}
return false;
}

QgsAbstractGeometryV2* QgsGeometryCollectionV2::segmentize() const
{
QgsAbstractGeometryV2* geom = QgsGeometryImport::geomFromWkbType( mWkbType );
QgsGeometryCollectionV2* geomCollection = dynamic_cast<QgsGeometryCollectionV2*>( geom );
if ( !geomCollection )
{
delete geom; return clone();
}

QVector< QgsAbstractGeometryV2* >::const_iterator geomIt = mGeometries.constBegin();
for ( ; geomIt != mGeometries.constEnd(); ++geomIt )
{
geomCollection->addGeometry(( *geomIt )->segmentize() );
}
return geomCollection;
}
@@ -92,6 +92,9 @@ class CORE_EXPORT QgsGeometryCollectionV2: public QgsAbstractGeometryV2

bool hasCurvedSegments() const override;

/**Returns a geometry without curves. Caller takes ownership*/
QgsAbstractGeometryV2* segmentize() const override;

protected:
QVector< QgsAbstractGeometryV2* > mGeometries;

@@ -106,14 +106,3 @@ bool QgsMultiCurveV2::addGeometry( QgsAbstractGeometryV2* g )
setZMTypeFromSubGeometry( g, QgsWKBTypes::MultiCurve );
return QgsGeometryCollectionV2::addGeometry( g );
}

QgsAbstractGeometryV2* QgsMultiCurveV2::segmentize() const
{
QgsMultiCurveV2* c = new QgsMultiCurveV2();
QVector< QgsAbstractGeometryV2* >::const_iterator geomIt = mGeometries.constBegin();
for ( ; geomIt != mGeometries.constEnd(); ++geomIt )
{
c->addGeometry(( *geomIt )->segmentize() );
}
return c;
}
@@ -36,8 +36,6 @@ class CORE_EXPORT QgsMultiCurveV2: public QgsGeometryCollectionV2

/**Adds a geometry and takes ownership. Returns true in case of success*/
virtual bool addGeometry( QgsAbstractGeometryV2* g ) override;
/**Returns a geometry without curves. Caller takes ownership*/
QgsAbstractGeometryV2* segmentize() const override;
};

#endif // QGSMULTICURVEV2_H
@@ -126,14 +126,3 @@ bool QgsMultiSurfaceV2::addGeometry( QgsAbstractGeometryV2* g )
setZMTypeFromSubGeometry( g, QgsWKBTypes::MultiSurface );
return QgsGeometryCollectionV2::addGeometry( g );
}

QgsAbstractGeometryV2* QgsMultiSurfaceV2::segmentize() const
{
QgsMultiSurfaceV2* c = new QgsMultiSurfaceV2();
QVector< QgsAbstractGeometryV2* >::const_iterator geomIt = mGeometries.constBegin();
for ( ; geomIt != mGeometries.constEnd(); ++geomIt )
{
c->addGeometry(( *geomIt )->segmentize() );
}
return c;
}
@@ -36,9 +36,6 @@ class CORE_EXPORT QgsMultiSurfaceV2: public QgsGeometryCollectionV2

/**Adds a geometry and takes ownership. Returns true in case of success*/
virtual bool addGeometry( QgsAbstractGeometryV2* g ) override;

/**Returns a geometry without curves. Caller takes ownership*/
QgsAbstractGeometryV2* segmentize() const override;
};

#endif // QGSMULTISURFACEV2_H

0 comments on commit 3b5df98

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