]> granicus.if.org Git - postgis/commitdiff
Ensure ST_Line_Interpolate_Point always returns POINT (#2108)
authorSandro Santilli <strk@keybit.net>
Thu, 29 Nov 2012 18:30:48 +0000 (18:30 +0000)
committerSandro Santilli <strk@keybit.net>
Thu, 29 Nov 2012 18:30:48 +0000 (18:30 +0000)
git-svn-id: http://svn.osgeo.org/postgis/trunk@10757 b70326c6-7e19-0410-871a-916f4a2858ee

postgis/lwgeom_functions_analytic.c
regress/tickets.sql
regress/tickets_expected

index 94a76e180b1b2ae85606cfd306342956e8301318..868dc2cea21ffc584916f525715c6f404c7143bd 100644 (file)
@@ -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;
index d19f583023c3aff6cbab010d89a5c8d34879dc70..bb050b03f25a1c6489171bd4e5461e0af6b3a78a 100644 (file)
@@ -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
index d999778bb7e5a6231c47cec930f7c4c19d61ebce..e0f691fa23b992aaf783b3aa3e2cd2f86ccb07d6 100644 (file)
@@ -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