From: Sandro Santilli Date: Thu, 29 Nov 2012 18:30:48 +0000 (+0000) Subject: Ensure ST_Line_Interpolate_Point always returns POINT (#2108) X-Git-Tag: 2.1.0beta2~347 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=a1df0584c32b0e608d490ca2ef3154ced67baf34;p=postgis Ensure ST_Line_Interpolate_Point always returns POINT (#2108) git-svn-id: http://svn.osgeo.org/postgis/trunk@10757 b70326c6-7e19-0410-871a-916f4a2858ee --- diff --git a/postgis/lwgeom_functions_analytic.c b/postgis/lwgeom_functions_analytic.c index 94a76e180..868dc2cea 100644 --- a/postgis/lwgeom_functions_analytic.c +++ b/postgis/lwgeom_functions_analytic.c @@ -80,6 +80,7 @@ PG_FUNCTION_INFO_V1(LWGEOM_line_interpolate_point); Datum LWGEOM_line_interpolate_point(PG_FUNCTION_ARGS) { GSERIALIZED *gser = (GSERIALIZED *)PG_DETOAST_DATUM(PG_GETARG_DATUM(0)); + GSERIALIZED *result; double distance = PG_GETARG_FLOAT8(1); LWLINE *line; LWGEOM *geom; @@ -101,6 +102,15 @@ Datum LWGEOM_line_interpolate_point(PG_FUNCTION_ARGS) PG_RETURN_NULL(); } + /* Empty.InterpolatePoint == Point Empty */ + if ( gserialized_is_empty(gser) ) + { + geom = lwpoint_construct_empty(gserialized_get_srid(gser), gserialized_has_z(gser), gserialized_has_m(gser)); + result = geometry_serialize(lwpoint_as_lwgeom(geom)); + lwgeom_free(geom); + PG_RETURN_POINTER(result); + } + geom = lwgeom_from_gserialized(gser); line = lwgeom_as_lwline(geom); ipa = line->points; diff --git a/regress/tickets.sql b/regress/tickets.sql index d19f58302..bb050b03f 100644 --- a/regress/tickets.sql +++ b/regress/tickets.sql @@ -788,6 +788,7 @@ FROM (SELECT 'POLYGON((1 1 1, 5 1 1,5 5 1, 1 5 1,1 1 1))'::geometry as a, 'LINES ) as foo; -- 2112 -- End +SELECT '#2108', ST_AsEWKT(ST_Line_Interpolate_Point('SRID=3395;LINESTRING M EMPTY'::geometry, 0.5)); SELECT '#2117', ST_AsEWKT(ST_PointOnSurface('SRID=3395;MULTIPOLYGON M EMPTY'::geometry)); -- Clean up diff --git a/regress/tickets_expected b/regress/tickets_expected index d999778bb..e0f691fa2 100644 --- a/regress/tickets_expected +++ b/regress/tickets_expected @@ -240,4 +240,5 @@ ERROR: invalid GML representation #2048|3|f|f #2112a|0|LINESTRING(2.5 2.5 1,2.5 2.5 1) #2112b|1|LINESTRING(1 1 1,1 0 1) +#2108|SRID=3395;POINTM EMPTY #2117|SRID=3395;POINTM EMPTY