Skip to content

Commit 03d8565

Browse files
committedDec 13, 2017
- Update api_break.dox
- rename isIntersect to isIntersection - rename inter to intersectionPoint
1 parent c6838fd commit 03d8565

File tree

4 files changed

+20
-19
lines changed

4 files changed

+20
-19
lines changed
 

‎doc/api_break.dox

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1453,7 +1453,8 @@ QgsGeometryUtils {#qgis_api_break_3_0_QgsGeometryUtils}
14531453

14541454
- componentType enum has been renamed to ComponentType and its members were CamelCased too: VERTEX, RING and PART become Vertex, Ring and Part, respectively.
14551455
- adjacentVertices was removed - use QgsAbstractGeometry.adjacentVertices instead.
1456-
1456+
- segmentIntersection takes an optional boolean parameter "acceptImproperIntersection" returning true even if the intersection is improper.
1457+
Takes another boolean argument "isIntersection" returning if there is an intersection or not. The "inter" parameter has been renamed "intersectionPoint".
14571458

14581459
QgsGPSConnectionRegistry {#qgis_api_break_3_0_QgsGPSConnectionRegistry}
14591460
------------------------

‎python/core/geometry/qgsgeometryutils.sip

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -98,15 +98,15 @@ class QgsGeometryUtils
9898
:rtype: bool
9999
%End
100100

101-
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 );
101+
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 );
102102
%Docstring
103103
Compute the intersection between two segments
104104
\param p1 First segment start point
105105
\param p2 First segment end point
106106
\param q1 Second segment start point
107107
\param q2 Second segment end point
108-
\param inter Output parameter, the intersection point
109-
\param isIntersect Output parameter, return true if an intersection is found
108+
\param intersectionPoint Output parameter, the intersection point
109+
\param isIntersection Output parameter, return true if an intersection is found
110110
\param tolerance The tolerance to use
111111
\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).
112112
:return: Whether the segments intersect

‎src/core/geometry/qgsgeometryutils.cpp

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -251,9 +251,9 @@ bool QgsGeometryUtils::lineIntersection( const QgsPoint &p1, QgsVector v, const
251251
return true;
252252
}
253253

254-
bool QgsGeometryUtils::segmentIntersection( const QgsPoint &p1, const QgsPoint &p2, const QgsPoint &q1, const QgsPoint &q2, QgsPoint &inter, bool &isIntersect, double tolerance, bool acceptImproperIntersection )
254+
bool QgsGeometryUtils::segmentIntersection( const QgsPoint &p1, const QgsPoint &p2, const QgsPoint &q1, const QgsPoint &q2, QgsPoint &intersectionPoint, bool &isIntersection, double tolerance, bool acceptImproperIntersection )
255255
{
256-
isIntersect = false;
256+
isIntersection = false;
257257

258258
QgsVector v( p2.x() - p1.x(), p2.y() - p1.y() );
259259
QgsVector w( q2.x() - q1.x(), q2.y() - q1.y() );
@@ -267,53 +267,53 @@ bool QgsGeometryUtils::segmentIntersection( const QgsPoint &p1, const QgsPoint &
267267
v = v / vl;
268268
w = w / wl;
269269

270-
if ( !QgsGeometryUtils::lineIntersection( p1, v, q1, w, inter ) )
270+
if ( !QgsGeometryUtils::lineIntersection( p1, v, q1, w, intersectionPoint ) )
271271
{
272272
return false;
273273
}
274274

275-
isIntersect = true;
275+
isIntersection = true;
276276
if ( acceptImproperIntersection )
277277
{
278278
if ( ( p1 == q1 ) || ( p1 == q2 ) )
279279
{
280-
inter = p1;
280+
intersectionPoint = p1;
281281
return true;
282282
}
283283
else if ( ( p2 == q1 ) || ( p2 == q2 ) )
284284
{
285-
inter == p2;
285+
intersectionPoint == p2;
286286
return true;
287287
}
288288

289289
double x, y;
290290
if ( qgsDoubleNear( QgsGeometryUtils::sqrDistToLine( p1.x(), p1.y(), q1.x(), q1.y(), q2.x(), q2.y(), x, y, tolerance ), 0.0, tolerance ) )
291291
{
292-
inter == p1;
292+
intersectionPoint == p1;
293293
return true;
294294
}
295295
else if ( qgsDoubleNear( QgsGeometryUtils::sqrDistToLine( p2.x(), p2.y(), q1.x(), q1.y(), q2.x(), q2.y(), x, y, tolerance ), 0.0, tolerance ) )
296296
{
297-
inter == p2;
297+
intersectionPoint == p2;
298298
return true;
299299
}
300300
else if ( qgsDoubleNear( QgsGeometryUtils::sqrDistToLine( q1.x(), q1.y(), p1.x(), p1.y(), p2.x(), p2.y(), x, y, tolerance ), 0.0, tolerance ) )
301301
{
302-
inter == q1;
302+
intersectionPoint == q1;
303303
return true;
304304
}
305305
else if ( qgsDoubleNear( QgsGeometryUtils::sqrDistToLine( q2.x(), q2.y(), p1.x(), p1.y(), p2.x(), p2.y(), x, y, tolerance ), 0.0, tolerance ) )
306306
{
307-
inter == q2;
307+
intersectionPoint == q2;
308308
return true;
309309
}
310310
}
311311

312-
double lambdav = QgsVector( inter.x() - p1.x(), inter.y() - p1.y() ) * v;
312+
double lambdav = QgsVector( intersectionPoint.x() - p1.x(), intersectionPoint.y() - p1.y() ) * v;
313313
if ( lambdav < 0. + tolerance || lambdav > vl - tolerance )
314314
return false;
315315

316-
double lambdaw = QgsVector( inter.x() - q1.x(), inter.y() - q1.y() ) * w;
316+
double lambdaw = QgsVector( intersectionPoint.x() - q1.x(), intersectionPoint.y() - q1.y() ) * w;
317317
return !( lambdaw < 0. + tolerance || lambdaw >= wl - tolerance );
318318
}
319319

‎src/core/geometry/qgsgeometryutils.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -106,8 +106,8 @@ class CORE_EXPORT QgsGeometryUtils
106106
* \param p2 First segment end point
107107
* \param q1 Second segment start point
108108
* \param q2 Second segment end point
109-
* \param inter Output parameter, the intersection point
110-
* \param isIntersect Output parameter, return true if an intersection is found
109+
* \param intersectionPoint Output parameter, the intersection point
110+
* \param isIntersection Output parameter, return true if an intersection is found
111111
* \param tolerance The tolerance to use
112112
* \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).
113113
* \returns Whether the segments intersect
@@ -135,7 +135,7 @@ class CORE_EXPORT QgsGeometryUtils
135135
* # (True, 'Point (0 0)', True)
136136
* \endcode
137137
*/
138-
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 );
138+
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 );
139139

140140
/**
141141
* \brief Project the point on a segment

0 commit comments

Comments
 (0)
Please sign in to comment.