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
| Parameter | Type | Description |
|---|---|---|
WKT | text | A WKT string representing a GeometryCollection object. |
srid | integer | The 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_GeomCollFromTextperforms additional input validation, which makes it slower thanST_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 thanST_GeomCollFromTextbecause it does not perform GeometryCollection-specific input validation
该文章对您有帮助吗?