Navigation Menu

Skip to content

Commit

Permalink
Use GEOSPreparedDistance when available
Browse files Browse the repository at this point in the history
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 e8c9411
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
11 changes: 11 additions & 0 deletions src/core/geometry/qgsgeos.cpp
Expand Up @@ -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 )

Expand Down
2 changes: 1 addition & 1 deletion src/core/pal/pointset.cpp
Expand Up @@ -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() ) );
Expand Down

0 comments on commit e8c9411

Please sign in to comment.