The ST_LocateAlong() function
The ST_LocateAlong() function takes a geometry object and a measure to return as an ST_MultiPoint the set of points found having that measure.
Syntax
ST_LocateAlong(g1 ST_Geometry, m1 double precision)
Usage
SE_LocateAlong() returns the location as an ST_MultiPoint.
If the source geometry's dimension is 0 (for ST_Point and ST_MultiPoint), only points with a matching measure value are returned as an ST_MultiPoint. However, for source geometries whose dimension is greater than 0, the location is interpolated. For example, if the requested measure value is 5.5 and the ST_LineString vertices have measures of 3, 4, 5, 6, and 7, an interpolated point that falls exactly halfway between the vertices with measure values 5 and 6 is returned.
Return type
ST_Geometry
Example
CREATE TABLE locatealong_test (gid integer,
g1 ST_Geometry);
INSERT INTO locatealong_test VALUES(
1,
ST_MLineFromText('multilinestring m ((10.29 19.23 5,23.82 20.29
6,30.19 18.47 7,45.98 20.74 8),(23.82 20.29 6,30.98 23.98 7,42.92
25.98 8))', 1000)
);
INSERT INTO locatealong_test VALUES(
2,
ST_MPointFromText('multipoint m (10.29 19.23 5,23.82 20.29
6,30.19 18.47 7,45.98 20.74 8,23.82 20.29 6,30.98 23.98 7,42.92
25.98 8)', 1000)
);
SELECT gid, SE_locatealong(g1,6.5) Geometry
FROM locatealong_test;
gid 1
geometry 1000 MULTIPOINT M (27.005 19.38 6.5, 27.4 22.135 6.5)
gid 2
geometry 1000 POINT M EMPTY
SELECT gid, SE_locatealong(g1,7) Geometry
FROM locatealong_test;
gid 1
geometry 1000 MULTIPOINT M (30.19 18.47 7, 30.98 23.98 7)
gid 2
geometry 1000 MULTIPOINT M (30.19 18.47 7, 30.98 23.98 7)