STV_IsValidReason

Determines if a spatial object is well formed or valid.

Determines if a spatial object is well formed or valid. If the object is not valid, STV_IsValidReason returns a string that explains where the invalidity occurs.

A polygon or multipolygon is valid if all of the following are true:

  • The polygon is closed; its start point is the same as its end point.

  • Its boundary is a set of linestrings.

  • The boundary does not touch or cross itself.

  • Any polygons in the interior that do not have more than one point touching the boundary of the exterior polygon.

If you pass an invalid object to a Vertica Place function, the function fails or returns incorrect results. To determine if a polygon is valid, first run ST_IsValid. ST_IsValid returns TRUE if the polygon is valid, FALSE otherwise.

Behavior type

Immutable

Syntax

STV_IsValidReason( g )

Arguments

g
Geospatial object to test for validity, value of type GEOMETRY or GEOGRAPHY (WGS84).

Returns

LONG VARCHAR

Supported data types

Data Type GEOMETRY GEOGRAPHY (Perfect Sphere) GEOGRAPHY (WGS84)
Point Yes No No
Multipoint Yes No No
Linestring Yes No No
Multilinestring Yes No No
Polygon Yes No Yes
Multipolygon Yes No No
GeometryCollection Yes No No

Examples

The following example shows how to use STV_IsValidReason.

Returns a string describing where the polygon is invalid:

=> SELECT STV_IsValidReason(ST_GeomFromText('POLYGON((1 3,3 2,1 1,
   3 0,1 0,1 3))'));
               STV_IsValidReason
-----------------------------------------------
 Ring Self-intersection at or near POINT (1 1)
(1 row)

See also

ST_IsValid