Skip to content

Commit 6bd7600

Browse files
committedMar 4, 2018
Expose segmentization parameters to QgsGeometry::convertToStraightSegment
1 parent 871132e commit 6bd7600

File tree

3 files changed

+9
-4
lines changed

3 files changed

+9
-4
lines changed
 

‎python/core/geometry/qgsgeometry.sip.in

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1423,10 +1423,13 @@ An empty geometry will be returned in the case of errors.
14231423
.. versionadded:: 3.0
14241424
%End
14251425

1426-
void convertToStraightSegment();
1426+
void convertToStraightSegment( double tolerance = M_PI / 180., QgsAbstractGeometry::SegmentationToleranceType toleranceType = QgsAbstractGeometry::MaximumAngle );
14271427
%Docstring
14281428
Converts the geometry to straight line segments, if it is a curved geometry type.
14291429

1430+
:param tolerance: segmentation tolerance
1431+
:param toleranceType: maximum segmentation angle or maximum difference between approximation and curve
1432+
14301433
.. versionadded:: 2.10
14311434

14321435
.. seealso:: :py:func:`requiresConversionToStraightSegments`

‎src/core/geometry/qgsgeometry.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2312,14 +2312,14 @@ QgsGeometry QgsGeometry::polygonize( const QVector<QgsGeometry> &geometryList )
23122312
return result;
23132313
}
23142314

2315-
void QgsGeometry::convertToStraightSegment()
2315+
void QgsGeometry::convertToStraightSegment( double tolerance, QgsAbstractGeometry::SegmentationToleranceType toleranceType )
23162316
{
23172317
if ( !d->geometry || !requiresConversionToStraightSegments() )
23182318
{
23192319
return;
23202320
}
23212321

2322-
std::unique_ptr< QgsAbstractGeometry > straightGeom( d->geometry->segmentize() );
2322+
std::unique_ptr< QgsAbstractGeometry > straightGeom( d->geometry->segmentize( tolerance, toleranceType ) );
23232323
reset( std::move( straightGeom ) );
23242324
}
23252325

‎src/core/geometry/qgsgeometry.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1413,10 +1413,12 @@ class CORE_EXPORT QgsGeometry
14131413

14141414
/**
14151415
* Converts the geometry to straight line segments, if it is a curved geometry type.
1416+
* \param tolerance segmentation tolerance
1417+
* \param toleranceType maximum segmentation angle or maximum difference between approximation and curve
14161418
* \since QGIS 2.10
14171419
* \see requiresConversionToStraightSegments
14181420
*/
1419-
void convertToStraightSegment();
1421+
void convertToStraightSegment( double tolerance = M_PI / 180., QgsAbstractGeometry::SegmentationToleranceType toleranceType = QgsAbstractGeometry::MaximumAngle );
14201422

14211423
/**
14221424
* Returns true if the geometry is a curved geometry type which requires conversion to

0 commit comments

Comments
 (0)
Please sign in to comment.