ST_IsValid

更新时间:
复制 MD 格式

Checks whether a geometry object is in a valid format.

Syntax

boolean ST_IsValid(geometry g);
boolean ST_IsValid(geometry g, integer flags);

Parameters

ParameterTypeDescription
ggeometryThe geometry object to check.
flagsintegerA bitfield that controls validity rules. Set to 1 to treat a self-intersection ring forming a hole as valid. This is the Environmental Systems Research Institute (ESRI) validity flag.

Description

Returns true if the geometry object is valid, or false if it is not. When the geometry is invalid, the function also outputs a notice that describes the reason for invalidity, such as the location of a self-intersection.

Examples

SELECT ST_IsValid('POLYGON((0 0,0 1,1 0,1 1,0 0))'::geometry);
NOTICE:  Self-intersection at or near point 0.5 0.5
 st_isvalid
------------
 f
(1 row)