Skip to content
Permalink
Browse files
Use GEOSDistanceWithin when available
  • Loading branch information
strk authored and nyalldawson committed Oct 14, 2021
1 parent 51d728b commit e5c188da7577bbf11bb506417b643142ee696132
Showing with 11 additions and 2 deletions.
  1. +11 −2 src/core/geometry/qgsgeos.cpp
@@ -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
}

0 comments on commit e5c188d

Please sign in to comment.