ST_StartPoint
ST_StartPoint takes a linestring as an input parameter and returns the point that is the first point of the linestring. The resulting point is represented in the spatial reference system of the given linestring.
This result is equivalent to the function call ST_PointN(linestring, 1).
If the given curve is null or is empty, then null is returned.
Syntax
Parameters
- linestring
- A value of type ST_LineString that represents the geometry from which the first point is returned.
Return type
db2gse.ST_Point
Example
In the following example, two linestrings
are added to the SAMPLE_LINES table. The first one is a linestring
with X and Y coordinates. The second one is a linestring with X, Y,
and Z coordinates. The ST_StartPoint function is used to return the
first point in each linestring.
SET CURRENT FUNCTION PATH = CURRENT FUNCTION PATH, db2gse
CREATE TABLE sample_lines (id INTEGER, line ST_LineString)
INSERT INTO sample_lines
VALUES (1, ST_LineString ('linestring
(10 10, 5 5, 0 0, 10 0, 5 5, 0 10)', 0))
INSERT INTO sample_lines
VALUES (1, ST_LineString ('linestring z
(0 0 4, 5 5 5, 10 10 6, 5 5 7, 0 0 8)', 0))
SELECT id, CAST( ST_AsText( ST_StartPoint( line ) ) AS VARCHAR(80))
START_POINT
FROM sample_lines
Results:
ID START_POINT
----------- --------------------------------------------
1 POINT ( 10.00000000 10.00000000)
2 POINT Z ( 0.00000000 0.00000000 4.00000000)
