QgsPointXY: add a method distanceCompare using fuzzyDistancEqual

This commit is contained in:
Loïc Bartoletti 2023-12-14 20:34:31 +01:00
parent 6b1c38a482
commit 41ff06f813
3 changed files with 50 additions and 0 deletions

View File

@ -221,7 +221,23 @@ Compares this point with another point with a fuzzy tolerance
:return: ``True`` if points are equal within specified tolerance
.. seealso:: :py:func:`distanceCompare`
.. versionadded:: 2.9
%End
bool distanceCompare( const QgsPointXY &other, double epsilon = 4 * DBL_EPSILON ) const /HoldGIL/;
%Docstring
Compares this point with another point with a fuzzy tolerance using distance comparison
:param other: point to compare with
:param epsilon: maximum difference for coordinates between the points
:return: ``True`` if points are equal within specified tolerance
.. seealso:: :py:func:`compare`
.. versionadded:: 3.36
%End
bool operator==( const QgsPointXY &other ) /HoldGIL/;

View File

@ -221,7 +221,23 @@ Compares this point with another point with a fuzzy tolerance
:return: ``True`` if points are equal within specified tolerance
.. seealso:: :py:func:`distanceCompare`
.. versionadded:: 2.9
%End
bool distanceCompare( const QgsPointXY &other, double epsilon = 4 * DBL_EPSILON ) const /HoldGIL/;
%Docstring
Compares this point with another point with a fuzzy tolerance using distance comparison
:param other: point to compare with
:param epsilon: maximum difference for coordinates between the points
:return: ``True`` if points are equal within specified tolerance
.. seealso:: :py:func:`compare`
.. versionadded:: 3.36
%End
bool operator==( const QgsPointXY &other ) /HoldGIL/;

View File

@ -255,6 +255,9 @@ class CORE_EXPORT QgsPointXY
* \param other point to compare with
* \param epsilon maximum difference for coordinates between the points
* \returns TRUE if points are equal within specified tolerance
*
* \see distanceCompare
*
* \since QGIS 2.9
*/
bool compare( const QgsPointXY &other, double epsilon = 4 * std::numeric_limits<double>::epsilon() ) const SIP_HOLDGIL
@ -262,6 +265,21 @@ class CORE_EXPORT QgsPointXY
return QgsGeometryUtilsBase::fuzzyEqual( epsilon, mX, mY, other.x(), other.y() );
}
/**
* Compares this point with another point with a fuzzy tolerance using distance comparison
* \param other point to compare with
* \param epsilon maximum difference for coordinates between the points
* \returns TRUE if points are equal within specified tolerance
*
* \see compare
*
* \since QGIS 3.36
*/
bool distanceCompare( const QgsPointXY &other, double epsilon = 4 * std::numeric_limits<double>::epsilon() ) const SIP_HOLDGIL
{
return QgsGeometryUtilsBase::fuzzyDistanceEqual( epsilon, mX, mY, other.x(), other.y() );
}
//! equality operator
bool operator==( const QgsPointXY &other ) SIP_HOLDGIL
{