The ST_LocateBetween() function
The ST_LocateBetween() function takes an ST_Geometry object and two measure locations and returns an ST_Geometry that represents the set of disconnected paths between the two measure locations.
Syntax
ST_LocateBetween(g1 ST_Geometry, fm double precision, tm double precision)
Usage
If the source geometry dimension is 0, SE_LocateBetween() returns an ST_MultiPoint consisting of all points whose measures lie between the two source measures.
For source geometries whose dimension is greater than 0, SE_LocateBetween() returns an ST_MultiLineString if a path can be interpolated; otherwise, SE_LocateBetween() returns an ST_MultiPoint containing the point locations.
An empty point is returned whenever SE_LocateBetween() cannot interpolate a path or find a location between the measures.
SE_LocateBetween() performs an inclusive search of the geometries; therefore, the geometry measures must be greater than or equal to the from measure and less than or equal to the to measure.
Return type
ST_Geometry
Example
CREATE TABLE locatebetween_test (gid integer, g1 ST_Geometry);
INSERT INTO locatebetween_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 locatebetween_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, ST_LocateBetween(g1,6.5,7.5) Geometry
FROM locatebetween_test;
gid 1
geometry 1000 MULTILINESTRING M ((27.005 19.38 6.5, 30.19 18.47
7, 38.085 19.6
05 7.5),(27.4 22.135 6.5, 30.98 23.98 7, 36.95 24.98 7.5))
gid 2
geometry 1000 MULTIPOINT M (30.19 18.47 7, 30.98 23.98 7)