Skip to content
Permalink
Browse files

Rename variables for a more intuitive documentation

  • Loading branch information
tschmetzer committed Oct 29, 2020
1 parent c0d76e1 commit df0950c6e6b09eb6ab9ffafc3a2449653bf19861
@@ -549,18 +549,17 @@ In case of error -1 will be returned.
.. versionadded:: 3.0
%End


QgsPointXY closestVertex( const QgsPointXY &point, int &atVertex /Out/, int &beforeVertex /Out/, int &afterVertex /Out/, double &sqrDist /Out/ ) const;
QgsPointXY closestVertex( const QgsPointXY &point, int &closestVertexIndex /Out/, int &previousVertexIndex /Out/, int &nextVertexIndex /Out/, double &sqrDist /Out/ ) const;
%Docstring
Returns the vertex closest to the given point, the corresponding vertex index, squared distance snap point / target point
and the indices of the vertices before and after the closest vertex.

:param point: point to search for

:return: - closest point in geometry. If not found (empty geometry), returns null point and sqrDist is negative.
- atVertex: will be set to the vertex index of the closest found vertex
- beforeVertex: will be set to the vertex index of the previous vertex from the closest one. Will be set to -1 if not present.
- afterVertex: will be set to the vertex index of the next vertex after the closest one. Will be set to -1 if not present.
- closestVertexIndex: will be set to the vertex index of the closest found vertex
- previousVertexIndex: will be set to the vertex index of the previous vertex from the closest one. Will be set to -1 if not present.
- nextVertexIndex: will be set to the vertex index of the next vertex after the closest one. Will be set to -1 if not present.
- sqrDist: will be set to the square distance between the closest vertex and the specified point
%End

@@ -685,7 +684,7 @@ ring and item (first number is index 0))

QgsGeometry nearestPoint( const QgsGeometry &other ) const;
%Docstring
Returns the nearest point on this geometry to another geometry.
Returns the nearest (closest) point on this geometry to another geometry.

.. seealso:: :py:func:`shortestLine`

@@ -717,7 +716,7 @@ Searches for the closest vertex in this geometry to the given point.
- atVertex: Receives index of the closest vertex
%End

double closestSegmentWithContext( const QgsPointXY &point, QgsPointXY &minDistPoint /Out/, int &afterVertex /Out/, int *leftOf /Out/ = 0, double epsilon = DEFAULT_SEGMENT_EPSILON ) const;
double closestSegmentWithContext( const QgsPointXY &point, QgsPointXY &minDistPoint /Out/, int &nextVertexIndex /Out/, int *leftOrRightOfSegment /Out/ = 0, double epsilon = DEFAULT_SEGMENT_EPSILON ) const;
%Docstring
Searches for the closest segment of geometry to the given point

@@ -726,8 +725,8 @@ Searches for the closest segment of geometry to the given point

:return: - The squared Cartesian distance is also returned in sqrDist, negative number on error
- minDistPoint: Receives the nearest point on the segment
- afterVertex: Receives index of the vertex after the closest segment. The vertex before the closest segment is always afterVertex - 1
- leftOf: Out: Returns if the point lies on the left of left side of the geometry ( < 0 means left, > 0 means right, 0 indicates that the test was unsuccessful, e.g. for a point exactly on the line)
- nextVertexIndex: Receives index of the next vertex after the closest segment. The vertex before the closest segment is always nextVertexIndex - 1
- leftOrRightOfSegment: Out: Returns if the point is located on the left or right side of the geometry ( < 0 means left, > 0 means right, 0 indicates that the test was unsuccessful, e.g. for a point exactly on the line)
%End

OperationResult addRing( const QVector<QgsPointXY> &ring );
@@ -382,8 +382,7 @@ bool QgsGeometry::isMultipart() const
}
return QgsWkbTypes::isMultiType( d->geometry->wkbType() );
}

