ST_Envelope takes a geometry object and returns its bounding box as a geometry.
Syntax
db2gse.ST_Envelope(g db2gse.ST_Geometry)
Return type
db2gse.ST_Geometry
Examples
The GEOTYPE column in the ENVELOPE_TEST table stores the name of the geometry subclass stored in the G1 geometry column.
CREATE TABLE ENVELOPE_TEST (geotype varchar(20), g1 db2gse.ST_Geometry)
The following INSERT statements insert each geometry subclass into the ENVELOPE_TEST table.
INSERT INTO ENVELOPE_TEST VALUES('Point', db2gse.ST_PointFromText('point (10.02 20.01)', db2gse.coordref()..srid(0))) INSERT INTO ENVELOPE_TEST VALUES ('Linestring', db2gse.ST_LineFromText('linestring (10.01 20.01, 10.01 30.01, 10.01 40.01)', db2gse.coordref()..srid(0))) INSERT INTO ENVELOPE_TEST VALUES('Linestring', db2gse.ST_LineFromText('linestring (10.02 20.01,10.32 23.98,11.92 25.64)', db2gse.coordref()..srid(0))) INSERT INTO ENVELOPE_TEST VALUES('Polygon', db2gse.ST_PolyFromText('polygon ((10.02 20.01,11.92 35.64,25.02 34.15, 19.15 33.94,10.02 20.01))', db2gse.coordref()..srid(0))) INSERT INTO ENVELOPE_TEST VALUES('Multipoint', db2gse.ST_MPointFromText('multipoint (10.02 20.01,10.32 23.98,11.92 25.64)', db2gse.coordref()..srid(0))) INSERT INTO ENVELOPE_TEST VALUES('Multilinestring', db2gse.ST_MLineFromText('multilinestring ((10.01 20.01,20.01 20.01,30.01 20.01), (30.01 20.01,40.01 20.01,50.01 20.01))', db2gse.coordref()..srid(0))) INSERT INTO ENVELOPE_TEST VALUES('Multilinestring', db2gse.ST_MLineFromText('multilinestring ((10.02 20.01,10.32 23.98,11.92 25.64), ( 9.55 23.75,15.36 30.11))', db2gse.coordref()..srid(0))) INSERT INTO ENVELOPE_TEST VALUES('Multipolygon', db2gse.ST_MPolyFromText('multipolygon (((10.02 20.01,11.92 35.64,25.02 34.15, 19.15 33.94,10.02 20.01)), ((51.71 21.73,73.36 27.04,71.52 32.87, 52.43 31.90,51.71 21.73)))', db2gse.coordref()..srid(0)))
The following SELECT statement lists the subclass name next to its envelope. Because the ST_Envelope function returns either a point, linestring, or polygon, its output is converted to text with the ST_AsText function. The CAST function converts the default varchar(4000) result of the ST_AsText function to a varchar(280).
SELECT GEOTYPE, CAST(db2gse.ST_AsText(db2gse.ST_Envelope(g1)) AS varchar(280)) "The envelope" FROM ENVELOPE_TEST
The following result set is returned.
GEOTYPE The envelope -------------------- ---------------------------------------------------------- Point POINT ( 10.02000000 20.01000000) Linestring LINESTRING ( 10.01000000 20.01000000, 10.01000000 40.01000000) Linestring POLYGON (( 10.02000000 20.01000000, 11.92000000 20.01000000, 11.92000000 25.64000000, 10.02000000 25.64000000, 10.02000000 20.01000000)) Polygon POLYGON (( 10.02000000 20.01000000, 25.02000000 20.01000000, 25.02000000 35.64000000, 10.02000000 35.64000000, 10.02000000 20.01000000)) Multipoint POLYGON (( 10.02000000 20.01000000, 11.92000000 20.01000000, 11.92000000 25.64000000, 10.02000000 25.64000000, 10.02000000 20.01000000)) Multilinestring LINESTRING ( 10.01000000 20.01000000, 50.01000000 20.01000000) Multilinestring POLYGON (( 9.55000000 20.01000000, 15.36000000 20.01000000, 15.36000000 30.11000000, 9.55000000 30.11000000, 9.55000000 20.01000000)) Multipolygon POLYGON (( 10.02000000 20.01000000, 73.36000000 20.01000000, 73.36000000 35.64000000, 10.02000000 35.64000000, 10.02000000 20.01000000)) 8 record(s) selected.