Skip to content
Permalink
Browse files

Use prepared nearest points in QgsGeos::closestPoint when available

  • Loading branch information
strk authored and nyalldawson committed Nov 16, 2020
1 parent e8c9411 commit 2550d455697525e5e64d8d01293febf7777c001e
Showing with 12 additions and 0 deletions.
  1. +12 −0 src/core/geometry/qgsgeos.cpp
@@ -2247,7 +2247,19 @@ QgsGeometry QgsGeos::closestPoint( const QgsGeometry &other, QString *errorMsg )
double ny = 0.0;
try
{
#if GEOS_VERSION_MAJOR>3 || ( GEOS_VERSION_MAJOR == 3 && GEOS_VERSION_MINOR>=9 )
geos::coord_sequence_unique_ptr nearestCoord;
if ( mGeosPrepared ) // use faster version with prepared geometry
{
nearestCoord.reset( GEOSNearestPoints_r( geosinit()->ctxt, mGeos.get(), otherGeom.get() ) );
}
else
{
nearestCoord.reset( GEOSPreparedNearestPoints_r( geosinit()->ctxt, mGeosPrepared.get(), otherGeom.get() ) );
}
#else
geos::coord_sequence_unique_ptr nearestCoord( GEOSNearestPoints_r( geosinit()->ctxt, mGeos.get(), otherGeom.get() ) );
#endif

( void )GEOSCoordSeq_getX_r( geosinit()->ctxt, nearestCoord.get(), 0, &nx );
( void )GEOSCoordSeq_getY_r( geosinit()->ctxt, nearestCoord.get(), 0, &ny );

0 comments on commit 2550d45

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