ST_IsSimple function

The ST_IsSimple function takes a geometry as an input parameter and returns 1 if the specified geometry is simple. Otherwise, 0 (zero) is returned.

Points, surfaces, and multisurfaces are always simple. A curve is simple if it does not pass through the same point twice; a multipoint is simple if it does not contain two equal points; and a multicurve is simple if all of its curves are simple and the only intersections occur at points that are on the boundary of the curves in the multicurve.

If the specified geometry is empty, then 1 is returned. If it is null, null is returned.

Syntax

Read syntax diagramSkip visual syntax diagramST_IsSimple(geometry)

Parameter

geometry
A value of type ST_Geometry or one of its subtypes that represents the geometry to be tested.

Return type

INTEGER

Examples

In this example, several geometries are created and checked if they are simple. The geometry with an ID of 4 is not considered simple because it contains more than one point that is the same. The geometry with an ID of 6 is not considered simple because the linestring crosses over itself.

CREATE TABLE sample_geoms (id INTEGER, geometry ST_Geometry)

INSERT INTO sample_geoms VALUES
       (1, ST_Geometry('point EMPTY' ,0))

INSERT INTO sample_geoms VALUES
       (2, ST_Geometry('point (21 33)' ,0))

INSERT INTO sample_geoms VALUES
       (3, ST_Geometry('multipoint(10 10, 20 20, 30 30)' ,0))

INSERT INTO sample_geoms VALUES
       (4, ST_Geometry('multipoint(10 10, 20 20, 30 30, 20 20)' ,0))

INSERT INTO sample_geoms VALUES
       (5, ST_Geometry('linestring(60 60, 70 60, 70 70)' ,0))

INSERT INTO sample_geoms VALUES
       (6, ST_Geometry('linestring(20 20, 30 30, 30 20, 20 30  )' ,0))

INSERT INTO sample_geoms VALUES
       (7, ST_Geometry('polygon((40 40, 50 40, 50 50, 40 40  ))' ,0))

SELECT id, ST_IsSimple(geometry) Is_Simple
FROM sample_geoms

Results:

ID          IS_SIMPLE
----------- -----------
          1           1
          2           1
          3           1
          4           0
          5           1
          6           0
          7           1