]> granicus.if.org Git - postgis/commitdiff
Have pglwgeom_getbox2d_p compute a bounding box when not cached. Fixes #1023.
authorSandro Santilli <strk@keybit.net>
Mon, 4 Jul 2011 15:34:50 +0000 (15:34 +0000)
committerSandro Santilli <strk@keybit.net>
Mon, 4 Jul 2011 15:34:50 +0000 (15:34 +0000)
git-svn-id: http://svn.osgeo.org/postgis/trunk@7583 b70326c6-7e19-0410-871a-916f4a2858ee

postgis/lwgeom_pg.c

index 0a48b71fdc2ba1e5153d195b2b4b91268025687a..0438633acb0c14400896666b2fe13b60fba39e2a 100644 (file)
@@ -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