This page in other versions: Unsupported versions: 6.5

Geometric Functions

The geometric types point, box, lseg, line, path, polygon, and circle have a large set of native support functions.

Table 5-6. Geometric Functions

Function Returns Description Example
area(box) float8 area of box area('((0,0),(1,1))'::box)
area(circle) float8 area of circle area('((0,0),2.0)'::circle)
box(box,box) box boxes to intersection box box('((0,0),(1,1))','((0.5,0.5),(2,2))')
center(box) point center of object center('((0,0),(1,2))'::box)
center(circle) point center of object center('((0,0),2.0)'::circle)
diameter(circle) float8 diameter of circle diameter('((0,0),2.0)'::circle)
height(box) float8 vertical size of box height('((0,0),(1,1))'::box)
isclosed(path) bool a closed path? isclosed('((0,0),(1,1),(2,0))'::path)
isopen(path) bool an open path? isopen('[(0,0),(1,1),(2,0)]'::path)
length(lseg) float8 length of line segment length('((-1,0),(1,0))'::lseg)
length(path) float8 length of path length('((0,0),(1,1),(2,0))'::path)
pclose(path) path convert path to closed popen('[(0,0),(1,1),(2,0)]'::path)
point(lseg,lseg) point intersection point('((-1,0),(1,0))'::lseg,'((-2,-2),(2,2))'::lseg)
points(path) int4 number of points points('[(0,0),(1,1),(2,0)]'::path)
popen(path) path convert path to open popen('((0,0),(1,1),(2,0))'::path)
radius(circle) float8 radius of circle radius('((0,0),2.0)'::circle)
width(box) float8 horizontal size width('((0,0),(1,1))'::box)

Table 5-7. Geometric Type Conversion Functions

Function Returns Description Example
box(circle) box convert circle to box box('((0,0),2.0)'::circle)
box(point,point) box convert points to box box('(0,0)'::point,'(1,1)'::point)
box(polygon) box convert polygon to box box('((0,0),(1,1),(2,0))'::polygon)
circle(box) circle convert to circle circle('((0,0),(1,1))'::box)
circle(point,float8) circle convert to circle circle('(0,0)'::point,2.0)
lseg(box) lseg convert diagonal to lseg lseg('((-1,0),(1,0))'::box)
lseg(point,point) lseg convert to lseg lseg('(-1,0)'::point,'(1,0)'::point)
path(polygon) point convert to path path('((0,0),(1,1),(2,0))'::polygon)
point(circle) point convert to point (center) point('((0,0),2.0)'::circle)
point(lseg,lseg) point convert to point (intersection) point('((-1,0),(1,0))'::lseg, '((-2,-2),(2,2))'::lseg)
point(polygon) point center of polygon point('((0,0),(1,1),(2,0))'::polygon)
polygon(box) polygon convert to polygon with 12 points polygon('((0,0),(1,1))'::box)
polygon(circle) polygon convert to 12-point polygon polygon('((0,0),2.0)'::circle)
polygon(npts,circle) polygon convert to npts polygon polygon(12,'((0,0),2.0)'::circle)
polygon(path) polygon convert to polygon polygon('((0,0),(1,1),(2,0))'::path)

Table 5-8. Geometric Upgrade Functions

Function Returns Description Example
isoldpath(path) path test path for pre-v6.1 form isoldpath('(1,3,0,0,1,1,2,0)'::path)
revertpoly(polygon) polygon convert pre-v6.1 polygon revertpoly('((0,0),(1,1),(2,0))'::polygon)
upgradepath(path) path convert pre-v6.1 path upgradepath('(1,3,0,0,1,1,2,0)'::path)
upgradepoly(polygon) polygon convert pre-v6.1 polygon upgradepoly('(0,1,2,0,1,0)'::polygon)
Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group