ST_PointN
定义
ST_PointN 采用 ST_LineString 和整型索引,并返回 ST_LineString 的路径中作为第 n 个折点的点。
语法
Oracle 和 PostgreSQL
sde.st_pointn (line1 sde.st_linestring, index integer)
SQLite
st_pointn (line1 st_linestring, index int32)
返回类型
ST_Point
示例
使用唯一识别各行的 gid 列和 ln1 ST_LineString 列创建 pointn_test 表。INSERT 语句插入两个线串值。第一个线串没有 z 坐标和度量值,而第二个线串具有这两者。
SELECT 查询使用 ST_PointN 和 ST_AsText 函数返回每个线串第二个折点的熟知文本。
Oracle
CREATE TABLE pointn_test (
 gid integer,
 ln1 sde.st_geometry
);
INSERT INTO POINTN_TEST VALUES (
 1,
 sde.st_linefromtext ('linestring (10.02 20.01, 23.73 21.92, 30.10 40.23)', 4326)
);
INSERT INTO POINTN_TEST VALUES (
 2,
 sde.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)', 4326)
);
SELECT gid, sde.st_astext (sde.st_pointn (ln1, 2)) The_2ndvertex
 FROM POINTN_TEST;
GID The_2ndvertex
1   POINT (23.73 21.92)
2   POINT ZM (23.73 21.92 6.5 7.1)
PostgreSQL
CREATE TABLE pointn_test (
 gid serial,
 ln1 sde.st_geometry
);
INSERT INTO pointn_test (ln1) VALUES (
 sde.st_linestring ('linestring (10.02 20.01, 23.73 21.92, 30.10 40.23)', 4326)
);
INSERT INTO pointn_test (ln1) VALUES (
 sde.st_linestring ('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)', 4326)
);
SELECT gid, sde.st_astext (sde.st_pointn (ln1, 2)) 
 AS The_2ndvertex
 FROM pointn_test;
gid the_2ndvertex
1   POINT (23.73 21.92)
2   POINT ZM (23.73 21.92 6.5 7.1)
SQLite
CREATE TABLE pointn_test (
 gid integer primary key autoincrement not null
);
SELECT AddGeometryColumn(
 NULL,
 'pointn_test',
 'ln1',
 4326,
 'linestringzm',
 'xyzm',
 'null'
);
INSERT INTO pointn_test (ln1) VALUES (
 st_linestring ('linestring (10.02 20.01, 23.73 21.92, 30.10 40.23)', 4326)
);
INSERT INTO pointn_test (ln1) VALUES (
 st_linestring ('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)', 4326)
);
SELECT gid, st_astext (st_pointn (ln1, 2)) 
 AS "Second Vertex"
 FROM pointn_test;
gid  Second Vertex
1   POINT ( 23.73000000 21.92000000)
2   POINT ZM ( 23.73000000 21.92000000 6.50000000 7.10000000)
相关主题
5/25/2014