Checks whether a geometry object is valid and returns a structured row containing the validity status, the reason for invalidity, and the location of the invalid part. Use this function instead of calling ST_IsValid and ST_IsValidReason separately.
Syntax
validDetail ST_IsValidDetail(geometry geom);
validDetail ST_IsValidDetail(geometry geom, integer flags);Parameters
| Parameter | Description |
|---|---|
geom | The geometry object to validate. |
flags | A bitfield that controls validity semantics. If you specify this parameter to 1, the self-intersection ring forming a hole is considered to be valid. This is known as the Environmental Systems Research Institute (ESRI) flag. |
Return value
The function returns a validDetail row with three fields:
| Field | Type | Description |
|---|---|---|
valid | Boolean | true if the geometry is valid; false otherwise. |
reason | varchar | The reason for invalidity. |
location | geometry | The location of the invalid part of the geometry. |
Examples
The following example checks an invalid polygon with a self-intersection. The function returns valid=f and identifies the intersection point.
SELECT (g).valid, (g).reason, st_astext((g).location)
FROM (
SELECT ST_IsValidDetail('POLYGON((0 0,0 1,1 0,1 1,0 0))'::geometry) AS g
) AS t;Output:
valid | reason | st_astext
-------+-------------------+----------------
f | Self-intersection | POINT(0.5 0.5)
(1 row)该文章对您有帮助吗?