From: Paul Ramsey Date: Tue, 10 Jan 2012 23:22:18 +0000 (+0000) Subject: Add ST_LocateAlong support for multipoints too (completeness) X-Git-Tag: 2.0.0alpha1~118 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=559feb23d9edcdf8ba4f8fcce134dba8b2174854;p=postgis Add ST_LocateAlong support for multipoints too (completeness) git-svn-id: http://svn.osgeo.org/postgis/trunk@8758 b70326c6-7e19-0410-871a-916f4a2858ee --- diff --git a/liblwgeom/lwlinearreferencing.c b/liblwgeom/lwlinearreferencing.c index f3c698d02..093fafbb1 100644 --- a/liblwgeom/lwlinearreferencing.c +++ b/liblwgeom/lwlinearreferencing.c @@ -165,6 +165,28 @@ lwpoint_locate_along(const LWPOINT *lwpoint, double m, double offset) return lwpoint_construct_empty(lwgeom_get_srid(lwg), lwgeom_has_z(lwg), lwgeom_has_m(lwg)); } +static LWMPOINT* +lwmpoint_locate_along(const LWMPOINT *lwin, double m, double offset) +{ + LWGEOM *lwg = lwmpoint_as_lwgeom(lwin); + LWMPOINT *lwout = NULL; + int i; + + /* Construct return */ + lwout = lwmpoint_construct_empty(lwgeom_get_srid(lwg), lwgeom_has_z(lwg), lwgeom_has_m(lwg)); + + for ( i = 0; i < lwin->ngeoms; i++ ) + { + double point_m = lwpoint_get_m(lwin->geoms[i]); + if ( FP_EQUALS(m, point_m) ) + { + lwmpoint_add_lwpoint(lwout, lwpoint_clone(lwin->geoms[i])); + } + } + + return lwout; +} + LWGEOM* lwgeom_locate_along(const LWGEOM *lwin, double m, double offset) { @@ -177,6 +199,8 @@ lwgeom_locate_along(const LWGEOM *lwin, double m, double offset) { case POINTTYPE: return (LWGEOM*)lwpoint_locate_along((LWPOINT*)lwin, m, offset); + case MULTIPOINTTYPE: + return (LWGEOM*)lwmpoint_locate_along((LWMPOINT*)lwin, m, offset); case LINETYPE: return (LWGEOM*)lwline_locate_along((LWLINE*)lwin, m, offset); case MULTILINETYPE: diff --git a/postgis/lwgeom_functions_lrs.c b/postgis/lwgeom_functions_lrs.c index ef7ff6409..137b47633 100644 --- a/postgis/lwgeom_functions_lrs.c +++ b/postgis/lwgeom_functions_lrs.c @@ -573,7 +573,6 @@ Datum ST_LocateAlong(PG_FUNCTION_ARGS) double measure = PG_GETARG_FLOAT8(1); double offset = PG_GETARG_FLOAT8(2);; - lwnotice("offset %g",offset); lwin = lwgeom_from_gserialized(gin); lwout = lwgeom_locate_along(lwin, measure, offset); lwgeom_free(lwin);