Skip to content

Commit

Permalink
Add "convert to curves" algorithm followup
Browse files Browse the repository at this point in the history
  • Loading branch information
olivierdalang committed May 12, 2020
1 parent 9939142 commit ab423ca
Show file tree
Hide file tree
Showing 6 changed files with 38 additions and 7 deletions.
15 changes: 15 additions & 0 deletions python/core/auto_generated/geometry/qgsgeometry.sip.in
Expand Up @@ -1229,6 +1229,21 @@ Curved geometry types are automatically segmentized by this routine.
.. seealso:: :py:func:`densifyByCount`

.. versionadded:: 3.0
%End

QgsGeometry convertToCurves( double distanceTolerance = 1e-8, double angleTolerance = 1e-8 ) const;
%Docstring
Attempts to convert a non-curved geometry into a curved geometry type (e.g.
LineString to CompoundCurve, Polygon to CurvePolygon).

The ``distanceTolerance`` specifies the maximum deviation allowed between the original location
of vertices and where they would fall on the candidate curved geometry.

This method only consider a segments as suitable for replacing with an arc if the points are all
regularly spaced on the candidate arc. The ``pointSpacingAngleTolerance`` parameter specifies the maximum
angular deviation (in radians) allowed when testing for regular point spacing.

.. versionadded:: 3.14
%End

QgsGeometry centroid() const;
Expand Down
18 changes: 17 additions & 1 deletion python/core/auto_generated/geometry/qgsgeometryutils.sip.in
Expand Up @@ -242,7 +242,7 @@ Project the point on a segment

static int leftOfLine( const double x, const double y, const double x1, const double y1, const double x2, const double y2 );
%Docstring
Returns a value < 0 if the point (``x``, ``y``) is left of the line from (``x1``, ``y1``) -> ( ``x2``, ``y2``).
Returns a value < 0 if the point (``x``, ``y``) is left of the line from (``x1``, ``y1``) -> (``x2``, ``y2``).
A positive return value indicates the point is to the right of the line.

If the return value is 0, then the test was unsuccessful (e.g. due to testing a point exactly
Expand Down Expand Up @@ -352,6 +352,22 @@ Calculates the direction angle of a circle tangent (clockwise from north in radi
Convert circular arc defined by p1, p2, p3 (p1/p3 being start resp. end point, p2 lies on the arc) into a sequence of points.

.. versionadded:: 3.0
%End

static bool pointContinuesArc( const QgsPoint &a1, const QgsPoint &a2, const QgsPoint &a3, const QgsPoint &b, double distanceTolerance,
double pointSpacingAngleTolerance );
%Docstring
Returns true if point ``b`` is on the arc formed by points ``a1``, ``a2``, and ``a3``, but not within
that arc portion already described by ``a1``, ``a2`` and ``a3``.

The ``distanceTolerance`` specifies the maximum deviation allowed between the original location
of point \b and where it would fall on the candidate arc.

This method only consider a segments as continuing an arc if the points are all regularly spaced
on the candidate arc. The ``pointSpacingAngleTolerance`` parameter specifies the maximum
angular deviation (in radians) allowed when testing for regular point spacing.

.. versionadded:: 3.14
%End

static int segmentSide( const QgsPoint &pt1, const QgsPoint &pt3, const QgsPoint &pt2 );
Expand Down
6 changes: 3 additions & 3 deletions src/analysis/processing/qgsalgorithmconverttocurves.h
Expand Up @@ -15,8 +15,8 @@
* *
***************************************************************************/

#ifndef QGSALGORITHMSEGMENTIZE_H
#define QGSALGORITHMSEGMENTIZE_H
#ifndef QGSALGORITHMCONVERTTOCURVES_H
#define QGSALGORITHMCONVERTTOCURVES_H

#define SIP_NO_FILE

Expand Down Expand Up @@ -65,6 +65,6 @@ class QgsConvertToCurvesAlgorithm : public QgsProcessingFeatureBasedAlgorithm

///@endcond PRIVATE

#endif // QGSALGORITHMSEGMENTIZE_H
#endif // QGSALGORITHMCONVERTTOCURVES_H


2 changes: 1 addition & 1 deletion src/core/geometry/qgsgeometry.h
Expand Up @@ -1254,7 +1254,7 @@ class CORE_EXPORT QgsGeometry
* regularly spaced on the candidate arc. The \a pointSpacingAngleTolerance parameter specifies the maximum
* angular deviation (in radians) allowed when testing for regular point spacing.
*
* \since QGIS 3.2
* \since QGIS 3.14
*/
QgsGeometry convertToCurves( double distanceTolerance = 1e-8, double angleTolerance = 1e-8 ) const;

Expand Down
2 changes: 1 addition & 1 deletion src/core/geometry/qgsgeometryutils.h
Expand Up @@ -383,7 +383,7 @@ class CORE_EXPORT QgsGeometryUtils
* on the candidate arc. The \a pointSpacingAngleTolerance parameter specifies the maximum
* angular deviation (in radians) allowed when testing for regular point spacing.
*
* \since QGIS 3.2
* \since QGIS 3.14
*/
static bool pointContinuesArc( const QgsPoint &a1, const QgsPoint &a2, const QgsPoint &a3, const QgsPoint &b, double distanceTolerance,
double pointSpacingAngleTolerance );
Expand Down
2 changes: 1 addition & 1 deletion src/core/geometry/qgsinternalgeometryengine.h
Expand Up @@ -177,7 +177,7 @@ class QgsInternalGeometryEngine
* regularly spaced on the candidate arc. The \a pointSpacingAngleTolerance parameter specifies the maximum
* angular deviation (in radians) allowed when testing for regular point spacing.
*
* \since QGIS 3.2
* \since QGIS 3.14
*/
QgsGeometry convertToCurves( double distanceTolerance, double angleTolerance ) const;

Expand Down

0 comments on commit ab423ca

Please sign in to comment.