ST_LineFromText function

The ST_LineFromText function takes a well-known text representation of a linestring and, optionally, a spatial reference system identifier as input parameters and returns the corresponding linestring.

If the given well-known text representation is null, then null is returned.

The preferred version for this functionality is ST_LineString.

Syntax

Read syntax diagramSkip visual syntax diagramdb2gse.ST_LineFromText(wkt,srs_id)

Parameter

wkt
A value of type CLOB(2G) that contains the well-known text representation of the resulting linestring.
srs_id
A value of type INTEGER that identifies the spatial reference system for the resulting linestring.

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 error is returned (SQLSTATE 38SU1).

Return type

db2gse.ST_LineString

Example

In the following examples, the lines of results have been reformatted for readability. The spacing in your results will vary according to your online display.

The following code uses the ST_LineFromText function to create and insert a line from a well-known text (WKT) line representation. The rows are inserted into the SAMPLE_LINES table with an ID and a line value in spatial reference system 1 in WKT representation.

SET CURRENT FUNCTION PATH = CURRENT FUNCTION PATH, db2gse 

CREATE TABLE sample_lines(id SMALLINT, geometry ST_LineString)

INSERT INTO sample_lines(id, geometry)
VALUES
    (1110, ST_LineFromText('linestring(850 250, 850 850)', 1) ),
    (1111, ST_LineFromText('linestring empty', 1) )

SELECT id, cast(geometry..ST_AsText AS varchar(75)) AS linestring
FROM   sample_lines

Results:

ID     LINESTRING
------ ------------------------------------------------------------------
  1110 LINESTRING ( 850.00000000 250.00000000, 850.00000000 850.00000000)
  1111 LINESTRING EMPTY