openGauss 几何类型转换函数

Agenfeng 秀才 2022-10-17 15:32:04
  • box(circle)

    描述:将圆转换成矩形

    返回类型:box

    示例:

    openGauss=# SELECT box(circle '((0,0),2.0)') AS RESULT;
                                      result                                   
    ---------------------------------------------------------------------------
     (1.41421356237309,1.41421356237309),(-1.41421356237309,-1.41421356237309)
    (1 row)
    
  • box(point, point)

    描述:将点转换成矩形

    返回类型:box

    示例:

    openGauss=# SELECT box(point '(0,0)', point '(1,1)') AS RESULT;
       result    
    -------------
     (1,1),(0,0)
    (1 row)
    
  • box(polygon)

    描述:将多边形转换成矩形

    返回类型:box

    示例:

    openGauss=# SELECT box(polygon '((0,0),(1,1),(2,0))') AS RESULT;
       result    
    -------------
     (2,1),(0,0)
    (1 row)
    
  • circle(box)

    描述:矩形转换成圆

    返回类型:circle

    示例:

    openGauss=# SELECT circle(box '((0,0),(1,1))') AS RESULT;
                result             
    -------------------------------
     <(0.5,0.5),0.707106781186548>
    (1 row)
    
  • circle(point, double precision)

    描述:将圆心和半径转换成圆

    返回类型:circle

    示例:

    openGauss=# SELECT circle(point '(0,0)', 2.0) AS RESULT;
      result   
    -----------
     <(0,0),2>
    (1 row)
    
  • circle(polygon)

    描述:将多边形转换成圆

    返回类型:circle

    示例:

    openGauss=# SELECT circle(polygon '((0,0),(1,1),(2,0))') AS RESULT;
                      result                   
    -------------------------------------------
     <(1,0.333333333333333),0.924950591148529>
    (1 row)
    
  • lseg(box)

    描述:矩形对角线转化成线段

    返回类型:lseg

    示例:

    openGauss=# SELECT lseg(box '((-1,0),(1,0))') AS RESULT;
         result     
    ----------------
     [(1,0),(-1,0)]
    (1 row)
    
  • lseg(point, point)

    描述:点转换成线段

    返回类型:lseg

    示例:

    openGauss=# SELECT lseg(point '(-1,0)', point '(1,0)') AS RESULT;
         result     
    ----------------
     [(-1,0),(1,0)]
    (1 row)
    
  • slope(point, point)

    描述:计算两个点构成直线的斜率

    返回类型: double

    示例:

    openGauss=# SELECT slope(point '(1,1)', point '(0,0)') AS RESULT;
     result
    --------
          1
    (1 row)
    
  • path(polygon)

    描述:多边形转换成路径

    返回类型:path

    示例:

    openGauss=# SELECT path(polygon '((0,0),(1,1),(2,0))') AS RESULT;
           result        
    ---------------------
     ((0,0),(1,1),(2,0))
    (1 row)
    
  • point(double precision, double precision)

    描述:节点

    返回类型:point

    示例:

    openGauss=# SELECT point(23.4, -44.5) AS RESULT;
        result    
    --------------
     (23.4,-44.5)
    (1 row)
    
  • point(box)

    描述:矩形的中心

    返回类型:point

    示例:

    openGauss=# SELECT point(box '((-1,0),(1,0))') AS RESULT;
     result 
    --------
     (0,0)
    (1 row)
    
  • point(circle)

    描述:圆心

    返回类型:point

    示例:

    openGauss=# SELECT point(circle '((0,0),2.0)') AS RESULT;
     result 
    --------
     (0,0)
    (1 row)
    
  • point(lseg)

    描述:线段的中心

    返回类型:point

    示例:

    openGauss=# SELECT point(lseg '((-1,0),(1,0))') AS RESULT;
     result 
    --------
     (0,0)
    (1 row)
    
  • point(polygon)

    描述:多边形的中心

    返回类型:point

    示例:

    openGauss=# SELECT point(polygon '((0,0),(1,1),(2,0))') AS RESULT;
            result         
    -----------------------
     (1,0.333333333333333)
    (1 row)
    
  • polygon(box)

    描述:矩形转换成4点多边形

    返回类型:polygon

    示例:

    openGauss=# SELECT polygon(box '((0,0),(1,1))') AS RESULT;
              result           
    ---------------------------
     ((0,0),(0,1),(1,1),(1,0))
    (1 row)
    
  • polygon(circle)

    描述:圆转换成12点多边形

    返回类型:polygon

    示例:

    openGauss=# SELECT polygon(circle '((0,0),2.0)') AS RESULT;
                                                                                                                                                    result                                                                                      
        
    -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
     ((-2,0),(-1.73205080756888,1),(-1,1.73205080756888),(-1.22464679914735e-16,2),(1,1.73205080756888),(1.73205080756888,1),(2,2.44929359829471e-16),(1.73205080756888,-0.999999999999999),(1,-1.73205080756888),(3.67394039744206e-16,-2),(-0.999999999999999,-1.73205080756888),(-1.73205080756888,-1))
    (1 row)
    
  • polygon(npts, circle)

    描述:圆转换成npts点多边形

    返回类型:polygon

    示例:

    openGauss=# SELECT polygon(12, circle '((0,0),2.0)') AS RESULT;
                                                                                                                                                    result                                                                                      
        
    -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
     ((-2,0),(-1.73205080756888,1),(-1,1.73205080756888),(-1.22464679914735e-16,2),(1,1.73205080756888),(1.73205080756888,1),(2,2.44929359829471e-16),(1.73205080756888,-0.999999999999999),(1,-1.73205080756888),(3.67394039744206e-16,-2),(-0.999999999999999,-1.73205080756888),(-1.73205080756888,-1))
    (1 row)
    
  • polygon(path)

    描述:路径转换成多边形

    返回类型:polygon

    示例:

    openGauss=# SELECT polygon(path '((0,0),(1,1),(2,0))') AS RESULT;
           result        
    ---------------------
     ((0,0),(1,1),(2,0))
    (1 row)
...全文
356 回复 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
回复
切换为时间正序
请发表友善的回复…
发表回复

80,050

社区成员

发帖
与我相关
我的任务
社区描述
汇集数据库的爱好者和关注者,大家共同学习、探索、分享数据库前沿知识和技术,像松鼠一样剥开科学的坚果;交流Gauss及其他数据库的使用心得和经验,互助解决问题,共建数据库技术交流圈。
数据库数据仓库 企业社区 北京·海淀区
社区管理员
  • Gauss松鼠会
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

欢迎大家同时关注Gauss松鼠会专家酷哥。

https://www.zhihu.com/people/ku-ge-78-98

试试用AI创作助手写篇文章吧