Skip to content

Commit c6838fd

Browse files
committedDec 13, 2017
Update doc
1 parent 9bd7212 commit c6838fd

File tree

2 files changed

+48
-2
lines changed

2 files changed

+48
-2
lines changed
 

‎python/core/geometry/qgsgeometryutils.sip

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,8 +108,31 @@ class QgsGeometryUtils
108108
\param inter Output parameter, the intersection point
109109
\param isIntersect Output parameter, return true if an intersection is found
110110
\param tolerance The tolerance to use
111-
\param acceptImproperIntersection By defaut this method return only intersection point if segments are not contigus. If set on true, return also contigus point as an intersection point.
111+
\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
113+
* Example:
114+
\code{.py}
115+
epsilon = 1e-8
116+
ret = QgsGeometryUtils.segmentIntersection( QgsPoint( 0, 0 ), QgsPoint( 0, 1 ), QgsPoint( 1, 1 ), QgsPoint( 1, 0 ), epsilon )
117+
ret[0], ret[1].asWkt(), ret[2]
118+
# Whether the segments intersect, the intersection point, is intersect
119+
# (False, 'Point (0 0)', False)
120+
ret = QgsGeometryUtils.segmentIntersection( QgsPoint( 0, 0 ), QgsPoint( 0, 5 ), QgsPoint( 0, 5 ), QgsPoint( 1, 5 ), epsilon )
121+
ret[0], ret[1].asWkt(), ret[2]
122+
# (False, 'Point (0 5)', True)
123+
ret = QgsGeometryUtils.segmentIntersection( QgsPoint( 0, 0 ), QgsPoint( 0, 5 ), QgsPoint( 0, 5 ), QgsPoint( 1, 5 ), epsilon, True )
124+
ret[0], ret[1].asWkt(), ret[2]
125+
# (True, 'Point (0 5)', True)
126+
ret = QgsGeometryUtils.segmentIntersection( QgsPoint( 0, 0 ), QgsPoint( 0, 5 ), QgsPoint( 0, 2 ), QgsPoint( 1, 5 ), epsilon )
127+
ret[0], ret[1].asWkt(), ret[2]
128+
# (False, 'Point (0 2)', True)
129+
ret = QgsGeometryUtils.segmentIntersection( QgsPoint( 0, 0 ), QgsPoint( 0, 5 ), QgsPoint( 0, 2 ), QgsPoint( 1, 5 ), epsilon, True )
130+
ret[0], ret[1].asWkt(), ret[2]
131+
# (True, 'Point (0 2)', True)
132+
ret = QgsGeometryUtils.segmentIntersection( QgsPoint( 0, -5 ), QgsPoint( 0, 5 ), QgsPoint( 2, 0 ), QgsPoint( -1, 0 ), epsilon )
133+
ret[0], ret[1].asWkt(), ret[2]
134+
# (True, 'Point (0 0)', True)
135+
\endcode
113136
:rtype: bool
114137
%End
115138

‎src/core/geometry/qgsgeometryutils.h

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,8 +109,31 @@ class CORE_EXPORT QgsGeometryUtils
109109
* \param inter Output parameter, the intersection point
110110
* \param isIntersect Output parameter, return true if an intersection is found
111111
* \param tolerance The tolerance to use
112-
* \param acceptImproperIntersection By defaut this method return only intersection point if segments are not contigus. If set on true, return also contigus point as an intersection point.
112+
* \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
114+
* * Example:
115+
* \code{.py}
116+
* epsilon = 1e-8
117+
* ret = QgsGeometryUtils.segmentIntersection( QgsPoint( 0, 0 ), QgsPoint( 0, 1 ), QgsPoint( 1, 1 ), QgsPoint( 1, 0 ), epsilon )
118+
* ret[0], ret[1].asWkt(), ret[2]
119+
* # Whether the segments intersect, the intersection point, is intersect
120+
* # (False, 'Point (0 0)', False)
121+
* ret = QgsGeometryUtils.segmentIntersection( QgsPoint( 0, 0 ), QgsPoint( 0, 5 ), QgsPoint( 0, 5 ), QgsPoint( 1, 5 ), epsilon )
122+
* ret[0], ret[1].asWkt(), ret[2]
123+
* # (False, 'Point (0 5)', True)
124+
* ret = QgsGeometryUtils.segmentIntersection( QgsPoint( 0, 0 ), QgsPoint( 0, 5 ), QgsPoint( 0, 5 ), QgsPoint( 1, 5 ), epsilon, True )
125+
* ret[0], ret[1].asWkt(), ret[2]
126+
* # (True, 'Point (0 5)', True)
127+
* ret = QgsGeometryUtils.segmentIntersection( QgsPoint( 0, 0 ), QgsPoint( 0, 5 ), QgsPoint( 0, 2 ), QgsPoint( 1, 5 ), epsilon )
128+
* ret[0], ret[1].asWkt(), ret[2]
129+
* # (False, 'Point (0 2)', True)
130+
* ret = QgsGeometryUtils.segmentIntersection( QgsPoint( 0, 0 ), QgsPoint( 0, 5 ), QgsPoint( 0, 2 ), QgsPoint( 1, 5 ), epsilon, True )
131+
* ret[0], ret[1].asWkt(), ret[2]
132+
* # (True, 'Point (0 2)', True)
133+
* ret = QgsGeometryUtils.segmentIntersection( QgsPoint( 0, -5 ), QgsPoint( 0, 5 ), QgsPoint( 2, 0 ), QgsPoint( -1, 0 ), epsilon )
134+
* ret[0], ret[1].asWkt(), ret[2]
135+
* # (True, 'Point (0 0)', True)
136+
* \endcode
114137
*/
115138
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 );
116139

0 commit comments

Comments
 (0)
Please sign in to comment.