Skip to content

PostgreSQL npoints() 函数 ​

PostgreSQL npoints() 函数计算指定的路径或多边形上的点的数量并返回。

npoints() 语法 ​

这是 PostgreSQL npoints() 函数的语法:

sql
npoints(geometric_type) -> integer

参数 ​

  • geometric_type

    必需的。 它可以是一个 多边形 polygon 或一个路径 path。

返回值 ​

PostgreSQL npoints() 函数返回通过参数指定的路径或多边形上的点的数量。

npoints() 示例 ​

下面的语句示例展示了如何使用 PostgreSQL npoints() 计算一个开放路径 path '[(2,0),(0,0)]' 上的点的数量。

sql
SELECT npoints(path '[(2,0),(0,0)]');
bash
 npoints
---------
       2

下面的语句示例展示了如何使用 PostgreSQL npoints() 计算一个闭合路径 path '((2,0),(0,0))' 上的点的数量。

sql
SELECT npoints(path '((2,0),(0,0))');
bash
 npoints
--------
      2

下面的语句示例展示了如何使用 PostgreSQL npoints() 计算一个多边形 polygon '(0,0),(2,2),(4,0)' 上的点的数量。

sql
SELECT npoints(polygon '(0,0),(2,2),(4,0)');
bash
 npoints
---------
       3