From: Mark Cave-Ayland Date: Sat, 9 May 2009 12:53:25 +0000 (+0000) Subject: Fix #178: ST_XMax() and ST_YMax() return incorrect values. This was caused by the... X-Git-Tag: 1.4.0b1~52 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=fc2571e1a49497f6cc70937c94adf5027575a743;p=postgis Fix #178: ST_XMax() and ST_YMax() return incorrect values. This was caused by the fact that the min/max routines did not check whether the result for each axis was actually the min or max, but instead simply returned the structure value. Hence if an inverted coordinate system were being used, the wrong value would be returned. git-svn-id: http://svn.osgeo.org/postgis/trunk@4079 b70326c6-7e19-0410-871a-916f4a2858ee --- diff --git a/postgis/lwgeom_box3d.c b/postgis/lwgeom_box3d.c index 462359d32..7d0a7413a 100644 --- a/postgis/lwgeom_box3d.c +++ b/postgis/lwgeom_box3d.c @@ -328,42 +328,42 @@ PG_FUNCTION_INFO_V1(BOX3D_xmin); Datum BOX3D_xmin(PG_FUNCTION_ARGS) { BOX3D *box = (BOX3D *)PG_GETARG_POINTER(0); - PG_RETURN_FLOAT8(box->xmin); + PG_RETURN_FLOAT8(LWGEOM_Mind(box->xmin, box->xmax)); } PG_FUNCTION_INFO_V1(BOX3D_ymin); Datum BOX3D_ymin(PG_FUNCTION_ARGS) { BOX3D *box = (BOX3D *)PG_GETARG_POINTER(0); - PG_RETURN_FLOAT8(box->ymin); + PG_RETURN_FLOAT8(LWGEOM_Mind(box->ymin, box->ymax)); } PG_FUNCTION_INFO_V1(BOX3D_zmin); Datum BOX3D_zmin(PG_FUNCTION_ARGS) { BOX3D *box = (BOX3D *)PG_GETARG_POINTER(0); - PG_RETURN_FLOAT8(box->zmin); + PG_RETURN_FLOAT8(LWGEOM_Mind(box->zmin, box->zmax)); } PG_FUNCTION_INFO_V1(BOX3D_xmax); Datum BOX3D_xmax(PG_FUNCTION_ARGS) { BOX3D *box = (BOX3D *)PG_GETARG_POINTER(0); - PG_RETURN_FLOAT8(box->xmax); + PG_RETURN_FLOAT8(LWGEOM_Maxd(box->xmin, box->xmax)); } PG_FUNCTION_INFO_V1(BOX3D_ymax); Datum BOX3D_ymax(PG_FUNCTION_ARGS) { BOX3D *box = (BOX3D *)PG_GETARG_POINTER(0); - PG_RETURN_FLOAT8(box->ymax); + PG_RETURN_FLOAT8(LWGEOM_Maxd(box->ymin, box->ymax)); } PG_FUNCTION_INFO_V1(BOX3D_zmax); Datum BOX3D_zmax(PG_FUNCTION_ARGS) { BOX3D *box = (BOX3D *)PG_GETARG_POINTER(0); - PG_RETURN_FLOAT8(box->zmax); + PG_RETURN_FLOAT8(LWGEOM_Maxd(box->zmin, box->zmax)); }