Returns a text description of whether a geometry object is valid. If the geometry is invalid, the description states the reason.
Syntax
boolean ST_IsValidReason(geometry geomA);
boolean ST_IsValidReason(geometry geomA, integer flags);Parameters
| Parameter | Description |
|---|---|
geomA | The geometry object to validate. |
flags | An integer bitfield that controls validation behavior. Set to 1 to treat self-intersecting rings that form holes as valid. This is the Environmental Systems Research Institute (ESRI) standard. |
Description
ST_IsValidReason returns a text string describing the validity of a geometry object. For invalid geometries, it returns the reason of the first validity problem detected.
Use ST_IsValidReason together with ST_IsValid to generate detailed validity reports — ST_IsValid identifies whether a geometry is invalid, and ST_IsValidReason explains why.
Examples
The following example checks a self-intersecting polygon. The polygon (0 0, 0 1, 1 0, 1 1, 0 0) forms a bowtie shape where the edges cross at point (0.5, 0.5).
SELECT ST_IsValidReason('POLYGON((0 0,0 1,1 0,1 1,0 0))'::geometry);Output:
st_isvalidreason
----------------------------
Self-intersection[0.5 0.5]
(1 row)该文章对您有帮助吗?