Skip to content
Permalink
Browse files

Add method to calculate shortestLine from a QgsAbstractGeometry inste…

…ad of QgsGeometry
  • Loading branch information
nyalldawson committed Feb 23, 2021
1 parent d2e0e8d commit 61edbb3afe312ae8e68ad4f666c3b7f89c34a02d
Showing with 13 additions and 1 deletion.
  1. +6 −1 src/core/geometry/qgsgeos.cpp
  2. +7 −0 src/core/geometry/qgsgeos.h
@@ -2279,7 +2279,12 @@ QgsGeometry QgsGeos::shortestLine( const QgsGeometry &other, QString *errorMsg )
return QgsGeometry();
}

geos::unique_ptr otherGeom( asGeos( other.constGet(), mPrecision ) );
return shortestLine( other.constGet(), errorMsg );
}

QgsGeometry QgsGeos::shortestLine( const QgsAbstractGeometry *other, QString *errorMsg ) const
{
geos::unique_ptr otherGeom( asGeos( other, mPrecision ) );
if ( !otherGeom )
{
return QgsGeometry();
@@ -282,6 +282,13 @@ class CORE_EXPORT QgsGeos: public QgsGeometryEngine
*/
QgsGeometry shortestLine( const QgsGeometry &other, QString *errorMsg = nullptr ) const;

/**
* Returns the shortest line joining this geometry to the other geometry.
* \see closestPoint()
* \since QGIS 3.20
*/
QgsGeometry shortestLine( const QgsAbstractGeometry *other, QString *errorMsg = nullptr ) const;

/**
* Returns a distance representing the location along this linestring of the closest point
* on this linestring geometry to the specified point. Ie, the returned value indicates

0 comments on commit 61edbb3

Please sign in to comment.