ST_BdPolyFromText

更新时间:
复制 MD 格式

Constructs a polygon from one or more closed linestrings represented by a Well-Known Text (WKT) string.

Syntax

geometry ST_BdPolyFromText(text WKT, integer srid);

Parameters

ParameterDescription
WKTThe WKT string to use. Must represent a MultiLineString object.
sridThe spatial reference identifier (SRID) of the polygon.

Usage notes

  • If the WKT string does not represent a MultiLineString object, the function returns an error.

  • If the WKT string produces a MultiPolygon result, the function returns an error. In this case, use ST_BdMPolyFromText or ST_BuildArea instead.

Examples

Convert a MultiLineString WKT string to a polygon:

SELECT st_AsText(ST_BdPolyFromText(ST_AsText(ST_GeomFromText('MultiLineString((1 1,1 2),(2 2,1 1),(1 2,2 2))')),4326));

Output:

        st_astext
----------------------------
 POLYGON((1 1,1 2,2 2,1 1))
(1 row)