]> granicus.if.org Git - postgis/commitdiff
Make the ST_Equals test insensitive to minor box differences.
authorPaul Ramsey <pramsey@cleverelephant.ca>
Thu, 8 Dec 2011 17:54:38 +0000 (17:54 +0000)
committerPaul Ramsey <pramsey@cleverelephant.ca>
Thu, 8 Dec 2011 17:54:38 +0000 (17:54 +0000)
git-svn-id: http://svn.osgeo.org/postgis/trunk@8323 b70326c6-7e19-0410-871a-916f4a2858ee

postgis/lwgeom_geos.c

index 63f79e09ce1a7112e8092dd079f35b9e4f414b2c..f05e60fc3ababebcabd5f0c16d5f817904b7be03 100644 (file)
@@ -3038,19 +3038,18 @@ Datum geomequals(PG_FUNCTION_ARGS)
        if ( gserialized_is_empty(geom1) && gserialized_is_empty(geom2) )
                PG_RETURN_BOOL(TRUE);
 
-
        /*
-        * short-circuit: if geom2 bounding box does not equal
-        * geom1 bounding box we can prematurely return FALSE.
-        * Do the test IFF BOUNDING BOX AVAILABLE.
+        * short-circuit: Loose test, if they don't intersect they
+        * sure can't be equal.
         */
        if ( gserialized_get_gbox_p(geom1, &box1) &&
             gserialized_get_gbox_p(geom2, &box2) )
        {
-               if ( FP_NEQUALS(box2.xmax, box1.xmax) ) PG_RETURN_BOOL(FALSE);
-               if ( FP_NEQUALS(box2.xmin, box1.xmin) ) PG_RETURN_BOOL(FALSE);
-               if ( FP_NEQUALS(box2.ymax, box1.ymax) ) PG_RETURN_BOOL(FALSE);
-               if ( FP_NEQUALS(box2.ymin, box1.ymin) ) PG_RETURN_BOOL(FALSE);
+               if ( ( box2.xmax < box1.xmin ) || ( box2.xmin > box1.xmax ) ||
+                    ( box2.ymax < box1.ymin ) || ( box2.ymin > box1.ymax ) )
+               {
+                       PG_RETURN_BOOL(FALSE);
+               }
        }
 
        initGEOS(lwnotice, lwgeom_geos_error);