ST_BdMPolyFromText

更新时间:
复制 MD 格式

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

ParameterDescription
WKTThe WKT string. Must represent a MultiLineString object.
sridThe 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)