Geometric Functions

I l @ ve RuBoard

Somewhat unique among popular RDBMSs, PostgreSQL provides an extensive set of geometric-oriented functions. These functions and their associated operators are useful when performing calculations on spatial- related data sets.

AREA

Description

The AREA function computes the area occupied by a given object.

Input
 AREA(obj) 
Example
 AREA(box '((1,1),(3,3))')  4 

BOX

Description

There are several versions of the BOX function. Most perform conversions from other geometric types to the box data type. However, if the BOX function is passed two overlapping boxes, the result will be a box that represents where the intersection occurs.

Inputs

BOX(box,box) ”Perform an intersection.

BOX(circle) ” Convert a circle to a box.

BOX(point,point) ”Convert from points to a box.

BOX(polygon) ”Convert from a polygon to a box.

Examples
 BOX(box'((1,1),(3,3))', box'((2,2),(4,4))')  BOX'(3,3),(2,2)'  BOX(circle'(0,0),2')  BOX'(1.41, 1.41), (-1.41, -1.41)'  BOX(point'(0,0)', point'(1,1)')  BOX'(1,1),(0,0)'  BOX(polygon'(0,0),(1,1),(1,0)'  BOX'(1,1),(0,0)' 

CENTER

Description

The CENTER function returns the center point of the object passed to it.

Input
 CENTER(obj) 
Example
 CENTER(box'(0,0),(1,1)')  point'(.5,.5)' 

CIRCLE

Description

The CIRCLE function converts from box data types to a circle.

Input

CIRCLE(box) ”Convert from box to circle.

Example
 CIRCLE(box'(0,0),(1,1)')  CIRCLE'(.5,.5),.707016' 

DIAMETER

Description

The DIAMETER function returns the diameter of a supplied circle.

Input
 DIAMETER(circle) 
Example
 DIAMETER(circle'((0,0),2)')  4 

HEIGHT

Description

The HEIGHT function is used to compute the vertical height of a supplied box.

Input
 HEIGHT(box) 
Example
 HEIGHT(box'(0,0),(3,3)')  3 

ISCLOSED

Description

The ISCLOSED function returns a Boolean value that represents whether the supplied path is open or closed.

Input
 ISCLOSED(path) 
Example
 ISCLOSED(path'(0,0),(1,1),(1,0),(0,0)')  t 

ISOPEN

Description

The ISOPEN function returns a Boolean value that represents whether the supplied path is open or closed.

Input
 ISOPEN(path) 
Example
 ISOPEN(path'(0,0),(1,1),(1,0),(0,0)')  f 

LENGTH

Description

The LENGTH function returns the length of the supplied lseg .

Input
 LENGTH(lseg) 
Example
 LENGTH(lseg'(0,0),(1,1)'  1.41422135623731 
Notes

If the LENGTH function is passed a BOX data type, it will interpret the opposite corners of the box as the lseg to compute.

LSEG

Description

The LSEG function converts from either a box or a pair of points to an lseg data type.

Inputs
 LSEG(box)  LSEG(point,point) 
Example
 LSEG(box'(0,0),(1,1)')  LSEG'(1,1),(0,0)' 

NPOINTS

Description

The NPOINTS function returns the number of points that compose the supplied path.

Inputs
 NPOINTS(path)  NPOINTS(polygon) 
Example
 NPOINTS(path'(0,0),(1,1)')  2 

PATH

Description

The PATH function converts from a polygon to a path.

Input
 PATH(polygon) 
Example
 PATH(polygon'(0,0),(1,1),(1,0)')  PATH'((0,0),(1,1),(1,0))' 
Notes

Notice the closed representation "(" in the example provided. For more information on open or closed path representation, refer to the PATH data type.

PCLOSE

Description

The PCLOSE function converts a path to the closed representation of a path.

Input
 PCLOSE(path) 
Example
 PCLOSE(path'(0,0),(1,1),(1,0)')  PATH'((0,0),(1,1),(1,0))' 
Notes

See the PATH data type for more information on how paths are represented as being open or closed.

POINT

Description

The POINT function provides various geometric services, depending on the supplied object type.

Inputs

POINT(circle) ”Return the center of the supplied circle.

POINT(lseg, lseg) ”Return the intersection of the supplied lsegs.

POINT( polygon) ”Return the center of the supplied polygon.

Examples
 POINT(circle'((0,0),2)')  POINT'(0,0)'  POINT(polygon'(0,0),(1,1),(1,0)')  POINT'(.66),.33)' 

POLYGON

Description

The POLYGON function converts various geometric types to a polygon.

Inputs

POLYGON(box) ”Convert a box to a 12-point polygon.

POLYGON( circle) ”Convert a circle to a 12-point polygon.

POLYGON(n, circle) ”Convert a circle to an n-point polygon.

POLYGON(path) ”Convert a path to a polygon.

Examples
 POLYGON(4, circle'((0,0),4)')  POLYGON'(-4,0),(2.041,4),(4,-4.0827),(-6.12,-4)' 

POPEN

Description

The POPEN function converts a path to an open path.

Input
 POPEN(path) 
Example
 POPEN(path'(0,0),(1,1),(1,0)')  PATH'[(0,0),(1,1),(1,0)]' 
Notes

Notice the open representation of the returned path. For more information on open or closed path representations, refer to the PATH data type.

RADIUS

Description

The RADIUS function returns the radius of a supplied circle.

Input
 RADIUS(circle) 
Example
 RADIUS(circle'((0,0),2)')  2 

WIDTH

Description

The WIDTH function returns the horizontal size of a supplied box.

Input
 WIDTH(box) 
Example
 WIDTH(box'(0,0),(2,2)')  2 
I l @ ve RuBoard


PostgreSQL Essential Reference
PostgreSQL Essential Reference
ISBN: 0735711216
EAN: 2147483647
Year: 2001
Pages: 118
Authors: Barry Stinson

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net