Last updated on
ST_ISCLOSED
Description
Determines whether a LINESTRING is closed. A LINESTRING is closed when its first and last points are exactly equal. This function does not use a distance tolerance.
Syntax
ST_ISCLOSED( <shape> )
Parameters
| Parameter | Description |
|---|---|
<shape> | An encoded geometry value (VARCHAR) returned by a spatial constructor such as ST_GeometryFromText or ST_LineFromText. Raw WKT text must first be converted with a constructor. |
Return Value
Returns a BOOLEAN value:
trueif the input is a validLINESTRINGwhose first and last points are exactly equal.falseif the input is a validLINESTRINGwhose first and last points are different.NULLif the input isNULL, is not aLINESTRING, or cannot be decoded as a valid geometry.
In SQL output, true is displayed as 1 and false as 0.
Example
Closed LineString
SELECT ST_IsClosed(
ST_GeometryFromText('LINESTRING(0 0, 1 1, 0 0)')
) AS is_closed;
+-----------+
| is_closed |
+-----------+
| 1 |
+-----------+
Open LineString
SELECT ST_IsClosed(
ST_GeometryFromText('LINESTRING(0 0, 1 1)')
) AS is_closed;
+-----------+
| is_closed |
+-----------+
| 0 |
+-----------+
NULL Input
SELECT ST_IsClosed(NULL) AS is_closed;
+-----------+
| is_closed |
+-----------+
| NULL |
+-----------+
Non-LineString Input
SELECT ST_IsClosed(ST_Point(0, 0)) AS is_closed;
+-----------+
| is_closed |
+-----------+
| NULL |
+-----------+