]> granicus.if.org Git - postgis/commitdiff
Add ST_LocateAlong support for multipoints too (completeness)
authorPaul Ramsey <pramsey@cleverelephant.ca>
Tue, 10 Jan 2012 23:22:18 +0000 (23:22 +0000)
committerPaul Ramsey <pramsey@cleverelephant.ca>
Tue, 10 Jan 2012 23:22:18 +0000 (23:22 +0000)
git-svn-id: http://svn.osgeo.org/postgis/trunk@8758 b70326c6-7e19-0410-871a-916f4a2858ee

liblwgeom/lwlinearreferencing.c
postgis/lwgeom_functions_lrs.c

index f3c698d0253d0c2e180485a41dda7e7df905812b..093fafbb1086090d3282f748d91ef06d8c3aa2a1 100644 (file)
@@ -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:
index ef7ff6409647c0241590fbf7f01ed5ef57754148..137b47633c5e933415930e526a8ec1fcb5d34e54 100644 (file)
@@ -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);