Expose segmentization parameters to QgsGeometry::convertToStraightSegment

This commit is contained in:
Nyall Dawson 2018-03-04 12:10:27 +10:00
parent 871132eae6
commit 6bd7600aa3
3 changed files with 9 additions and 4 deletions

View File

@ -1423,10 +1423,13 @@ An empty geometry will be returned in the case of errors.
.. versionadded:: 3.0
%End
void convertToStraightSegment();
void convertToStraightSegment( double tolerance = M_PI / 180., QgsAbstractGeometry::SegmentationToleranceType toleranceType = QgsAbstractGeometry::MaximumAngle );
%Docstring
Converts the geometry to straight line segments, if it is a curved geometry type.
:param tolerance: segmentation tolerance
:param toleranceType: maximum segmentation angle or maximum difference between approximation and curve
.. versionadded:: 2.10
.. seealso:: :py:func:`requiresConversionToStraightSegments`

View File

@ -2312,14 +2312,14 @@ QgsGeometry QgsGeometry::polygonize( const QVector<QgsGeometry> &geometryList )
return result;
}
void QgsGeometry::convertToStraightSegment()
void QgsGeometry::convertToStraightSegment( double tolerance, QgsAbstractGeometry::SegmentationToleranceType toleranceType )
{
if ( !d->geometry || !requiresConversionToStraightSegments() )
{
return;
}
std::unique_ptr< QgsAbstractGeometry > straightGeom( d->geometry->segmentize() );
std::unique_ptr< QgsAbstractGeometry > straightGeom( d->geometry->segmentize( tolerance, toleranceType ) );
reset( std::move( straightGeom ) );
}

View File

@ -1413,10 +1413,12 @@ class CORE_EXPORT QgsGeometry
/**
* Converts the geometry to straight line segments, if it is a curved geometry type.
* \param tolerance segmentation tolerance
* \param toleranceType maximum segmentation angle or maximum difference between approximation and curve
* \since QGIS 2.10
* \see requiresConversionToStraightSegments
*/
void convertToStraightSegment();
void convertToStraightSegment( double tolerance = M_PI / 180., QgsAbstractGeometry::SegmentationToleranceType toleranceType = QgsAbstractGeometry::MaximumAngle );
/**
* Returns true if the geometry is a curved geometry type which requires conversion to