ST_GeomCollection function
Use the ST_GeomCollection function to construct a geometry collection.
- A well-known text representation
- A well-known binary representation
- An ESRI shape representation
- A representation in the geography markup language (GML)
An optional spatial reference system identifier can be specified to identify the spatial reference system that the resulting geometry collection is in.
If the well-known text representation, the well-known binary representation, the ESRI shape representation, or the GML representation is null, then null is returned.
Syntax
Parameter
- wkt
- A value of type CLOB(2G) that contains the well-known text representation of the resulting geometry collection.
- wkb
- A value of type BLOB(2G) that contains the well-known binary representation of the resulting geometry collection.
- shape
- A value of type BLOB(2G) that represents the ESRI shape representation of the resulting geometry collection.
- gml
- A value of type CLOB(2G) that represents the resulting geometry collection using the geography markup language (GML).
- srs_id
- A value of type INTEGER that identifies the spatial reference
system for the resulting geometry collection.
If the srs_id parameter is omitted, the spatial reference system with the numeric identifier 0 (zero) is used implicitly.
If srs_id does not identify a spatial reference system listed in the catalog view DB2GSE.ST_SPATIAL_REFERENCE_SYSTEMS, then an error is returned (SQLSTATE 38SU1).
Return type
db2gse.ST_GeomCollection
Notes
If the srs_id parameter is omitted, cast wkt and gml explicitly to the CLOB data type. Otherwise, the function call might be resolved to the function used to cast values from the reference type REF(ST_GeomCollection) to the ST_GeomCollection type.
Example
The following examples shows how to ensure that a function call to db2gse.ST_GeomCollection resolves to the correct function. Also, the lines that show results are reformatted for readability. The spacing in your results can vary according to your online display.
SET CURRENT FUNCTION PATH = CURRENT FUNCTION PATH, db2gse
CREATE TABLE sample_geomcollections(id INTEGER,
geometry ST_GEOMCOLLECTION)
INSERT INTO sample_geomcollections(id, geometry)
VALUES
(4001, ST_GeomCollection('multipoint(1 2, 4 3, 5 6)', 1) ),
(4002, ST_GeomCollection('multilinestring(
(33 2, 34 3, 35 6),
(28 4, 29 5, 31 8, 43 12),
(39 3, 37 4, 36 7))', 1) ),
(4003, ST_GeomCollection('multipolygon(((3 3, 4 6, 5 3, 3 3),
(8 24, 9 25, 1 28, 8 24),
(13 33, 7 36, 1 40, 10 43, 13 33)))', 1)),
(4004, ST_GeomCollection('<gml:MultiPoint srsName="EPSG:4269"
><gml:PointMember><gml:Point>
<gml:coord><gml:X>10</gml:X>
<gml:Y>20</gml:Y></gml: coord></gml:Point>
</gml:PointMember><gml:PointMember>
<gml:Point><gml:coord><gml:X>30</gml:X>
<gml:Y>40</gml:Y></gml:coord></gml:Point>
</gml:PointMember></gml:MultiPoint>', 1))
SELECT id, cast(geometry..ST_AsText AS varchar(350)) AS geomcollection
FROM sample_geomcollections
ID GEOMCOLLECTION
----------- -----------------------------------------------------------------
4001 MULTIPOINT ( 1.00000000 2.00000000, 4.00000000 3.00000000,
5.00000000 6.00000000)
4002 MULTILINESTRING (( 33.00000000 2.00000000, 34.00000000
3.00000000, 35.00000000 6.00000000),( 28.00000000 4.00000000,
29.00000000 5.00000000, 31.00000000 8.00000000, 43.00000000
12.00000000),(39.00000000 3.00000000, 37.00000000 4.00000000,
36.00000000 7.00000000))
4003 MULTIPOLYGON ((( 13.00000000 33.00000000, 10.00000000
43.00000000, 1.00000000 40.00000000, 7.00000000 36.00000000,
13.00000000 33.00000000)),(( 8.00000000 24.00000000, 9.00000000
25.00000000, 1.00000000 28.00000000, 8.00000000 24.00000000)),
(( 3.00000000 3.00000000,5.00000000 3.00000000, 4.00000000
6.00000000,3.00000000 3.00000000)))
4004 MULTIPOINT ( 10.00000000 20.00000000, 30.00000000
40.00000000)