Skip to content
Permalink
Browse files

Use GEOSPreparedDistance when available

Allow speeding up GEOSDistance computation.
See
#39970 (review)

Requires GEOS-3.9+

Also fixes a conditional about GEOS for nearestPoints
  • Loading branch information
strk authored and nyalldawson committed Nov 16, 2020
1 parent ef7e80d commit e8c94112b37579fbd70897363aaea065d5317a7c
Showing with 12 additions and 1 deletion.
  1. +11 −0 src/core/geometry/qgsgeos.cpp
  2. +1 −1 src/core/pal/pointset.cpp
@@ -430,7 +430,18 @@ double QgsGeos::distance( const QgsAbstractGeometry *geom, QString *errorMsg ) c

try
{
#if GEOS_VERSION_MAJOR>3 || ( GEOS_VERSION_MAJOR == 3 && GEOS_VERSION_MINOR>=9 )
if ( mGeosPrepared )
{
GEOSPreparedDistance_r( geosinit()->ctxt, mGeosPrepared.get(), otherGeosGeom.get(), &distance );
}
else
{
GEOSDistance_r( geosinit()->ctxt, mGeos.get(), otherGeosGeom.get(), &distance );
}
#else
GEOSDistance_r( geosinit()->ctxt, mGeos.get(), otherGeosGeom.get(), &distance );
#endif
}
CATCH_GEOS_WITH_ERRMSG( -1.0 )

@@ -842,7 +842,7 @@ double PointSet::minDistanceToPoint( double px, double py, double *rx, double *r
#endif
}

#if GEOS_VERSION_MAJOR>3 || GEOS_VERSION_MINOR>=9
#if GEOS_VERSION_MAJOR>3 || ( GEOS_VERSION_MAJOR == 3 && GEOS_VERSION_MINOR>=9 )
geos::coord_sequence_unique_ptr nearestCoord( GEOSPreparedNearestPoints_r( geosctxt, preparedExtRing, geosPt.get() ) );
#else
geos::coord_sequence_unique_ptr nearestCoord( GEOSNearestPoints_r( geosctxt, extRing, geosPt.get() ) );

0 comments on commit e8c9411

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