User's Guide and Reference

ST_PointN

ST_PointN takes a linestring and an integer index and returns a point that is the nth vertice in the linestring's path.

Syntax

db2gse.ST_PointN(l db2gse.ST_Curve, n Integer)

Return type

db2gse.ST_Point

Examples

The following CREATE TABLE statement creates the POINTN_TEST table, which has two columns: the GID column, which uniquely identifies each row, and the LN1 linestring column.

CREATE TABLE POINTN_TEST (gid integer, ln1 db2gse.ST_LineString) 

The following INSERT statements insert two linestring values. The first linestring does not have Z coordinates or measures, while the second linestring has both.

INSERT INTO POINTN_TEST VALUES(1,
db2gse.ST_LineFromText('linestring (10.02 20.01,23.73 21.92,30.10 40.23)',
db2gse.coordref()..srid(0)))
 
INSERT INTO POINTN_TEST VALUES(2,
db2gse.ST_LineFromText('linestring  zm (10.02 20.01 5.0 7.0,23.73 21.92 6.5 7.1,30.10
40.23 6.9 7.2)', db2gse.coordref()..srid(0))) 

The following SELECT statement and the corresponding result set lists the GID column and the second vertice of each linestring. The first row results in a point without a Z coordinate or measure, while the second row results in a point with a Z coordinate and a measure. The ST_PointN function returns points with a Z coordinate or a measure if they exist in the source linestring.

SELECT gid, CAST(db2gse.ST_AsText(db2gse.ST_PointN(ln1,2)) AS varchar(60)) 
"The 2nd vertice"
FROM POINTN_TEST
 
GID         The 2nd vertice
----------- ------------------------------------------------------------
          1 POINT ( 23.73000000 21.92000000)
          2 POINT ZM ( 23.73000000 21.92000000 7.00000000 7.10000000)
 
  2 record(s) selected. 


[ Top of Page | Previous Page | Next Page ]