User's Guide and Reference

ST_GeometryFromText

ST_GeometryFromText takes a well-known text representation and a spatial reference system identity and returns a geometry object.

Syntax

db2gse.ST_GeometryFromText(geometryTaggedText Varchar(4000), cr db2gse.coordref)

Return type

db2gse.ST_Geometry

Examples

The GEOMETRY_TEST table contains the integer GID column, which uniquely identifies each row, and the G1 column, which stores the geometry.

CREATE TABLE GEOMETRY_TEST (gid smallint, g1 db2gse.ST_Geometry)

The INSERT statements inserts the data into the GID and G1 columns of the GEOMETRY_TEST table. The ST_GeometryFromText function converts the text representation of each geometry into its corresponding DB2 Spatial Extender instantiable subclass.

INSERT INTO GEOMETRY_TEST
VALUES(1, db2gse.ST_GeometryFromText('point (10.02 20.01)', db2gse.coordref()..srid(0)))
 
INSERT INTO GEOMETRY_TEST
VALUES (2,
        db2gse.ST_GeometryFromText('linestring (10.01 20.01, 10.01 30.01, 10.01 40.01)',
                         db2gse.coordref()..srid(0)))
 
INSERT INTO GEOMETRY_TEST
VALUES(3,
       db2gse.ST_GeometryFromText('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 GEOMETRY_TEST
VALUES(4,
       db2gse.ST_GeometryFromText('multipoint (10.02 20.01,10.32 23.98,11.92 25.64)',
                        db2gse.coordref()..srid(0)))
 
INSERT INTO GEOMETRY_TEST
VALUES(5,
       db2gse.ST_GeometryFromText('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 GEOMETRY_TEST
VALUES(6,
       db2gse.ST_GeometryFromText('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)))


[ Top of Page | Previous Page | Next Page ]