ST_IsSimple

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

Points, polygons, and multipolygons are always simple. A linestring 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 multilinestring is simple if all of its linestrings are simple and the only intersections occur at points that are on the boundary of the linestrings in the multilinestring.

If the given geometry is empty, then 1 is returned. If the geometry is null, null is returned.

Syntax

Read syntax diagramSkip visual syntax diagramdb2gse.ST_IsSimple(geometry)

Parameter

geometry
A value of one of the seven distinct spatial data types that represents the geometry that is 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.

SET CURRENT FUNCTION PATH = CURRENT FUNCTION PATH, db2gse
CREATE TABLE sample_geoms (id INTEGER, geometry ST_Geometry)

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

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

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

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

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

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

INSERT INTO sample_geoms VALUES
       (7, ST_Geometry(ST_Polygon('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