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.
sridThe spatial reference identifier (SRID) of the MultiPolygon.

Usage notes

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

  • The function returns a MultiPolygon, even when the input describes a single Polygon.

To construct a MultiPolygon from a single Polygon, use ST_BdPolyFromText instead.

Examples

Convert a WKT string representing a 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));
                           st_astext
---------------------------------------------------------------
 MULTIPOLYGON(((-1 -2,-2 -2,-1 -1,-1 -2)),((1 2,2 2,1 1,1 2)))
(1 row)