Name

ST_SetEndM — Sets the M coordinate of the last point of a LineString, CircularLineString, or NURBSCurve.

Synopsis

geometry ST_SetEndM(geometry geom, float8 m);

Description

Returns a copy of the input LINESTRING, CIRCULARLINESTRING, or NURBSCURVE geometry with the M coordinate of the last point set to the specified value. If the input geometry does not have an M dimension, it will be added. Returns NULL if the input is not a LINESTRING, CIRCULARLINESTRING, or NURBSCURVE.

This method supports Circular Strings and Curves.

Examples

Set end M value of a LineString

Code
SELECT ST_SetEndM('LINESTRING M(0 0 10,1 1 20,2 0 30)'::geometry, 999);
Output
LINESTRING M (0 0 10,1 1 20,2 0 999)
Figure
Geometry figure for visual-st-setendm-01

Add M dimension and set end M value

Code
SELECT ST_SetEndM('LINESTRING(0 0,1 1,2 0)'::geometry, 75);
Output
LINESTRING M (0 0 0,1 1 0,2 0 75)
Figure
Geometry figure for visual-st-setendm-02

Set end M value of a CircularString

Code
SELECT ST_SetEndM('CIRCULARSTRING M(0 0 5,1 1 10,2 0 15)'::geometry, 88);
Output
CIRCULARSTRING M (0 0 5,1 1 10,2 0 88)
Figure
Geometry figure for visual-st-setendm-03

Set end M value of a NURBSCurve

Code
SELECT ST_SetEndM('NURBSCURVE M(2, (0 0 100, 1 1 200, 2 0 300))'::geometry, 999);
Output
NURBSCURVE M (DEGREE 2,CONTROLPOINTS M (NURBSPOINT(WEIGHTEDPOINT M (0 0 100),WEIGHT 1), NURBSPOINT(WEIGHTEDPOINT M (1 1 200),WEIGHT 1), NURBSPOINT(WEIGHTEDPOINT M (2 0 999),WEIGHT 1)),KNOTS (KNOT(0,3), KNOT(1,3)))
Figure
Geometry figure for visual-st-setendm-04