st_pointn.sql 1.0 KB

12345678910111213141516171819202122232425262728
  1. -- The pointn_test table is created with the gid column,
  2. -- which uniquely identifies each row, and the ln1 ST_LineString column.
  3. CREATE TABLE pointn_test (gid integer,
  4. ln1 ST_LineString);
  5. -- The INSERT statements insert two linestring values.
  6. -- The first linestring doesn't have Z coordinates or measures,
  7. -- while the second linestring has both.
  8. INSERT INTO pointn_test VALUES(
  9. 1,
  10. ST_LineFromText('linestring (10.02 20.01,23.73 21.92,30.10 40.23)',1000)
  11. );
  12. INSERT INTO pointn_test VALUES(
  13. 2,
  14. 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)',1000)
  15. );
  16. -- The query lists the gid column and the second vertex of each linestring.
  17. -- The first row results in a ST_Point without a Z coordinate or measure,
  18. -- while the second row results in a ST_Point with a Z coordinate and a
  19. -- measure. The ST_PointN function will also include a Z coordinate or
  20. -- measure value if they exist in the source linestring.
  21. SELECT gid, ST_PointN(ln1,2) the_2nd_vertex
  22. FROM pointn_test;