12 Geometric data types represent two-dimensional spatial objects.
13 Table 8.20 shows the geometric types available in PostgreSQL.
15 Table 8.20. Geometric Types
16 Name Storage Size Description Representation
17 point 16 bytes Point on a plane (x,y)
18 line 24 bytes Infinite line {A,B,C}
19 lseg 32 bytes Finite line segment [(x1,y1),(x2,y2)]
20 box 32 bytes Rectangular box (x1,y1),(x2,y2)
21 path 16+16n bytes Closed path (similar to polygon) ((x1,y1),...)
22 path 16+16n bytes Open path [(x1,y1),...]
23 polygon 40+16n bytes Polygon (similar to closed path) ((x1,y1),...)
24 circle 24 bytes Circle <(x,y),r> (center point and radius)
26 In all these types, the individual coordinates are stored as double
27 precision (float8) numbers.
29 A rich set of functions and operators is available to perform various
30 geometric operations such as scaling, translation, rotation, and
31 determining intersections. They are explained in Section 9.11.
35 Points are the fundamental two-dimensional building block for geometric
36 types. Values of type point are specified using either of the following
41 where x and y are the respective coordinates, as floating-point
44 Points are output using the first syntax.
48 Lines are represented by the linear equation Ax + By + C = 0, where A
49 and B are not both zero. Values of type line are input and output in
53 Alternatively, any of the following forms can be used for input:
54 [ ( x1 , y1 ) , ( x2 , y2 ) ]
55 ( ( x1 , y1 ) , ( x2 , y2 ) )
56 ( x1 , y1 ) , ( x2 , y2 )
59 where (x1,y1) and (x2,y2) are two different points on the line.
61 8.8.3. Line Segments #
63 Line segments are represented by pairs of points that are the endpoints
64 of the segment. Values of type lseg are specified using any of the
66 [ ( x1 , y1 ) , ( x2 , y2 ) ]
67 ( ( x1 , y1 ) , ( x2 , y2 ) )
68 ( x1 , y1 ) , ( x2 , y2 )
71 where (x1,y1) and (x2,y2) are the end points of the line segment.
73 Line segments are output using the first syntax.
77 Boxes are represented by pairs of points that are opposite corners of
78 the box. Values of type box are specified using any of the following
80 ( ( x1 , y1 ) , ( x2 , y2 ) )
81 ( x1 , y1 ) , ( x2 , y2 )
84 where (x1,y1) and (x2,y2) are any two opposite corners of the box.
86 Boxes are output using the second syntax.
88 Any two opposite corners can be supplied on input, but the values will
89 be reordered as needed to store the upper right and lower left corners,
94 Paths are represented by lists of connected points. Paths can be open,
95 where the first and last points in the list are considered not
96 connected, or closed, where the first and last points are considered
99 Values of type path are specified using any of the following syntaxes:
100 [ ( x1 , y1 ) , ... , ( xn , yn ) ]
101 ( ( x1 , y1 ) , ... , ( xn , yn ) )
102 ( x1 , y1 ) , ... , ( xn , yn )
103 ( x1 , y1 , ... , xn , yn )
104 x1 , y1 , ... , xn , yn
106 where the points are the end points of the line segments comprising the
107 path. Square brackets ([]) indicate an open path, while parentheses
108 (()) indicate a closed path. When the outermost parentheses are
109 omitted, as in the third through fifth syntaxes, a closed path is
112 Paths are output using the first or second syntax, as appropriate.
116 Polygons are represented by lists of points (the vertices of the
117 polygon). Polygons are very similar to closed paths; the essential
118 semantic difference is that a polygon is considered to include the area
119 within it, while a path is not.
121 An important implementation difference between polygons and paths is
122 that the stored representation of a polygon includes its smallest
123 bounding box. This speeds up certain search operations, although
124 computing the bounding box adds overhead while constructing new
127 Values of type polygon are specified using any of the following
129 ( ( x1 , y1 ) , ... , ( xn , yn ) )
130 ( x1 , y1 ) , ... , ( xn , yn )
131 ( x1 , y1 , ... , xn , yn )
132 x1 , y1 , ... , xn , yn
134 where the points are the end points of the line segments comprising the
135 boundary of the polygon.
137 Polygons are output using the first syntax.
141 Circles are represented by a center point and radius. Values of type
142 circle are specified using any of the following syntaxes:
148 where (x,y) is the center point and r is the radius of the circle.
150 Circles are output using the first syntax.