Skip to content

Commit

Permalink
Expose segmentization parameters to QgsGeometry::convertToStraightSeg…
Browse files Browse the repository at this point in the history
…ment
  • Loading branch information
nyalldawson committed Mar 4, 2018
1 parent 871132e commit 6bd7600
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 4 deletions.
5 changes: 4 additions & 1 deletion python/core/geometry/qgsgeometry.sip.in
Expand Up @@ -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`
Expand Down
4 changes: 2 additions & 2 deletions src/core/geometry/qgsgeometry.cpp
Expand Up @@ -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 ) );
}

Expand Down
4 changes: 3 additions & 1 deletion src/core/geometry/qgsgeometry.h
Expand Up @@ -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
Expand Down

0 comments on commit 6bd7600

Please sign in to comment.