QgsPointXY QgsGeometry::closestVertex( const QgsPointXY &point, int &atVertex, int &beforeVertex, int &afterVertex, double &sqrDist ) const
QgsPointXY QgsGeometry::closestVertex( const QgsPointXY &point, int &closestVertexIndex, int &previousVertexIndex, int &nextVertexIndex, double &sqrDist ) const
{
if ( !d->geometry )
{
@@ -405,9 +404,9 @@ QgsPointXY QgsGeometry::closestVertex( const QgsPointXY &point, int &atVertex, i
QgsVertexId prevVertex;
QgsVertexId nextVertex;
d->geometry->adjacentVertices( id, prevVertex, nextVertex );
atVertex = vertexNrFromVertexId( id );
beforeVertex = vertexNrFromVertexId( prevVertex );
afterVertex = vertexNrFromVertexId( nextVertex );
closestVertexIndex = vertexNrFromVertexId( id );
previousVertexIndex = vertexNrFromVertexId( prevVertex );
nextVertexIndex = vertexNrFromVertexId( nextVertex );
return QgsPointXY( vp.x(), vp.y() );
}

@@ -655,8 +654,8 @@ double QgsGeometry::closestVertexWithContext( const QgsPointXY &point, int &atVe

double QgsGeometry::closestSegmentWithContext( const QgsPointXY &point,
QgsPointXY &minDistPoint,
int &afterVertex,
int *leftOf,
int &nextVertexIndex,
int *leftOrRightOfSegment,
double epsilon ) const
{
if ( !d->geometry )
@@ -667,13 +666,13 @@ double QgsGeometry::closestSegmentWithContext( const QgsPointXY &point,
QgsPoint segmentPt;
QgsVertexId vertexAfter;

double sqrDist = d->geometry->closestSegment( QgsPoint( point ), segmentPt, vertexAfter, leftOf, epsilon );
double sqrDist = d->geometry->closestSegment( QgsPoint( point ), segmentPt, vertexAfter, leftOrRightOfSegment, epsilon );
if ( sqrDist < 0 )
return -1;

minDistPoint.setX( segmentPt.x() );
minDistPoint.setY( segmentPt.y() );
afterVertex = vertexNrFromVertexId( vertexAfter );
nextVertexIndex = vertexNrFromVertexId( vertexAfter );
return sqrDist;
}

@@ -624,21 +624,19 @@ class CORE_EXPORT QgsGeometry
*/
double hausdorffDistanceDensify( const QgsGeometry &geom, double densifyFraction ) const;

//TODO QGIS 4.0 - rename beforeVertex to previousVertex, afterVertex to nextVertex

/**
* Returns the vertex closest to the given point, the corresponding vertex index, squared distance snap point / target point
* and the indices of the vertices before and after the closest vertex.
* \param point point to search for
* \param atVertex will be set to the vertex index of the closest found vertex
* \param beforeVertex will be set to the vertex index of the previous vertex from the closest one. Will be set to -1 if
* \param closestVertexIndex will be set to the vertex index of the closest found vertex
* \param previousVertexIndex will be set to the vertex index of the previous vertex from the closest one. Will be set to -1 if
* not present.
* \param afterVertex will be set to the vertex index of the next vertex after the closest one. Will be set to -1 if
* \param nextVertexIndex will be set to the vertex index of the next vertex after the closest one. Will be set to -1 if
* not present.
* \param sqrDist will be set to the square distance between the closest vertex and the specified point
* \returns closest point in geometry. If not found (empty geometry), returns null point and sqrDist is negative.
*/
QgsPointXY closestVertex( const QgsPointXY &point, int &atVertex SIP_OUT, int &beforeVertex SIP_OUT, int &afterVertex SIP_OUT, double &sqrDist SIP_OUT ) const;
QgsPointXY closestVertex( const QgsPointXY &point, int &closestVertexIndex SIP_OUT, int &previousVertexIndex SIP_OUT, int &nextVertexIndex SIP_OUT, double &sqrDist SIP_OUT ) const;

/**
* Returns the distance along this geometry from its first vertex to the specified vertex.
@@ -747,7 +745,7 @@ class CORE_EXPORT QgsGeometry
double sqrDistToVertexAt( QgsPointXY &point SIP_IN, int atVertex ) const;

/**
* Returns the nearest point on this geometry to another geometry.
* Returns the nearest (closest) point on this geometry to another geometry.
* \see shortestLine()
* \since QGIS 2.14
*/
@@ -777,14 +775,14 @@ class CORE_EXPORT QgsGeometry
* Searches for the closest segment of geometry to the given point
* \param point Specifies the point for search
* \param minDistPoint Receives the nearest point on the segment
* \param afterVertex Receives index of the vertex after the closest segment. The vertex
* before the closest segment is always afterVertex - 1
* \param leftOf Out: Returns if the point lies on the left of left side of the geometry ( < 0 means left, > 0 means right, 0 indicates
* \param nextVertexIndex Receives index of the next vertex after the closest segment. The vertex
* before the closest segment is always nextVertexIndex - 1
* \param leftOrRightOfSegment Out: Returns if the point is located on the left or right side of the geometry ( < 0 means left, > 0 means right, 0 indicates
* that the test was unsuccessful, e.g. for a point exactly on the line)
* \param epsilon epsilon for segment snapping
* \returns The squared Cartesian distance is also returned in sqrDist, negative number on error
*/
double closestSegmentWithContext( const QgsPointXY &point, QgsPointXY &minDistPoint SIP_OUT, int &afterVertex SIP_OUT, int *leftOf SIP_OUT = nullptr, double epsilon = DEFAULT_SEGMENT_EPSILON ) const;
double closestSegmentWithContext( const QgsPointXY &point, QgsPointXY &minDistPoint SIP_OUT, int &nextVertexIndex SIP_OUT, int *leftOrRightOfSegment SIP_OUT = nullptr, double epsilon = DEFAULT_SEGMENT_EPSILON ) const;

/**
* Adds a new ring to this geometry. This makes only sense for polygon and multipolygons.

0 comments on commit df0950c

Please sign in to comment.
You can’t perform that action at this time.