top of page
CerebroSQL

MySQL: 

ST_ISVALID

ST_IsValid(g)

Returns 1 if the argument is geometrically valid, 0 if the argument is
not geometrically valid. Geometry validity is defined by the OGC
specification.

The only valid empty geometry is represented in the form of an empty
geometry collection value. ST_IsValid() returns 1 in this case. MySQL
does not support GIS EMPTY values such as POINT EMPTY.

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

o If the geometry has a geographic SRS with a longitude or latitude
that is out of range, an error occurs:

o If a longitude argument is not in the range (?180, 180], an
ER_GEOMETRY_PARAM_LONGITUDE_OUT_OF_RANGE
(https://dev.mysql.com/doc/mysql-errors/8.0/en/server-error-referen
ce.html#error_er_geometry_param_longitude_out_of_range) error
occurs (ER_LONGITUDE_OUT_OF_RANGE
(https://dev.mysql.com/doc/mysql-errors/8.0/en/server-error-referen
ce.html#error_er_longitude_out_of_range) prior to MySQL 8.0.12).

o If a latitude argument is not in the range [?90, 90], an
ER_GEOMETRY_PARAM_LATITUDE_OUT_OF_RANGE
(https://dev.mysql.com/doc/mysql-errors/8.0/en/server-error-referen
ce.html#error_er_geometry_param_latitude_out_of_range) error occurs
(ER_LATITUDE_OUT_OF_RANGE
(https://dev.mysql.com/doc/mysql-errors/8.0/en/server-error-referen
ce.html#error_er_latitude_out_of_range) prior to MySQL 8.0.12).

Ranges shown are in degrees. If an SRS uses another unit, the range
uses the corresponding values in its unit. The exact range limits
deviate slightly due to floating-point arithmetic.

URL: https://dev.mysql.com/doc/refman/8.0/en/spatial-convenience-functions.html

Example

mysql> SET @ls1 = ST_GeomFromText('LINESTRING(0 0,-0.00 0,0.0 0)');
mysql> SET @ls2 = ST_GeomFromText('LINESTRING(0 0, 1 1)');
mysql> SELECT ST_IsValid(@ls1);
+------------------+
| ST_IsValid(@ls1) |
+------------------+
| 0 |
+------------------+
mysql> SELECT ST_IsValid(@ls2);
+------------------+
| ST_IsValid(@ls2) |
+------------------+
| 1 |
+------------------+

bottom of page