]> granicus.if.org Git - postgis/commitdiff
Fixed bbox computation of SnapToGrid output
authorSandro Santilli <strk@keybit.net>
Fri, 2 Dec 2005 09:12:10 +0000 (09:12 +0000)
committerSandro Santilli <strk@keybit.net>
Fri, 2 Dec 2005 09:12:10 +0000 (09:12 +0000)
git-svn-id: http://svn.osgeo.org/postgis/branches/pgis_1_0@2130 b70326c6-7e19-0410-871a-916f4a2858ee

CHANGES
lwgeom/lwgeom_functions_analytic.c

diff --git a/CHANGES b/CHANGES
index 36067f238086fc7d5291ae302384e179663324d8..e92bbe1092394a2fc6d0d7faeed9ba2f9492f6da 100644 (file)
--- a/CHANGES
+++ b/CHANGES
@@ -8,6 +8,7 @@ PostGIS 1.0.6CVS
        - Fixed short-allocation in lwcollection_clone()
        - Fixed bug in segmentize()
        - Added missing SRID mismatch checks in GEOS ops
+       - Fixed bbox computation of SnapToGrid output
 
 PostGIS 1.0.5
 2005/11/25
index ee7e99404a82b01469bc4f47c693fb9cf3167b0d..75e4ee2022611b5a529b6a9361f3ba53b84723d5 100644 (file)
@@ -797,7 +797,7 @@ Datum LWGEOM_snaptogrid(PG_FUNCTION_ARGS)
        PG_LWGEOM *out_geom = NULL;
        LWGEOM *out_lwgeom;
        gridspec grid;
-       BOX2DFLOAT4 *box;
+       BOX3D box3d;
 
        if ( PG_ARGISNULL(0) ) PG_RETURN_NULL();
        datum = PG_GETARG_DATUM(0);
@@ -830,16 +830,18 @@ Datum LWGEOM_snaptogrid(PG_FUNCTION_ARGS)
        /* COMPUTE_BBOX WHEN_SIMPLE */
        if ( in_lwgeom->bbox )
        {
-               box = palloc(sizeof(BOX2DFLOAT4));
-               box->xmin = rint((in_lwgeom->bbox->xmin - grid.ipx)/grid.xsize)
+               box2df_to_box3d_p(in_lwgeom->bbox, &box3d);
+
+               box3d.xmin = rint((box3d.xmin - grid.ipx)/grid.xsize)
                        * grid.xsize + grid.ipx;
-               box->xmax = rint((in_lwgeom->bbox->xmax - grid.ipx)/grid.xsize)
+               box3d.xmax = rint((box3d.xmax - grid.ipx)/grid.xsize)
                        * grid.xsize + grid.ipx;
-               box->ymin = rint((in_lwgeom->bbox->ymin - grid.ipy)/grid.ysize)
+               box3d.ymin = rint((box3d.ymin - grid.ipy)/grid.ysize)
                        * grid.ysize + grid.ipy;
-               box->ymax = rint((in_lwgeom->bbox->ymax - grid.ipy)/grid.ysize)
+               box3d.ymax = rint((box3d.ymax - grid.ipy)/grid.ysize)
                        * grid.ysize + grid.ipy;
-               out_lwgeom->bbox = box;
+
+               out_lwgeom->bbox = box3d_to_box2df(&box3d);
        }
 
 #if VERBOSE