Constructs a polygon from one or more closed linestrings represented as a Well-Known Text (WKT) string.
Syntax
geometry ST_BdPolyFromText(text WKT, integer srid);Parameters
| Parameter | Description |
|---|---|
| WKT | The WKT string that you want to specify. |
| srid | The spatial reference identifier (SRID) of the resulting polygon. |
Usage notes
Note: The WKT string must represent a MultiLineString. Passing any other geometry type returns an error.
Note: If the WKT string produces a MultiPolygon, the function returns an error. To build a MultiPolygon, useST_BdMPolyFromText. For a more flexible approach that handles both single polygons and MultiPolygons, useST_BuildArea.
Example
Convert a MultiLineString WKT string into 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)该文章对您有帮助吗?