ST_GeomCollFromText

更新时间:
复制 MD 格式

ST_GeomCollFromText constructs a GeometryCollection object from a Well-Known Text (WKT) string and an optional spatial reference identifier (SRID).

Syntax

geometry ST_GeomCollFromText(text WKT, integer srid);
geometry ST_GeomCollFromText(text WKT);

Parameters

ParameterTypeDescription
WKTtextA WKT string representing a GeometryCollection object.
sridintegerThe SRID of the GeometryCollection object. If omitted, defaults to 0.

Usage notes

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

If you cannot make sure that the WKT string represents a GeometryCollection object, do not use this function. ST_GeomCollFromText performs additional input validation, which makes it slower than ST_GeomFromText.

Example

SELECT ST_AsText(ST_GeomCollFromText('GEOMETRYCOLLECTION(POINT(1 2),LINESTRING(3 4, 5 6))'));
                     st_astext
----------------------------------------------------
 GEOMETRYCOLLECTION(POINT(1 2),LINESTRING(3 4,5 6))
(1 row)

See also

  • ST_GeomFromText — constructs any geometry type from a WKT string; faster than ST_GeomCollFromText because it does not perform GeometryCollection-specific input validation