Constructs a MultiPolygon geometry from one or more closed linestrings, polygons, or MultiLineStrings represented as a Well-Known Text (WKT) string.
Syntax
geometry ST_BdMPolyFromText(text WKT, integer srid)Parameters
| Parameter | Description |
|---|---|
WKT | The WKT string. Must represent a MultiLineString object. |
srid | The spatial reference identifier (SRID) of the returned MultiPolygon. |
Usage notes
If the WKT string does not represent a MultiLineString, the function returns an error.
The function always returns a MultiPolygon, even when the input describes a single polygon. To build a polygon from a single closed linestring, use ST_BdPolyFromText instead.
Example
Convert a WKT MultiLineString into a MultiPolygon.
SELECT st_AsText(ST_BdMPolyFromText('MultiLineString((1 1,1 2),(2 2,1 1),(1 2,2 2),(-1 -1,-1 -2),(-2 -2,-1 -1),(-1 -2,-2 -2))',4326));Output:
st_astext
---------------------------------------------------------------
MULTIPOLYGON(((-1 -1,-1 -2,-2 -2,-1 -1)),((1 1,1 2,2 2,1 1)))
(1 row)该文章对您有帮助吗?