Skip to content

Commit

Permalink
Use GEOSDistanceWithin when available
Browse files Browse the repository at this point in the history
  • Loading branch information
strk authored and nyalldawson committed Oct 14, 2021
1 parent 51d728b commit e5c188d
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions src/core/geometry/qgsgeos.cpp
Expand Up @@ -491,20 +491,29 @@ bool QgsGeos::distanceWithin( const QgsAbstractGeometry *geom, double maxdist, Q
// TODO: optimize implementation of this function to early-exit if
// any part of othergeosGeom is found to be within the given
// distance

double distance;


try
{
#if GEOS_VERSION_MAJOR>3 || ( GEOS_VERSION_MAJOR == 3 && GEOS_VERSION_MINOR>=9 )
if ( mGeosPrepared )
{
#if GEOS_VERSION_MAJOR>3 || ( GEOS_VERSION_MAJOR == 3 && GEOS_VERSION_MINOR>=10 )
return GEOSPreparedDistanceWithin_r( geosinit()->ctxt, mGeosPrepared.get(), otherGeosGeom.get(), maxdist );
#else
GEOSPreparedDistance_r( geosinit()->ctxt, mGeosPrepared.get(), otherGeosGeom.get(), &distance );
#endif
}
else
{
#if GEOS_VERSION_MAJOR>3 || ( GEOS_VERSION_MAJOR == 3 && GEOS_VERSION_MINOR>=10 )
return GEOSDistanceWithin_r( geosinit()->ctxt, mGeos.get(), otherGeosGeom.get(), maxdist );
#else
GEOSDistance_r( geosinit()->ctxt, mGeos.get(), otherGeosGeom.get(), &distance );
#endif
}
#else
#else // GEOS < 3.3.9
GEOSDistance_r( geosinit()->ctxt, mGeos.get(), otherGeosGeom.get(), &distance );
#endif
}
Expand Down

0 comments on commit e5c188d

Please sign in to comment.