top of page
CerebroSQL

MySQL: 

ST_ISCLOSED

ST_IsClosed(ls)

For a LineString value ls, ST_IsClosed() returns 1 if ls is closed
(that is, its ST_StartPoint() and ST_EndPoint() values are the same).

For a MultiLineString value ls, ST_IsClosed() returns 1 if ls is closed
(that is, the ST_StartPoint() and ST_EndPoint() values are the same for
each LineString in ls).

ST_IsClosed() returns 0 if ls is not closed, and NULL if ls is NULL.

ST_IsClosed() handles its arguments as described in the introduction to
this section, with this exception:

o If the geometry has an SRID value for a geographic spatial reference
system (SRS), an ER_NOT_IMPLEMENTED_FOR_GEOGRAPHIC_SRS
(https://dev.mysql.com/doc/mysql-errors/8.0/en/server-error-reference
.html#error_er_not_implemented_for_geographic_srs) error occurs.

URL: https://dev.mysql.com/doc/refman/8.0/en/gis-linestring-property-functions.html

Example

mysql> SET @ls1 = 'LineString(1 1,2 2,3 3,2 2)';
mysql> SET @ls2 = 'LineString(1 1,2 2,3 3,1 1)';

mysql> SELECT ST_IsClosed(ST_GeomFromText(@ls1));
+------------------------------------+
| ST_IsClosed(ST_GeomFromText(@ls1)) |
+------------------------------------+
| 0 |
+------------------------------------+

mysql> SELECT ST_IsClosed(ST_GeomFromText(@ls2));
+------------------------------------+
| ST_IsClosed(ST_GeomFromText(@ls2)) |
+------------------------------------+
| 1 |
+------------------------------------+

mysql> SET @ls3 = 'MultiLineString((1 1,2 2,3 3),(4 4,5 5))';

mysql> SELECT ST_IsClosed(ST_GeomFromText(@ls3));
+------------------------------------+
| ST_IsClosed(ST_GeomFromText(@ls3)) |
+------------------------------------+
| 0 |
+------------------------------------+

bottom of page