The ST_Polygon constructs a polygon from a given input.
If the polygon is constructed from a linestring and the given linestring is null, then null is returned. If the given linestring is empty, then an empty polygon is returned. If the polygon is constructed from its well-known text representation, its well-known binary representation, its shape representation, or its GML representation, and if the representation is null, then null is returned.
This function can also be called as a method for the following cases only: ST_Polygon(linestring) and ST_Polygon(linestring, srs_id).
>>-db2gse.ST_Polygon--(--+-linestring-+--+-----------+--)------>< +-wkt--------+ '-,--srs_id-' +-wkb--------+ +-shape------+ '-gml--------'
If the polygon is constructed from a given linestring parameter and the srs_id parameter is omitted, then the spatial reference system from linestring is used implicitly. Otherwise, if the srs_id parameter is omitted, the spatial reference system with the numeric identifier 0 (zero) is used.
If srs_id does not identify a spatial reference system listed in the catalog view DB2GSE.ST_SPATIAL_REFERENCE_SYSTEMS, then an exception condition is raised (SQLSTATE 38SU1).
db2gse.ST_Polygon
In the following example, the lines of results have been reformatted for readability. The spacing in your results will vary according to your online display.
SET CURRENT FUNCTION PATH = CURRENT FUNCTION PATH, db2gse
CREATE TABLE sample_polys (id INTEGER, geometry ST_Polygon)
INSERT INTO sample_polys
VALUES (1100,
ST_Polygon (ST_LineString ('linestring
(10 20, 10 40, 20 30, 10 20)',1), 1))
INSERT INTO sample_polys
VALUES (1101,
ST_Polygon ('polygon
((110 120, 110 140, 120 130, 110 120))', 1))
INSERT INTO sample_polys
VALUES (1102,
ST_Polygon ('polygon
((110 120, 110 140, 130 140, 130 120, 110 120),
(115 125, 115 135, 125 135, 125 135, 115 125))', 1))
The following SELECT statement returns the polygons that
were recorded in the table: SELECT id, CAST( ST_AsText( geometry ) AS VARCHAR(120) ) POLYGONS
FROM sample_polys
Results: ID POLYGONS
------- ----------------------------------------------------------------
1110 POLYGON (( 10.00000000 20.00000000, 20.00000000 30.00000000
10.00000000 40.00000000, 10.00000000 20.00000000))
1101 POLYGON (( 110.00000000 120.00000000, 120.00000000 130.00000000
110.00000000 140.00000000, 110.00000000 120.00000000))
1102 POLYGON (( 110.00000000 120.00000000, 130.00000000 120.00000000
130.00000000 140.00000000, 110.00000000 140.00000000
110.00000000 120.00000000),
( 115.00000000 125.00000000, 115.00000000 135.00000000
125.00000000 135.00000000, 125.00000000 135.00000000
115.00000000 125.00000000))