From a4617586fc93349a7b8ed25609fdf8344debe3a5 Mon Sep 17 00:00:00 2001 From: Sandro Santilli Date: Tue, 27 Jul 2004 17:51:50 +0000 Subject: [PATCH] short-circuit test for 'contains' git-svn-id: http://svn.osgeo.org/postgis/trunk@650 b70326c6-7e19-0410-871a-916f4a2858ee --- postgis_geos.c | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/postgis_geos.c b/postgis_geos.c index 7c938ac68..941c94764 100644 --- a/postgis_geos.c +++ b/postgis_geos.c @@ -10,6 +10,9 @@ * ********************************************************************** * $Log$ + * Revision 1.36 2004/07/27 17:51:50 strk + * short-circuit test for 'contains' + * * Revision 1.35 2004/07/27 17:49:59 strk * Added short-circuit test for the within function. * @@ -928,6 +931,15 @@ Datum contains(PG_FUNCTION_ARGS) Geometry *g1,*g2; bool result; + /* + * short-circuit: if geom2 bounding box is not completely inside + * geom1 bounding box we can prematurely return FALSE + */ + if ( geom2->bvol.LLB.x < geom1->bvol.LLB.x ) PG_RETURN_BOOL(FALSE); + if ( geom2->bvol.URT.x > geom1->bvol.URT.x ) PG_RETURN_BOOL(FALSE); + if ( geom2->bvol.LLB.y < geom1->bvol.LLB.y ) PG_RETURN_BOOL(FALSE); + if ( geom2->bvol.URT.y > geom1->bvol.URT.y ) PG_RETURN_BOOL(FALSE); + errorIfGeometryCollection(geom1,geom2); initGEOS(MAXIMUM_ALIGNOF); @@ -962,8 +974,8 @@ Datum within(PG_FUNCTION_ARGS) /* - * short-circuit: if g1 bounding box is not completely inside - * g2 bounding box we can prematurely return FALSE + * short-circuit: if geom1 bounding box is not completely inside + * geom2 bounding box we can prematurely return FALSE */ if ( geom1->bvol.LLB.x < geom2->bvol.LLB.x ) PG_RETURN_BOOL(FALSE); if ( geom1->bvol.URT.x > geom2->bvol.URT.x ) PG_RETURN_BOOL(FALSE); -- 2.40.0