]> granicus.if.org Git - postgis/commitdiff
Fix ST_ClipByBox2D after gbox calculations centralization (r13313)
authorSandro Santilli <strk@keybit.net>
Fri, 6 Mar 2015 10:35:58 +0000 (10:35 +0000)
committerSandro Santilli <strk@keybit.net>
Fri, 6 Mar 2015 10:35:58 +0000 (10:35 +0000)
See #3073

git-svn-id: http://svn.osgeo.org/postgis/trunk@13320 b70326c6-7e19-0410-871a-916f4a2858ee

postgis/lwgeom_geos.c

index dcf735211947b45ef6ee98d9fc9be9edd0ef4396..825d1897c19c13d0c445e577aa725ad4717ba955 100644 (file)
@@ -1679,7 +1679,8 @@ Datum ST_ClipByBox2d(PG_FUNCTION_ARGS)
        bbox2 = (GBOX *)PG_GETARG_POINTER(1);
 
        /* If bbox1 outside of bbox2, return empty */
-       if ( ! gbox_overlaps_2d(bbox1, bbox2) )
+       if ( bbox1->xmin > bbox2->xmax || bbox1->xmax < bbox2->xmin ||
+            bbox1->ymin > bbox2->ymax || bbox1->ymax < bbox2->ymin )
        {
                lwresult = lwgeom_construct_empty(lwgeom1->type, lwgeom1->srid, 0, 0);
                lwgeom_free(lwgeom1);
@@ -1690,7 +1691,8 @@ Datum ST_ClipByBox2d(PG_FUNCTION_ARGS)
        }
 
        /* if bbox1 is covered by bbox2, return lwgeom1 */
-       if ( gbox_contains_2d(bbox2, bbox1) )
+       if ( bbox1->xmax <= bbox2->xmax && bbox1->xmin >= bbox2->xmin &&
+            bbox1->ymax <= bbox2->ymax && bbox1->ymin >= bbox2->ymin )
        {
                lwgeom_free(lwgeom1);
                PG_RETURN_POINTER(geom1);