From: Sandro Santilli Date: Wed, 1 Jun 2011 12:31:58 +0000 (+0000) Subject: The box2d of an empty geometry is NULL, not a point. Closes ticket #938 and regress... X-Git-Tag: 2.0.0alpha1~1507 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=5c758a4fa9dd1edc585324f7ce273cca2cdfd539;p=postgis The box2d of an empty geometry is NULL, not a point. Closes ticket #938 and regress-tests it. git-svn-id: http://svn.osgeo.org/postgis/trunk@7307 b70326c6-7e19-0410-871a-916f4a2858ee --- diff --git a/postgis/lwgeom_box2dfloat4.c b/postgis/lwgeom_box2dfloat4.c index b330799d2..0fbca2808 100644 --- a/postgis/lwgeom_box2dfloat4.c +++ b/postgis/lwgeom_box2dfloat4.c @@ -143,6 +143,10 @@ Datum LWGEOM_to_BOX2DFLOAT4(PG_FUNCTION_ARGS) PG_LWGEOM *lwgeom = (PG_LWGEOM *)PG_DETOAST_DATUM(PG_GETARG_DATUM(0)); BOX2DFLOAT4 *result; + /* Cannot box empty! */ + if ( pglwgeom_is_empty(lwgeom) ) + PG_RETURN_NULL(); + result = palloc(sizeof(BOX2DFLOAT4)); if ( ! pglwgeom_getbox2d_p(lwgeom, result) ) { diff --git a/regress/tickets.sql b/regress/tickets.sql index adc228e4d..cade7fcb8 100644 --- a/regress/tickets.sql +++ b/regress/tickets.sql @@ -380,6 +380,8 @@ select '#884', id, ST_Within( ST_GeomFromText('POINT (-113.4 35.6)', -1), the_geom ) from foo; +select '#938', 'POLYGON EMPTY'::geometry::box2d; + DROP TABLE foo; -- Clean up diff --git a/regress/tickets_expected b/regress/tickets_expected index 59b2c86c3..607563d8c 100644 --- a/regress/tickets_expected +++ b/regress/tickets_expected @@ -110,3 +110,4 @@ ERROR: First argument must be a LINESTRING #834|GEOMETRYCOLLECTION(POINT(0 0 5),LINESTRING(10 10 5,10 0 5)) #884|1|f #884|2|t +#938|