From: Sandro Santilli Date: Wed, 14 Dec 2011 14:37:18 +0000 (+0000) Subject: Return empty geoms snapped to a grid as immutated (#1089) X-Git-Tag: 2.0.0alpha1~465 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=ed841457ad164462307718a9ece55c898cf4d92b;p=postgis Return empty geoms snapped to a grid as immutated (#1089) Also introduces an "empty" regression test git-svn-id: http://svn.osgeo.org/postgis/trunk@8408 b70326c6-7e19-0410-871a-916f4a2858ee --- diff --git a/postgis/lwgeom_functions_analytic.c b/postgis/lwgeom_functions_analytic.c index 4354a7195..45682795b 100644 --- a/postgis/lwgeom_functions_analytic.c +++ b/postgis/lwgeom_functions_analytic.c @@ -530,8 +530,8 @@ Datum LWGEOM_snaptogrid(PG_FUNCTION_ARGS) /* Do not support gridding Z and M values for now */ grid.ipz=grid.ipm=grid.zsize=grid.msize=0; - /* Return input geometry if grid is null */ - if ( grid_isNull(&grid) ) + /* Return input geometry if grid is null or input geometry is empty */ + if ( grid_isNull(&grid) || gserialized_is_empty(in_geom) ) { PG_RETURN_POINTER(in_geom); } diff --git a/regress/Makefile.in b/regress/Makefile.in index 67e82b993..d0625da90 100644 --- a/regress/Makefile.in +++ b/regress/Makefile.in @@ -58,6 +58,7 @@ TESTS = \ snaptogrid \ summary \ affine \ + empty \ measures \ long_xact \ ctors \ diff --git a/regress/empty.sql b/regress/empty.sql new file mode 100644 index 000000000..d4e40ea70 --- /dev/null +++ b/regress/empty.sql @@ -0,0 +1,3 @@ +SELECT 'T1.1', ST_AsEWKT(ST_SnapToGrid('POINT EMPTY', 1)); +SELECT 'T1.2', ST_AsEWKT(ST_SnapToGrid('LINESTRING EMPTY', 1)); +SELECT 'T1.3', ST_AsEWKT(ST_SnapToGrid('SRID=4326;POLYGON EMPTY', 1)); diff --git a/regress/empty_expected b/regress/empty_expected new file mode 100644 index 000000000..7bca4a358 --- /dev/null +++ b/regress/empty_expected @@ -0,0 +1,3 @@ +T1.1|POINT EMPTY +T1.2|LINESTRING EMPTY +T1.3|SRID=4326;POLYGON EMPTY