Geometric types represent two-dimensional spatial objects. The most fundamental type, the point, forms the basis for all of the other types.
Tabla 17. Postgres Geometric Types
Geometric Type | Storage | Representation | Description |
---|---|---|---|
point | 16 bytes | (x,y) | Point in space |
line | 32 bytes | ((x1,y1),(x2,y2)) | Infinite line |
lseg | 32 bytes | ((x1,y1),(x2,y2)) | Finite line segment |
box | 32 bytes | ((x1,y1),(x2,y2)) | Rectangular box |
path | 4+32n bytes | ((x1,y1),...) | Closed path (similar to polygon) |
path | 4+32n bytes | [(x1,y1),...] | Open path |
polygon | 4+32n bytes | ((x1,y1),...) | Polygon (similar to closed path) |
circle | 24 bytes | <(x,y),r> | Circle (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.
Points are the fundamental two-dimensional building block for geometric types.
point is specified using the following syntax:
( x , y ) x , y where x is the x-axis coordinate as a floating point number y is the y-axis coordinate as a floating point number |
Line segments (lseg) are represented by pairs of points.
lseg is specified using the following syntax:
( ( x1 , y1 ) , ( x2 , y2 ) ) ( x1 , y1 ) , ( x2 , y2 ) x1 , y1 , x2 , y2 where (x1,y1) and (x2,y2) are the endpoints of the segment |
Boxes are represented by pairs of points which are opposite corners of the box.
box is specified using the following syntax:
( ( x1 , y1 ) , ( x2 , y2 ) ) ( x1 , y1 ) , ( x2 , y2 ) x1 , y1 , x2 , y2 where (x1,y1) and (x2,y2) are opposite 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. Functions popen(p) and pclose(p) are supplied to force a path to be open or closed, and functions isopen(p) and isclosed(p) are supplied to select either type in a query.
path is specified using the following syntax:
( ( x1 , y1 ) , ... , ( xn , yn ) ) [ ( x1 , y1 ) , ... , ( xn , yn ) ] ( x1 , y1 ) , ... , ( xn , yn ) ( x1 , y1 , ... , xn , yn ) x1 , y1 , ... , xn , yn where (x1,y1),...,(xn,yn) are points 1 through n a leading "[" indicates an open path a leading "(" indicates 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.
polygon is specified using the following syntax:
( ( x1 , y1 ) , ... , ( xn , yn ) ) ( x1 , y1 ) , ... , ( xn , yn ) ( x1 , y1 , ... , xn , yn ) x1 , y1 , ... , xn , yn where (x1,y1),...,(xn,yn) are points 1 through n |
Circles are represented by a center point and a radius.
circle is specified using the following syntax:
< ( x , y ) , r > ( ( x , y ) , r ) ( x , y ) , r x , y , r where (x,y) is the center of the circle r is the radius of the circle |