User's Guide and Reference

ST_Dimension

ST_Dimension takes a geometry object and returns its dimension.

Syntax

db2gse.ST_Dimension(g1 db2gse.ST_Geometry)

Return type

Integer

Examples

The DIMENSION_TEST table is created with the columns GEOTYPE and G1. The GEOTYPE column stores the name of the geometry subclass that is stored in the G1 geometry column.

CREATE TABLE DIMENSION_TEST (geotype varchar(20), g1 db2gse.ST_Geometry) 

The INSERT statements insert a sample subclass into the DIMENSION_TEST table.

INSERT INTO DIMENSION_TEST
VALUES('Point',
       db2gse.ST_PointFromText('point (10.02 20.01)', db2gse.coordref()..srid(0)))
 
INSERT INTO DIMENSION_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 DIMENSION_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 DIMENSION_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 DIMENSION_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 DIMENSION_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 stored in the GEOTYPE column with the dimension of that geotype.

SELECT geotype, db2gse.ST_Dimension(g1) "The dimension"
FROM DIMENSION_TEST

The following result set is returned.

GEOTYPE              The dimension
-------------------- -------------
ST_Point                    0
ST_Linestring               1
ST_Polygon                  2
ST_Multipoint               0
ST_Multilinestring          1
ST_Multipolygon             2
 
  6 record(s) selected.


[ Top of Page | Previous Page | Next Page ]