mirror of
https://github.com/qgis/QGIS.git
synced 2025-02-22 00:06:12 -05:00
Add method to directly convert QgsAbstractGeometry to QPolygonF lists
This overload avoids creating a QgsGeometry if we only have a QgsAbstractGeometry pointer object to convert
This commit is contained in:
parent
0cd5ccd42a
commit
60360f9b97
@ -814,6 +814,15 @@ how the geometry should be drawn for a symbol of the given ``type``,
|
||||
as a list of geometry parts and rings.
|
||||
|
||||
.. versionadded:: 3.40
|
||||
%End
|
||||
|
||||
static QList< QList< QPolygonF > > toQPolygonF( const QgsAbstractGeometry *geometry, Qgis::SymbolType type );
|
||||
%Docstring
|
||||
Converts a ``geometry`` to a set of QPolygonF objects representing
|
||||
how the geometry should be drawn for a symbol of the given ``type``,
|
||||
as a list of geometry parts and rings.
|
||||
|
||||
.. versionadded:: 3.42
|
||||
%End
|
||||
|
||||
static QPointF polygonCentroid( const QPolygonF &points );
|
||||
|
@ -814,6 +814,15 @@ how the geometry should be drawn for a symbol of the given ``type``,
|
||||
as a list of geometry parts and rings.
|
||||
|
||||
.. versionadded:: 3.40
|
||||
%End
|
||||
|
||||
static QList< QList< QPolygonF > > toQPolygonF( const QgsAbstractGeometry *geometry, Qgis::SymbolType type );
|
||||
%Docstring
|
||||
Converts a ``geometry`` to a set of QPolygonF objects representing
|
||||
how the geometry should be drawn for a symbol of the given ``type``,
|
||||
as a list of geometry parts and rings.
|
||||
|
||||
.. versionadded:: 3.42
|
||||
%End
|
||||
|
||||
static QPointF polygonCentroid( const QPolygonF &points );
|
||||
|
@ -4498,15 +4498,23 @@ QPolygonF curveToPolygonF( const QgsCurve *curve )
|
||||
|
||||
QList<QList<QPolygonF> > QgsSymbolLayerUtils::toQPolygonF( const QgsGeometry &geometry, Qgis::SymbolType type )
|
||||
{
|
||||
return toQPolygonF( geometry.constGet(), type );
|
||||
}
|
||||
|
||||
QList<QList<QPolygonF> > QgsSymbolLayerUtils::toQPolygonF( const QgsAbstractGeometry *geometry, Qgis::SymbolType type )
|
||||
{
|
||||
if ( !geometry )
|
||||
return {};
|
||||
|
||||
switch ( type )
|
||||
{
|
||||
case Qgis::SymbolType::Marker:
|
||||
{
|
||||
QPolygonF points;
|
||||
|
||||
if ( QgsWkbTypes::flatType( geometry.wkbType() ) == Qgis::WkbType::MultiPoint )
|
||||
if ( QgsWkbTypes::flatType( geometry->wkbType() ) == Qgis::WkbType::MultiPoint )
|
||||
{
|
||||
for ( auto it = geometry.vertices_begin(); it != geometry.vertices_end(); ++it )
|
||||
for ( auto it = geometry->vertices_begin(); it != geometry->vertices_end(); ++it )
|
||||
points << QPointF( ( *it ).x(), ( *it ).y() );
|
||||
}
|
||||
else
|
||||
@ -4519,9 +4527,9 @@ QList<QList<QPolygonF> > QgsSymbolLayerUtils::toQPolygonF( const QgsGeometry &ge
|
||||
case Qgis::SymbolType::Line:
|
||||
{
|
||||
QList< QList<QPolygonF> > res;
|
||||
if ( QgsWkbTypes::geometryType( geometry.wkbType() ) == Qgis::GeometryType::Line )
|
||||
if ( QgsWkbTypes::geometryType( geometry->wkbType() ) == Qgis::GeometryType::Line )
|
||||
{
|
||||
for ( auto it = geometry.const_parts_begin(); it != geometry.const_parts_end(); ++it )
|
||||
for ( auto it = geometry->const_parts_begin(); it != geometry->const_parts_end(); ++it )
|
||||
{
|
||||
res << ( QList< QPolygonF >() << curveToPolygonF( qgsgeometry_cast< const QgsCurve * >( *it ) ) );
|
||||
}
|
||||
@ -4533,7 +4541,7 @@ QList<QList<QPolygonF> > QgsSymbolLayerUtils::toQPolygonF( const QgsGeometry &ge
|
||||
{
|
||||
QList< QList<QPolygonF> > res;
|
||||
|
||||
for ( auto it = geometry.const_parts_begin(); it != geometry.const_parts_end(); ++it )
|
||||
for ( auto it = geometry->const_parts_begin(); it != geometry->const_parts_end(); ++it )
|
||||
{
|
||||
QList<QPolygonF> thisPart;
|
||||
const QgsCurvePolygon *surface = qgsgeometry_cast< const QgsCurvePolygon * >( *it );
|
||||
|
@ -763,6 +763,15 @@ class CORE_EXPORT QgsSymbolLayerUtils
|
||||
*/
|
||||
static QList< QList< QPolygonF > > toQPolygonF( const QgsGeometry &geometry, Qgis::SymbolType type );
|
||||
|
||||
/**
|
||||
* Converts a \a geometry to a set of QPolygonF objects representing
|
||||
* how the geometry should be drawn for a symbol of the given \a type,
|
||||
* as a list of geometry parts and rings.
|
||||
*
|
||||
* \since QGIS 3.42
|
||||
*/
|
||||
static QList< QList< QPolygonF > > toQPolygonF( const QgsAbstractGeometry *geometry, Qgis::SymbolType type );
|
||||
|
||||
//! Calculate the centroid point of a QPolygonF
|
||||
static QPointF polygonCentroid( const QPolygonF &points );
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user