From 2f55b6e1390e32e85de8d81363d2f04b21ae67e4 Mon Sep 17 00:00:00 2001 From: Sandro Santilli Date: Fri, 2 Dec 2005 09:12:10 +0000 Subject: [PATCH] Fixed bbox computation of SnapToGrid output git-svn-id: http://svn.osgeo.org/postgis/branches/pgis_1_0@2130 b70326c6-7e19-0410-871a-916f4a2858ee --- CHANGES | 1 + lwgeom/lwgeom_functions_analytic.c | 16 +++++++++------- 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/CHANGES b/CHANGES index 36067f238..e92bbe109 100644 --- 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 diff --git a/lwgeom/lwgeom_functions_analytic.c b/lwgeom/lwgeom_functions_analytic.c index ee7e99404..75e4ee202 100644 --- a/lwgeom/lwgeom_functions_analytic.c +++ b/lwgeom/lwgeom_functions_analytic.c @@ -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 -- 2.40.0