ST_IsSimple

更新时间:
复制 MD 格式

Returns true if a geometry object has no self-intersections; returns false otherwise.

Syntax

boolean ST_IsSimple(geometry geomA);

Parameters

ParameterDescription
geomAThe geometry object to evaluate.

Description

This function supports 3D geometries and preserves Z coordinates.

Examples

Simple geometry (returns `true`)

The following LINESTRING forms a closed triangle. Each segment meets only at endpoints, so no self-intersection exists.

SELECT ST_IsSimple('LINESTRING(0 0,0 2,2 0,0 0)'::geometry);
 st_issimple
-------------
 t
(1 row)

Non-simple geometry (returns `false`)

The following LINESTRING retraces its path, meaning the line crosses itself at the start point. This creates a self-intersection that violates the simplicity condition.

SELECT ST_IsSimple('LINESTRING(0 0,0 2,0 0)'::geometry);
 st_issimple
-------------
 f
(1 row)