Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Use prepared nearest points in QgsGeos::closestPoint when available
  • Loading branch information
strk authored and nyalldawson committed Nov 16, 2020
1 parent e8c9411 commit 2550d45
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions src/core/geometry/qgsgeos.cpp
Expand Up @@ -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 );
Expand Down

0 comments on commit 2550d45

Please sign in to comment.