-- The locatealong_test table is created with two columns:
-- the gid column uniquely identifies each row,
-- and the g1 ST_Geometry column stores sample geometry.

CREATE TABLE locatealong_test (gid integer,
                               g1  ST_Geometry);

-- The INSERT statements insert two rows. The first is
-- a multilinestring, while the second is a multipoint.

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)
);

-- In this query the SE_LocateAlong function finds points whose
-- measure is 6.5. The first row returns a ST_MultiPoint containing two
-- points. However, the second row returns an empty point.
-- For linear features (geometry with a dimension greater than 0),
-- SE_LocateAlong can interpolate the point, but for multipoints
-- the target measure must match exactly.

SELECT gid, SE_locatealong(g1,6.5) Geometry
   FROM locatealong_test;

-- In this query the SE_LocateAlong function returns a ST_MultiPoint
-- for both rows.  The target measure of 7 matches measures in both
-- the ST_MultiLineString and ST_MultiPoint source data.

SELECT gid, SE_locatealong(g1,7) Geometry
   FROM locatealong_test;
