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
| Parameter | Description |
|---|---|
g | The geometry object. Must be a LineString. |
Usage notes
Returns
NULLfor any input that is not aLineString.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
ST_StartPoint: Returns the first point of a
LineString.ST_PointN: Returns the Nth point of a
LineString.
该文章对您有帮助吗?