Checks whether a geometry object is in a valid format and returns details about any validity violations.
Syntax
boolean ST_IsValid(geometry g);
boolean ST_IsValid(geometry g, integer flags);Parameters
| Parameter | Description |
|---|---|
g | The geometry object to validate. |
flags | A 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) flag. |
Description
When the input geometry object is invalid, ST_IsValid returns false and emits a NOTICE message describing the violation, such as the location of a self-intersection.
Examples
The following example checks a self-intersecting polygon. Because the polygon's edges cross each other, the geometry is invalid and the function returns f (false).
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)该文章对您有帮助吗?