ST_MLineFromText function

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

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

The recommended function for achieving the same result is the ST_MultiLineString function. It is recommended because of its flexibility: ST_MultiLineString takes additional forms of input as well as the well-known text representation.

Syntax

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

Parameters

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

If the srs_id parameter is omitted, the spatial reference system with the numeric identifier 0 (zero) is used.

If the specified 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).

Return type

db2gse.ST_MultiLineString

Example

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.

This example illustrates how ST_MLineFromText can be used to create and insert a multilinestring from its well-known text representation. The record that is inserted has ID = 1110, and the geometry is a multilinestring in spatial reference system 1. The multilinestring is in the well-known text representation of a multilinestring. The X and Y coordinates for this geometry are:
  • Line 1: (33, 2) (34, 3) (35, 6)
  • Line 2: (28, 4) (29, 5) (31, 8) (43, 12)
  • Line 3: (39, 3) (37, 4) (36, 7)

SET CURRENT FUNCTION PATH = CURRENT FUNCTION PATH, db2gse
CREATE TABLE sample_mlines (id INTEGER, geometry ST_MultiLineString)

INSERT INTO sample_mlines
  VALUES (1110, ST_MLineFromText ('multilinestring ( (33 2, 34 3, 35 6),
                                                   (28 4, 29 5, 31 8, 43 12),
                                                   (39 3, 37 4, 36 7) )', 1) )
The following SELECT statement returns the multilinestring that was recorded in the table:

SELECT id, CAST( ST_AsText( geometry ) AS VARCHAR(280) ) MULTI_LINE_STRING
  FROM sample_mlines
  WHERE id = 1110
Results:

ID         MULTI_LINE_STRING
---------- --------------------------------------------------------------------
      1110 MULTILINESTRING (( 33.00000000 2.00000000, 34.00000000 3.00000000,
              35.00000000 6.00000000),
                            ( 28.00000000 4.00000000, 29.00000000 5.00000000,
              31.00000000 8.0000000, 43.00000000 12.00000000),
                            ( 39.00000000 3.00000000, 37.00000000 4.00000000,
              36.00000000 7.00000000 ))