mirror of
https://github.com/qgis/QGIS.git
synced 2025-03-12 00:02:25 -04:00
Implement segmentize method in QgsGeometryCollection2 instead of subclasses
This commit is contained in:
parent
06b472550d
commit
3b5df98332
@ -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
|
||||
|
Loading…
x
Reference in New Issue
Block a user