mirror of
https://github.com/qgis/QGIS.git
synced 2025-04-15 00:04:00 -04:00
Re-add QgsGeometryEngine::combine taking a list of QgsAbstractGeometries
This commit is contained in:
parent
efc00c38a1
commit
fde740a3ba
@ -73,6 +73,14 @@ class QgsGeometryEngine
|
||||
%Docstring
|
||||
Calculate the combination of this and ``geom``.
|
||||
|
||||
.. versionadded:: 3.0
|
||||
:rtype: QgsAbstractGeometry
|
||||
%End
|
||||
|
||||
virtual QgsAbstractGeometry *combine( const QList<QgsAbstractGeometry *> &geomList, QString *errorMsg ) const = 0 /Factory/;
|
||||
%Docstring
|
||||
Calculate the combination of this and ``geometries``.
|
||||
|
||||
.. versionadded:: 3.0
|
||||
:rtype: QgsAbstractGeometry
|
||||
%End
|
||||
|
@ -91,6 +91,13 @@ class CORE_EXPORT QgsGeometryEngine
|
||||
*/
|
||||
virtual QgsAbstractGeometry *combine( const QgsAbstractGeometry *geom, QString *errorMsg = nullptr ) const = 0 SIP_FACTORY;
|
||||
|
||||
/**
|
||||
* Calculate the combination of this and \a geometries.
|
||||
*
|
||||
* \since QGIS 3.0 \a geom is a pointer
|
||||
*/
|
||||
virtual QgsAbstractGeometry *combine( const QList<QgsAbstractGeometry *> &geomList, QString *errorMsg ) const = 0 SIP_FACTORY;
|
||||
|
||||
/**
|
||||
* Calculate the combination of this and \a geometries.
|
||||
*
|
||||
|
@ -308,6 +308,30 @@ QgsAbstractGeometry *QgsGeos::combine( const QgsAbstractGeometry *geom, QString
|
||||
return overlay( geom, OverlayUnion, errorMsg ).release();
|
||||
}
|
||||
|
||||
QgsAbstractGeometry *QgsGeos::combine( const QList<QgsAbstractGeometry *> &geomList, QString *errorMsg ) const
|
||||
{
|
||||
QVector< GEOSGeometry * > geosGeometries;
|
||||
geosGeometries.reserve( geomList.size() );
|
||||
for ( const QgsAbstractGeometry *g : geomList )
|
||||
{
|
||||
if ( !g )
|
||||
continue;
|
||||
|
||||
geosGeometries << asGeos( g, mPrecision ).release();
|
||||
}
|
||||
|
||||
geos::unique_ptr geomUnion;
|
||||
try
|
||||
{
|
||||
geos::unique_ptr geomCollection = createGeosCollection( GEOS_GEOMETRYCOLLECTION, geosGeometries );
|
||||
geomUnion.reset( GEOSUnaryUnion_r( geosinit.ctxt, geomCollection.get() ) );
|
||||
}
|
||||
CATCH_GEOS_WITH_ERRMSG( nullptr )
|
||||
|
||||
std::unique_ptr< QgsAbstractGeometry > result = fromGeos( geomUnion.get() );
|
||||
return result.release();
|
||||
}
|
||||
|
||||
QgsAbstractGeometry *QgsGeos::combine( const QList<QgsGeometry> &geomList, QString *errorMsg ) const
|
||||
{
|
||||
QVector< GEOSGeometry * > geosGeometries;
|
||||
|
@ -135,6 +135,7 @@ class CORE_EXPORT QgsGeos: public QgsGeometryEngine
|
||||
std::unique_ptr< QgsAbstractGeometry > subdivide( int maxNodes, QString *errorMsg = nullptr ) const;
|
||||
|
||||
QgsAbstractGeometry *combine( const QgsAbstractGeometry *geom, QString *errorMsg = nullptr ) const override;
|
||||
QgsAbstractGeometry *combine( const QList<QgsAbstractGeometry *> &geomList, QString *errorMsg ) const override;
|
||||
QgsAbstractGeometry *combine( const QList< QgsGeometry > &, QString *errorMsg = nullptr ) const override;
|
||||
QgsAbstractGeometry *symDifference( const QgsAbstractGeometry *geom, QString *errorMsg = nullptr ) const override;
|
||||
QgsAbstractGeometry *buffer( double distance, int segments, QString *errorMsg = nullptr ) const override;
|
||||
|
Loading…
x
Reference in New Issue
Block a user