ST_LineString
The ST_LineString function has two variations.
In the first variation, ST_LineString constructs a linestring from a well-known text representation, a well-known binary representation, an ESRI shape representation, or a Geography Markup Language (GML) representation. A spatial reference system identifier can be provided optionally to identify the spatial reference system that the resulting linestring is in.
In the second variation, ST_LineString takes ST_Geometry as an input parameter and casts the output type to ST_LineString. If the given geometry is null, then null is returned.
Syntax for variation 1
Variation 1
Parameters for variation 1
- wkt
- A value of type CLOB(8M) that contains the well-known text representation of the resulting linestring. If the well-known text representation is null, then null is returned.
- wkb
- A value of type BLOB(4M) that contains the well-known binary representation of the resulting linestring. If the well-known binary representation is null, then null is returned.
- shape
- A value of type BLOB(4M) that contains the shape representation of the resulting linestring. If the shape representation is null, then null is returned.
- gml
- A value of type CLOB(8M) that contains the GML representation of the geometry. If the GML representation is null, then null is returned.
- srs_id
- A value of type INTEGER that identifies the spatial reference
system for the resulting linestring.
If srs_id does not identify a spatial reference system listed in the catalog view DB2GSE.ST_SPATIAL_REFERENCE_SYSTEMS, an error is returned (SQLSTATE 38SU1).
Return type for variation 1
db2gse.ST_LineString
Syntax for variation 2
Variation 2
Parameter for variation 2
- geometry
- A value of type ST_Geometry.
Return type for variation 2
ST_LineString
Examples
The following example uses the ST_LineString function to create linestrings from WKT and GML representations and inserts two rows into the sample_lines table with an ID and line in spatial reference system 1.
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_LineString('linestring(850 250, 850 850)', 1) ),
(1111, ST_LineString('<gml:LineString srsName=";EPSG:4269";><gml:coord>
<gml:X>90</gml:X><gml:Y>90</gml:Y>
<gml:coord><gml:coord><gml:X>100</gml:X>
<gml:Y>100</gml:Y><gml:coord>
<gml:LineString>', 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 ( 90.00000000 90.00000000, 100.00000000 100.00000000)