云数据库 GAUSSDB-几何函数和操作符:几何函数

时间:2024-01-23 20:08:30

几何函数

  • area(object)

    描述:计算图形的面积。

    返回类型:double precision

    示例:

    1
    2
    3
    4
    5
    openGauss=# SELECT area(box '((0,0),(1,1))') AS RESULT;
     result 
    --------
          1
    (1 row)
    
  • center(object)

    描述:计算图形的中心。

    返回类型:point

    示例:

    1
    2
    3
    4
    5
    openGauss=# SELECT center(box '((0,0),(1,2))') AS RESULT;
     result  
    ---------
     (0.5,1)
    (1 row)
    
  • diameter(circle)

    描述:计算圆的直径。

    返回类型:double precision

    示例:

    1
    2
    3
    4
    5
    openGauss=# SELECT diameter(circle '((0,0),2.0)') AS RESULT;
     result 
    --------
          4
    (1 row)
    
  • height(box)

    描述:矩形的竖直高度。

    返回类型:double precision

    示例:

    1
    2
    3
    4
    5
    openGauss=# SELECT height(box '((0,0),(1,1))') AS RESULT;
     result 
    --------
          1
    (1 row)
    
  • isclosed(path)

    描述:图形是否为闭合路径。

    返回类型:Boolean

    示例:

    1
    2
    3
    4
    5
    openGauss=# SELECT isclosed(path '((0,0),(1,1),(2,0))') AS RESULT;
     result 
    --------
     t
    (1 row)
    
  • isopen(path)

    描述:图形是否为开放路径。

    返回类型:Boolean

    示例:

    1
    2
    3
    4
    5
    openGauss=# SELECT isopen(path '[(0,0),(1,1),(2,0)]') AS RESULT;
     result 
    --------
     t
    (1 row)
    
  • length(object)

    描述:计算图形的长度。

    返回类型:double precision

    示例:

    1
    2
    3
    4
    5
    openGauss=# SELECT length(path '((-1,0),(1,0))') AS RESULT;
     result 
    --------
          4
    (1 row)
    
  • npoints(path)

    描述:计算路径的顶点数。

    返回类型:int

    示例:

    1
    2
    3
    4
    5
    openGauss=# SELECT npoints(path '[(0,0),(1,1),(2,0)]') AS RESULT;
     result 
    --------
          3
    (1 row)
    
  • npoints(polygon)

    描述:计算多边形的顶点数。

    返回类型:int

    示例:

    1
    2
    3
    4
    5
    openGauss=# SELECT npoints(polygon '((1,1),(0,0))') AS RESULT;
     result 
    --------
          2
    (1 row)
    
  • pclose(path)

    描述:把路径转换为闭合路径。

    返回类型:path

    示例:

    1
    2
    3
    4
    5
    openGauss=# SELECT pclose(path '[(0,0),(1,1),(2,0)]') AS RESULT;
           result        
    ---------------------
     ((0,0),(1,1),(2,0))
    (1 row)
    
  • popen(path)

    描述:把路径转换为开放路径。

    返回类型:path

    示例:

    1
    2
    3
    4
    5
    openGauss=# SELECT popen(path '((0,0),(1,1),(2,0))') AS RESULT;
           result        
    ---------------------
     [(0,0),(1,1),(2,0)]
    (1 row)
    
  • radius(circle)

    描述:计算圆的半径。

    返回类型:double precision

    示例:

    1
    2
    3
    4
    5
    openGauss=# SELECT radius(circle '((0,0),2.0)') AS RESULT;
     result 
    --------
          2
    (1 row)
    
  • width(box)

    描述:计算矩形的水平尺寸。

    返回类型:double precision

    示例:

    1
    2
    3
    4
    5
    openGauss=# SELECT width(box '((0,0),(1,1))') AS RESULT;
     result 
    --------
          1
    (1 row)
    
support.huaweicloud.com/centralized-devg-v2-gaussdb/devg_03_0391.html