1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225
|
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>8.7.Geometric Types</title>
<link rel="stylesheet" href="stylesheet.css" type="text/css">
<link rev="made" href="pgsql-docs@postgresql.org">
<meta name="generator" content="DocBook XSL Stylesheets V1.70.0">
<link rel="start" href="index.html" title="PostgreSQL 8.1.4 Documentation">
<link rel="up" href="datatype.html" title="Chapter8.Data Types">
<link rel="prev" href="datatype-boolean.html" title="8.6.Boolean Type">
<link rel="next" href="datatype-net-types.html" title="8.8.Network Address Types">
<link rel="copyright" href="ln-legalnotice.html" title="Legal Notice">
</head>
<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"><div class="sect1" lang="en">
<div class="titlepage"><div><div><h2 class="title" style="clear: both">
<a name="datatype-geometric"></a>8.7.Geometric Types</h2></div></div></div>
<p> Geometric data types represent two-dimensional spatial
objects. <a href="datatype-geometric.html#datatype-geo-table" title="Table8.16.Geometric Types">Table8.16, “Geometric Types”</a> shows the geometric
types available in <span class="productname">PostgreSQL</span>. The
most fundamental type, the point, forms the basis for all of the
other types.
</p>
<div class="table">
<a name="datatype-geo-table"></a><p class="title"><b>Table8.16.Geometric Types</b></p>
<div class="table-contents"><table summary="Geometric Types" border="1">
<colgroup>
<col>
<col>
<col>
<col>
</colgroup>
<thead><tr>
<th>Name</th>
<th>Storage Size</th>
<th>Representation</th>
<th>Description</th>
</tr></thead>
<tbody>
<tr>
<td><code class="type">point</code></td>
<td>16 bytes</td>
<td>Point on the plane</td>
<td>(x,y)</td>
</tr>
<tr>
<td><code class="type">line</code></td>
<td>32 bytes</td>
<td>Infinite line (not fully implemented)</td>
<td>((x1,y1),(x2,y2))</td>
</tr>
<tr>
<td><code class="type">lseg</code></td>
<td>32 bytes</td>
<td>Finite line segment</td>
<td>((x1,y1),(x2,y2))</td>
</tr>
<tr>
<td><code class="type">box</code></td>
<td>32 bytes</td>
<td>Rectangular box</td>
<td>((x1,y1),(x2,y2))</td>
</tr>
<tr>
<td><code class="type">path</code></td>
<td>16+16n bytes</td>
<td>Closed path (similar to polygon)</td>
<td>((x1,y1),...)</td>
</tr>
<tr>
<td><code class="type">path</code></td>
<td>16+16n bytes</td>
<td>Open path</td>
<td>[(x1,y1),...]</td>
</tr>
<tr>
<td><code class="type">polygon</code></td>
<td>40+16n bytes</td>
<td>Polygon (similar to closed path)</td>
<td>((x1,y1),...)</td>
</tr>
<tr>
<td><code class="type">circle</code></td>
<td>24 bytes</td>
<td>Circle</td>
<td><(x,y),r> (center and radius)</td>
</tr>
</tbody>
</table></div>
</div>
<br class="table-break"><p> 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 <a href="functions-geometry.html" title="9.10.Geometric Functions and Operators">Section9.10, “Geometric Functions and Operators”</a>.
</p>
<div class="sect2" lang="en">
<div class="titlepage"><div><div><h3 class="title">
<a name="id589831"></a>8.7.1.Points</h3></div></div></div>
<a name="id589835"></a><p> Points are the fundamental two-dimensional building block for geometric types.
Values of type <code class="type">point</code> are specified using the following syntax:
</p>
<pre class="synopsis">( <em class="replaceable"><code>x</code></em> , <em class="replaceable"><code>y</code></em> )
<em class="replaceable"><code>x</code></em> , <em class="replaceable"><code>y</code></em></pre>
<p>
where <em class="replaceable"><code>x</code></em> and <em class="replaceable"><code>y</code></em> are the respective
coordinates as floating-point numbers.
</p>
</div>
<div class="sect2" lang="en">
<div class="titlepage"><div><div><h3 class="title">
<a name="id589880"></a>8.7.2.Line Segments</h3></div></div></div>
<a name="id589884"></a><a name="id589890"></a><p> Line segments (<code class="type">lseg</code>) are represented by pairs of points.
Values of type <code class="type">lseg</code> are specified using the following syntax:
</p>
<pre class="synopsis">( ( <em class="replaceable"><code>x1</code></em> , <em class="replaceable"><code>y1</code></em> ) , ( <em class="replaceable"><code>x2</code></em> , <em class="replaceable"><code>y2</code></em> ) )
( <em class="replaceable"><code>x1</code></em> , <em class="replaceable"><code>y1</code></em> ) , ( <em class="replaceable"><code>x2</code></em> , <em class="replaceable"><code>y2</code></em> )
<em class="replaceable"><code>x1</code></em> , <em class="replaceable"><code>y1</code></em> , <em class="replaceable"><code>x2</code></em> , <em class="replaceable"><code>y2</code></em></pre>
<p>
where
<code class="literal">(<em class="replaceable"><code>x1</code></em>,<em class="replaceable"><code>y1</code></em>)</code>
and
<code class="literal">(<em class="replaceable"><code>x2</code></em>,<em class="replaceable"><code>y2</code></em>)</code>
are the end points of the line segment.
</p>
</div>
<div class="sect2" lang="en">
<div class="titlepage"><div><div><h3 class="title">
<a name="id589988"></a>8.7.3.Boxes</h3></div></div></div>
<a name="id589992"></a><a name="id589999"></a><p> Boxes are represented by pairs of points that are opposite
corners of the box.
Values of type <code class="type">box</code> are specified using the following syntax:
</p>
<pre class="synopsis">( ( <em class="replaceable"><code>x1</code></em> , <em class="replaceable"><code>y1</code></em> ) , ( <em class="replaceable"><code>x2</code></em> , <em class="replaceable"><code>y2</code></em> ) )
( <em class="replaceable"><code>x1</code></em> , <em class="replaceable"><code>y1</code></em> ) , ( <em class="replaceable"><code>x2</code></em> , <em class="replaceable"><code>y2</code></em> )
<em class="replaceable"><code>x1</code></em> , <em class="replaceable"><code>y1</code></em> , <em class="replaceable"><code>x2</code></em> , <em class="replaceable"><code>y2</code></em></pre>
<p>
where
<code class="literal">(<em class="replaceable"><code>x1</code></em>,<em class="replaceable"><code>y1</code></em>)</code>
and
<code class="literal">(<em class="replaceable"><code>x2</code></em>,<em class="replaceable"><code>y2</code></em>)</code>
are any two opposite corners of the box.
</p>
<p> 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.
</p>
</div>
<div class="sect2" lang="en">
<div class="titlepage"><div><div><h3 class="title">
<a name="id590100"></a>8.7.4.Paths</h3></div></div></div>
<a name="id590104"></a><p> Paths are represented by lists of connected points. Paths can be
<em class="firstterm">open</em>, where
the first and last points in the list are not considered connected, or
<em class="firstterm">closed</em>,
where the first and last points are considered connected.
</p>
<p> Values of type <code class="type">path</code> are specified using the following syntax:
</p>
<pre class="synopsis">( ( <em class="replaceable"><code>x1</code></em> , <em class="replaceable"><code>y1</code></em> ) , ... , ( <em class="replaceable"><code>xn</code></em> , <em class="replaceable"><code>yn</code></em> ) )
[ ( <em class="replaceable"><code>x1</code></em> , <em class="replaceable"><code>y1</code></em> ) , ... , ( <em class="replaceable"><code>xn</code></em> , <em class="replaceable"><code>yn</code></em> ) ]
( <em class="replaceable"><code>x1</code></em> , <em class="replaceable"><code>y1</code></em> ) , ... , ( <em class="replaceable"><code>xn</code></em> , <em class="replaceable"><code>yn</code></em> )
( <em class="replaceable"><code>x1</code></em> , <em class="replaceable"><code>y1</code></em> , ... , <em class="replaceable"><code>xn</code></em> , <em class="replaceable"><code>yn</code></em> )
<em class="replaceable"><code>x1</code></em> , <em class="replaceable"><code>y1</code></em> , ... , <em class="replaceable"><code>xn</code></em> , <em class="replaceable"><code>yn</code></em> </pre>
<p>
where the points are the end points of the line segments
comprising the path. Square brackets (<code class="literal">[]</code>) indicate
an open path, while parentheses (<code class="literal">()</code>) indicate a
closed path.
</p>
<p> Paths are output using the first syntax.
</p>
</div>
<div class="sect2" lang="en">
<div class="titlepage"><div><div><h3 class="title">
<a name="id590235"></a>8.7.5.Polygons</h3></div></div></div>
<a name="id590239"></a><p> Polygons are represented by lists of points (the vertexes of the
polygon). Polygons should probably be
considered equivalent to closed paths, but are stored differently
and have their own set of support routines.
</p>
<p> Values of type <code class="type">polygon</code> are specified using the following syntax:
</p>
<pre class="synopsis">( ( <em class="replaceable"><code>x1</code></em> , <em class="replaceable"><code>y1</code></em> ) , ... , ( <em class="replaceable"><code>xn</code></em> , <em class="replaceable"><code>yn</code></em> ) )
( <em class="replaceable"><code>x1</code></em> , <em class="replaceable"><code>y1</code></em> ) , ... , ( <em class="replaceable"><code>xn</code></em> , <em class="replaceable"><code>yn</code></em> )
( <em class="replaceable"><code>x1</code></em> , <em class="replaceable"><code>y1</code></em> , ... , <em class="replaceable"><code>xn</code></em> , <em class="replaceable"><code>yn</code></em> )
<em class="replaceable"><code>x1</code></em> , <em class="replaceable"><code>y1</code></em> , ... , <em class="replaceable"><code>xn</code></em> , <em class="replaceable"><code>yn</code></em> </pre>
<p>
where the points are the end points of the line segments
comprising the boundary of the polygon.
</p>
<p> Polygons are output using the first syntax.
</p>
</div>
<div class="sect2" lang="en">
<div class="titlepage"><div><div><h3 class="title">
<a name="id590332"></a>8.7.6.Circles</h3></div></div></div>
<a name="id590336"></a><p> Circles are represented by a center point and a radius.
Values of type <code class="type">circle</code> are specified using the following syntax:
</p>
<pre class="synopsis">< ( <em class="replaceable"><code>x</code></em> , <em class="replaceable"><code>y</code></em> ) , <em class="replaceable"><code>r</code></em> >
( ( <em class="replaceable"><code>x</code></em> , <em class="replaceable"><code>y</code></em> ) , <em class="replaceable"><code>r</code></em> )
( <em class="replaceable"><code>x</code></em> , <em class="replaceable"><code>y</code></em> ) , <em class="replaceable"><code>r</code></em>
<em class="replaceable"><code>x</code></em> , <em class="replaceable"><code>y</code></em> , <em class="replaceable"><code>r</code></em> </pre>
<p>
where
<code class="literal">(<em class="replaceable"><code>x</code></em>,<em class="replaceable"><code>y</code></em>)</code>
is the center and <em class="replaceable"><code>r</code></em> is the radius of the circle.
</p>
<p> Circles are output using the first syntax.
</p>
</div>
</div></body>
</html>
|