Skip to content

Commit

Permalink
Return empty point instead of point( 0, 0 )
Browse files Browse the repository at this point in the history
  • Loading branch information
uclaros authored and nyalldawson committed May 19, 2020
1 parent d03d190 commit 0beee90
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 6 deletions.
4 changes: 2 additions & 2 deletions src/core/geometry/qgsgeometry.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -385,7 +385,7 @@ QgsPointXY QgsGeometry::closestVertex( const QgsPointXY &point, int &atVertex, i
if ( !d->geometry )
{
sqrDist = -1;
return QgsPointXY( 0, 0 );
return QgsPointXY();
}

QgsPoint pt( point.x(), point.y() );
Expand All @@ -395,7 +395,7 @@ QgsPointXY QgsGeometry::closestVertex( const QgsPointXY &point, int &atVertex, i
if ( !id.isValid() )
{
sqrDist = -1;
return QgsPointXY( 0, 0 );
return QgsPointXY();
}
sqrDist = QgsGeometryUtils::sqrDistance2D( pt, vp );

Expand Down
6 changes: 3 additions & 3 deletions src/core/geometry/qgsgeometry.h
Original file line number Diff line number Diff line change
Expand Up @@ -632,7 +632,7 @@ class CORE_EXPORT QgsGeometry
* \param afterVertex 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 nad sqrDist is negative.
* \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;

Expand Down Expand Up @@ -731,7 +731,7 @@ class CORE_EXPORT QgsGeometry
/**
* Returns coordinates of a vertex.
* \param atVertex index of the vertex
* \returns Coordinates of the vertex or QgsPoint(0,0) on error
* \returns Coordinates of the vertex or empty QgsPoint() on error
*/
QgsPoint vertexAt( int atVertex ) const;

Expand Down Expand Up @@ -1630,7 +1630,7 @@ class CORE_EXPORT QgsGeometry
*
* Any z or m values present in the geometry will be discarded.
*
* \warning If the geometry is not a single-point type, a QgsPoint( 0, 0 ) will be returned.
* \warning If the geometry is not a single-point type, an empty QgsPointXY() will be returned.
*/
QgsPointXY asPoint() const;
#else
Expand Down
2 changes: 1 addition & 1 deletion src/core/geometry/qgstriangle.h
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ class CORE_EXPORT QgsTriangle : public QgsPolygon
/**
* Returns coordinates of a vertex.
* \param atVertex index of the vertex
* \returns Coordinates of the vertex or QgsPoint(0,0) on error (\a atVertex < 0 or > 3).
* \returns Coordinates of the vertex or empty QgsPoint() on error (\a atVertex < 0 or > 3).
*/
QgsPoint vertexAt( int atVertex ) const;

Expand Down

0 comments on commit 0beee90

Please sign in to comment.