From: Sandro Santilli Date: Mon, 4 Jul 2011 15:34:50 +0000 (+0000) Subject: Have pglwgeom_getbox2d_p compute a bounding box when not cached. Fixes #1023. X-Git-Tag: 2.0.0alpha1~1259 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=20036d2151f0639b2df07649363a1aedbfe7db82;p=postgis Have pglwgeom_getbox2d_p compute a bounding box when not cached. Fixes #1023. git-svn-id: http://svn.osgeo.org/postgis/trunk@7583 b70326c6-7e19-0410-871a-916f4a2858ee --- diff --git a/postgis/lwgeom_pg.c b/postgis/lwgeom_pg.c index 0a48b71fd..0438633ac 100644 --- a/postgis/lwgeom_pg.c +++ b/postgis/lwgeom_pg.c @@ -533,7 +533,15 @@ int pglwgeom_ndims(const PG_LWGEOM *geom) int pglwgeom_getbox2d_p(const PG_LWGEOM *geom, BOX2DFLOAT4 *box) { #ifdef GSERIALIZED_ON - return gserialized_get_gbox_p(geom, box); + LWGEOM *lwgeom; + int ret = gserialized_get_gbox_p(geom, box); + if ( LW_FAILURE == ret ) { + /* See http://trac.osgeo.org/postgis/ticket/1023 */ + lwgeom = lwgeom_from_gserialized(geom); + ret = lwgeom_calculate_gbox(lwgeom, box); + lwgeom_free(lwgeom); + } + return ret; #else return getbox2d_p(SERIALIZED_FORM(geom), box); #endif