The ST_IsSimple() function

The ST_IsSimple() function returns t (TRUE) if the geometry object is simple; otherwise, it returns f (FALSE). Properties of geometries are described in ids_spat_036.html.

Syntax

ST_IsSimple (g1 ST_Geometry)

Return type

BOOLEAN

Example

The table issimple_test is created with two columns. The pid column is a SMALLINT containing the unique identifier for each row. The g1 ST_Geometry column stores the simple and nonsimple geometry samples:
CREATE TABLE issimple_test (pid smallint,
                            g1  ST_Geometry);
The following INSERT statements insert two records into the issimple_test table. The first is a simple linestring because it does not intersect its interior. The second is non-simple because it does intersect its interior:
INSERT INTO issimple_test VALUES(
   1,
   ST_LineFromText('linestring (10 10, 20 20, 30 30)',1000)
);

INSERT INTO issimple_test VALUES(
   2,
   ST_LineFromText('linestring (10 10,20 20,20 30,10 30,10 20,20 10)',1000)
);
The query returns the results of the ST_IsSimple() function. The first record returns t because the linestring is simple, while the second record returns f because the linestring is not simple:
SELECT pid, ST_IsSimple(g1) Is_it_simple 
   FROM issimple_test;

   pid is_it_simple 

     1            t
     2            f