Geometric data types represent two-dimensional spatial objects. Table 8-16 shows the geometric types available in PostgreSQL. The most fundamental type, the point, forms the basis for all of the other types.
Table 8-16. Geometric Types
Name
Storage Size
Representation
Description
point
16 bytes
Point on the plane
(x,y)
line
32 bytes
Infinite line (not fully implemented)
((x1,y1),(x2,y2))
lseg
32 bytes
Finite line segment
((x1,y1),(x2,y2))
box
32 bytes
Rectangular box
((x1,y1),(x2,y2))
path
16+16n bytes
Closed path (similar to polygon)
((x1,y1),...)
path
16+16n bytes
Open path
[(x1,y1),...]
polygon
40+16n bytes
Polygon (similar to closed path)
((x1,y1),...)
circle
24 bytes
Circle
<(x,y),r> (center and radius)
A rich set of functions and operators is available to perform various geometric operations such as scaling, translation, rotation, and determining intersections. They are explained in Section 9.9.
where (x1,y1) and (x2,y2) are the opposite corners of the box.
Boxes are output using the first syntax. The corners are reordered on input to store the upper right corner, then the lower left corner. Other corners of the box can be entered, but the lower left and upper right corners are determined from the input and stored corners.
Paths are represented by connected sets of points. Paths can be open, where the first and last points in the set are not connected, and closed, where the first and last point are connected. The functions popen(p) and pclose(p) are supplied to force a path to be open or closed, and the functions isopen(p) and isclosed(p) are supplied to test for either type in an expression.
Values of type path are specified using the following syntax:
where the points are the end points of the line segments comprising the path. Square brackets ([]) indicate an open path, while parentheses (()) indicate a closed path.
Polygons are represented by sets of points. Polygons should probably be considered equivalent to closed paths, but are stored differently and have their own set of support routines.
Values of type polygon are specified using the following syntax:
Deliver First Class Web Sites: 101 Essential Checklists Want to learn how to make your web sites usable and accessible? Want to ensure that your sites meet current best practice, without spending hours trawling through incomprehensible specifications and recommendations from dozens of different books, research papers, and web sites? Want to make sure that the sites you build are "right the first time," requiring no costly redevelopments?