ST_EndPoint

更新时间:
复制 MD 格式

Returns the last point of a LineString geometry as a POINT. Returns NULL if the input is not a LineString.

Syntax

geometry ST_EndPoint(geometry g);

Parameters

ParameterDescription
gThe geometry object. Must be a LineString.

Usage notes

  • Returns NULL for any input that is not a LineString.

  • Preserves Z coordinates for 3D objects.

  • Supports circular strings and curves.

Examples

End point of a 2D LineString

SELECT ST_AsText(ST_EndPoint('LINESTRING(0 0,2 2)'::geometry));
 st_astext
------------
 POINT(2 2)
(1 row)

End point of a non-LineString is NULL

SELECT ST_EndPoint('POINT(1 1)'::geometry) IS NULL AS is_null;
 is_null
---------
 t
(1 row)

End point of a 3D LineString

SELECT ST_AsEWKT(ST_EndPoint('LINESTRING(1 1 2, 1 2 3, 0 0 5)'::geometry));
    st_asewkt
--------------
 POINT(0 0 5)
(1 row)

End point of a circular string

SELECT ST_AsText(ST_EndPoint('CIRCULARSTRING(5 2,-3 1.999999,-2 1,-4 2,6 3)'::geometry));
 st_astext
-----------
 POINT(6 3)
(1 row)

What's next