ST_PointN — 返回几何图形中第一个线串或圆形线串中的第 N 个点。
geometry ST_PointN(geometry a_linestring, integer n);
返回几何图形中单个线串或圆形线串中的第 N 个点。负值从 LineString 末尾开始向后计数,因此 -1 是最后一个点。如果几何图形中没有线串,则返回 NULL。
|
|
|
Index is 1-based as for OGC specs since version 0.8.0. Backward indexing (negative index) is not in OGC. Previous versions implemented this as 0-based instead. |
|
|
|
如果要获取 MultiLineString 中每个 LineString 的第 N 个点,请与 ST_Dump 结合使用 |
此方法实现了 SQL 1.1 的 OGC 简单功能规范。
该方法实现了SQL/MM规范。 SQL-MM 3: 7.2.5, 7.3.5
该函数支持 3d 并且不会丢失 z-index。
此方法支持圆形字符串和曲线。
更改:2.0.0 不再适用于单个几何multilinestrings。 在旧版本的 PostGIS 中——单行 multilinestring可以与此函数很好地配合并返回起点。 在 2.0.0 中,它像任何其他 multilinestring一样只返回 NULL。
更改:2.3.0:负索引可用(-1 是最后一点)
This example extracts all POINT geometries from a LineString.
SELECT ST_PointN(
column1,
generate_series(1, ST_NPoints(column1))
)
FROM ( VALUES ('LINESTRING(0 0,1 1,2 2)'::geometry) ) AS foo;
POINT(0 0) POINT(1 1) POINT(2 2) (3 rows)
This example uses a CircularString.
SELECT ST_PointN('CIRCULARSTRING(1 2,3 2,1 2)', 2);
POINT(3 2)
The index is 1-based. A negative index counts backward from the end of the LineString.
SELECT f
FROM ST_GeomFromText('LINESTRING(0 0 0,1 1 1,2 2 2)') AS g
CROSS JOIN ST_PointN(g, -2) AS f;
POINT Z (1 1 1)