ST_Endpoint

ST_Endpoint takes a linestring as an input parameter and returns the point that is the last point of the linestring. The resulting point is represented in the spatial reference system of the given linestring.

If the given linestring is null or is empty, then null is returned.

Syntax

Read syntax diagramSkip visual syntax diagramdb2gse.ST_EndPoint(linestring)

Parameter

linestring
A value of type ST_Linestring that represents the geometry from which the last point is returned.

Return type

db2gse.ST_Point

Example

The SELECT statement finds the endpoint of each of the geometries in the SAMPLE_LINES table.

SET CURRENT FUNCTION PATH = CURRENT FUNCTION PATH, db2gse
CREATE TABLE sample_lines(id INTEGER, line ST_Linestring)


INSERT INTO sample_lines VALUES
    (1, ST_LineString('linestring (10 10, 5 5, 0 0, 10 0, 5 5, 0 10)', 0) )

INSERT INTO sample_lines VALUES
    (2, ST_LineString('linestring z (0 0 4, 5 5 5, 10 10 6, 5 5 7)', 0) )


SELECT id, CAST(ST_AsText(ST_EndPoint(line)) as VARCHAR(50)) Endpoint
FROM   sample_lines

Results:

ID          ENDPOINT
----------- --------------------------------------------------
          1 POINT ( 0.00000000 10.00000000)
          2 POINT Z ( 5.00000000 5.00000000 7.00000000)