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
| Parameter | Description |
|---|---|
| WKT | The WKT string to use. Must represent a MultiLineString object. |
| srid | The 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_BdMPolyFromTextorST_BuildAreainstead.
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)该文章对您有帮助吗?