From 03d8565e2aa6351a34d3c06cb1b8a37b1596de8a Mon Sep 17 00:00:00 2001 From: lbartoletti Date: Wed, 13 Dec 2017 14:03:55 +0100 Subject: [PATCH] - Update api_break.dox - rename isIntersect to isIntersection - rename inter to intersectionPoint --- doc/api_break.dox | 3 ++- python/core/geometry/qgsgeometryutils.sip | 6 +++--- src/core/geometry/qgsgeometryutils.cpp | 24 +++++++++++------------ src/core/geometry/qgsgeometryutils.h | 6 +++--- 4 files changed, 20 insertions(+), 19 deletions(-) diff --git a/doc/api_break.dox b/doc/api_break.dox index 803e7b0950a..6d52cd7ee4d 100644 --- a/doc/api_break.dox +++ b/doc/api_break.dox @@ -1453,7 +1453,8 @@ QgsGeometryUtils {#qgis_api_break_3_0_QgsGeometryUtils} - componentType enum has been renamed to ComponentType and its members were CamelCased too: VERTEX, RING and PART become Vertex, Ring and Part, respectively. - adjacentVertices was removed - use QgsAbstractGeometry.adjacentVertices instead. - +- segmentIntersection takes an optional boolean parameter "acceptImproperIntersection" returning true even if the intersection is improper. +Takes another boolean argument "isIntersection" returning if there is an intersection or not. The "inter" parameter has been renamed "intersectionPoint". QgsGPSConnectionRegistry {#qgis_api_break_3_0_QgsGPSConnectionRegistry} ------------------------ diff --git a/python/core/geometry/qgsgeometryutils.sip b/python/core/geometry/qgsgeometryutils.sip index cc5f29502ab..089b28d1a6b 100644 --- a/python/core/geometry/qgsgeometryutils.sip +++ b/python/core/geometry/qgsgeometryutils.sip @@ -98,15 +98,15 @@ class QgsGeometryUtils :rtype: bool %End - static bool segmentIntersection( const QgsPoint &p1, const QgsPoint &p2, const QgsPoint &q1, const QgsPoint &q2, QgsPoint &inter /Out/, bool &isIntersect /Out/, double tolerance, bool acceptImproperIntersection = false ); + static bool segmentIntersection( const QgsPoint &p1, const QgsPoint &p2, const QgsPoint &q1, const QgsPoint &q2, QgsPoint &intersectionPoint /Out/, bool &isIntersection /Out/, double tolerance, bool acceptImproperIntersection = false ); %Docstring Compute the intersection between two segments \param p1 First segment start point \param p2 First segment end point \param q1 Second segment start point \param q2 Second segment end point - \param inter Output parameter, the intersection point - \param isIntersect Output parameter, return true if an intersection is found + \param intersectionPoint Output parameter, the intersection point + \param isIntersection Output parameter, return true if an intersection is found \param tolerance The tolerance to use \param acceptImproperIntersection By default, this method returns true only if segments have proper intersection. If set true, returns also true if segments have improper intersection (end of one segment on other segment ; continuous segments). :return: Whether the segments intersect diff --git a/src/core/geometry/qgsgeometryutils.cpp b/src/core/geometry/qgsgeometryutils.cpp index fcd96b2d001..539294ed0e9 100644 --- a/src/core/geometry/qgsgeometryutils.cpp +++ b/src/core/geometry/qgsgeometryutils.cpp @@ -251,9 +251,9 @@ bool QgsGeometryUtils::lineIntersection( const QgsPoint &p1, QgsVector v, const return true; } -bool QgsGeometryUtils::segmentIntersection( const QgsPoint &p1, const QgsPoint &p2, const QgsPoint &q1, const QgsPoint &q2, QgsPoint &inter, bool &isIntersect, double tolerance, bool acceptImproperIntersection ) +bool QgsGeometryUtils::segmentIntersection( const QgsPoint &p1, const QgsPoint &p2, const QgsPoint &q1, const QgsPoint &q2, QgsPoint &intersectionPoint, bool &isIntersection, double tolerance, bool acceptImproperIntersection ) { - isIntersect = false; + isIntersection = false; QgsVector v( p2.x() - p1.x(), p2.y() - p1.y() ); QgsVector w( q2.x() - q1.x(), q2.y() - q1.y() ); @@ -267,53 +267,53 @@ bool QgsGeometryUtils::segmentIntersection( const QgsPoint &p1, const QgsPoint & v = v / vl; w = w / wl; - if ( !QgsGeometryUtils::lineIntersection( p1, v, q1, w, inter ) ) + if ( !QgsGeometryUtils::lineIntersection( p1, v, q1, w, intersectionPoint ) ) { return false; } - isIntersect = true; + isIntersection = true; if ( acceptImproperIntersection ) { if ( ( p1 == q1 ) || ( p1 == q2 ) ) { - inter = p1; + intersectionPoint = p1; return true; } else if ( ( p2 == q1 ) || ( p2 == q2 ) ) { - inter == p2; + intersectionPoint == p2; return true; } double x, y; if ( qgsDoubleNear( QgsGeometryUtils::sqrDistToLine( p1.x(), p1.y(), q1.x(), q1.y(), q2.x(), q2.y(), x, y, tolerance ), 0.0, tolerance ) ) { - inter == p1; + intersectionPoint == p1; return true; } else if ( qgsDoubleNear( QgsGeometryUtils::sqrDistToLine( p2.x(), p2.y(), q1.x(), q1.y(), q2.x(), q2.y(), x, y, tolerance ), 0.0, tolerance ) ) { - inter == p2; + intersectionPoint == p2; return true; } else if ( qgsDoubleNear( QgsGeometryUtils::sqrDistToLine( q1.x(), q1.y(), p1.x(), p1.y(), p2.x(), p2.y(), x, y, tolerance ), 0.0, tolerance ) ) { - inter == q1; + intersectionPoint == q1; return true; } else if ( qgsDoubleNear( QgsGeometryUtils::sqrDistToLine( q2.x(), q2.y(), p1.x(), p1.y(), p2.x(), p2.y(), x, y, tolerance ), 0.0, tolerance ) ) { - inter == q2; + intersectionPoint == q2; return true; } } - double lambdav = QgsVector( inter.x() - p1.x(), inter.y() - p1.y() ) * v; + double lambdav = QgsVector( intersectionPoint.x() - p1.x(), intersectionPoint.y() - p1.y() ) * v; if ( lambdav < 0. + tolerance || lambdav > vl - tolerance ) return false; - double lambdaw = QgsVector( inter.x() - q1.x(), inter.y() - q1.y() ) * w; + double lambdaw = QgsVector( intersectionPoint.x() - q1.x(), intersectionPoint.y() - q1.y() ) * w; return !( lambdaw < 0. + tolerance || lambdaw >= wl - tolerance ); } diff --git a/src/core/geometry/qgsgeometryutils.h b/src/core/geometry/qgsgeometryutils.h index eb648272854..e34aa8f9512 100644 --- a/src/core/geometry/qgsgeometryutils.h +++ b/src/core/geometry/qgsgeometryutils.h @@ -106,8 +106,8 @@ class CORE_EXPORT QgsGeometryUtils * \param p2 First segment end point * \param q1 Second segment start point * \param q2 Second segment end point - * \param inter Output parameter, the intersection point - * \param isIntersect Output parameter, return true if an intersection is found + * \param intersectionPoint Output parameter, the intersection point + * \param isIntersection Output parameter, return true if an intersection is found * \param tolerance The tolerance to use * \param acceptImproperIntersection By default, this method returns true only if segments have proper intersection. If set true, returns also true if segments have improper intersection (end of one segment on other segment ; continuous segments). * \returns Whether the segments intersect @@ -135,7 +135,7 @@ class CORE_EXPORT QgsGeometryUtils * # (True, 'Point (0 0)', True) * \endcode */ - static bool segmentIntersection( const QgsPoint &p1, const QgsPoint &p2, const QgsPoint &q1, const QgsPoint &q2, QgsPoint &inter SIP_OUT, bool &isIntersect SIP_OUT, double tolerance, bool acceptImproperIntersection = false ); + static bool segmentIntersection( const QgsPoint &p1, const QgsPoint &p2, const QgsPoint &q1, const QgsPoint &q2, QgsPoint &intersectionPoint SIP_OUT, bool &isIntersection SIP_OUT, double tolerance, bool acceptImproperIntersection = false ); /** * \brief Project the point on a segment