pgsql.cc 提供对 postgresql.org 官网内容的中文翻译,由 Pigsty 团队维护。
几何类型 point 、 box 、 lseg 、 line 、 path 、 polygon 和 circle 有一大套 原生支持的函数和操作符。
表 4.15. 几何操作符
| 操作符 | 描述 | 用法 |
|---|---|---|
| + | 平移 | box '((0,0),(1,1))' + point '(2.0,0)' |
| - | 平移 | box '((0,0),(1,1))' - point '(2.0,0)' |
| * | 缩放/旋转 | box '((0,0),(1,1))' * point '(2.0,0)' |
| / | 缩放/旋转 | box '((0,0),(2,2))' / point '(2.0,0)' |
| # | 交集 | '((1,-1),(-1,1))' # '((1,1),(-1,-1))' |
| # | 多边形中的点数 | # '((1,0),(0,1),(-1,0))' |
| ## | 最近邻近点 | point '(0,0)' ## lseg '((2,0),(0,2))' |
| && | 是否重叠?(有一个公共点即为真。) | box '((0,0),(1,1))' && box '((0,0),(2,2))' |
| &< | 重叠或在左边? | box '((0,0),(1,1))' &< box '((0,0),(2,2))' |
| &> | 重叠或在右边? | box '((0,0),(3,3))' &> box '((0,0),(2,2))' |
| <-> | 两者之间的距离 | circle '((0,0),1)' <-> circle '((5,0),1)' |
| << | 是否位于左侧? | circle '((0,0),1)' << circle '((5,0),1)' |
| <^ | 是否位于下方? | circle '((0,0),1)' <^ circle '((0,5),1)' |
| >> | 是否位于右侧? | circle '((5,0),1)' >> circle '((0,0),1)' |
| >^ | 是否位于上方? | circle '((0,5),1)' >^ circle '((0,0),1)' |
| ?# | 相交或重叠 | lseg '((-1,0),(1,0))' ?# box '((-2,-2),(2,2))'; |
| ?- | 是否水平? | point '(1,0)' ?- point '(0,0)' |
| ?-| | 是否互相垂直? | lseg '((0,0),(0,1))' ?-| lseg '((0,0),(1,0))' |
| @-@ | 长度或周长 | @-@ path '((0,0),(1,0))' |
| ?| | 是否竖直? | point '(0,1)' ?| point '(0,0)' |
| ?|| | 是否平行? | lseg '((-1,0),(1,0))' ?|| lseg '((-1,2),(1,2))' |
| @ | 包含于或位于其上 | point '(1,1)' @ circle '((0,0),2)' |
| @@ | 中心 | @@ circle '((0,0),10)' |
| ~= | 是否相同? | polygon '((0,0),(1,1))' ~= polygon '((1,1),(0,0))' |
表 4.16. 几何函数
| 函数 | 返回类型 | 描述 | 示例 |
|---|---|---|---|
| area (object) | double precision | 对象的面积 | area(box '((0,0),(1,1))') |
| box (box, box) | box | 交集矩形框 | box(box '((0,0),(1,1))',box '((0.5,0.5),(2,2))') |
| center (object) | point | 对象的中心 | center(box '((0,0),(1,2))') |
| diameter (circle) | double precision | 圆的直径 | diameter(circle '((0,0),2.0)') |
| height (box) | double precision | 矩形框的竖直尺寸 | height(box '((0,0),(1,1))') |
| isclosed (path) | boolean | 是否为闭合路径? | isclosed(path '((0,0),(1,1),(2,0))') |
| isopen (path) | boolean | 是否为开放路径? | isopen(path '[(0,0),(1,1),(2,0)]') |
| length (object) | double precision | 对象的长度 | length(path '((-1,0),(1,0))') |
| pclose (path) | path | 将路径转换为闭合路径 | popen(path '[(0,0),(1,1),(2,0)]') |
| npoint (path) | int4 | 点数 | npoints(path '[(0,0),(1,1),(2,0)]') |
| popen (path) | path | 把路径转换为开放路径 | popen(path '((0,0),(1,1),(2,0))') |
| radius (circle) | double precision | 圆的半径 | radius(circle '((0,0),2.0)') |
| width (box) | double precision | 水平尺寸 | width(box '((0,0),(1,1))') |
表 4.17. 几何类型转换函数
| 函数 | 返回类型 | 描述 | 示例 |
|---|---|---|---|
| box ( circle ) | box | 将圆转换为矩形框 | box(circle '((0,0),2.0)') |
| box ( point , point ) | box | 将点转换为矩形框 | box(point '(0,0)', point '(1,1)') |
| box ( polygon ) | box | 将多边形转换为矩形框 | box(polygon '((0,0),(1,1),(2,0))') |
| circle ( box ) | circle | 转换为圆 | circle(box '((0,0),(1,1))') |
| circle ( point , double precision ) | circle | 把点转换为圆 | circle(point '(0,0)', 2.0) |
| lseg ( box ) | lseg | 矩形框对角线转换为线段 | lseg(box '((-1,0),(1,0))') |
| lseg ( point , point ) | lseg | 由点构造线段 | lseg(point '(-1,0)', point '(1,0)') |
| path ( polygon ) | point | 将多边形转换为路径 | path(polygon '((0,0),(1,1),(2,0))') |
| point ( circle ) | point | 中心 | point(circle '((0,0),2.0)') |
| point ( lseg , lseg ) | point | 交集 | point(lseg '((-1,0),(1,0))', lseg '((-2,-2),(2,2))') |
| point ( polygon ) | point | 中心 | point(polygon '((0,0),(1,1),(2,0))') |
| polygon ( box ) | polygon | 12 点多边形 | polygon(box '((0,0),(1,1))') |
| polygon ( circle ) | polygon | 12 点多边形 | polygon(circle '((0,0),2.0)') |
polygon(npts, circle) |
polygon | npts 点多边形 |
polygon(12, circle '((0,0),2.0)') |
| polygon ( path ) | polygon | 将路径转换为多边形 | polygon(path '((0,0),(1,1),(2,0))') |
译文有误、术语不当或页面显示问题,请到译文仓库 pgsty/pgdoc 报告译文问题。 英文原文本身的问题,请在当前版本的对应页面向上游反馈;上游不再修订已结束维护的版本。