Constructs a GeometryCollection geometry 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
| Parameter | Description |
|---|---|
| WKT | The WKT string to parse. Must represent a GeometryCollection. |
| srid | The SRID of the resulting geometry. Defaults to 0 if omitted. |
Usage notes
If the WKT string does not represent a GeometryCollection, the function returns an error. If you cannot guarantee the input type, use
ST_GeomFromTextinstead — it accepts any geometry type and skips the additional validation that makes this function slower.
Examples
SELECT ST_AsText(ST_GeomCollFromText('GEOMETRYCOLLECTION(POINT(1 2),LINESTRING(3 4, 5 6))'));Output:
st_astext
----------------------------------------------------
GEOMETRYCOLLECTION(POINT(1 2),LINESTRING(3 4,5 6))
(1 row)该文章对您有帮助吗?