ST_IsSimple()

Returns 1 when a geometry is simple and 0 when it has an anomalous self-intersection.

Syntax

ST_IsSimple(geom)

Aliases: none.

Arguments

geom is a GEOMETRY or GEOMETRY32 value.

Return Value

Returns BOOL; NULL input returns NULL.

Usage Notes

  • A crossing or backtracking LINESTRING is not simple.

Examples

DROP DATABASE IF EXISTS geo_is_simple_demo;
CREATE DATABASE geo_is_simple_demo;
USE geo_is_simple_demo;

SELECT ST_IsSimple(ST_GeomFromText('LINESTRING(0 0, 1 0, 2 0)')) AS simple_line,
       ST_IsSimple(ST_GeomFromText('LINESTRING(0 0, 2 2, 0 2, 2 0)')) AS crossing_line;

DROP DATABASE geo_is_simple_demo;

See Also

ST_IsValid(), ST_Validate().