]> begriffs open source - ai-pg/blob - full-docs/txt/datatype-geometric.txt
Convert HTML docs to more streamlined TXT
[ai-pg] / full-docs / txt / datatype-geometric.txt
1
2 8.8. Geometric Types #
3
4    8.8.1. Points
5    8.8.2. Lines
6    8.8.3. Line Segments
7    8.8.4. Boxes
8    8.8.5. Paths
9    8.8.6. Polygons
10    8.8.7. Circles
11
12    Geometric data types represent two-dimensional spatial objects.
13    Table 8.20 shows the geometric types available in PostgreSQL.
14
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)
25
26    In all these types, the individual coordinates are stored as double
27    precision (float8) numbers.
28
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.
32
33 8.8.1. Points #
34
35    Points are the fundamental two-dimensional building block for geometric
36    types. Values of type point are specified using either of the following
37    syntaxes:
38 ( x , y )
39   x , y
40
41    where x and y are the respective coordinates, as floating-point
42    numbers.
43
44    Points are output using the first syntax.
45
46 8.8.2. Lines #
47
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
50    the following form:
51 { A, B, C }
52
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 )
57     x1 , y1   ,   x2 , y2
58
59    where (x1,y1) and (x2,y2) are two different points on the line.
60
61 8.8.3. Line Segments #
62
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
65    following syntaxes:
66 [ ( x1 , y1 ) , ( x2 , y2 ) ]
67 ( ( x1 , y1 ) , ( x2 , y2 ) )
68   ( x1 , y1 ) , ( x2 , y2 )
69     x1 , y1   ,   x2 , y2
70
71    where (x1,y1) and (x2,y2) are the end points of the line segment.
72
73    Line segments are output using the first syntax.
74
75 8.8.4. Boxes #
76
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
79    syntaxes:
80 ( ( x1 , y1 ) , ( x2 , y2 ) )
81   ( x1 , y1 ) , ( x2 , y2 )
82     x1 , y1   ,   x2 , y2
83
84    where (x1,y1) and (x2,y2) are any two opposite corners of the box.
85
86    Boxes are output using the second syntax.
87
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,
90    in that order.
91
92 8.8.5. Paths #
93
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
97    connected.
98
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
105
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
110    assumed.
111
112    Paths are output using the first or second syntax, as appropriate.
113
114 8.8.6. Polygons #
115
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.
120
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
125    polygons.
126
127    Values of type polygon are specified using any of the following
128    syntaxes:
129 ( ( x1 , y1 ) , ... , ( xn , yn ) )
130   ( x1 , y1 ) , ... , ( xn , yn )
131   ( x1 , y1   , ... ,   xn , yn )
132     x1 , y1   , ... ,   xn , yn
133
134    where the points are the end points of the line segments comprising the
135    boundary of the polygon.
136
137    Polygons are output using the first syntax.
138
139 8.8.7. Circles #
140
141    Circles are represented by a center point and radius. Values of type
142    circle are specified using any of the following syntaxes:
143 < ( x , y ) , r >
144 ( ( x , y ) , r )
145   ( x , y ) , r
146     x , y   , r
147
148    where (x,y) is the center point and r is the radius of the circle.
149
150    Circles are output using the first syntax.